Over view

This project describes connecting a Slamtech RPLIDAR A1 directly to an Arduino using its in-built serial port. So no need to use the supplied USB interface.

DESCRIPTION

RPLiDAR A1M8 360 Degree Laser Range Finder – 6m (Radius Range) is a low-cost 360-degree 2D laser scanner (LIDAR) solution developed by SLAMTEC. The system can perform a 360-degree scan within a 6-meter range. The produced 2D point cloud data can be used in mapping, localization, and object/environment modelling.

RPLIDAR A1’s scanning frequency reached 5.5 Hz when sampling 360 points each round. And it can be configured up to 10 Hz maximum. RPLIDAR A1 is basically a laser triangulation measurement system. It can work excellently in indoor and outdoor environments without sunlight.

Note: The range of this RPLiDAR is 6-meter if we consider radius and 12-meter if we consider diameter. So we can also name as RPLiDAR A1M8 360 Degree Laser Range Finder – 12M.

Components required table

S.NCOMPONENTSDESCRIPTIONQUANTITYlink
1 RPLIDAR A1 RPLIDAR A11https://www.amazon.in/youyeetoo-Scanning-Obstacle-Avoidance-Navigation
2Arduino Mega 2560 Arduino Mega 25601https://www.amazon.in/AUTO-BOTIX-Arduino-Compatible-Atmega
3jumper wiresjumper wires20https://www.amazon.in/YUVS-Jumper-Wires-female-Pieces

Application:

  1. Home service /cleaning robot navigation and localization.
  2. General robot navigation and localization.
  3. Smart toy localization and obstacle avoidance.
  4. Environment scanning and 3D re-modelling.
  5. General simultaneous localization and mapping

System Connection:

Features:

  1. Measuring distance: Up to 6 meters (Radius).
  2. Measures distance data in more than 8000 times/s.
  3. 360 Degree Omnidirectional Laser Range Scanning.
  4. 8000 times the sample rate, the highest in the current economical LIDAR industry.
  5. OPTMAG Original Design, prolong the lifespan.
  6. Configurable Scan Rate from 2-10Hz.
  7. Ideal for Robot Navigation and Localization.
  8. Plug and Play.

Specifications

ModelRP LIDAR A1M8
Distance range0.2 – 6m (Radius)
0.2 – 12m (Diameter)
Angular range0-360°
Distance resolution<0.5mm (1% of the distance)
Angular resolution=<1°
Sample duration0.125 Mili Seconds
Sample frequency>=8000 Hz
StandoffsM2.5 x 15mm
Scan rate5.5Hz
Length (mm)60
Width (mm)70
Height (mm)99
Weight (gm)170
Shipment Weight0.2 kg
Shipment Dimensions8 × 9 × 8 cm

Pinouts

Download Rplidar a1 for GitHub

First, you’ll need to install the RPLIDAR library from robopeak/rplidar_ros – GitHub

Include library file in Arduino shown below figure

after downloading this GitHub file extract and copy and paste the file into the given path location C:\Users\Devilal\Documents\Arduino\libraries

  • Now open the “simple_connect” example code that is included in the library.
  • Open Arduino File->Example->RPlidarDriver->sample_connect
  • Connect the RPLIDAR’s serial port (RX/TX/GND) to your Arduino Mega board (Pin 0 and Pin1)
  • Connect the RPLIDAR’s motor ctrl pin to the Arduino board pin 3
  • Use an external 5V power supply to power the motor control pin and the LIDAR.

Final Source File

/*
 * RoboPeak RPLIDAR Arduino Example
 * This example shows the easy and common way to fetch data from an RPLIDAR
 * 
 * You may freely add your application code based on this template
 *
 * USAGE:
 * ---------------------------------
 * 1. Download this sketch code to your Arduino board
 * 2. Connect the RPLIDAR's serial port (RX/TX/GND) to your Arduino board (Pin 0 and Pin1)
 * 3. Connect the RPLIDAR's motor ctrl pin to the Arduino board pin 3 
 */
 
/* 
 * Copyright (c) 2014, RoboPeak 
 * All rights reserved.
 * RoboPeak.com
 *
 * Redistribution and use in source and binary forms, with or without modification, 
 * are permitted provided that the following conditions are met:
 *
 * 1. Redistributions of source code must retain the above copyright notice, 
 *    this list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form must reproduce the above copyright notice, 
 *    this list of conditions and the following disclaimer in the documentation 
 *    and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 
 * SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 
 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 
 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 */
 
// This sketch code is based on the RPLIDAR driver library provided by RoboPeak
#include <RPLidar.h>

// You need to create an driver instance 
RPLidar lidar;

#define RPLIDAR_MOTOR 3 // The PWM pin for control the speed of RPLIDAR's motor.
                        // This pin should connected with the RPLIDAR's MOTOCTRL signal 
                       
                        
void setup() {

   Serial.begin(115200);
  // bind the RPLIDAR driver to the arduino hardware serial
  lidar.begin(Serial3);
  
  // set pin modes
  pinMode(RPLIDAR_MOTOR, OUTPUT);
}

void loop() {
  if (IS_OK(lidar.waitPoint())) {
    float distance = lidar.getCurrentPoint().distance; //distance value in mm unit
    float angle    = lidar.getCurrentPoint().angle; //anglue value in degree
    bool  startBit = lidar.getCurrentPoint().startBit; //whether this point is belong to a new scan
    byte  quality  = lidar.getCurrentPoint().quality; //quality of the current measurement
    
    //perform data processing here... 

     Serial.print(distance);       
     Serial.print(" ");  
     Serial.print(angle);       
     Serial.print(" "); 
     Serial.print(startBit);       
     Serial.print(" "); 
     Serial.print(quality);       
     Serial.println(" "); 
  } else {
    analogWrite(RPLIDAR_MOTOR, 0); //stop the rplidar motor
    
    // try to detect RPLIDAR... 
    rplidar_response_device_info_t info;
    if (IS_OK(lidar.getDeviceInfo(info, 100))) {
       // detected...
       lidar.startScan();
       
       // start motor rotating at max allowed speed
       analogWrite(RPLIDAR_MOTOR, 255);
       delay(1000);
    }
  }
}

Output Images

Test Rplidar A1 Scanner

Open give path location and download the ultra_simple.exe

1st open the downloaded .exe file and select the respective port and board rate

2nd after that click on the search button

3rd place your hand beside the rplidar then it will show the result

By Devilal

Leave a Reply

Your email address will not be published. Required fields are marked *