-
Notifications
You must be signed in to change notification settings - Fork 167
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
Allow ros2 topic echo output to be used in ros2 topic pub #919
Comments
Does the |
Yea, looks like it does.
Then, copy the content, type the command, add quotes for the message, and paste it in.
If this is the intent of |
I'm not totally sure what the original intent of it was, but certainly an update to the documentation would be welcome. |
i think root@tomoyafujita:~/ros2_ws/colcon_ws# ros2 topic pub /tf_static tf2_msgs/msg/TFMessage "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 echo --once /tf_static
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 echo --once --flow-style /tf_static
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}}}]
--- but it does not help if that is not the collection arrays, root@tomoyafujita:~/ros2_ws/colcon_ws# ros2 topic pub /turtle1/cmd_vel geometry_msgs/msg/Twist "{linear: {x: 2.0, y: 0.0, z: 0.0}, angular: {x: 0.0, y: 0.0, z: 1.8}}"
root@tomoyafujita:~/ros2_ws/colcon_ws# ros2 topic echo --once /turtle1/cmd_vel
linear:
x: 2.0
y: 0.0
z: 0.0
angular:
x: 0.0
y: 0.0
z: 1.8
---
root@tomoyafujita:~/ros2_ws/colcon_ws# ros2 topic echo --once --flow-style /turtle1/cmd_vel
linear:
x: 2.0
y: 0.0
z: 0.0
angular:
x: 0.0
y: 0.0
z: 1.8
---
so probably not for this use case...
this works even without root@tomoyafujita:~/ros2_ws/colcon_ws# ros2 topic pub /turtle1/cmd_vel geometry_msgs/msg/Twist "linear:
x: 2.0
y: 0.0
z: 0.0
angular:
x: 0.0
y: 0.0
z: 1.8
"
publisher: beginning loop
publishing #1: geometry_msgs.msg.Twist(linear=geometry_msgs.msg.Vector3(x=2.0, y=0.0, z=0.0), angular=geometry_msgs.msg.Vector3(x=0.0, y=0.0, z=1.8))
publishing #2: geometry_msgs.msg.Twist(linear=geometry_msgs.msg.Vector3(x=2.0, y=0.0, z=0.0), angular=geometry_msgs.msg.Vector3(x=0.0, y=0.0, z=1.8)) maybe we can add some suggestion about
i think this is useful new feature during development and debugging, we can easily modify the certain data amount to play back by yaml file. we could use |
Discussion from maintenance triage: It was agreed that |
Neat, I'm off on holiday weekend, but will review this when I get back Tuesday. Thanks for working on it! |
Feature request
Feature description
I want to use
ros2 topic echo
, copy the contents of a message in CLI, and runros2 topic pub
to publish the data without having to reformat it.Currently, you can echo a topic like this:
Then, you need to tediously reformat it like this to publish:
$ ros2 topic pub /geo_path geographic_msgs/msg/GeoPath '{poses: [{pose: {position: {latitude: 1.0, longitude: 2.0, altitude: 3.0}}}, {pose: {position: {latitude: 4.0, longitude: 5.0, altitude: 6.0}}}]}'
Implementation considerations
Proposal: Allow publishing by yaml file like so:
ros2 topic pub /geo_path geographic_msgs/msg/GeoPath --yaml my_message.yaml
Where
my_message.yaml
is the direct YAML from ros2 topic echo.I'm open to other alternatives such as
cat
operation on the yaml file and piping it toxargs
.cat my_message.yaml | xargs -I{} ros2 topic pub /geo_path geographic_msgs/msg/GeoPath {}
The text was updated successfully, but these errors were encountered: