Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Bizarre Driving Issue (http://www.chiefdelphi.com/forums/showthread.php?t=53594)

AndrewN 07-02-2007 14:10

Re: Bizarre Driving Issue
 
1 Attachment(s)
Really the math almost succeeds by accident ... try out the following code:
Attachment 5029
Code:

#include <stdio.h>

int
main(void)
{
        unsigned char p2_x;
        unsigned char deadx;

    p2_x = 0;
    while (1) {

                if(p2_x<122)    //more than 5 below 127
                {//scaling so we don't just jump from 127 to 121 but can still reach 0
                        //deadx = (p2_x - 122);
                        deadx = ((p2_x - 122) * 127);
                        //deadx = ((p2_x - 122) * 127)/122;
                        //deadx = ((p2_x - 122) * 127)/122 + 127;
                } else if(p2_x>132)    //more than 5 above 127
                {
                        deadx = ((p2_x - 132) * 127)/122 + 127; //scaling
                } else
                {
                        deadx = 127;    //don't move if within 5 of 127
                }

                        printf("p2_x: %d -> deadx: %d\n", p2_x, deadx);

                p2_x++;
            if (p2_x == 0) return 0;  // I'm taking advantage of the wrap around
    }
}

Uncomment each of the four //deadx lines in turn and run it on any old C compiler and watch the output for the values below 122. I'll bet they are not what you expect.
I left the rest alone just so you could see how it almost works... I'm very suprised and delighted at how close it comes to being correct :yikes:

But you still have a further overflow problem with the lines like:
Code:

pair1 = deady+127-deadx;
Don't take my word for it, you'll learn more (and have more fun) by experimenting with the code using small programs like the one above.

kaszeta 08-02-2007 13:21

Re: Bizarre Driving Issue
 
Quote:

Originally Posted by Kelly (Post 573488)
I'm pretty sure your current problems are caused by overflowing unsigned variables, however, if you're like us, the next problem you'll have is with your robot listing to one side or another as it drives. We fixed it by collecting data about the pwms and making a lookup table that relates desired wheel speeds and actual pwms.

Another easy solution is to use the kit gyro and a simple PID feedback loop to adjust your heading. This year's bot (and last years) have pretty noticeable drive train power asymmetry and this generally takes care of it quite well.

kitscuzz 08-02-2007 14:51

Re: Bizarre Driving Issue
 
Actually, I'm hoping that we can avoid the use of a gyro (and the overhead from running four PID loops), but could someone please explain what exactly a PID loop is? We're all essentially self-taught here, with no mentor, so we're lost on some of the finer points.

Perhaps as a simple example, just one motor, one joystick, and one encoder? We know how to set up and run all the separate parts, and we know essentially what a PID loop should do (compare input to output), but how exactly it does it do the calculation?

Tom Line 08-02-2007 15:24

Re: Bizarre Driving Issue
 
A PID loop controls by looking at error.

The proportional portion says:
"Where should I be" - "Where I am". Then it multiples that by a gain factor.

So - in pseudocode

Gyro_Proportional_Amount = (Current_Gyro_Heading - Gyro_Heading_We_Want) * Gain

Modify the drive values going to the motors with the Gyro_Proportional_Amount.

The I and D are basically the same, but one works on the accumulated error (the I or integrative) and one works on the error rate of change (D or derivative). There is a bit of sample code in the PID whitepaper you can search for here - it does a great job of explaining. MOST times, you can get away with just the "P" portion of the code I showed above.

kaszeta 08-02-2007 15:30

Re: Bizarre Driving Issue
 
Quote:

Originally Posted by kitscuzz (Post 574439)
Actually, I'm hoping that we can avoid the use of a gyro (and the overhead from running four PID loops)

PID loops aren't difficult, and the overhead is minimal. Heck, I posted some of Team 95's previous gyro control loops here on CD. (See http://www.chiefdelphi.com/forums/sh...174#post454174, for example).

kitscuzz 08-02-2007 16:00

Re: Bizarre Driving Issue
 
Oh, and we just uploaded the code. Sure enough:

Overflow. It works fine now. We flipped around the motors that were reversed so now the deadzones for going forward and backward are matched, but going left and right still suffers from the weird "two get going faster before the others." They seem even enough after they make it past a certain point, but it's still upleasant.

kaszeta:
Although PID loops may not contain much overhead, that would still need four geartooth sensors, which WOULD generate a lot of overhead. Though, I guess technically we... might be able to put only two on and just force all the pairs to match.

It's still unfortunate to need any gearteeth, just because it's difficult to mount them as close as they need to be on the robot, and when we crash, they tend to crash into the gears (well... okay that only happened once on a testbed, but still stinks to buy new parts).

kaszeta 08-02-2007 16:37

Re: Bizarre Driving Issue
 
Quote:

Originally Posted by kitscuzz (Post 574481)
Although PID loops may not contain much overhead, that would still need four geartooth sensors, which WOULD generate a lot of overhead. Though, I guess technically we... might be able to put only two on and just force all the pairs to match.

Or one gyro. Gyro's are simple to use and mount.

kitscuzz 08-02-2007 17:24

Re: Bizarre Driving Issue
 
We didn't recieve our gyro panel in the mail, and realized too late :- (

But anyway:
Whoa! I think I may have figured out something awesome.

Everyone has been talking about these "asymmetrical" deadzones, but no one has ever found a good solution outside of lookup tables (at least not in this thread). But weirdly enough has anyone ever tried recalibration of the Victors? We set up this simple code like so:

Code:

void Process_Data_From_Master_uP(void)
{
        Getdata(&rxdata);
                if(p1_sw_trig == 1)
                        pwm01=pwm02=pwm03=pwm04=254;
                else if(p1_sw_top == 1)
                        pwm01=pwm02=pwm03=pwm04=0;
                else
                        pwm01=pwm02=pwm03=pwm04=127;
        Putdata(&txdata);
}

And then ran the Victor calibration (described here). The wheels now seem to have none of the strange speed difference between forwards and backwards. Anyone else want to give it a try and report results?

RichardCMongler 11-02-2007 17:02

Re: Bizarre Driving Issue
 
We had a problem with uneven deadzones on the four wheels in our holonomic drive; calibrating the Victors completely solved this problem. I highly recommend calibration.


All times are GMT -5. The time now is 00:23.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi