Step 0. Create a project in ROS Development Studio(ROSDS)
ROSDS helps you follow our tutorial in a fast pace without dealing without setting up an environment locally. If you haven’t had an account yet, you can create a free account here. Let’s create a new project and call it laser_qa.
Step 1. Clone the code and create a package
The questioner provides the code he used. Let’s clone it first.
cd catkin_ws/src
git clone http://github.com/erenaud3/fakeLaserScan.git
In the /launch/fakeLaserScan.launch file, please leave the node tag and comment out the others since we don’t need them. Then we can compile and run the package
cd ~/catkin_ws
catkin_make
source devel/setup.bash
roslaunch beginner_tutorial fakeLaserScan.launch
To visualize the laser scan, we’ll use rviz
rosrun rviz rviz
After launching rviz, go to Tools->Graphical Tool. You’ll see the rviz window pops out.
In rviz, click Add->LaserScan to add a visualization. Then we select the topic /fakeScan, however, there is nothing.
It turns out the size of the display is too small. Please change it to a larger value. e.g. 0.1
You should see the visualization now.
Want to learn more?
If you are interested in learning more about ROS, please check our ROS Basic in 5 Days course.
Edit by: Tony Huang
We Love Feedback
Did you like this video? Do you have questions about what is explained? Whatever the case, please leave a comment on the comments section below, so we can interact and learn from each other.
If you want to learn about other ROS topics, please let us know in the comments area and we will do a video about it.
In this video we are going to see how to convert a PointCloud into a laser scan. You can use later that laserscan as a lidar for robot navigation. This allows to do navigation with a very cheap sensor.
▸ Get the code of the video by clicking on this link: https://goo.gl/z3fNCs (You need an account on ROSDS. Once you click on the link, the whole code will appear on your ROSDS account ready to use. Watch the video for additional instructions)
Below are the step by step instructions for creating the project on ROSDS.
NOTE: if you are not using the ROSDS and you are using your local ROS installation, then you need to have installed the ROS package PointCloud To LaserScan (find the link below in the related links section).
Step 1
Head to Robot Development Studio and create a new project
Provide a suitable project name and some useful description (we are using the name “pointcloud to laser”)
Open the project (this will take few seconds)
Once the project is loaded run the IDE from the tools menu. Also verify that the inital directory structure should look like following
Simulate a turtlebot2 by choosing Turtlebot 2 option in the Simulation menu.
Next we will create a package pc2l (stands for PointCloud2Laser). Open a shell, browse to ~/catkin_ws/src directory and create a package with name pc2l
$ cd ~/catkin_ws/src
$ catkin_create_pkg pc2l
Further, we need to create a launch file that will create a node to do the conversion of pointcloud data to laser scan data (using pointcloud_to_laserscan library). We will create a launch directory then a launch file by name start.launch. We can use the IDE tool to achieve the same
Create a new file (inside the launch folder) with name start.launch and input the following contents (Note: The pointcloud_to_laserscan library needs to be installed in the system)
<launch>
<node pkg="pointcloud_to_laserscan" type="pointcloud_to_laserscan_node" name="pointcloud_to_laserscan">
<remap from="cloud_in" to="/camera/depth/points"/>
<remap from="scan" to="/camera/scan" />
<rosparam>
target_frame: camera_link
transform_tolerance: 0.01
min_height: 0.0
max_height: 1.0
angle_min: -1.5708
angle_max: 1.5708
angle_increment: 0.0087
scan_time: 0.3333
range_min: 0.45
range_max: 4.0
use_inf: true
#concurrency_level affects number of pc queued for processing and the number of threadsused
# 0: Detect number of cores
# 1: Single threaded
# 2: inf : Parallelism level
concurrency_level: 1
</rosparam>
</node>
</launch>
This **launch file** set’s up various parameters which are briefed below:
cloud_in : This argument contains the name of the topic that is publishing the pointcloud data. scan : This argument contains topic name (created by pointcloud_to_laserscan) that contains the converted scan data. target_frame : Tells the frame of reference for laser scan min and max height : Define the height range which will be taken into account while converting the pointcloud min and max angle : Define the range of angle over which laser scan data is composed about angle increment : The step increase in angle between conscuting scans scan time : The scan time is the interval between publishing two scans min and max range : This arguments defines the range of distance captured in the scans use inf : A point detected further than max range is encoded as inf point concurrency : This parameters controls how much cpu you want to allocate to the pointcloud to laser scan processing
Step 3
Now we can run the launch file, visualize the data (laser scan) and compare the pointcloud converted laser scan data with laser scan data provided by a laser scanner mounted on the robot.
In the Shell type the following command to run the launch file
$ roslaunchg pc2l start.launch
This command will start a new topic with name /camera/scan. To verify start a new Shell and run the command
$ rostopic list
To visualize the data published over the /camera/scan topic we will run rviz In the shell, type the following command
$ rosrun rviz rviz
To see the rviz window we require a Graphical Tool
Once the rviz loads we will fix the errors by choosing appropriate value for Fixed Frame parameter. Then we will add following new displays
Laser display 1 : We will select the topic /camera/scan
Laser display 2 : We will select the topic /kobuki/laser/scan
Robot Model : We will add a robot model to visualize a turtlebot inside the rviz window
After we are done with all settings we will see the following
There are two laser scans one is from the /camera/scan (white colored) and the other is from /kobuki/laser/scan. We are done at this point.
// RELATED LINKS
▸ Point Cloud To LaserScan ROS package: http://wiki.ros.org/pointcloud_to_laserscan ▸ ROS Development Studio: https://goo.gl/tnjCD5 ▸ Robot Ignite Academy: https://goo.gl/8EhkWn ▸ ROS Navigation in 5 days online course: https://goo.gl/mkRYiR