ROS2 topic echo Selected field
In ROS1, you could perform:
rostopic echo /mavros/state/armed for topic rostopic echo /mavros/state
In ROS2, I didn't succed to find how to do it.
ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
In ROS1, you could perform:
rostopic echo /mavros/state/armed for topic rostopic echo /mavros/state
In ROS2, I didn't succed to find how to do it.
You can use the --field
flag of the ros2 topic echo
command. Here is an example:
ros2 topic echo /imu_test --field linear_acceleration
which will give the output
x: 0.0
y: 0.0
z: 0.0
---
You can go further into the field by putting periods after each subsection, so
ros2 topic echo /imu_test --field linear_acceleration.x
will give you
0.0
---
I do not know a ROS2 equivalent of the command you described . However a simple workaround to get a similar behavior could be to use grep
for this purpose. You can specify the number of lines that should be visible after your search key with the -A [num lines after match]
option. Just set it to the size of the data field of interest.
For example to view the linear acceleration of an sensor_msgs/msg/Imu one could write:
ros2 topic echo /imu_topic | grep -A 3 "linear"
linear:
x: 0.0
y: 0.0
z: 0.0
(...)
Asked: 2020-10-22 01:28:20 -0500
Seen: 6,107 times
Last updated: May 28 '22
ROS2 one action client calling multiple servers
how to organize data transfer between nodes on multiple PCs on ROS2
Waiting for TransformListener with ROS2 and Python?
Using Occupancy Grids with ROS 2: frame problem and probability map
[ROS2] How to set QoS policy for topic in cpp script
I am getting an error using Ros2 Iron and micro-ROS on RP2040
ROS vs ROS 2.0 vs ROS industrial
ROS2 Bag - DB3 CDR Deserialization
Why image not recieved using ROS2 functions in the node?
[ROS2] asyncio await with timeout a service call in a callback
Hi! Did you find how to do it without grep?