RPLIDAR 2017-05-15 rev.1.0 Low Cost 360 Degree Laser Range Scanner Introduction to Standard SDK w w w .sla m te c .c om S h a n g h a i S la m te c .C o .
Contents CONTENTS ................................................................................................................................................... 1 INTRODUCTION ......................................................................................................................................... 3 SDK ORGANIZATION ......................................................................................................................................... 3 BUILD SDK AND DEMO APPLICATIONS ..
Introduction This document introduces the open source RPLIDAR standard SDK. The SDK can be used in Windows, MacOS (10.x) and Linux environment by using Microsoft Visual C++ 2010 and Makefile. SDK Organization The RPLIDAR standard SDK organized as bellow: Figure 1-1 The RPLIDAR standard SDK organization The workspaces directory contains VS project files for SDK and related demo applications.
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).
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.
Demo Application Figure 1-4 Develop RPLIDAR Standard SDK in MacOS 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 with Make build system. 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.
Figure 2-1 ultra_simple Demo Application Data Output Steps: 1) Connect RPLIDAR to PC by using the provided USB cable. (The chip transforming the USB to serial port is embedded in the RPLIDAR development kit) 2) Start application by using the following command: o Windows ultra_simple Note: if the com number is larger than 9, e.g. com11, then you should start application use command like this: ultra_grabber \\.\com11 o Linux ultra_simple e.g. ultra_simple /dev/ttyUSB0.
ultra_simple e.g. ultra_simple /dev/tty.SLAB_USBtoUART. 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.
Note: if the com number is larger than 9, e.g. com11, then you should start application use command like this: ultra_grabber \\.\com11 o Linux simple_grabber e.g. ultra_simple /dev/ttyUSB0. o Linux simple_grabber e.g. ultra_simple /dev/tty.SLAB_USBtoUART. frame_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.
Steps: 1) Connect RPLIDAR to pc using provided USB cable. (USB to serial chip embedded in RPLIDAR development kit) 2) Choose correct com port number through com port selection dialog. 3) Press start scan button (marked in red in the figure above) to start. 10 / 17 Copyright (c) 2009-2013 RoboPeak Team Copyright (c) 2013-2017 Shanghai Slamtec Co., Ltd.
SDK Usage and Development Guide 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.
This header defines low-level data structures and constants for RPLIDAR protocol. o rplidar_cmd.h This header defines request/answer data structures and constants for RPLIDAR protocol. o rptypes.h This header defines platform-independent data structures and constants. SDK Initialization and Termination User programs are required to create an RPlidarDriver instance via SDK before communicating with an RPLIDAR device.
Once the user program finishes operation, it can call the disconnect() function to close the connection and release the serial port device. Motor Start and Stop Control The following functions are related to the motor control: Function Name Brief Introduction startMotor() Request RPLIDAR to start the motor rotating. For RPLIDAR A1, this interface will enable DTR to set the motor start rotating by default.
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 grabScanData() function to fetch. User programs can use the grabScanData() 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.
The Operations Related to the Accessory Board For the accessory board included in some RPLIDAR development kits, since the board supports speed control via PWM, this feature can be implemented by invoking the following functions: Function Name checkMotorCtrlSupport () setMotorPWM () Brief description Check whether the accessory board supports the PWM control. Please refer to the SDK header files notes for details about the usage.
Revision History Date 2013-3-5 2014-1-25 2014-3-8 2014-7-25 2016-4-12 2016-05-03 2017-05-15 Description Initial version Added Linux content and updated related information Added description for the ultra_simple demo application Added description about developing under MacOS environment Added description about the cross compiling Added description about the newly added firmware interface of 1.5.1 Added description about the newly added interface of 1.5.
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 ..............................................................................................