We plan on using the compass to keep our robot heading straight. I
figured (after some reading) that a PID algorithm would probably be
the best way to keep it in line without oscillation. Previous groups
had such a problem, with their bot continuously overshooting its
setpoint. Our plan is to use the compass heading as our sensor
reading, and to use this algorithm to control the motors in order to
bring the robot smoothly back onto its proper path.
Can anyone point me in the direction of some C source code? We are
running this on Linux (CentOS) laptop as well. I understand that
there will be much testing and fine-tuning necessary, but I'm hoping
having some code on hand will at least help us get a place to start.
Thank you, I appreciate it.
You can still get overshoot (and stranger things) even with a PID
controller -- the PID controller is just the standard way to get things
done and is well understood.
If you want to delve deeper, look at my other articles,
http://www.wescottdesign.com/articles/articles.html, or buy my book:
http://www.wescottdesign.com/actfes/actfes.html.
--
Tim Wescott
Wescott Design Services
http://www.wescottdesign.com
Posting from Google? See http://cfaj.freeshell.org/google/
"Applied Control Theory for Embedded Systems" came out in April.
See details at http://www.wescottdesign.com/actfes/actfes.html
><snip>
>or buy my book:
>http://www.wescottdesign.com/actfes/actfes.html.
Which can be a very good deal, as you can pepper the author with your
questions! Very hard to beat a book that can sensibly reply. ;)
Jon
>Hello all! Well, my partners and I are implementing the control
>scheme on an autonomous robot.
>Can anyone point me in the direction of some C source code?
Check this out http://www.chiefdelphi.com/media/papers/download/1829
And in so doing, help to improve future printings of the book. Perhaps
even future editions as well, assuming I go crazy enough to want to do
it over again, yet remain sane enough to do a good job.
The PID is extremely trivial. If you didn't understand
the theory behind it, it won't be going to work anyway.
Rene
--
Ing.Buero R.Tschaggelar - http://www.ibrtses.com
& commercial newsgroups - http://www.talkto.net
Good article, thanks for that.
> If you want to delve deeper, look at my other articles,
> http://www.wescottdesign.com/articles/articles.html, or buy my book:
> http://www.wescottdesign.com/actfes/actfes.html.
You might have made a sale here.
>Hello all! Well, my partners and I are implementing the control
>scheme on an autonomous robot. We are using a laser ranger and
>infrared for obstacle avoidance, and a GPS plus digital compass for
>navigation.
This robot is travelling over what distances?
GPS is not much use for small distances (a few metres or less).
>We plan on using the compass to keep our robot heading straight. I
>figured (after some reading) that a PID algorithm would probably be
>the best way to keep it in line without oscillation. Previous groups
>had such a problem, with their bot continuously overshooting its
>setpoint. Our plan is to use the compass heading as our sensor
>reading, and to use this algorithm to control the motors in order to
>bring the robot smoothly back onto its proper path.
What are you going to use as the error term, GPS or compass?
If the robot is trying to travel 100's of metres then it should be use
GPS to calculate what heading you should be on, THEN use the compass
to work out required heading error.
It is amazing how many get this wrong.
>Can anyone point me in the direction of some C source code? We are
>running this on Linux (CentOS) laptop as well. I understand that
>there will be much testing and fine-tuning necessary, but I'm hoping
>having some code on hand will at least help us get a place to start.
>
>Thank you, I appreciate it.
Needing to know what distance accuracy and resolution is your first step.
This will help to determine how much fine tuning capability you need, to
determine your software algorithm and its implementation. As well as
the resolution of the sensors required.
--
Paul Carpenter | pa...@pcserviceselectronics.co.uk
<http://www.pcserviceselectronics.co.uk/> PC Services
<http://www.gnuh8.org.uk/> GNU H8 & mailing list info
<http://www.badweb.org.uk/> For those web sites you hate
Rene - that is terribly, terribly wrong. At it's most basic level,
sure, a PID controller can be fairly simple to implement and tweak.
But PID controllers can also be incredibly complicated. For example -
how simple do you think an auto-tuning PID controller is? Not simple!
Or when you need to design a PID controller to have specific
overshoots, rise times, and steady state times? Not terribly simple.
-Mike
Mike Noone wrote:
>>>We plan on using the compass to keep our robot heading straight. I
>>>figured (after some reading) that a PID algorithm would probably be
>>>the best way to keep it in line without oscillation.
>>>Can anyone point me in the direction of some C source code? We are
>>>running this on Linux (CentOS) laptop as well. I understand that
>>>there will be much testing and fine-tuning necessary, but I'm hoping
>>>having some code on hand will at least help us get a place to start.
>>
>>The PID is extremely trivial. If you didn't understand
>>the theory behind it, it won't be going to work anyway.
I completely agree with Rene. If someone don't know what is PID, it is
too early for him to think about robots.
> Rene - that is terribly, terribly wrong. At it's most basic level,
> sure, a PID controller can be fairly simple to implement and tweak.
There is no need to tweak anything. Once the system response is
determined, the analytical design of PID is very trivial and
straightforward.
> But PID controllers can also be incredibly complicated.
It usually happens if somebody is trying to make PID to work by tweaking.
> For example -
> how simple do you think an auto-tuning PID controller is? Not simple!
This is a basic problem from any entry-level textbook.
> Or when you need to design a PID controller to have specific
> overshoots, rise times, and steady state times? Not terribly simple.
Yes, it is little bit more complicated then 2 x 2 = 4
Vladimir Vassilevsky
DSP and Mixed Signal Design Consultant
So - a complete knowledge of PID is necessary to do work in robotics?!
Right...
No.
> There is no need to tweak anything. Once the system response is
> determined, the analytical design of PID is very trivial and
> straightforward.
And determining system response is incredibly easy, let me tell you...
*rolls eyes*
> It usually happens if somebody is trying to make PID to work by tweaking.
Which often is the only viable route unless you want to spend half
your life doing simulation.
> > For example -
> > how simple do you think an auto-tuning PID controller is? Not simple!
>
> This is a basic problem from any entry-level textbook.
Ummmmm... No, what textbook would this be? People write their theses
on stuff like this. PID can be as simple or as complicated as you want
it to be.
> > Or when you need to design a PID controller to have specific
> > overshoots, rise times, and steady state times? Not terribly simple.
>
> Yes, it is little bit more complicated then 2 x 2 = 4
Good one, really.
Please back up your statements. I think you're pulling them out of a
place where the sun don't shine.
-Mike
When used by somebody that doesn't know what they're doing, sure.
Implement DGPS, or add in accelerometers and do kalman filtering, or
do many other things and you can get accuracy in the cm range.
-Mike
Mike Noone wrote:
>>I completely agree with Rene. If someone don't know what is PID, it is
>>too early for him to think about robots.
>
>
> So - a complete knowledge of PID is necessary to do work in robotics?!
> Right...
>
> No.
PID is the very very basics of the automatic control. If one doesn't
know what is PID, there is nothing to talk about.
>>There is no need to tweak anything. Once the system response is
>>determined, the analytical design of PID is very trivial and
>>straightforward.
>
>
> And determining system response is incredibly easy, let me tell you...
> *rolls eyes*
Yes, it is not too complex. You just have to think a little bit and then
put the numbers together. It requires no more then the basic science
from high school to estimate the responce of a mechanical or electrical
system with the required accuracy.
>>It usually happens if somebody is trying to make PID to work by tweaking.
>
> Which often is the only viable route unless you want to spend half
> your life doing simulation.
Big mistake. How about tweaking on the space rocket?
As for simulation, is a brute force approach. As Wiener said, the
computer can be used as the amplifier for the head, but not as the
substitute. Simulation is useful to check the fine aspects of the
nonlinear and time variant systems; however the simulation should be
based on the analysis, not vice versa.
>>>For example -
>>>how simple do you think an auto-tuning PID controller is? Not simple!
>>
>>This is a basic problem from any entry-level textbook.
>
> Ummmmm... No, what textbook would this be?
Probably, Mr. Tim Wescott has that. Hey, Tim?
I like "Advances in the PID control" book, there is also a number of
books on the robust control.
People write their theses
> on stuff like this. PID can be as simple or as complicated as you want
> it to be.
Ziegler and Nichols solved the basic problem of PID design in 1940.
After that, there were few small refinements and elaborations.
>
>>>Or when you need to design a PID controller to have specific
>>>overshoots, rise times, and steady state times? Not terribly simple.
>>
>>Yes, it is little bit more complicated then 2 x 2 = 4
>
>
> Good one, really.
>
> Please back up your statements. I think you're pulling them out of a
> place where the sun don't shine.
I suggest you to read books instead of tweaking the parameters. You
will be surprised; it is really helpfull.
If you're just using plug and chug formulas - sure. If you actually
want to understand where those formulas come from, not as simple.
> >>It usually happens if somebody is trying to make PID to work by tweaking.
>
> > Which often is the only viable route unless you want to spend half
> > your life doing simulation.
>
> Big mistake. How about tweaking on the space rocket?
> As for simulation, is a brute force approach. As Wiener said, the
> computer can be used as the amplifier for the head, but not as the
> substitute. Simulation is useful to check the fine aspects of the
> nonlinear and time variant systems; however the simulation should be
> based on the analysis, not vice versa.
Of course sometimes simulation is the only viable route. However, in
most situations that I've run across simulation has been only good
enough to get a starting point for gain values, and to get perfection
those have to be hand tweaked.
> >>>For example -
> >>>how simple do you think an auto-tuning PID controller is? Not simple!
>
> >>This is a basic problem from any entry-level textbook.
>
> > Ummmmm... No, what textbook would this be?
>
> Probably, Mr. Tim Wescott has that. Hey, Tim?
> I like "Advances in the PID control" book, there is also a number of
> books on the robust control.
Not familiar with that one - will take a look some time. I'll mention
that any book that covers that in the beginning is glossing over all
the nuts and bolts of control systems, which in my humble opinion is
not proper form, unless it is assumed that the reader already has a
solid foundation in control systems.
> People write their theses
>
> > on stuff like this. PID can be as simple or as complicated as you want
> > it to be.
>
> Ziegler and Nichols solved the basic problem of PID design in 1940.
> After that, there were few small refinements and elaborations.
I guess that's why there's about 6000 papers on auto tuning PID:
http://scholar.google.com/scholar?q=auto+tuning+PID&hl=en&lr=&btnG=Search
> > Please back up your statements. I think you're pulling them out of a
> > place where the sun don't shine.
>
> I suggest you to read books instead of tweaking the parameters. You
> will be surprised; it is really helpfull.
Not willing to back up anything? Guess that isn't too surprising.
I think you're arguing that using other's work and formulas and
whatnot to implement PIDs is easy. This is true. However, if you
actually want to know what is going on, you'll need a foundation in
control systems.
-Mike
Mike Noone wrote:
This will provide for the resolution, not for the accuracy.
However, there is GPS with better accuracy, too. But there is one
problem with it: the GPS with 10m guaranteed accuracy is $$, and the GPS
with 10cm accuracy is $$$$. Perhaps, it can do even better for $$$$$$,
but it doesn't seem to be a very good option...
Even better than that.
Best regards,
Spehro Pefhany
--
"it's the network..." "The Journey is the reward"
sp...@interlog.com Info for manufacturers: http://www.trexon.com
Embedded software/hardware/analog Info for designers: http://www.speff.com
Carrier phase correction will get down to 10cm. It is doable for
$1000.
You need a stable clock source, dro and pll, precision delays (ns),
high speed dividers (GHz). It will be a lunch box size and takes
about 5 Watts.
I would suggest doing some more research on that topic then. You are
misinformed. There are countless papers on this topic so I won't go
into much depth on it. But if you were to combine kalman filtering
with DGPS you can get some very, very good accuracy as well as
resolution.
> However, there is GPS with better accuracy, too. But there is one
> problem with it: the GPS with 10m guaranteed accuracy is $$, and the GPS
> with 10cm accuracy is $$$$. Perhaps, it can do even better for $$$$$$,
> but it doesn't seem to be a very good option...
>
> Vladimir Vassilevsky
Cleverness can overcome cost. You may find this website interesting:
http://precision-gps.org/
-Mike
This is based on the idea that the you have a stable reference source
at both places (a fixed and rover location) and that the receiver
clocks does not drift apart. Yes, you have a narrow processing window
after calibration, but the clock phases will drift randomly
afterward. Namely, error rate increase in time after calibration.
My proposal is to eliminate the clock drift with a stable laser tuned
Cesium clock.
Aren't they related?
>
> However, there is GPS with better accuracy, too. But there is one
> problem with it: the GPS with 10m guaranteed accuracy is $$, and the GPS
> with 10cm accuracy is $$$$. Perhaps, it can do even better for $$$$$$,
A few hundred $ for an OEM board with Carrier Phase info.
Good enough if you can constantly recalibrate the drift.
Not good if you don't have a fixed reference.
The receiver has to be in both places at the same time for
calibration.
I guess that the non-physics version of Uncertainty Principle.
And everybody says it's tricky but nobody ever bothers to
give even any hints as to how to determine the coefficients...
Read some books on Linear Algebra, Feedback Stabilities,
Matrix Algebra and Different Equations. We don't have to
repeat the college courses that you should have taken.
> On Mar 14, 3:48 am, Rene Tschaggelar <n...@none.net> wrote:
>
>>TenmaNeko wrote:
the robot smoothly back onto its proper path.
>>
>>>Can anyone point me in the direction of some C source code? We are
>>>running this on Linux (CentOS) laptop as well. I understand that
>>>there will be much testing and fine-tuning necessary, but I'm hoping
>>>having some code on hand will at least help us get a place to start.
>>
>>The PID is extremely trivial. If you didn't understand
>>the theory behind it, it won't be going to work anyway.
>
> Rene - that is terribly, terribly wrong. At it's most basic level,
> sure, a PID controller can be fairly simple to implement and tweak.
> But PID controllers can also be incredibly complicated. For example -
> how simple do you think an auto-tuning PID controller is? Not simple!
> Or when you need to design a PID controller to have specific
> overshoots, rise times, and steady state times? Not terribly simple.
Mike,
the code for a simple PID is a threeliner. Plus an
additional line to stop the integrator when the
output hits the rails. We're not talking autowhatever.
First one has to have a basic understanding on
system behavious, whether a system is integrating
or not. Then one has to estimate the nonlinearities.
One has to have an idea about frequency response and
phase. When you have heard about all this, then the
threeliner is done. Just in case you have more sensors
than the one for the eventual measurement, and the
system is not acting as expected, a state control is
the way to go further. Once you heard a semester about
state control with virtual viewer, then the few more
lines are also trivial, the parameters take a bit
more then.
The original post showed little detail of what was trying to be achieved
except 'hand-waving' and technology 'buzzwords'. no information on expected
travel time or distance, let alone how close to the end point is classed
as being at 'set point'.
Until you know the scope of what is being attempted, PID or whatever
algorithm is pointless. Especially if what is being used to determine
error may cause more oscillations or drift than any algorithm can
correct.
The points made refered to what was the original poster trying to achieve
NOT what can be achieved with limitless budgets and limitless resources.
Until you know what is trying to be achieved, any assistance is just
'hand waving', based on personal experience which may be different to
the questioners experience or expectations.
For all we know the original poster could be
a) tring to achieve the DARPA autonomous vehicle challenge
b) moving a CNC machine workpiece no more than 10 mm steps
max distance of 1m in less than 0.1 seconds.
c) anything in between the two.
I would disagree - what a great way of learning about PID controllers. If
the OP's software can accept the PID constants easily, then he can
experiment with different setups and see the effects instantly with his
robot.
He could:
- Try pure I (slow but quiet) and pure P and think about results
- Add some I (slow) to his P and some D and think about results
- try some anti reset windup on the I and see what happens
- think about the affects of his AD & DA resolution will have in his
system
- think about sampling time, and what effect that will have (including on
the D term)
Is there anything else (if the OP isn't trying to get maximum performance
from his system)? I think that is it.
The OP would of course be recommended to do some reading on the subject
from good sources, but that doesn't preclude him from getting some good
practical experience with this stuff.
Regards,
Paul.
I ignored this thread originally because it was another one of those
where the poor new guy gets to hear all the "old timers" tell him/her
about why they are too stupid/ignorant/inexperienced to try what they
are attempting and if they don't fully understand the concept behind the
X, Y or Z technology they are just ignorant and should go back to
school, or bitch about how they didn't post a full spec on the project.
That being said, I'm sure those "old timers" forgot that the best (and
most memorable) lessons they ever learned were from jumping in to
something WAYYYY over their heads and slogging it out until they
understood what was going on.
So, in a nut shell, I agree with you. By all means, get a good book on
PID algorithms. Read it cover to cover, but then LIVE it by trying to
make some real tangible thing and see what happens. It is pretty sad
when we are discouraging a person from trying something that will
educate them. Sure it might not work, but that is knowledge too.
How many of you have a bin of prototypes around that didn't work?
Why do you keep them?
What did you learn?
Jim
It's a shelf in my case, and I refer to it as the Wall of Folly.
Products are positioned according to how expensive they were to make.
Currently the top item is a little device that cost [the company for
which I was working] almost $300,000 plus another $100,000 in
miscellaneous marketing, shipping, returns acceptance, collections and
interest. I wasn't involved in the design or debug of the piece of the
product that didn't work, but that didn't help me...
Jim
There are thousands, if not millions, of PID loops in mills and
factories around the world that are specified, installed, maintained,
and tuned by people who don't understand PID, yet build machines with
them that do their jobs adequately, if not not optimally.
So I disagree.
Having said that, there are also innumerable applications where PID
control is the correct answer, but where you'll never get it working
without understanding the theory. Moreover, without the theory you
won't necessarily know which type of problem you're dealing with unless
you try and either succeed or fail.
For the former type of system there's my article on PID. For the
latter, there's my book -- or me.
Yes, efficiency is the key.
You can run feedback loops with or without PID.
But for robotics, using minimum energy might be desirable.
> Having said that, there are also innumerable applications where PID
> control is the correct answer, but where you'll never get it working
> without understanding the theory. Moreover, without the theory you
> won't necessarily know which type of problem you're dealing with unless
> you try and either succeed or fail.
Unfortunately, many don't even know why they are needed,
since they only learn about fancy interfaces and not about
getting more mileages (auto is a good example).