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,493 times
Last updated: May 28 '22
ROS2 controller manager migration from foxy to humble: controller manager not available
How to add C++ plugin to sdf file in ROS2 Humble ?
ROS in arm/v7, Docker, and Limited Storage Robot
Update odometry based on pose estimate
rviz2 does not display an urdf file
/odom topic doesn't work on ROS2
Hi! Did you find how to do it without grep?