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,421 times
Last updated: May 28 '22
Declaring a dependency on a system package that is not available on Windows
Create Dockerfile for ros2 package : ament_cmake error
How to use multiple laser scanners for slam and navigation
ROS2 nodes launched with systemd aren't discovered
How to use WS2812B LED lights with ROS 2 node
Getting the rclcpp::Duration in microseconds
how to debug a ros2 python launch file
Can we use MQTT in ROS2? [closed]
Hi! Did you find how to do it without grep?