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.

转载于:https://www.cnblogs.com/ShaneZhang/archive/2013/05/22/3093305.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值