Update rate of commands

How often is the “Execute” method run on commands in command-based? We are trying to do something which relies on sensor and motor controller values being updated at a constant rate. I am worried that these methods will be called at irregular intervals. So if there is a set rate at which they are called, what is it? And if they are called irregularly, how might I go about ensuring that this information is updated at a regular rate? We are using C++, if it matters.

Each execute method should be called approximately every 20ms. This can vary a few ms in either direction though.

In fact, if you’re following standard structuring of your command-based code, Teleop/Autonomous/DisabledPeriodic in Robot.cpp is called once per data packet received from the driver station. Which can be irregular if you drop packets.

You could use the Notifier class to set up a periodic event that will call a function at regular intervals. If you’re trying to do this for PID control, the PIDController class is already set up for regular timing to run the PID algorithm and set motor outputs.