Giter VIP home page Giter VIP logo

rplidar_arduino's People

Contributors

cheaven avatar robopeak avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rplidar_arduino's Issues

How to import these files into my project?

Hello
I use sublime text2 as my Arduino IDE, but when I try to import these files in to my project, it gives me an error:
2015-10-31 11 07 03
please help me to fix this issue, thanks a lot!

improper data with Arduino

I have tried the simple_connect example with Arduino Mega. Because I can't use Arduino UNO for checking results. Here, I have tried to use Serial1 for checking lidar data, but the data is improper.

Output:

theta: 200.25 Dist: 01659.00 Q: 47
theta: 50.80 Dist: 01700.00 Q: 47
theta: 340.80 Dist: 02213.00 Q: 47
theta: 73.33 Dist: 02208.00 Q: 47
theta: 211.89 Dist: 02222.00 Q: 47
theta: 111.44 Dist: 02229.00 Q: 47
theta: 79.00 Dist: 02234.00 Q: 47
theta: 204.55 Dist: 02238.00 Q: 47

Is there any way to solve this problem?

arduino doesn't work like that "roslaunch rplidar_ros rplidarNodeClient"?

i following robopeak example "simple_connent"
but that protocol send measuring samples very little
⸮P⸮%⸮ angle : 40.36, distance : 217.50
angle : 34.48, distance : 227.25
angle : 36.42, distance : 222.75
angle : 37.09, distance : 221.50
angle : 37.77, distance : 221.00
angle : 38.42, distance : 220.00
angle : 39.09, distance : 219.50
angle : 40.02, distance : 0.00
angle : 40.44, distance : 208.00
angle : 40.06, distance : 218.50
angle : 41.77, distance : 217.75
angle : 42.41, distance : 217.25
angle : 41.97, distance : 4687.50
⸮P⸮%⸮ angle : 287.13, distance : 392.00
angle : 272.73, distance : 431.00
angle : 273.47, distance : 427.75
angle : 278.63, distance : 0.00
angle : 279.36, distance : 0.00
angle : 280.02, distance : 0.00
angle : 276.97, distance : 370.25
angle : 277.13, distance : 370.50
angle : 278.25, distance : 370.50
angle : 278.73, distance : 370.00
angle : 279.67, distance : 349.00
angle : 279.94, distance : 347.50
angle : 281.02, distance : 5306.25
⸮P⸮%⸮

how to recieve samples like roslaunch rplidar_ros rplidarNodeClient?

my code ::

#include <RPLidar.h>

RPLidar lidar;

#define RPLIDAR_MOTOR 3
void setup() {
lidar.begin(Serial);
pinMode(RPLIDAR_MOTOR, OUTPUT);

}
void Count() {
time += 0.1;
}

int a=0;
void loop() {
while(IS_OK(lidar.waitPoint())) {
//perform data processing here...

float distance = lidar.getCurrentPoint().distance;
float angle = lidar.getCurrentPoint().angle;

      Serial.print("angle : ");
      Serial.print(angle);
      Serial.print(", distance : ");
      Serial.println(distance);

}

rplidar_response_device_info_t info;
if (IS_OK(lidar.getDeviceInfo(info, 100)) && !IS_OK(lidar.waitPoint())) {

   //detected...
   lidar.startScan();
   
   analogWrite(RPLIDAR_MOTOR, 255);
   delay(500);

  }

}

baud rade

so the thing is working its turning but which baud raid I need to use to see the result because now there are only "?" marks

Arduino - stepper - Lidar

Hello,

I'm using Arduino UNO with RPLIDAR A1 and Stepper motor. I'm trying to run both together and get the output in this way:
Step no:
Angle:
Distance:
Step no:
Angle:
Distance:
and so on.

When I run the code, stepper runs for some time and then LIDAR comes into motion along with stepper after some rotations finished by stepper motor.
On the serial monitor also I'm not seeing in the format that I want to see.

How do I run both simultaneously and get the LIDAR's angle and distance output for each step of the stepper motor? I need help with running both together.

I've researched some resources online and I've got to know that delay function should not be used in stepper mode code. micros() function is used in my code.

How do I approach this issue such that I can make both LIDAR and my motor run at once and fetch data together? Please help me with this situation.

RPLIDAR A1 code is from https://github.com/robopeak/rplidar_arduino

I've edited the distance_to_color.ino file from the examples section in the above URL according to my requirement. Let me know how I can solve this problem.

`
/*
RoboPeak RPLIDAR Arduino Example
This example shows how to control an RGB led based on the scan data of the RPLIDAR

The RGB led will change its hue based on the direction of the closet object RPLIDAR has been detected.
Also, the light intensity changes according to the object distance.

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
  4. Connect an RGB LED to your Arduino board, with the Red led to pin 9, Blue led to pin 10, Green led to pin 11
  5. Connect the required power supplies.
  6. RPLIDAR will start rotating when the skecth code has successfully detected it.
  7. Remove objects within the 0.5 meters' radius circule range of the RPLIDAR
  8. Place some object inside the 0.5 meters' range, check what will happen to the RGB led :)
    */

/*
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 pin used
const int stepPin = 9;
const int dirPin = 8;

long previoustime = 0;
long interval = 1000;

float distance, angle;
/////////////////////////////////////////////////////////////////////////////

#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() {
// bind the RPLIDAR driver to the arduino hardware serial
lidar.begin(Serial);

// set pin mode for LIDAR Motor
pinMode(RPLIDAR_MOTOR, OUTPUT);

// set the two pins for Stepper motor as outputs
pinMode(stepPin, OUTPUT);
pinMode(dirPin, OUTPUT);

}

// digitalWrite(dirPin,HIGH); //Enables the motor to move in a cw direction
// // for one full rotation required 960 pulses
// for(int x = 0; x < 960; x++){
// digitalWrite(stepPin,HIGH);
// delayMicroseconds(1000);
// digitalWrite(stepPin,LOW);
// delayMicroseconds(1000);
// }
//
// digitalWrite(dirPin, LOW); //Enables the motor to move in the opposite direction
// for(int x = 0; x < 960; x++){
// digitalWrite(stepPin,HIGH);
// delayMicroseconds(1000);
// digitalWrite(stepPin,LOW);
// delayMicroseconds(1000);
// }

void loop() {
digitalWrite(dirPin, HIGH); //Enables the motor to move in a cw direction
// for one full rotation required 960 pulses
for (int x = 0; x < 960; x++) {

unsigned long currenttime = micros();
if (currenttime - previoustime > interval)
{
  digitalWrite(stepPin, LOW);
  digitalWrite(stepPin, HIGH);
  distance = lidar.getCurrentPoint().distance;
  angle = lidar.getCurrentPoint().angle;
  Serial.println("1Angle is:" + String(angle));
  Serial.println("1Distance is:" + String(distance));

  previoustime = currenttime;
}
Serial.println("Step:" + String(x));

}

digitalWrite(dirPin, LOW); //Enables the motor to move in the opposite direction
// for one full rotation required 960 pulses
for (int x = 0; x < 960; x++) {

unsigned long currenttime = micros();
if (currenttime - previoustime > interval)
{
  digitalWrite(stepPin, LOW);
  digitalWrite(stepPin, HIGH);
  distance = lidar.getCurrentPoint().distance;
  angle = lidar.getCurrentPoint().angle;
  Serial.println("2Angle is:" + String(angle));
  Serial.println("2Distance is:" + String(distance));
  previoustime = currenttime;
}
Serial.println("Step:" + String(x));

}

if (IS_OK(lidar.waitPoint())) {
//perform data processing here...

distance = lidar.getCurrentPoint().distance;
angle = lidar.getCurrentPoint().angle;
Serial.println("3Angle is:" + String(angle));
Serial.println("3Distance is:" + String(distance));

}
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();
analogWrite(RPLIDAR_MOTOR, 255);
delay(1000);
}
}
}`

Support for RP Lidar A2

Hello,

I currently am facing some issues when using this library with the Lidar A2. So, I was wondering if there was any support specific for the A2.

How to use the variables: startBit & quality?

Hi,

I would like to know how to use the following variables:

bool  startBit = lidar.getCurrentPoint().startBit; //whether this point is belong to a new scan
byte  quality  = lidar.getCurrentPoint().quality; //quality of the current measurement

Documentation ? A2 / 4K support ?

Hello,

I buyed RPLIDAR A2 and I want to implement the 4K frame reading on the powerfull arduino compatible PIC32MX795 (Diligent ChipKit)

This lib support 4K express scan mode ?

Thanks.

RPLidar.h: No such file or directory

Hallo
Hello
I need your help please I work with ardouino Mega 250 and RPLidar A1 during compilation my said this error knowing that I try to add the yib file for the binlioteck
in between I notice that there is no librery file for this project
than what I want to do and thank you

RPLIDAR A1 with Arduino Leonardo

Hi.
I want to connect RPLIDAR with arduino leonardo.
So I tried to use below code.

#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
bool transmit = false;
byte incomingByte;

void setup() {
  // bind the RPLIDAR driver to the arduino hardware serial
  Serial.begin(9600);
  lidar.begin(Serial1);
 
  Serial.begin(115200);
  while (!Serial) {
    ; //
  }

  // 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
    if (Serial.available() > 0) {
      incomingByte = Serial.read();
      transmit = !transmit;
    }
    Serial.println(distance);
    //perform data processing here...


  } 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))) {

      Serial.println("Detected");
      // detected...
      lidar.startScan();
      analogWrite(RPLIDAR_MOTOR, 255);
      delay(1000);
    }
  }
}

When I executed this program, RPLIDAR didn't work.
The code is stuck in the "else" part.
When I did "analogWrite(RPLIDAR_MOTOR, 255);" motor rotated well but data was empty.
Maybe RPLIDAR didn't connected... "if (IS_OK(lidar.getDeviceInfo(info, 100)))" this part is "False".
How can I fix this problem??

recording a frame

Hi,

an example on how to record one frame and send it by serial port would be nice. (It is clear that some data may be lost during the serial output)

I tried it with my Arduino Mega. Lidar on UART3, PC on USB.
I tried to record one frame in an int array[359] and send it as soon as the next frame starts. But this results in very strange output. After two hours of try and error I concluded that I must run into a memory overflow. I don't know how much memory gets allocated during runtime - but this may be the issue.

Long story short request:
A demo for grabing and sending one frame woulde be nice.

Thanks
Robert

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.