Hello!
My current project involves a lidar lite (v3) rangefinder mounted on two Dynamixel MX-12W smart servos (stepper motors actually) connected to an Arbotix-M microcontroller that sends sensor data via Xbee into a PLX-DAQ table.
My desired result is that the positions of the servos along with the rangefinder measurements would be sent together with the same time stamps CONTINUOUSLY into PLX-DAQ while the code still coordinates the pre-programmed servo movements. The end product of this is ideally going to be the ability to generate 3D points from this data.
Currently I'm doing this:
void loop()
{
//variable declarations
int tiltpos = 1175;
int panpos;
while (tiltpos < 3073) {
milli_time = millis();
SendSensorData(); // replaces big block of code previously used
// 1. counter clockwise sweep
for (int panpos = 0; panpos < 4096; panpos += 10) //increment pan servo 0 to 4096 by 10
{
SendSensorData();
SetPosition(1, panpos); //set the position of servo #1 to the current value of 'panpos'
delay(10);
}
// 2. Move sensor tilt up one after first sweep
tiltpos = tiltpos + 11;
delay(10);
SetPosition(2, tiltpos); //set position of servo #2 tilt to +11 steps (approx. 1 degree)
SendSensorData();
// 3. Clockwise sweep at new tilt position
for (int panpos = 4096; panpos > 0; panpos -= 10) //decrement pan from 4096 to 0 by 10
{
SendSensorData();
SetPosition(1, panpos);
delay(10);
}
// 4. Move sensor tilt up one after sweep
tiltpos = tiltpos + 11;
delay(10);
SetPosition(2, tiltpos);
SendSensorData();
}
So basically trying to send all the aforementioned data continuously while the servos sweep 360, move up, sweep the other way, move up, until it reaches a certain upward angle, after which the program signals it is done.
My issue is that filling in the space between each and every servo command seems clunky and it results in tiny little holes in the resulting PLX-DAQ table.
I tried using two different microcontrollers for the servos and lidar lite but PLX-DAQ and Xbee don't like that i.e. will only read one COM port at a time.
Anybody have an idea of how to do this more elegantly and without all the repetition of the SendSensorData function?
Thank you in advance for any wisdom offered!
*edited code to (hopefully) make more readable