|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Velocity PID control and setpoint ramping
For the first time, 449 is running a drive with velocity PID control (well, actually P control with a simple integrator on the output).
On the whole we are quite happy with it, but various people have noticed that driving with it can be a bit "jerky" and violent compared to standard controls. Namely, if the driver lets go of the joystick while the robot is moving full speed, the control loop will (as it should) stop the robot as fast as possible (which is actually pretty close to instantaneously, it seems). This is not something we're used to, and has caused some concern, though it has gotten better with additional driver practice. Additionally, we managed to shear all the teeth off of the 14-tooth gear in one of our WCP SS gearboxes at our last event. We're replacing these with steel gears, but we're also concerned that the sudden stops are placing additional stress on the drive, and as we only have steel replacements for the 14-tooth gears (and not for the 60-tooth gears meshing with them) we'd like to err on the side of caution. So, we're looking at potentially implementing a setpoint ramp to tame it a bit. I was wondering if other teams have had any experience with this, and if they found setpoint ramping to be a necessary/helpful addition and, if so, what ramp rates they found to work best. EDIT: We're handling our PIDs using the PIDSubsystem object in WPILib. Last edited by Oblarg : 14-03-2016 at 16:39. |
|
#2
|
||||
|
||||
|
Re: Velocity PID control and setpoint ramping
If the problem is just when the robot stops, I would actually recommend that you use a smaller proportional value whenever the commanded speed is close to zero. This will make the drivetrain drift more if your drivers want it to. It should also stop ruining your gears; they are probably being worn down by constantly oscillating back and forth when trying to stop, but when PIDing to a non-zero value they shouldn't see any abnormal loads.
|
|
#3
|
||||
|
||||
|
Re: Velocity PID control and setpoint ramping
I am pretty sure that there is a velocity ramp function for Talon SRX, where you can make a max ramp steepness, so that there is less jerkiness.
|
|
#4
|
|||
|
|||
|
Re: Velocity PID control and setpoint ramping
Quote:
We're doing our PID on the RoboRio, not on the motor controllers. Since our PID output is integrated we can implement a voltage ramp rate using the default setOutputRange() function, but I've heard that input ramping is a better way of handling this than output ramping. |
|
#5
|
||||
|
||||
|
Re: Velocity PID control and setpoint ramping
We use LabVIEW, and this VI is probably what does the trick.
I am sure that this method is available in Java and C++. |
|
#6
|
||||
|
||||
|
Re: Velocity PID control and setpoint ramping
Quote:
Code:
if(commandedSetpoint < some value that is close to 0) {
yourSubsystem.getPIDController().setPID(small kP, kI, kD);
} else {
yourSubsystem.getPIDController().setPID(normal kP, kI, kD);
}
|
|
#7
|
|||
|
|||
|
Re: Velocity PID control and setpoint ramping
Ah, didn't know there was a method to change the PID values after instantiating the object. Thanks! We'll give this a look, too.
|
|
#8
|
||||
|
||||
|
Re: Velocity PID control and setpoint ramping
Are you using TalonSRX's with their built in PID control? If so, I highly recommend following the procedure for tuning PID in the Talon user guide. We have been doing things in a way similar to you (mostly P) and had similar results. Then we got the great advice to try things "by the book". That means starting with 0's all around for PID and upping the F, feed forward, term until you get the speed you expect based on your input. Then use PID to tune that. Drive is much smoother now.
|
|
#9
|
|||
|
|||
|
Re: Velocity PID control and setpoint ramping
Quote:
Since we're using an integrator on our output, we can't really use the supported feedforward term. We could implement our own, but I'm not sure the lack of a feedforward term is what's causing problems. |
|
#10
|
|||||
|
|||||
|
Re: Velocity PID control and setpoint ramping
Consider what would happen if you added feedforward and took the output of the FPID directly to control the motor rather than integrating it.
|
|
#11
|
|||
|
|||
|
Re: Velocity PID control and setpoint ramping
Quote:
It's worth noting that we're not seeing any problems with oscillations or overshoot, we're more worried about the taxing effect on the drive components from the (correct) behavior of the motors fighting the robot's forward momentum to come to a stop quickly. Last edited by Oblarg : 14-03-2016 at 20:23. |
|
#12
|
||||
|
||||
|
Re: Velocity PID control and setpoint ramping
I would set up something that limits how quickly your velocity setpoint can change when you are slowing down. You could put this in the part of your code where you're mapping joystick position to desired velocity.
For example, you could have something like: Code:
//set currentSetpoint here
if(currentSetpoint - lastSetpoint > .1){
currentSetpoint = lastSetpoint - .1;
}
//set your PID controller here
lastSetpoint = currentSetpoint;
|
|
#13
|
||||
|
||||
|
Re: Velocity PID control and setpoint ramping
Quote:
inputs: currentSetpoint = .1 lastSetpoint = 1 output: currentSetpoint is not updated |
|
#14
|
||||
|
||||
|
Re: Velocity PID control and setpoint ramping
Quote:
currentSetpoint is updated before the if statement, so the condition for the if statement isn't met, it will use the value of currentSetpoint set in the first line. It does only work in one direction though - if you wanted it to work in both directions for only decelerations, you'd need to know which way you were going. |
|
#15
|
||||
|
||||
|
Re: Velocity PID control and setpoint ramping
The large step in setpoint is allowed through without being ramped.
.1 - 1 = -.9 which is not > .1, so the logic does not prevent a jump in setpoint from 1 to .1. Last edited by Ether : 14-03-2016 at 21:44. |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|