[转]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 ...
随机推荐
- day133:2RenMJ:TypeScript的变量&函数&类&接口
目录 1.变量 2.函数 3.类 4.接口 1.变量 1.变量的声明 // 1.即指定数据类型 也指定值 var 变量名:类型 = 值; eg:var username:string = " ...
- Vue技术点整理-指令
我们通常给一个元素添加 v-if / v-show 来做权限管理,但如果判断条件繁琐且多个地方需要判断,这种方式的代码不仅不优雅而且冗余. 针对这种情况,我们可以通过全局自定义指令来处理:我们先在新建 ...
- 向指定url发送Get/Post请求
向指定url发送Get/Post请求 1.向指定url发送Get/Post请求 2.HttpUtil 工具类–向指定url发送Get/Post请求 1.向指定url发送Get/Post请求 impor ...
- 我们到底为什么要用 IoC 和 AOP
作为一名 Java 开发,对 Spring 框架是再熟悉不过的了.Spring 支持的控制反转(Inversion of Control,缩写为IoC)和面向切面编程(Aspect-oriented ...
- ODS(Operational Data Store)定义
ODS(Operational Data Store)可操作的数据存储. 很多人对ODS究竟是什么有很多的困惑,ODS对于不同的人可以有不同的看法,我主要说说什么是最主流的定义.首先我们需要注意,OD ...
- PTA甲级—STL使用
1051 Pop Sequence (25分) [stack] 简答的栈模拟题,只要把过程想清楚就能做出来. 扫描到某个元素时候,假如比栈顶元素还大,说明包括其本身的在内的数字都应该入栈.将栈顶元素和 ...
- office响应慢,但电脑速度没问题的解决方案
看了非常多教程都没有用,有点崩,最后终于解决了,记录一下. 问题描述 :office启动没问题,但word打开后,选中一段文字非常慢,大概延迟鼠标移动2-3秒.点击工具栏时也有延迟(点击动画看的十分清 ...
- 爬虫——urllib.request包
一.引用包 import urllib.request 二.常用方法 (1)urllib.request.urlretrieve(网址,本地文件存储地址):直接下载网页到本地 urllib.reque ...
- woj1018(HDU4384)KING KONG 循环群
title: woj1018(HDU4384)KING KONG 循环群 date: 2020-03-19 09:43:00 categories: [acm] tags: [acm,woj,数学] ...
- 5种设置ASP.NET Core应用程序URL的方法
默认情况下,ASP.NET Core应用程序监听以下URL: http://localhost:5000 https://localhost:5001 在这篇文章中,我展示了5种不同的方式来更改您的应 ...