support ros2 topic pub yaml file input#925
Conversation
Signed-off-by: Tomoya Fujita <Tomoya.Fujita@sony.com>
Signed-off-by: Tomoya Fujita <Tomoya.Fujita@sony.com>
fujitatomoya
left a comment
There was a problem hiding this comment.
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? |
ahcorde
left a comment
There was a problem hiding this comment.
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 <Tomoya.Fujita@sony.com>
|
@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. |
Ryanf55
left a comment
There was a problem hiding this comment.
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.
|
We talked about this feature a bit in ROS PMC meeting today. after all feature makes sense, so i will keep this open for review. @MichaelOrlov i do not think of the necessity to use |
|
This pull request has been mentioned on ROS Discourse. There might be relevant details there: https://discourse.ros.org/t/ros-pmc-meeting-minutes-2024-12-03/40941/1 |
MichaelOrlov
left a comment
There was a problem hiding this comment.
Hi @fujitatomoya, Conceptually, it looks good to me. However, I didn't do a thorough review.
|
@MichaelOrlov @clalancette thanks for the review and comments, i will address them soon. |
|
Pulls: #925 |
…--stdin`. Signed-off-by: Tomoya Fujita <Tomoya.Fujita@sony.com>
853e7f2 to
b03cf8a
Compare
|
Pulls: #925 |
|
@clalancette i have addressed your comments, and all tests are passing locally. can i have your approval? |
|
@clalancette @ahcorde can i have an approval either of you? |
|
Pulls: #925 |
closes #919