Hi guys,
For a while now ive been working on a "robot" to take photos for spherical panoramas (see my account for examples: Stock 360° Panoramic Images and Videos for VR and More | 360Cities). Like this: http://www.gigapan.com/cms/shop/store only not so expensive, and of course WITH the satisfaction of making it myself!
i have it working by driving on a timer, stopping every N'th seconds to take a photo. it calculates N by getting the value of a pot mapping that to 4-21 (amount of photos in one rotation) then dividing the known time of one revolution by the amount of photos in one rotation.
the problem with this is that as batteries die, the time it takes for one rev is longer and it doesnt run long enough and gets all out of whack.
what i plan on doing, (and have given it my best crack), is to Sparkfun's LSM303 - GitHub - pololu/lsm303-arduino: Arduino library for Pololu LSM303 boards
im using the same pot configuration to get amount of photos per revolution (photonum) but it is using 360 to calculate how long to drive the motor for.
this bit works. BUT what i need is a way to filter out erroneous values from the compass. It stops driving early because it thinks that it has arrived at the correct heading.
here is my code:
void drive(int gotodeg){ //gotodeg is the degrees that it drives (turns) to
Serial.print("driving to:");
Serial.println(gotodeg);
digitalWrite(motorpin, HIGH); //turn on motor
compassread(heading); //returns "heading" as degees 0-359
while (heading < gotodeg || heading > (gotodeg+(gotodeg/(20/photonum)))){
compassread(); //returns "heading" as degees 0-359
}
}
digitalWrite(motorpin, LOW); //turn off motor
}
here is my FAILED attempt to error correct:
void drive(int gotodeg){
Serial.print("driving to:");
Serial.println(gotodeg);
digitalWrite(motorpin, HIGH);
compassread();
while (heading < gotodeg || heading > (gotodeg+(gotodeg/(20/photonum)))){
delay(1000);
digitalWrite(motorpin, LOW);
delay(100);
compassread();
digitalWrite(motorpin, HIGH);
if (heading < gotodeg || heading > (gotodeg+(gotodeg/(20/photonum)))){
digitalWrite(motorpin, LOW);
for(int t=0; t < 10; t++){
delay(100);
compassread();
}
digitalWrite(motorpin, HIGH);
}
}
digitalWrite(motorpin, LOW);
}
any one know how i can smooth out the compass output to stop my issues?
i can post photos or video to help understand, as im sure my explanation could be better.
cheers
Gr0p3r