ROS(机器人操作系统)相关问题合辑【长期稳定更新】

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.

posted @ 2013-05-22 18:49  IT屁民  阅读(431)  评论(0编辑  收藏  举报