|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
||||
|
||||
|
Re: NavX MXP Continuous Angle to Calculate Derivative
Quote:
You should be able to use some modulo arithmetic operations to solve the jump from 0 / 360. I'm not sure how you have it configured but on our we have the issue because it jumps from -180 / 180. Question though - what are you trying to achieve by closing the loop to a specific turning speed? We use the same setup and close the loop on the current field orientation angle. In that way you can have the robot quickly turn when it's farther away from the set point, and slow down as it approaches where you want it to be so you have minimal overshoot. |
|
#2
|
|||||
|
|||||
|
Re: NavX MXP Continuous Angle to Calculate Derivative
Quote:
|
|
#3
|
||||
|
||||
|
Re: NavX MXP Continuous Angle to Calculate Derivative
Quote:
There was definitely a noticeable improvement on the conventional PID controller. One problem we were facing without the velocity controller was that our turns were highly dependent on momentum. We really would have liked to run the velocity loop underneath our teleop driving code too, but integral windup caused a lot of unpredictable behavior over long periods of time. Last edited by MichaelBick : 22-05-2016 at 01:57. |
|
#4
|
||||
|
||||
|
Re: NavX MXP Continuous Angle to Calculate Derivative
Quote:
Quote:
I haven't updated the NavX libraries yet, as we leave for Missouri State Champs at 3:00 tomorrow and we're in a time crunch. Ether's fix seemed the quickest and easiest. Thank you everyone for all the help! I can post source code for our autoalignment command and the derivative calculator in a few days if anyone is interested. |
|
#5
|
|||||
|
|||||
|
Re: NavX MXP Continuous Angle to Calculate Derivative
This year on 254 we switched to using a simple Rotation2d class for all angles (because, among other reasons, dealing with angle rollover as you did here is easy to screw up). Internally, this class stores the sine and cosine of an angle explicitly. This has some nice properties:
|
|
#6
|
||||
|
||||
|
Re: NavX MXP Continuous Angle to Calculate Derivative
Thanks Ether... learn something new everyday!
The way Microsoft's library present's this function is like so: IEEERemainder = dividend - (divisor * Math.Round(dividend / divisor)) It's great to see such a compatible use-case for this function as written in this thread... this function has also helped improve some bugs in my simulations as well. ![]() |
|
#7
|
||||
|
||||
|
Re: NavX MXP Continuous Angle to Calculate Derivative
Here is a c++ equivalent within standard libraries:
http://en.cppreference.com/w/cpp/numeric/math/remainder |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|