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,439 times
Last updated: May 28 '22
How can I check what middleware I am using in ros2?
Environment setup error - term 'call' is not recognized in PowerShell
SMACC or any other state machine for ROS2
ROS 2 Crystal : Can't get parameter list of string from YAML file
How to debug ROS2 Code with an IDE?
ROS 2 SLAM not working, 'queue is full'
netifaces Library installation failed
how to debug a ros2 python launch file
Hi! Did you find how to do it without grep?