How 'Infrequently' Should Rev's Get/Set Parameter API Be Used?

In Rev’s documentation for the SparkMaxPIDController they state that some methods “use the Get/Set Parameter API and should be used infrequantly”.

Ex from the SetP() method:

Set the Proportional Gain constant of the PIDF controller on the SPARK MAX. This uses the Set Parameter API and should be used infrequently. The parameter does not presist unless burnFlash() is called. The recommended method to configure this parameter is use to SPARK MAX GUI to tune and save parameters.

How infrequently should this be used, and why? Would there be some problem with using this too often? We are thinking about calling it once every time the robot turns on, while booting, to ensure the PID settings are correct.

This should be fine, I think the reason they don’t want you calling it too often is that it isn’t a very efficient task on the SPARKMax. Something like setVoltage(), REV would heavily optimize because teams will likely call it every cycle (which is 20ms).

I had a setCoastMode() for the 8 of our swerve motors running in disabled periodic and we found that it would give us loop times of ~60ms compared to ~12ms without it running in periodic. Setting the idle mode of the motor is also likely to be not optimized cause REV doesn’t expect teams to be doing it often.

1 Like

So are the set commands blocking too? Would these cause a large delay while the robot is starting up?

I believe so, but I’m not 100% sure.

Yes technically a “large” delay of maybe 30-60ms, but since its just initialization and there’s usually a lot of stuff being initialized at startup anyways. So it shouldn’t really matter, as it’ll go down while everything is done initalizing.