Author Topic: balancing robot without calibration at start? (PID)  (Read 3013 times)

0 Members and 1 Guest are viewing this topic.

Offline bulkheadTopic starter

  • Full Member
  • ***
  • Posts: 102
  • Helpful? 0
balancing robot without calibration at start? (PID)
« on: December 01, 2007, 07:26:39 PM »
I've searched this but I did not find anything on this.  Is it possible to program it to dynamically find the balance point?  Most of the ones I see need to be calibrated at the start.  I am guessing that for a PID loop it would somehow involve changing the "setpoint" value based on the history of error and the response.

On a side note, is it possible to do it with just an accelerometer (no gyro)?

Also, reading the PID tutorial here: http://www.societyofrobots.com/programming_PID.shtml it says that the "integral" term is acceleration or the next derivative.  How is that so?  From wikipedia, "the contribution from the integral term is proportional to both the magnitude of the error and the duration of the error".
« Last Edit: December 04, 2007, 01:13:34 AM by bulkhead »

Offline Ro-Bot-X

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,431
  • Helpful? 25
  • Store: RoBotXDesigns.ca
Re: balancing robot without calibration at start?
« Reply #1 on: December 02, 2007, 02:53:31 AM »
I don't think it will work without a gyro. Not sure about the calibrating part. You may use pots to manualy adjust the pid constants until you find the right one, then eliminate the pots and hardcode the value.
Take a look at nBot, maybe it will give you an ideea how to do this.
http://geology.heroy.smu.edu/~dpa-www/robo/nbot/
« Last Edit: December 02, 2007, 02:55:09 AM by Ro-Bot-X »
Check out the uBotino robot controller!

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,659
  • Helpful? 169
    • Society of Robots
Re: balancing robot without calibration at start?
« Reply #2 on: December 02, 2007, 11:15:12 AM »
PID inherently needs calibration. It's unavoidable.

However what you are asking for is something I like to call 'auto-calibration', which is where you have a sub-program that figures out the calibration for you.

I think it's possible. But I also think its really hard.

Its like programming a flying robot to learn how to fly. It either works or it doesn't. And failing could damage hardware . . .

The best way would be to handcode something that works well enough, then have it auto-calibrate to minimize oscillations on its own. Sorta like holding its hand to learn how to walk . . .

Quote
Also, reading the PID tutorial here: http://www.societyofrobots.com/programming_PID.shtml it says that the "integral" term is acceleration or the next derivative.  How is that so?  From wikipedia, "the contribution from the integral term is proportional to both the magnitude of the error and the duration of the error".

ehhhh so the integral term is the acceleration.

If you subtract that term from what you want the acceleration to actually be (or already is, depending on how you do it), then that is the error. So in that sense, yes, it is 'proportional to both the magnitude of the error and the duration of the error'.

Offline bens

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 332
  • Helpful? 3
Re: balancing robot without calibration at start?
« Reply #3 on: December 02, 2007, 05:10:46 PM »
If you're saying that the integral term of PID is the second derivative of the error curve, I have to strongly disagree.  I feel like your tutorial is completely mischaracterizing the integral term.  The integral term is the integral of the error curve (aka the area under the curve, or, in discrete situations, the sum of all the errors over a set period of time), which is why it's called "integral".  Typically this term is used to eliminate steady-state error (P and D can get you stuck in a state where your error is nonzero but not changing).  The drawback to the integral term is that, as a sum of past errors, it can result in overshoot.

Offline paulstreats

  • Supreme Robot
  • *****
  • Posts: 1,381
  • Helpful? 21
Re: balancing robot without calibration at start?
« Reply #4 on: December 02, 2007, 06:45:29 PM »
surely that would be a net error/overall error/gross error and not an integral error?

Offline bens

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 332
  • Helpful? 3
Re: balancing robot without calibration at start?
« Reply #5 on: December 02, 2007, 08:58:38 PM »
surely that would be a net error/overall error/gross error

That's what an integral is, and that's why it lets you handle cases where P and D result in nonzero steady-state error.  An integral is an infinite sum of the areas of infinitely thin slices of a function over a given domain.  In a discrete case, you can approximate the integral by adding up all of the function values you have in your domain multiplied by the section of the domain for which they apply (e.g. Riemann sum).  In the case of error feedback, your domain is time, so you sum your error values multiplied by the section of time for which they apply.  If you get error readings at a fixed rate, you can absorb the dt multiplication into your integral constant.

Imagine you're trying to follow a line on a robot with asymetric differential drive (motor 1 speed = base speed + P*error, motor 2 speed = base speed - P * error).  Because of the asymmetry, steady state will occur for some nonzero E where PE balances out the asymmetry.  The differential term does nothing for you here because in steady state, by definition, the error is not changing (so D = 0).  What saves you is I, which notes that the accumulated error is growing, and that some action should be taken to correct this.  If instead of I you're using a term that's the second derivative of the error function (which is what I believe http://www.societyofrobots.com/programming_PID.shtml  says), you get nothing in this scenario as the second derivative of the error is zero in the steady state.

Offline bulkheadTopic starter

  • Full Member
  • ***
  • Posts: 102
  • Helpful? 0
Re: balancing robot without calibration at start?
« Reply #6 on: December 04, 2007, 01:13:10 AM »
I guess I will just have to test it out when I get it running.

As for the PID explanation, I thought the "I" term was supposed to increase the response if the error persisted over time.

Offline bens

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 332
  • Helpful? 3
Re: balancing robot without calibration at start?
« Reply #7 on: December 04, 2007, 01:27:45 AM »
As for the PID explanation, I thought the "I" term was supposed to increase the response if the error persisted over time.
As an accumulation of past errors, this is exactly what it does.

I guess the most intuitive way to think about it is that the proportional term P your response to the current error, the D term is your response based upon the predicted future value of the error (it predicts this future value by looking at the current derivative and assuming that trend will continue), and the I term is based upon the recent history of the error.
« Last Edit: December 04, 2007, 01:36:19 AM by bens »

Offline bulkheadTopic starter

  • Full Member
  • ***
  • Posts: 102
  • Helpful? 0
Re: balancing robot without calibration at start? (PID)
« Reply #8 on: December 05, 2007, 04:07:26 AM »
Well, after some experimenting I think it is necessary to use a gyro.  The accelerometer just reacts too slow...

Also, I think that segways have it easier than balancing robots because they can live with a preset "setpoint"; the human rider shifts the center of mass so that the setpoint is the neutral position when it is desired (standing in place). 

 


Get Your Ad Here

data_list