[转]ROS Q&A | How to read LaserScan data
http://www.theconstructsim.com/read-laserscan-data/
Step 1. Open a project on ROS Development Studio(RDS)
We can reproduce the question easily using RDS. If you haven’t had an account yet, you can register one for free here. After registration, you can log in and open the project from Public(click on my projects to switch to public simulations) -> Kobuki. In the project, click simulations -> Turtlebot 2 to launch the simulation.
Step 2. Read LaserScan data
The simulation is up and running now. You can check all the topic available with the command
|
1
|
$ rostopic list
|
The LaserScan topic is called /kobuki/laser/scan. You can type the following command into the terminal to check the topic.
|
1
|
$ rostopic echo /kobuki/lase/scan -n1
|
The -n1 flag prints the topic exactly once. You’ll get something like this.
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
header:
seq: 5
stamp:
secs: 2829
nsecs: 69000000
frame_id: "laser_sensor_link"
angle_min: -1.57079994678
angle_max: 1.57079994678
angle_increment: 0.00436940183863
time_increment: 0.0
scan_time: 0.0
range_min: 0.10000000149
range_max: 30.0
ranges: [inf, inf, inf, inf, inf, ....]
|
The following command will give you the information for the topic
|
1
|
rostopic info /kobuki/laser/scan
|
You’ll see that the topic is using the message type called sensor_msgs/LaserScan. You can further check it with the command
|
1
|
rosmsg show sensor_msgs/LaserScan
|
The command gives you the message’s structure.
|
1
2
3
4
5
6
7
8
9
10
11
12
13
|
std_msgs/Header header
uint32 seq
time stamp
string frame_id
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
|
The angle_min and angle_max indicate the angle range(from -90 to 90 degree in this case) that the LaserScan is measuring and the ranges is an array which gives you the distance measured for each angle bin.
To explore the range value, let’s create a package.
|
1
2
3
4
|
$ cd ~/catkin_ws/src
$ catkin_create_pkg laser_values rospy
$ cd laser_values
$ mkdir launch
|
Add a python script under src with the following code
|
1
2
3
4
5
6
7
8
9
10
11
|
#! /usr/bin/env python
import rospy
from sensor_msgs.msg import LaserScan
def callback(msg):
print len(msg.ranges)
rospy.init_node('scan_values')
sub = rospy.Subscriber('/kobuki/laser/scan', LaserScan, callback)
rospy.spin()
|
Normally, you’ll need to give the script permission to execute with
|
1
|
$ chmod +x src/scan.py
|
Then we create a launch file under lunch directory to launch the script
|
1
2
3
4
5
|
<launch>
<node pkg="laser_values" type="scan.py" name="scan_values" output="screen">
</node>
</launch>
|
Now you can type
|
1
|
roslaunch laser_values laser.launch
|
to launch the script. You should also see that the length of the ranges array is 720 in the 180-degree range. So if we want to read the LaserScan data on the left, in front and on the right of the robot, we can change our script a bit.
|
1
2
3
4
5
6
7
8
9
|
...
def callback(msg):
# values at 0 degree
print msg.ranges[]
# values at 90 degree
print msg.ranges[360]
# values at 180 degree
print msg.ranges[719]
...
|
That’s all now you get the value. You can play with it to navigate the robot. If you want to learn more about this topic, you can go to Robot Ignite Academy. We have tons of courses which teach you how to navigate the robot in a more advanced way.
[转]ROS Q&A | How to read LaserScan data的更多相关文章
- [转]ROS 传感器消息及RVIZ可视化Laserscan和PointCloud
https://blog.csdn.net/yangziluomu/article/details/79576508 https://answers.ros.org/question/60239/ho ...
- ros使用RPLIDAR激光雷达
1.首先下载RPLIDAR的驱动功能包 https://github.com/robopeak/rplidar_ros 2.然后解压放到~/catkin_ws/src目录下 3.执行catkin_ma ...
- 在ros中使用rplidar Laser发布scan数据--25
原创博客:转载请表明出处:http://www.cnblogs.com/zxouxuewei/ 由于市面上买的激光雷达价格太贵了.所以在学习时会造成很大的经济压力.但是最近好多做机器人核心组件的公司都 ...
- Rplidar学习(四)—— ROS下进行rplidar雷达数据采集源码分析
一.子函数分析 1.发布数据子函数 (1)雷达数据数据类型 Header header # timestamp in the header is the acquisition time of # t ...
- ROS中发布激光扫描消息
激光雷达工作时会先在当前位置发出激光并接收反射光束,解析得到距离信息,而后激光发射器会转过一个角度分辨率对应的角度再次重复这个过程.限于物理及机械方面的限制,激光雷达通常会有一部分“盲区”.使用激光雷 ...
- 第十一课,ROS与传感器
1.Kinect 1)安装 sudo apt-get install ros-indigo-openni-camera sudo apt-get install ros-indigo-openni-l ...
- 在学习ROS过程中碰到的一些问题--1
好了,这是接触ROS的第三周了,初步了解了一下ROS,很多问题自己还是无法解决,但是想着很久没有在blog上记录自己的学习过程,就先胡乱写一下吧.^-^ 1.关于ROS各种基本概念的理解 这方面知识建 ...
- [转]ROS订阅激光数据
https://github.com/robopeak/rplidar_ros/blob/master/src/client.cpp /* * Copyright (c) 2014, RoboPe ...
- Q promise API简单翻译
详细API:https://github.com/kriskowal/q/wiki/API-Reference Q提供了promise的一种实现方式,现在在node中用的已经比较多了.因为没有中文的a ...
随机推荐
- 希尔伯特曲线python3实现
需要OpenGL库:https://www.lfd.uci.edu/~gohlke/pythonlibs/#pyopengl #coding:utf-8 from OpenGL.GL import * ...
- 4. Linux工作目录切换和文本文件编辑命令
1.pwd:显示用户当前所处的工作目录 举例:[root@Centos ~]# pwd /root 2.cd:切换工作路径 "cd -"命令返回到上一次所处的目录 " ...
- dedecms新建内容模型以及如何添加字段
dedecms新建内容模型以及如何添加字段 内容模型就是我们所说的频道模型,利用频道模型可以实现其使用他的栏目具备一些功能,比如说,图片模型,在使用他的栏目中就可以发表多个图片,并且能够达到相册的功能 ...
- Flink-v1.12官方网站翻译-P004-Flink Operations Playground
Flink操作训练场 在各种环境中部署和操作Apache Flink的方法有很多.无论这种多样性如何,Flink集群的基本构件保持不变,类似的操作原则也适用. 在这个操场上,你将学习如何管理和运行Fl ...
- 16天5面,我终于拿到了鹅厂Offer
目录 1 - 为什么要在年底离职 1.1 惊觉:没有什么成长 1.2 投简历,敲打自己 1.3 面试它来了 1.4 提前触到目标? 2 - 我的鹅厂面试 2.1 技术一面 Java 语言相关 通用学科 ...
- [The Preliminary Contest for ICPC Asia Shanghai 2019] B-Light bulbs(差分+思维)
前言 最近有很多算不上事的事,搞得有点心烦,补题难免就很水,没怎么搞,自我检讨一番~~ 说实话网络赛题目的质量还是挺高的,题目都设计的挺好的,很值得学习.这场比赛那会只有我们大二的在做,其他人去参加$ ...
- UVA 10480 Sabotage (最大流最小割)
题目链接:点击打开链接 题意:把一个图分成两部分,要把点1和点2分开.隔断每条边都有一个花费,求最小花费的情况下,应该切断那些边. 这题很明显是最小割,也就是最大流.把1当成源点,2当成汇点. 问题是 ...
- POJ - 1226 Substrings (后缀数组)
传送门:POJ - 1226 这个题跟POJ - 3294 和POJ - 3450 都是一样的思路,一种题型. POJ - 3294的题解可以见:https://www.cnblogs.com/li ...
- 主席树 【权值线段树】 && 例题K-th Number POJ - 2104
一.主席树与权值线段树区别 主席树是由许多权值线段树构成,单独的权值线段树只能解决寻找整个区间第k大/小值问题(什么叫整个区间,比如你对区间[1,8]建立一颗对应权值线段树,那么你不能询问区间[2,5 ...
- ++i和i++的区别
它们两个的数值变化的区别,我这里就不多说了 这里主要说明两者在效率上的区别 (1)首先如果是自带的数据类型,比如int型,++i和i++,编译器的实现方式是相同的,两者并没有效率上的区别,虽然也有副本 ...