Troubles Turning in place via Gyro!

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!

What do you mean? The input and output units of your controller are different.

Well that ProfilePidController needs to output to a value my drive motors understand, in this case percent output between -1 and 1

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.

Yes; that will be reflected in the scaling of the gains of the ProfiledPIDController.

Gotcha! This makes a lot of sense! If my error is 90 degrees I probably want to respond with a high amount of power to get it there!

makes sense!

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.

1 Like

great point!

Are you referring to the SimpleFeedForward class?

Yes.

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

Either getMaxAchievableVelocity or getMaxAchievableAcceleration.

Thanks. A lot of this feels overkill for a turn in place haha but good to know, just trying to accurately turn

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.

makes sense. I need to limit acceleration to avoid that beeping noise and then set my gains right.

Is there a way to profile your floor? I noticed the pid algorithm would try to drive with too small of a value

This is the job of the kS term in the WPILib feedforward classes.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.