![]() |
Re: Problem with NavX to turn around.
Quote:
One can easily cap the max speed of a P loop (let's be honest, for turn-to-angle you're probably not going to need any I or D) or tune the P term to avoid overshoot. In fact, one of the appeals of a P loop is precisely that the output ramps down as you approach the setpoint, such that you do not overshoot. In this capacity, it is quite a bit nicer than bang-bang control (which is what you are describing). |
Re: Problem with NavX to turn around.
Quote:
Let T be your desired angle position (in degrees, can be any range, even outside the range +/-360) the angle between them (let's call it ERR) is found by the equation: ERR = (T-S) - 360*floor(0.5+(T-S)/360); the above returns a value for ERR between -180 and +180 degrees, the shortest angle path to the target. Don't believe me? Try it. So it tells you which direction to rotate as well as how much to rotate. To use this with a PID, use processVariable = setpoint-ERR |
Re: Problem with NavX to turn around.
Quote:
|
Re: Problem with NavX to turn around.
Quote:
I was responding to DanielHa's post, to show a simple way to compute shortest angle... which would be useful to know for situations where the library functions or the hardware don't do the math for you. |
Re: Problem with NavX to turn around.
Quote:
There are few things that I hate more than debugging code "What does this do?" "Dunno, think it turns the robot". /sigh. Quote:
|
Re: Problem with NavX to turn around.
Quote:
Sometimes, of course, libraries are inadequate and you have to build your code from the ground up. But this is not always the case. |
Re: Problem with NavX to turn around.
Quote:
|
Re: Problem with NavX to turn around.
Quote:
|
Re: Problem with NavX to turn around.
While not speaking for Ether, I don't think either one of us was recommending that they reinvent the code / wheel. But the OP wanted to know the details and Ether supplied them. From his simple explanation it would be easy to write the code / PID function.
But I think both of us are recommending understanding how things work for the coders. |
| All times are GMT -5. The time now is 04:58. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi