ROS1/2参数之YAML

2022-05-01 10:32:44 浏览数 (2)

参考链接:

  1. roboticsbackend.com/ros-param-yaml-format
  2. roboticsbackend.com/ros2-yaml-params
  3. wiki.ros.org/ROS/YAMLCommandLine
  4. yaml.org
  5. 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 

0 人点赞