2: Download and Setup - Grantham00/rplidar_detection GitHub Wiki
Using a new terminal, download rplidar_detection from this github page to the documents folder
cd ~/Documents/ &&\
git clone https://github.com/Grantham00/rplidar_detection.git
Before we can run our script, let's ensure that the RPLIDAR device and driver are working correctly. Check the device version (A1, A2, A3) on the bottom of the device.
Running the robopeak/rplidar_ros driver with rviz:
Open a new terminal and run the following command if your device is A1/A2:
roslaunch rplidar_ros view_rplidar.launch
If it's the A3:
roslaunch rplidar_ros view_rplidar_a3.launch
If successful, this launch command will start a roscore and open rviz. Your RPLIDAR device should start spinning and you'll see the detected points visualized in rviz. If you see an error in the terminal, see the troubleshooting section for help.
To kill this process, exit rviz and CTRL-C the terminal.
Let's now run the robopeak/rplidar_ros driver without rviz:
Open a new terminal and run the following command if your device is A1/A2:
roslaunch rplidar_ros rplidar.launch
If it's the A3:
roslaunch rplidar_ros rplidar_a3.launch
The rplidar device should start spinning. Let's look at the data directly from the terminal:
Open a new terminal and run
rostopic list
This command lists current topics. /scan should be in this list if the driver is running correctly.
We can listen to the messages on this topic with
rostopic echo scan
The terminal is now echoing out scan messages. It will be a scrolling wall of numbers too fast to read. If the scrolling freezes or nothing shows up, the device may have disconnected and the above roslaunch command in the previous step should be killed and restarted.
Put simply, the robopeak/rplidar_ros driver talks to the rplidar device on the serial port, ingests and parses the data that it produces, packages the data into the ROS laserscan message format, and publishes the message on the topic \scan.
CTRL-C the terminal to kill the echo of '\scan'. We have viewed the data in the terminal and the visualized data in rviz. Remember, this stream of data is always running in the background, while we can have our program (or theoretically many programs) can subscribe to this topic to access the data.
To recap, our rplidar_detection script requires the robopeak/rplidar_ros driver to be publishing scan messages to the \scan topic. If \scan is not listed in rostopic list or if \scan is not actively publishing anything, our detection script will fail. We have viewed the data in the terminal and the visualized data in rviz. Remember, this stream of data is always running in the background. We can have our program (or many programs running seperately) subscribe to this topic to access the sensor's data.