jerzes
Published

LIDAR 3D point cloud scanner

LIDAR 3D scanner provide the 3D point cloud using ASCII format. It's possible to measure, review in CAD software, distance and area.

AdvancedWork in progress553
LIDAR 3D point cloud scanner

Things used in this project

Hardware components

Garmin Lidar-lite v3HP
×1
Arduino UNO
Arduino UNO
×1
Stepper Motor, Mini Step
Stepper Motor, Mini Step
×2
Driver DRV8825 for Stepper Motors for Theremino System
Driver DRV8825 for Stepper Motors for Theremino System
×2

Hand tools and fabrication machines

3D Printer (generic)
3D Printer (generic)
Soldering Station, 110 V
Soldering Station, 110 V

Story

Read more

Code

Arduino IDE

C/C++
#include <stdint.h>
#include <Wire.h>
#include <LIDARLite_v3HP.h>

#define FAST_I2C

LIDARLite_v3HP myLidarLite;

const float angleResolution = 0.9;
const int dirVerticalPin = 2;
const int stepVeritcalPin = 3;
const int dirHorizontalPin = 8;
const int stepHorizontalPin = 9;
const int stepsPerRevolution = 400;
float h_angle = 1;
float v_angle = 0;


void setup() {
  Serial.begin(115200);
  // Declare pins as Outputs
  pinMode(stepVeritcalPin, OUTPUT);
  pinMode(dirVerticalPin, OUTPUT);
  pinMode(stepHorizontalPin, OUTPUT);
  pinMode(dirHorizontalPin, OUTPUT);
  //Set motor direction clockwise
  digitalWrite(dirVerticalPin, LOW);
  digitalWrite(dirHorizontalPin, HIGH);
  Wire.begin();
  myLidarLite.configure(4);
}


void loop() {
  Serial.println('e');
  while (1) {

    if (Serial.available() > 0) {
      if ((uint8_t)Serial.read() == 'e') {
        lidar();
      }
    }
  }


  exit(0);
}
void lidar() {
  delay(2000);
  uint16_t newDistance;

  for (int h = 0; h < 200; h++) {

    for (int v = 0; v < stepsPerRevolution; v++) {
      float cord_x, cord_y, cord_z;

     if (v < 175 || v > 225) {
        myLidarLite.waitForBusy();
        myLidarLite.takeRange();
        myLidarLite.waitForBusy();
        newDistance = myLidarLite.readDistance();
     
      if (newDistance > 30) {
        cord_x = newDistance * sin(((v_angle * 1000) / 57296)) * cos(((h_angle * 1000) / 57296));
        cord_y = newDistance * sin(((v_angle * 1000) / 57296)) * sin(((h_angle * 1000) / 57296));
        cord_z = newDistance * cos(((v_angle * 1000) / 57296));

        Serial.print(cord_x);
        Serial.print(" ");
        Serial.print(cord_y);
        Serial.print(" ");
        Serial.println(cord_z);
      }
     }
      v_angle = angleResolution * v;
      digitalWrite(stepVeritcalPin, HIGH);
      delayMicroseconds(500);
      digitalWrite(stepVeritcalPin, LOW);
      delayMicroseconds(500);
    }

    digitalWrite(stepHorizontalPin, HIGH);
    delayMicroseconds(1000);
    digitalWrite(stepHorizontalPin, LOW);
    delayMicroseconds(1000);
    h_angle = angleResolution * h;
  }
  Serial.println('s');
}

Credits

jerzes
3 projects • 0 followers
Former IT specialist, now occupied by being unemployed
Contact

Comments

Please log in or sign up to comment.