-
Notifications
You must be signed in to change notification settings - Fork 166
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
support ros2 topic pub yaml file input #925
base: rolling
Are you sure you want to change the base?
support ros2 topic pub yaml file input #925
Conversation
Signed-off-by: Tomoya Fujita <[email protected]>
Signed-off-by: Tomoya Fujita <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This enables the following command line option with ros2 topic pub
.
Note that yaml files are saved with ros2 topic echo > xxx.yaml
.
root@tomoyafujita:~/ros2_ws/colcon_ws# cat chatter.yaml
---
data: 'Hello ROS Users'
---
---
data: Hello ROS Developers
---
data: Hello ROS Developers
---
---
data: 'Hello ROS Users'
root@tomoyafujita:~/ros2_ws/colcon_ws# ros2 topic pub /chatter std_msgs/msg/String --yaml-file chatter.yaml
publisher: beginning loop
publishing #1: std_msgs.msg.String(data='Hello ROS Users')
publishing #2: std_msgs.msg.String(data='Hello ROS Developers')
publishing #3: std_msgs.msg.String(data='Hello ROS Developers')
publishing #4: std_msgs.msg.String(data='Hello ROS Users')
root@tomoyafujita:~/ros2_ws/colcon_ws# cat tf2.yaml
transforms:
- header:
stamp:
sec: 1721935886
nanosec: 528868866
frame_id: foo
child_frame_id: bar
transform:
translation:
x: 1.0
y: 2.0
z: 3.0
rotation:
x: -0.4747921762038255
y: -0.07596622270177095
z: 0.24006245183344296
w: 0.8433098728485138
---
transforms:
- header:
stamp:
sec: 1721935886
nanosec: 528868866
frame_id: foo
child_frame_id: bar
transform:
translation:
x: 1.0
y: 2.0
z: 3.0
rotation:
x: -0.4747921762038255
y: -0.07596622270177095
z: 0.24006245183344296
w: 0.8433098728485138
root@tomoyafujita:~/ros2_ws/colcon_ws# ros2 topic pub /tf_static tf2_msgs/msg/TFMessage --yaml-file tf2.yaml
publisher: beginning loop
publishing #1: tf2_msgs.msg.TFMessage(transforms=[geometry_msgs.msg.TransformStamped(header=std_msgs.msg.Header(stamp=builtin_interfaces.msg.Time(sec=1721935886, nanosec=528868866), frame_id='foo'), child_frame_id='bar', transform=geometry_msgs.msg.Transform(translation=geometry_msgs.msg.Vector3(x=1.0, y=2.0, z=3.0), rotation=geometry_msgs.msg.Quaternion(x=-0.4747921762038255, y=-0.07596622270177095, z=0.24006245183344296, w=0.8433098728485138)))])
publishing #2: tf2_msgs.msg.TFMessage(transforms=[geometry_msgs.msg.TransformStamped(header=std_msgs.msg.Header(stamp=builtin_interfaces.msg.Time(sec=1721935886, nanosec=528868866), frame_id='foo'), child_frame_id='bar', transform=geometry_msgs.msg.Transform(translation=geometry_msgs.msg.Vector3(x=1.0, y=2.0, z=3.0), rotation=geometry_msgs.msg.Quaternion(x=-0.4747921762038255, y=-0.07596622270177095, z=0.24006245183344296, w=0.8433098728485138)))])
@mjcarroll @clalancette @sloretz what do you think? this can be useful for test and development. |
CC: @ahcorde if you have time, can you take a look? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a simplification of a rosbag, not sure about this feature, let's see what other people thing about it
yeah that is true. the difference what i think of is, probably much easier to use and modify the data contents that are saved as yaml via |
Signed-off-by: Tomoya Fujita <[email protected]>
@clalancette @sloretz what do you think about this option? it would be really easier for user to update the data contents and publish it compared to rosbag2. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I realized I never submitted my review. This functions exactly as I requested. I'm a big fan of this feature and would love to see it merged.
I think it's a much more usable way to publish messages and be able to edit the contents in a human readable way.
Currently, I would write a shell script with `ros2 topic pub /my_topic my_pkg/mytype
"{
and: [manually_formatted_yaml, in_a_shell_script]
}"
Where it's easy to mess up the syntax in a shell script without yaml syntax in my editor. This PR represents a significant improvement in readability and helps me document in README's example messages to publish to affect the state of my robotic system.
closes #919