|
|
|
![]() |
|
|||||||
|
||||||||
|
|
Thread Tools | Rate Thread | Display Modes |
|
#5
|
||||
|
||||
|
Re: PID crossing 0
Quote:
angle_error = target_angle - measured_angle; angle_error -= 360*floor(0.5+angle_error/360); then: setpoint = angle_error; process_variable = 0; OR setpoint = 0; process_variable = -angle_error; The disadvantage of the first approach is that the Derivative term will be disabled since the WPI Lib PIDs only look at the derivative of the process_variable. The disadvantage of the second approach is that, although the Derivative term will be active, it will respond to changes in BOTH the measured_angle as well as the target_angle, so be careful how you adjust it. Notice that the first two lines of code above (calculating the angle_error) calculate the shortest angle distance to the target. You need extra conditional logic only if you want to change the sign of wheel speed. See the discussion here. Last edited by Ether : 26-05-2011 at 09:44. |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|