LIDAR API - RobotCasserole1736/RobotCasserole2015 GitHub Wiki
FULL DISCLOSURE
To write this API, I went to someone else's github to download a file which strongly influenced how this api was written.
LIDAR Introduction
LIDAR is a technology. There exists a wikipedia page about LIDAR.
In a teeny tiny nutshell, LIDAR works by sending out some light, and measuring how long it takes for light to come back. Any light will do, but using a laser allows you to precisely target objects.
Different types of LIDAR use different methods of measuring the delay between sending light and getting it back. Light travels at like the speed of light, so it's really fast. Very interesting methods get used for figuring out the "time of flight" of the pulse.
Good news everyone! We paid $$$ to some engineers to do that work for us! We just get a nice little I2C communication interface where we can read an EXTREMELY precise distance, and the LIDAR unit does the "interesting" work for us.
We will use the LIDAR as a simple distance sensor, looking at the distance to a single point in front of us. Presumably, it will measure the distance to a tote. This will augment information acquired from the camera.
I2C Communication
For an excessively laborious explanation of I2C, please read this
LIDAR Hardware
For an excessively laborious explanation of the LIDAR unit we are using, see this
It's cool. It shoots lasers.
API Usage
The LIDAR is very straightforward to use.
You will need an object to describe the LIDAR
LIDAR test_lidar =new LIDAR();
This function sets aside memory for everything the LIDAR needs. How nice.
Before reading anything from the LIDAR, you will need to call the start() method. It's a good idea to do this during one of the init functions.
test_lidar.start();
This function kicks off a separate thread to acquire data from the LIDAR ten times a second. Like the gyro or the PID, this acquisition function runs separately in the background, constantly acquiring data from the LIDAR. You have only to access the data.
You access the data using this method:
measurement = test_lidar.getDistanceIn()
This returns a double representing the current distance read by the gyro in inches.