Hoping to get some advice or direction on a project of mine.
The project goal is to create a point map using distance measurements taken from a sensor. I have created a prototype, but I am running into a few issues.
The prototype consists of:
- Arduino Uno
- XBee mounted on an XBee shield
- Two Hi-tec HS-422 servos
- PulsedLight LIDAR-Lite IR distance sensor
Nothing special in the physical setup of this, the servos have 100uf decoupling capacitors. Here is a picture:
This prototype communicates with an XBee that I have plugged into my laptop. I read the serial data in a Visual Studio created program, in which I then draw a basic depth image using OpenGL.
The logical process of the Arduino prototype is:
- Scan horizontally right to left for 90 degrees, storing one measurement per degree
- Serially send the 90 values (I convert the array to a String and send the string)
- Move back to the rightmost position and vertically move down 2 degrees
- Repeat 1 to 3 until 45 horizontal scans have been completed
This provides a final array on my laptop that is 90 by 45 (array[45][90]). I then iterate over this and draw each point as its measurement value divided by 255 to get a colour value. So 0 being black and 1 being white, a measurement of 150cm becomes 150/255 = 0.588.
Here is a video of the prototype in action:
Working IR Scan (Youtube)
Here is the OpenGL result, which doesn't look too bad (although I have just realised that the shape on the left, which I thought was some shelves is actually a squashed version of the main image):
Now here is a video of one of the issues that I am encountering. About 50% of the time, at any point during the scan, the servos will start to move incredibly slowly and with random jitters. Does anyone know what could be causing this?
IR Scan with issues (Youtube)
One issue I have already overcome was the conflict between SoftwareSerial and Servo due to the libraries using interrupts (I think?), which is why I am using SoftwareServo within my Arduino code.
I would greatly appreciate any feedback or ideas on how to improve this design, even if it means changing a fundamental part. Some of my current thoughts are:
I am a little concerned at the speed of the device; there is obviously a massive hit in speed as soon as I start taking the IR distance measurements. Is there anything I could actually do to help this, or is that just the limitation of the Arduino Uno?
The final 2D depth image isn’t particularly clear, but I suppose that is just because of the resolution and could be resolved with more measurements (At the hit of a much slower scan). Can I move a servo for decimal degrees (ie. move it 0.5 each time to get double the readings)?