SLAMTEC RPLIDAR Low Cost 360 Degree Laser Range Scanner Instruction Manual

June 3, 2024
SLAMTEC

SLAMTEC RPLIDAR Low Cost 360 Degree Laser Range Scanner

Introduction

This document introduces the standard open source version of the RPLIDAR SDK V2.0. The SDK uses Microsoft Visual C++ 2010, Microsoft Visual C++ 2019 and Makefile to compile under the environment of Windows, MacOS (10.x) and Linux. RPLIDAR SDK V2.0 is designed in principle and compatible with v1.x version through macro definition.

SDK Organization

The RPLIDAR standard SDK organized as bellow: SLAMTEC-RPLIDAR-Low-Cost-360
-Degree-Laser-Range-Scanner-FIG-1

The workspaces directory contains VS project files for SDK and related demo applications. The sdk directory contains the external header files(the include folder) of RPLIDAR driver application and the internal implementation code of SDK itself(the src folder). The app directory contains the related sample code. And SLAMTEC provides the following demo applications in the app directory:

ultra_simple

An ultra-simple command line application demonstrates the simplest way to connect to an RPLIDAR device and continuously fetching the scan data and outputting the data to the console. Users can quickly integrate RPLIDAR to their existing system based on this demo application.

simple_grabber

  • A command line grab application. Each execution will grab two round of laser data and show as histogram.

frame_grabber

A win32 GUI grab application. When pressing start scan button, it will start scan continuously and show the data in the UI. For SDK after compilation, there will be two more subfolders in the SDK: obj and output. The output folder contains generated SDK static library (.lib or .a) and demo application executable files (exe or elf). obj folder contains intermediate files generated during compilation.

Build SDK and Demo Applications
If you’re developing under Windows, please open VS solution file sdk_and_demo.sln under workspaces\vc10 or workspaces\vc14. It contains the SDK project and all demo application projects.SLAMTEC-RPLIDAR-Low-Cost-360
-Degree-Laser-Range-Scanner-FIG-2

Now, you can develop SDK and all the demo applications in VS environment easily. There are two ways of compiling: Debug and Release. And you can choose according to your requirement. Depends on your build configure, the generated binary can be found under output\win32\Release or output\win32\Debug. If you’re developing under Linux or MacOS, just type “make” under the root of SDK directory to start compiling. It will do Release build by default, and you can also type “make DEBUG=1” to do Debug build. The generated binary can be found under the following folders:

  • Linux
    • output\Linux\Release
    • output\Linux\Debug.
  • MacOS
    • output\Darwin\Release
    • output\Darwin\Debug.SLAMTEC-RPLIDAR-Low-Cost-360-Degree-Laser-Range-Scanner-FIG-3SLAMTEC-RPLIDAR-Low-Cost-360-Degree-Laser-Range-Scanner-FIG-4

Cross Compile
The SDK build system allows you to generate binaries which run on another platform/system using the cross-compiling feature.

NOTE: this feature only works on where using Makefile. The cross compile process can be triggered by invoking the cross_compile.sh script under the SDK root folder. The common usage is:CROSS_COMPILE_PREFIX= ./cross_compile.sh  e.g. CROSS_COMPILE_PREFIX=arm-linux-gnueabihf ./cross_compile.sh

Demo Application

ultra_simple
The demo application simply connects to an RPLIDAR device and outputs the scan data to the console:SLAMTEC-RPLIDAR-Low-Cost-360-Degree-Laser-Range-Scanner-
FIG-5

Steps:

  1. According to the lidar model and configuration, the following three connection modes are available:
    • Connect RPLIDAR to PC by using the provided USB cable and PIC. (The chip transforming the USB to serial port is embedded in the RPLIDAR development kit)
    • Connect RPLIDAR to PC by using the provided Ethernet module. (using TCP/IP protocol)
    • Connect RPLIDAR to PC by using the body network cable. (using UDP protocol)
  2. According to the connection mode, the following command is used to start the sample program:
    • ultra_simple –channel –serial [baudrate] : the serial port # Windows: \\.\com3
    • MacOS: /dev/tty.SLAB_USBtoUART
    • Linux: /dev/ttyUSB0
    • [baudrate]: the communication baudrate
    • A2 : 115200
    • A3/S1: 256000
    • S2: 1000000
    • ultra_simple –channel –tcp [port] : the IP address of the radar or Ethernet module  [port]: Port number,20108
    • ultra_simple –channel –udp [port] : the IP address of the radar  [port] : Port number,8089

simple_grabber
This application demonstrates the process of getting RPLIDAR’s serial number, firmware version and healthy status after connecting the PC and RPLIDAR. Then the demo application grabs two round of scan data and shows the range data as histogram in the command line mode. User can print all scan data if needed .SLAMTEC-RPLIDAR-Low-Cost-360-Degree-Laser-Range-Scanner-
FIG-6

Steps:

  1. According to the lidar model and configuration, the following three connection modes are available:
    • Connect RPLIDAR to PC by using the provided USB cable and PIC. (The chip transforming the USB to serial port is embedded in the RPLIDAR development kit)
    • Connect RPLIDAR to PC by using the provided Ethernet module. (using TCP/IP protocol)
    • Connect RPLIDAR to PC by using the body network cable. (using UDP protocol)
  2. According to the connection mode, the following command is used to start the sample program:
    • ultra_simple –channel –serial [baudrate] : the serial port #
    • Windows: \\.\com3
    • o MacOS: /dev/tty.SLAB_USBtoUART
    • Linux: /dev/ttyUSB0
    • [baudrate]: the communication baudrate
    • A2: 115200
    • A3/S1: 256000
    • S2: 1000000
    • ultra_simple –channel –tcp [port] : the IP address of the radar or Ethernet module  [port]: Port number,20108
    • ultra_simple –channel –udp [port] : the IP address of the radar  [port] : Port number,8089frame_grabber

This demo application can show real-time laser scan data in the GUI with 0-360 degree environment range data. Note, this demo application only has win32 version. SLAMTEC-RPLIDAR-Low-Cost-360-Degree-Laser-Range-Scanner-
FIG-7

Steps:

  1. According to the lidar model and configuration, the following three connection modes are available:
    • Connect RPLIDAR to PC by using the provided USB cable and PIC. (The chip transforming the USB to serial port is embedded in the RPLIDAR development kit)
    • Connect RPLIDAR to PC by using the provided Ethernet module. (using TCP/IP protocol)
    • Connect RPLIDAR to PC by using the body network cable. (using UDP protocol)
  2. According to the connection mode, the following command is used to start the sample program:
    • Connect RPLIDAR to PC by using the provided USB cable and PIC. (The chip transforming the USB to serial port is embedded in the RPLIDAR development kit)  Select the correct serial port number in the dialog box.

SDK Usage and Development

Click the Start scan button (shown in the red box) to start the scan.

  * Always enter the correct IP address and port number in the dialog box Select TCP and click the OK button. Click the Start scan button (shown in the red box) to start the scan.
  * Always enter the correct IP address and port number in the dialog box. Select UDP and click the OK button. Click the Start scan button (shown in the red box) to start the scan.![SLAMTEC-RPLIDAR-Low-Cost-360-Degree-Laser-Range-Scanner-FIG-8](https://manuals.plus/wp-content/uploads/2022/11/SLAMTEC-RPLIDAR-Low-Cost-360-Degree-Laser-Range-Scanner-FIG-8.png)

Assumption
We strongly recommend developers learn RPLIDAR’s communication protocol and working mode before starting development by using the RPLIDAR SDK.
This document assumes developer has related knowledge about C++ development.

SDK usage
The RPLIDAR standard SDK provides static library for developers to integrated the SDK feature into their existing project. If the dynamic library is required, the developers can also set it by easily modifying the project configurations. When developing via RPLIDAR SDK, developers only need to include SDK’s external header files (under sdk\include) into their own source code and link the application with SDK’s static library (rplidar_driver.lib or rplidar_driver.a). For VS developers, they can also include the SDK’s VC project into their own project and set the related project dependence. For Linux developers, please refer to the simple_grabber’s Makefile for detailed settings. PS: To be compatible with earlier SDK, static libraries are still named rplidar_drvier. Please check rplidar_driver.h, sl_lidar_driver.h for details.

Runtime consistency
For windows developers: the SDK static library c uses VC10 MD C runtime library. If your project used different C runtime library may lead to compilation failure or unpredictable behavior. Then please change SDK settings accordingly.

SDK Headers

  • sl_lidar.h
    Usually, you only need to include this file to get all functions of RPLIDAR SDK.

  • sl_lidar_driver.h
    This header defines the SDK core drive interface: the RPLidarDriver class. Please refer to demo applications ultra_simple or simple_grabber to understand how to use it.

  • sl_lidar_protocol.h
    This header defines low-level data structures and constants for RPLIDAR protocol.

  • sl rplidar_cmd.h
    This header defines request/answer data structures and constants for RPLIDAR protocol.

  • sl rptypes.h
    This header defines platform-independent data structures and constants.

SDK Initialization and Termination
The communication between user program and an RPLIDAR device can be made by doing below actions (Details can be checked from sample program, for example, ultra simple):

    1. Create a LIDAR driver instance.
      ILidarDriver drv = createLidarDriver();
      Create a corresponding communication channel based on different connections of Lidar.
    • Connect RPLIDAR to PC by using the provided USB cable and PIC.
    • param device Serial port device
    • e.g. on Windows, it may be com3 or \\.\com10
    • on Unix-Like OS, it may be /dev/ttyS1, /dev/ttyUSB2, etc
    • param baudrate Baudrate
    • Please refer to the datasheet for the baudrate (maybe 115200 or 256000)
    • std::string device = “com3”; int baudrate = 115200; Result<IChannel*> channel = createSerialPortChannel(“/dev/ttyUSB0”, 115200);
    • Connect RPLIDAR to PC by using the provided Ethernet module. (using TCP/IP protocol) Result< IChannel *> channel = createTcpChannel(“192.168.11.2”, 20108);
    • Connect RPLIDAR to PC by using the body network cable. (using UDP protocol) Result< IChannel *> channel = createTcpChannel(“192.168.11.2”,8089);

An ILidarDriver instance can communicate with only one RPLIDAR in the system at the same time. However a user program can create any several ILidarDriver instances to communicate with any several RPLIDAR devices. Once user programs finish operations, all previously created lidar driver instances should be released explicitly using the following static function in order to free system memory.

  • delete drv;
  • delete channel;

Connecting to an RPLIDAR
After creating an IlidarDriver instance, the user program should invoke the connect() function firstly to open the serial port and connect with the RPLIDAR device. All RPLIDAR operations require invoking the connect() function first.

  • auto res = (lidar)->connect(channel);
  • The function returns RESULT_OK for success operation.

Once the user program finishes operation, it can call the disconnect() function to close the connection and release the serial port device.

Measurement Scan and Data Acquiring
The following functions are related to the measurement scan operation and help user programs to acquire the measurement data:SLAMTEC-RPLIDAR-Low-Cost-360
-Degree-Laser-Range-Scanner-FIG-11

The startScan() function will start a background worker thread to receive the measurement scan data sequence sent from RPLIDAR asynchronously. The received data sequence is stored in the driver’s internal cache for the grabScanDataHg() function to fetch. User programs can use the grabScanDataHg() function to retrieve the scan data sequence previously received and cached by the driver. This function always returns a latest and complete 360-degrees’ measurement scan data sequence. After each grabScanDataHg() call, the internal data cache will be cleared to ensure the grabScanDataHg() won’t get duplicated data. In case a complete 360-degrees’ scan sequence hasn’t been available at the time when grabScanDataHg() is called, the function will wait until a complete scan data is received by the driver or the given timeout duration is expired. User programs can tune this timeout value to meet different application requirements. Please refer to the comments in the header files and the implementation of SDK demo applications for details.

Retrieving Other Information of an RPLIDAR

The user program can retrieve other information of an RPLIDAR via the following functions. Please refer to the comments in the header files and the implementation of SDK demo applications for details.SLAMTEC-RPLIDAR-Low-
Cost-360-Degree-Laser-Range-Scanner-FIG-9

Revision History

SLAMTEC-RPLIDAR-Low-Cost-360-Degree-Laser-Range-Scanner-
FIG-10

Appendix

Image and Table Index

  • FIGURE 1-1 THE RPLIDAR STANDARD SDK ORGANIZATION ……………………………………………………………………………….. 3
  • FIGURE 1-2 THE RPLIDAR STANDARD SDK SOLUTION FILE ……………………………………………………………………………….. 4
  • FIGURE 1-3 DEVELOP RPLIDAR STANDARD SDK IN LINUX …………………………………………………………………………………. 5
  • FIGURE 1-4 DEVELOP RPLIDAR STANDARD SDK IN MACOS …………………………………………………………………………….. 6
  • FIGURE 2-1 ULTRA_SIMPLE DEMO APPLICATION DATA OUTPUT …………………………………………………………………………… 7
  • FIGURE 2-2 SIMPLE_GRABBER DEMO APPLICATION DATA OUTPUT ………………………………………………………………………. 9
  • FIGURE 2-3 FRAME_GRABBER DEMO APPLICATION DATA OUTPUT …………………………………………………………………….. 11
  • FIGURE 2-4 FRAME_GRABBER DEMO APPLICATION DIALOG …………………………………………………………………………………. 12
  • FIGURE 3-1RPLIDAR FUNCTIONS RELATED TO MEASUREMENT SCAN OPERATION………………………………………….. 16
  • FIGURE 3-2RPLIDAR FUNCTIONS RELATED TO RETRIEVING OTHER INFORMATION OPERATION …………………….. 17
    • Copyright (c) 2009-2013 RoboPeak Team
    • Copyright (c) 2013-2022 Shanghai Slamtec Co., Ltd.

Read User Manual Online (PDF format)

Loading......

Download This Manual (PDF format)

Download this manual  >>

SLAMTEC User Manuals

Related Manuals