Skip to content

bmegli/rplidar-a3-arduino

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rplidar-a3-arduino

Arduino/Teensy library for non-blocking communication with RPLidar A3.

Hardware

Library needs:

Purpose

  • speed motor control
  • non-blocking communication
  • raw measurement packets
  • precise timestamps

Note - this library doesn't decode the packets. It starts the lidar, controls the motor, gets the packets synchronizing to boundraries and checking CRC. You may add decoding on your own (hints below). I use this library for precisise synchronization of multiple sensors and do decoding on CPU.

State

Functional.

Implemented:

Dependencies

rpliar-a3-arduino uses Arduino-PID-Library.

Installation

  • in Arduino IDE Sketch -> Include Library -> Manage Libraries... -> PID -> Install
  • copy or clone rplidar-a3-arduino directory to your sketchbook libraries directory

Using

For real use see cave-craler-mcu

#include <rplidar.h>

const int pwmPin = 36;
const int rpm=600; 

//Use Teensy 3.5 hardware serial
RPLidar lidar(Serial1, pwmPin); 
RPLidarPacket packet;

void setup()
{
  lidar.setup(rpm);
  lidar.start();
}
  
void loop()
{
  //this function doesn't block waiting for the packet
  //but it expects the same from the rest of your code
  if( lidar.processAvailable(&packet) )
  {
    //do something with the packet
  }
}

Packet decoding notes

As was already mentioned this library doesn't decode the packets.

If you want to add the decoding:

rplidar_sdk needs 2 consecutive packets to do the decoding. Peeking into the SDK code you may probably decode everything but the last reading (or 4 readings) without the second packet.

For checking if the packets follow one another use the sequence field returned by the library (e.g. i, i+1 or uint8_t max, 0).

Working proof-of-concept:

License

Library is licensed under Mozilla Public License, v. 2.0

This is similiar to LGPL but more permissive:

  • you can use it as LGPL in prioprietrary software
  • unlike LGPL you may compile it statically with your code

Like in LGPL, if you modify this library, you have to make your changes available. Making a github fork of the library with your changes satisfies those requirements perfectly.

About

Arduino/Teensy library for non-blocking communication with RPLidar A3

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages