参考链接:
- roboticsbackend.com/ros-param-yaml-format
- roboticsbackend.com/ros2-yaml-params
- wiki.ros.org/ROS/YAMLCommandLine
- yaml.org
- yaml.org/spec/1.2.2
此处以ROS1为例:
代码语言:javascript复制Header header
uint32 seq
time stamp
string frame_id
Point point
float64 x
float64 y
float64 z
如下4中等效:
代码语言:javascript复制rostopic pub pt geometry_msgs/PointStamped '{stamp: now, frame_id: base_link}' '[1.0, 2.0, 3.0]'
rostopic pub pt geometry_msgs/PointStamped '[0, now, base_link]' '[1.0, 2.0, 3.0]'
rostopic pub pt geometry_msgs/PointStamped '{header: {stamp: now, frame_id: base_link}, point: [1.0, 2.0, 3.0]}'
rostopic pub pt geometry_msgs/PointStamped '{header: {stamp: now, frame_id: base_link}, point: {x: 1.0, y: 2.0, z: 3.0}}'
比如常用案例:
代码语言:javascript复制geometry_msgs/Vector3 linear
float64 x
float64 y
float64 z
geometry_msgs/Vector3 angular
float64 x
float64 y
float64 z
写成yaml:
代码语言:javascript复制linear: {
x: 0.2,
y: 0,
z: 0
}
angular: {
x: 0,
y: 0,
z: 0.2
}
使用:
rostopic pub /turtle1/cmd_vel geometry_msgs/Twist -f vel.yaml