TimedRobot change update period

What is the easiest way to modify the update period from the default of 20ms. I tried looking at the docs and saw that overriding getPeriod inside of our Robot class is how to change it but that didn’t seem to change anything.

Inside the TimedRobot constructor you can call super() with the period in seconds

Yeah we just have never had a Robot constructor but adding that and then the super(period) worked thanks, probably should be updated in their docs.

I’m unable to help, but I have a question. What is a benefit gained from doing that?

Wanted to test a PID loop running faster.

1 Like

Makes sense. Thank you!

EDIT: Read the docs, nvm, this doesn’t seam to work anymore for use in PIDSubsystems and PIDCommands in 2020…

You can set the Period of your PIDController objects individually in the constructor.

public PIDController​(double Kp,
                     double Ki,
                     double Kd,
                     double period)

Allocates a PIDController with the given constants for Kp, Ki, and Kd.

    Kp - The proportional coefficient.
    Ki - The integral coefficient.
    Kd - The derivative coefficient.
    period - The period between controller updates in seconds. 

We use our own PID controller anyway.

Yeah, if you are using regular Subsystem and just putting your own PIDController objects into it, what I said should still work (which I why I didn’t just delete my comment). I’d have to take a look at the source to see what’s up with the PIDSubsystem class.

The docs for changing the update rate have been updated now: https://docs.wpilib.org/en/latest/docs/software/wpilib-overview/creating-robot-program.html#timedrobot

Thanks for pointing this out!

1 Like

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