SweepObstacleDetector
Contents
Sweep Obstacle Detector
Purpose
The purpose of this board is to use the Scanse Sweep lidar sensor to detect obstacles in front of the vehicle and signal to the C2 when an obstacle is present.
Configuration
The Sweep is mounted on the front of the bike and is controlled by an Arduino Micro. It is connected to the C2 by TX and GND wires.
Pin connections
*Pin* | *Connection* | |
1 | Serial TX to C2 |
2 | Sweep Power Enable |
3 | Sweep Sync / Device Ready |
8 | Serial RX to Sweep (!SoftwareSerial) |
9 | Serial TX to Sweep (!SoftwareSerial) |
1st GND | |
2nd GND |
Code
Distance Lookup Table
DistanceLookupTable.h DistanceLookupTable.cpp
This class is used to generate a lookup table to represent the field around the trike wherein an obstacle can be found. Objects detected outside of this field are not obstacles.
How to Use
Create a DistanceLookupTable object like so, passing in the width of your vehicle, the speed of your vehicle, and the time to fully stop:
DistanceLookupTable table(vehicleWidth_cm, vehicleSpeed_cmPs, brakeTime_ms);
Then, query the table by passing in the angle (in degrees) of the reading:
uint16_t distance = table.getDistance(angle);
Sweep Obstacle Detector
Sweep_Obstacle_Detector.ino
This Arduino Micro sketch runs the Sweep and constantly checks readings to determine if an obstacle is present. If so, it writes an ElcanoSerial message to the C2.
The sweep-arduino library is needed to compile this sketch.
LowLevel Test
LowLevel_Test.ino
This is a simple test to be used with the LowLevel board. It tests the connection to the Sweep Arduino, and control of the brakes.
Distance Lookup Table Test
DistanceLookupTableTest.cpp
This utility takes command-line arguments, constructs a DistanceLookupTable object based on those arguments, and prints out the table.
-- Main.JohnsonB - 2017-11-06