Q:
Hi i am new to ROS, i have done the tutorials. But i am a bit unsure on how to read messages (in code)
If i have a ros node which has subscribed to a topic /LaserScan see bellow std_msgs/Header header float32 angle_min float32 angle_max float32 angle_increment float32 time_increment float32 scan_time float32 range_min float32 range_max float32[] ranges float32[] intensities
And I am in my call back function, def callback_lidar(data):
how do i access an individual variables, like the list ranges
would i do array = data.ranges?
I cant create the node an test it out since the lidar node requires a connected lidar.
A:
Yes, exactly like you said: data.ranges
.
Q:
What is the easiest way to load/write a message from/to a file in C++?
A:
The best way I see is to use rosbag. You can easily record messages from the command line by just executing
rosbag /topic1 /topic2
Rosbag also provides a C++ and a Python API for writing and reading streams of messages from your programs. Have a look at this page for more information on the API.