RPLIDAR Low Cost 360 Degree Laser Range Scanner Introduction to Standard SDK Model: A2M4 2016-05-03 rev.02 上海思岚科技有限公司 www.slamtec.
Contents CONTENTS ................................................................................................................................................... 1 1. INTRODUCTION ................................................................................................................................. 3 SDK ORGANIZATION ......................................................................................................................................... 3 BUILD SDK AND DEMO APPLICATIONS ......
1. 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.
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).
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.
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.
2. Demo Application ultra_simple The demo application simply connects to an RPLIDAR device and outputs the scan data to the console: 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.
o Linux ultra_simple e.g. ultra_simple /dev/ttyUSB0. o Linux 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.
Steps: 1) Connect RPLIDAR to pc using provided USB cable. (USB to serial chip embedded in RPLIDAR development kit) 2) Start application use command: simple_grabber o Windows simple_grabber 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.
Figure 2-3 frame_grabber Demo Application Data Output 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 / 18 Copyright (c) 2009-2013 RoboPeak Team Copyright (c) 2013-2016 Shanghai Slamtec Co., Ltd.
3. 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.
o rplidar_protocol.h 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.
When invoking this interface, by default, the SDK will call stopMotor to stop the rotating of motor. And the SDK will call startMotor to start the rotating of motor before taking measurement. Once the user program finishes operation, it can call the disconnect() function to close the connection and release the serial port device.
Function Name Brief description Request the RPLIDAR core to start measurement scan operation and send out result data continuously startScan() startScanNormal() If the Express Scan mode is supported, and the program invokes the startScan() by using the default parameters Force the RPLIDAR core to start measurement scan operation in Scan mode Force the RPLIDAR core to start measurement scan operation in startScanExpress() Express Scan mode.
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. Function Name getHealth() Brief description Get the healthy status of an RPLIDAR getDeviceInfo() Retrieve the device information, e.g.
Function Name Brief description Check whether the accessory board supports the PWM control. checkMotorCtrlSupport () setMotorPWM () Please refer to the SDK header files notes for details about the usage. Send specific PWM duty cycle to the accessory board to control the motor rotating speed of the RPLIDAR. Please refer to the SDK header files notes for details about the usage.
4. Revision History Date Description 2013-3-5 Initial version 2014-1-25 Added Linux content and updated related information 2014-3-8 Added description for the ultra_simple demo application 2014-7-25 2016-4-12 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 ..............................................................................................