I am trying to implement a Turn in place to a targeted Gyro value with the ‘ProfiledPidController’.
I am having a hard time making sense of units. My Gyro gives me a value in degrees, but I need a value from -1 to 1
Our drive is falcon500s and I’ve noticed if we immediately spike to a high voltage an awful sound. SO we need to ramp up, I figured that was the profiled pid controller was for as it limits the max acceleration.
Are there any good guides on how to do this? I can’t believe I am struggling as hard as I am on this!
Your PID gains are dependent on your measurement and output. If you have 1000 units of error and a P gain of 1, you get 1000 units of output. With a gain of 0.001, you get an output of 1. You should consider what error your system will approximately be working with and start with an estimation there.
As for the Max Velocity and Max Acceleration, how do the units of that factor in? With the gearbox and these falcons I can’t immediately send the motors to 100% output
You should look at the configuration options for the talons themselves.
You can set a voltage ramp rate that will govern the allowable increase/decrease in your motor controllers. This will help you get ride of that high pitched squeal you here. That high pitched squeal is the motor being stalled, meaning it’s drawing amperage but not spinning.
Setting the nominal and peak outputs, as well as the ramp rates will actually help your profiled Gyro PID turn quite a bit.
Last thing would just be to make sure you are using a feedforward value that is high enough to keep the robot physically moving. As your PID error gets low, our output from your controller can become small enough that it’s not actually enough to overcome friction.
Do not set a voltage ramp rate on a motor you are controlling with feedback. They interact poorly.
Instead, give the system achievable setpoints.
You have to choose a simultaneously-achievable velocity-acceleration pair to use as a set of constraints. The WPILib feedforward classes actually have helper methods to make it easier to determine such a pair.
thanks. I’ll have to look into that. What function were you refereeing to in SimpleMotorFeedFrward? after looking at it quickly its kinda unclear to me
It is, and it isn’t. Simpler methodologies typically require a lot more hacking around edge-cases to work acceptably in practice; motion profiling has more up-front engineering cost, but often the resulting solution is actually simpler.