Subject:
|
Re: balancing bot
|
Newsgroups:
|
lugnet.robotics
|
Date:
|
Fri, 31 Dec 2004 00:01:11 GMT
|
Original-From:
|
dan miller <danbmil99@yahoo.com^stopspammers^>
|
Viewed:
|
973 times
|
| |
| |
this looks similar to the logic I got working. I tweaked the parameters (equiv. to a,b,c in your
code) and it's much more stable now. Interestingly, I have to set 'b' very high, about 2X of what
'a' is set to -- most code I've seen is just the opposite. I suspect the flashlight I have (even
though it's a little AAA maglite) is making the balance more unstable, or at least giving it more
rotational inertia or something -- it's cantelievered off the front about 2 inches.
What I'm surprised at is that Hassenplug's original code doesn't have a derivative term at all!
However, he has this funny thing where he adds in the motor setting to the error term every 50 ms.
Perhaps that works out to a derivative term, or an integral or something... while his code didn't
work well for me, it had a better tendency to stay in one spot. The normal PID algorithm seems to
want to find a spot on the floor and stabilize to that. I'm thinking about adding rotation
sensors to the floor to get some control over speed & direction...
Very interesting stuff.
--- Philippe Hurbain <philohome@free.fr> wrote:
> >
> > You may have a look to YAL: http://news.lugnet.com/robotics/?n=22181
>
> ...and here is a NQC sample code that works on YAL, using Dick Swan's fast
> firmware.
>
> Try it on a clear color surface (not necessarily even, some patterns help
> stabilize position) with overhead diffuse lighting. YAL must be started balanced
> (sensor calibration).
>
> Philo
>
> -----------------------------------------------
> #include "swan.nqh"
>
> #define Front_S SENSOR_1
> #define Rear_S SENSOR_3
> #define Right_M OUT_A
> #define Right_Pwr 0
> #define Left_M OUT_C
> #define Left_Pwr 2
> #define a 15
> #define b 5
> #define c 5
>
> int Offset;
> int OldDif;
> int NewDif, MotCmd, OldMotCmd, MotPwr;
> int DispDbg;
>
> task main ()
> {
> SetUserDisplay (DispDbg,0);
>
> SetSensor (Front_S, SENSOR_LIGHT);
> SetSensor (Rear_S, SENSOR_LIGHT);
> SetSensorMode (Front_S, SENSOR_MODE_RAW);
> SetSensorMode (Rear_S, SENSOR_MODE_RAW);
>
> bFloatDuringInactiveMotorPWM = false;
> nMotorTransitionDelay = 0;
>
>
> Wait(10);
> Offset = Front_S - Rear_S;
> OldDif = 0;
>
> motorPower128(Right_Pwr) = 0;
> motorPower128(Left_Pwr) = 0;
>
> OnFwd (Right_M + Left_M);
> OldMotCmd = 1;
>
>
> while (true)
> {
> NewDif = Front_S - Rear_S - Offset;
> MotCmd = (a * NewDif + b * (NewDif - OldDif)) / c;
> OldDif = NewDif;
> DispDbg=MotCmd;
> MotPwr = (MotCmd > 0) ? MotCmd : -MotCmd;
> if(MotPwr > 127) MotPwr = 127;
> motorPower128(Right_Pwr) = MotPwr;
> motorPower128(Left_Pwr) = MotPwr;
> if(MotCmd > 0) OnFwd (Right_M + Left_M);
> else OnRev (Right_M + Left_M);
> }
> }
> --------------------------------------------------
>
|
|
Message is in Reply To:
| | Re: balancing bot
|
| (...) ...and here is a NQC sample code that works on YAL, using Dick Swan's fast firmware. Try it on a clear color surface (not necessarily even, some patterns help stabilize position) with overhead diffuse lighting. YAL must be started balanced (...) (20 years ago, 30-Dec-04, to lugnet.robotics)
|
8 Messages in This Thread:
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
|