Pages: 1 [2]   Go Down
Author Topic: filtering erroneous compass values  (Read 1476 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Jr. Member
**
Karma: 0
Posts: 91
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

nah, the delay inst a problem hey. i can only play after work anyway. only a few hours a day at most.
Ive made the changes you suggest, and right you are.
I had to add in this bit tho:
Code:
gotodeg = gotodeg % 360;
(see i used the % thing you taught me :p)
cos it was trying to drive to 360 or 10, which itll never get to.

can you also please look at:
Code:
for(int motorrun = (360/photonum); motorrun <= (360+(360/photonum)); motorrun = motorrun + (360/photonum)){
       takephoto(map(motorrun, 0, 360, 0, photonum));
       drive(motorrun);
     }
it doesnt seem to want to stop.
its part of this loop:
Code:
    for(i = 0; i < 180; i += 30){
     tilt.write(i);
     Serial.print("Tilting to degrees: ");
     Serial.println(i);
     for(int motorrun = (360/photonum); motorrun <= (360+(360/photonum)); motorrun = motorrun + (360/photonum)){
       takephoto(map(motorrun, 0, 360, 0, photonum));
       drive(motorrun);
     }
     drive(0);
    }
say i set photonum to 4, after a complete rotation, it doesnt tilt, just keeps on going.
output:
Code:
Tilting to degrees: 0
Now taking photo 1 of 4
driving to:90 or 100
heading: blah

Now taking photo 2 of 4
driving to:180 or 190
heading: blah

Now taking photo 3 of 4
driving to:270 or 280
heading: blah

Now taking photo 4 of 4
driving to:0 or 10
heading: blah
                                    *****  should tilt in here to 30 degrees
Now taking photo 5 of 4   *****  should reset back to 1
driving to:90 or 100
heading: blah

Logged

Norfolk UK
Offline Offline
Faraday Member
**
Karma: 70
Posts: 2587
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi gr0p3r,

I knocked up this test based on your supplied loop.
Code:
void setup() {
    // put your setup code here, to run once:
    Serial.begin(9600);
}

void loop() {
    // put your main code here, to run repeatedly:
    int photonum = 10;
    Serial.println();
    Serial.print("photonum = ");
    Serial.println(photonum);
    for(int i = 0; i < 180; i += 30){
        Serial.print("Tilting to degrees: ");
        Serial.println(i);
        for(int motorrun = (360/photonum); motorrun < (360+(360/photonum)); motorrun = motorrun + (360/photonum)){
            Serial.print("motorrun = ");
            Serial.print(motorrun);
            Serial.print(",  map(motorrun, 0, 360, 0, photonum) = ");
            int x =map(motorrun, 0, 360, 0, photonum);
            Serial.println(x);
        }
        Serial.println("Tilt");
    }
    Serial.println("Exit");

    while(1){
    }
}
I altered this line
for(int motorrun = (360/photonum); motorrun <= (360+(360/photonum)); motorrun = motorrun + (360/photonum)){
changing the <= to just < and get this result
Code:
Tilting to degrees: 0
motorrun = 90,  map(motorrun, 0, 360, 0, photonum) = 1
motorrun = 180,  map(motorrun, 0, 360, 0, photonum) = 2
motorrun = 270,  map(motorrun, 0, 360, 0, photonum) = 3
motorrun = 360,  map(motorrun, 0, 360, 0, photonum) = 4
Tilt
Tilting to degrees: 30
motorrun = 90,  map(motorrun, 0, 360, 0, photonum) = 1
motorrun = 180,  map(motorrun, 0, 360, 0, photonum) = 2
motorrun = 270,  map(motorrun, 0, 360, 0, photonum) = 3
motorrun = 360,  map(motorrun, 0, 360, 0, photonum) = 4
Tilt
Tilting to degrees: 60
motorrun = 90,  map(motorrun, 0, 360, 0, photonum) = 1
motorrun = 180,  map(motorrun, 0, 360, 0, photonum) = 2
motorrun = 270,  map(motorrun, 0, 360, 0, photonum) = 3
motorrun = 360,  map(motorrun, 0, 360, 0, photonum) = 4
Tilt
Tilting to degrees: 90
motorrun = 90,  map(motorrun, 0, 360, 0, photonum) = 1
motorrun = 180,  map(motorrun, 0, 360, 0, photonum) = 2
motorrun = 270,  map(motorrun, 0, 360, 0, photonum) = 3
motorrun = 360,  map(motorrun, 0, 360, 0, photonum) = 4
Tilt
Tilting to degrees: 120
motorrun = 90,  map(motorrun, 0, 360, 0, photonum) = 1
motorrun = 180,  map(motorrun, 0, 360, 0, photonum) = 2
motorrun = 270,  map(motorrun, 0, 360, 0, photonum) = 3
motorrun = 360,  map(motorrun, 0, 360, 0, photonum) = 4
Tilt
Tilting to degrees: 150
motorrun = 90,  map(motorrun, 0, 360, 0, photonum) = 1
motorrun = 180,  map(motorrun, 0, 360, 0, photonum) = 2
motorrun = 270,  map(motorrun, 0, 360, 0, photonum) = 3
motorrun = 360,  map(motorrun, 0, 360, 0, photonum) = 4
Tilt
Exit
I think this is what you was after as it now only takes the 4 pictures and not 5.
Logged


Offline Offline
Jr. Member
**
Karma: 0
Posts: 91
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Looks like it. Great thanks,

Ill change it when i get home and post the results. smiley-grin
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 91
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

yay! thanks so much Riva. its all working now. ill post pics if your interested in seeing what you helped troubleshoot?
Logged

Norfolk UK
Offline Offline
Faraday Member
**
Karma: 70
Posts: 2587
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

yay! thanks so much Riva. its all working now. ill post pics if your interested in seeing what you helped troubleshoot?
Glad to help. It would be great to see some pictures.
Logged


Offline Offline
Jr. Member
**
Karma: 0
Posts: 91
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ive tried posting them here. Keeps on failing. Had put in a description and everything but its lot now.
The pictures are here: http://gr0p3r.wordpress.com/2012/06/22/arduinorama/

an video showing its functions is here:

Iva also attache my code in entirety in case it ever interests anyone.

* pano_compass2.ino (8.39 KB - downloaded 3 times.)
Logged

Norfolk UK
Offline Offline
Faraday Member
**
Karma: 70
Posts: 2587
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi gr0p3r,

It looks good. Have you done any test runs with it yet and how do you stitch the images together after?
Logged


Offline Offline
Jr. Member
**
Karma: 0
Posts: 91
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

yep. Check out my 360cities profile:
Code:
http://www.360cities.net/profile/gr0p3r
these are ones done prior to the compass module going in and it was just on a timer. but same thing.
Logged

Pages: 1 [2]   Go Up
Jump to: