Robot platform construction (four)-assembling laser radar for the robot

Robot platform construction (four)-assembling laser radar for the robot

Overview

It is very necessary for a mobile robot to obtain information such as the specific location of obstacles and the internal outline of a room in the environment. This information is the basic data for the robot to create maps and conduct navigation. Lidar is used as a sensor in this scenario.
Lidar can be used to measure the distance between the robot and other objects.

1. Rplidar function package

For lidar, there is a corresponding driver function package-rplidar in ROS. The related topics and parameter setting interface of this function package are as follows.
(1) Topics and services
Topics released by the rplidar function package and services provided.
Thread Thread
Name: Scan
Type: sensor_msgs / LaserScan
Description: Published lidar data
services
Name: stop_motor
Type: std_srvs / Empty
Description: Stop the motor rotation

Name: start_motor
Type: std_srvs/Empty
Description: Start rotating the motor
(2) Parameters
available for configuration in the rplidar function package
Parameter: serial_port
Type: string
Default value: "/dev/ttyUSB0"
Description: Lidar serial port name

Parameter: serial_baudrate
Type: int
Default value: 115200
Description: Serial port baud rate

Parameter: frame_id
Type: string
Default value: "laser"
Description: Lidar coordinate system

Parameter: inverted
Type: bool
Default value: false
Description: Whether to install upside down

Parameter: angle_compensate
Type: bool
Default value: true
Description:
The installation of the angle compensation rplidar function package can be completed with the following command:

sudo apr-get install ros-kinetic-rplidar-ros

2. PC end drives rplidar

Connect rplidar to the USB interface on the PC side, and use the lsusb command to check whether the connection is successful.
It is possible to encounter serial port permission issues during the startup of lidar.
Use the following command to add user permissions to solve this problem. Among them, USER_NAME is the current user name. After setting, you need to log out and log in to the Ubuntu system again:

sudo gpasswd --add USER_NAME dialout

After normal work, you can use lidar to obtain information, use the following command to start the laser node:

rosrun rplidar_ros rplidarNode

If there is no error in the output information in the terminal, it means that rplidar has started successfully.
Use the rostopic command to view the list of topics in the current system:

rostopic list

If you want to see more information about the release of lidar, you can print it with the following command:

rostopic echo /scan

However, the laser data in the terminal is not vivid, so you can use rviz to display the laser radar data under the graphical interface. Modify the "Fixed Frame" to "laser", click the "Add" button to add the LaserScan display plug-in, set the plug-in to subscribe to the "/scan" topic, and you can see the lidar information.
You can also use the commands in the rplidar function package to view the laser data directly in rviz:

roslaunch rplidar_ros view_rplidar.launch

Guess you like

Origin blog.csdn.net/weixin_45661757/article/details/113192409