Using hls lfcd lds in conjunction with a motor driver for obsticle avoidance

asked 2018-04-09 23:56:26 -0600

sneakycoder gravatar image

updated 2018-04-10 03:30:24 -0600

gvdhoorn gravatar image

I have a hls lfcd lds that i am desperately trying to figure out how to integrate into my robot. i found an arduino library for the sensor Lidar arduino library

Now im trying yo figure out how to get this to play nicely with my motor driver.

Heres my code for the motor driver

my goal is just to establish comminication with the lidar, however im not the best with integrating libraries, and there arnt many examples out there for using the hls lfcd lidar with the arduino.

     /* Ardumoto Example Sketch
  by: Jim Lindblom
  date: November 8, 2013
  license: Public domain. Please use, reuse, and modify this 
  sketch!

  Adapted to v20 hardware by: Marshall Taylor
  date: March 31, 2017

  Three useful functions are defined:
    setupArdumoto() -- Setup the Ardumoto Shield pins
    driveArdumoto([motor], [direction], [speed]) -- Drive [motor] 
      (0 for A, 1 for B) in [direction] (0 or 1) at a [speed]
      between 0 and 255. It will spin until told to stop.
    stopArdumoto([motor]) -- Stop driving [motor] (0 or 1).

  setupArdumoto() is called in the setup().
  The loop() demonstrates use of the motor driving functions.
*/

// Clockwise and counter-clockwise definitions.
// Depending on how you wired your motors, you may need to swap.
#define FORWARD  0
#define REVERSE 1

// Motor definitions to make life easier:
#define MOTOR_A 0
#define MOTOR_B 1

// Pin Assignments //
//Default pins:
#define DIRA 2 // Direction control for motor A
#define PWMA 3  // PWM control (speed) for motor A
#define DIRB 4 // Direction control for motor B
#define PWMB 11 // PWM control (speed) for motor B

////Alternate pins:
//#define DIRA 8 // Direction control for motor A
//#define PWMA 9 // PWM control (speed) for motor A
//#define DIRB 7 // Direction control for motor B
//#define PWMB 10 // PWM control (speed) for motor B


void setup()
{
  setupArdumoto(); // Set all pins as outputs
}

void loop()
{
  // Drive motor A (and only motor A) at various speeds, then stop.
  driveArdumoto(MOTOR_A, REVERSE, 255); // Set motor A to REVERSE at max
  delay(1000);  // Motor A will spin as set for 1 second
  driveArdumoto(MOTOR_A, FORWARD, 127);  // Set motor A to FORWARD at half
  delay(1000);  // Motor A will keep trucking for 1 second 
  stopArdumoto(MOTOR_A);  // STOP motor A 

  // Drive motor B (and only motor B) at various speeds, then stop.
  driveArdumoto(MOTOR_B, REVERSE, 255); // Set motor B to REVERSE at max
  delay(1000);  // Motor B will spin as set for 1 second
  driveArdumoto(MOTOR_B, FORWARD, 127);  // Set motor B to FORWARD at half
  delay(1000);  // Motor B will keep trucking for 1 second
  stopArdumoto(MOTOR_B);  // STOP motor B 

  // Drive both
  driveArdumoto(MOTOR_A, FORWARD, 255);  // Motor A at max speed.
  driveArdumoto(MOTOR_B, FORWARD, 255);  // Motor B at max speed.
  delay(1000);  // Drive forward for a second
  // Now go backwards at half that speed:
  driveArdumoto(MOTOR_A, REVERSE, 127);  // Motor A at max speed.
  driveArdumoto(MOTOR_B, REVERSE, 127);  // Motor B at max speed.
  delay(1000);  // Drive forward for a second

  // Now spin in place!
  driveArdumoto(MOTOR_A, FORWARD, 255);  // Motor A at max speed.
  driveArdumoto(MOTOR_B, REVERSE, 255);  // Motor ...
(more)
edit retag flag offensive close merge delete

Comments

gvdhoorn gravatar image gvdhoorn  ( 2018-04-10 05:26:48 -0600 )edit

I can't find it what you want in your writing.

Pyo gravatar image Pyo  ( 2018-04-10 18:45:45 -0600 )edit

i just want to integrate the turtebots lidar sensor with the arduino on a extremely basic level

sneakycoder gravatar image sneakycoder  ( 2018-04-10 18:47:12 -0600 )edit

The LDS library provided by OpenCR is the same as the other Arduino libraries. You can use it as you like. I still don't know what your exact question is.

Pyo gravatar image Pyo  ( 2018-04-15 16:43:59 -0600 )edit