Robot Scan Time

I am trying to find the scan time of my robot. As in how long the gap is in between each command processed by the robot itself.

Thanks in advance.

What language are you using? In LabVIEW you can set custom loop times, and in Java/C++ the loop interval for the scheduler is defaulted to 20ms (noted here: https://wpilib.screenstepslive.com/s/4485/m/13809/l/241892-what-is-command-based-programming).

Note that he is referring to code written in Periodic Tasks, code written in Teleop will be executed only when a packet from the driver station is received.

We are using java to program our robot and we would like to know the scan time if the scan time were ever to fluctuate.

It shouldn’t fluctuate unless you start dropping packets and experience sporadic ping timings. What are you going to use this information for?

We want to have acceleration for our drive train.

My idea was to increase the speed of a motor at a constant rate multiplied by the scan time of the robot.

if(maxSpeed > currentSpeed)
{
    currentSpeed += ACCELERATION * SCANTIME;
}

The time elapsed is going to be approximately 20ms, but it will fluctuate depending on network latencies.

Just perform the calculation each time through the loop.


currentTime = Timer.getFPGATimestamp(); //time in seconds
elapsedTime = currentTime - lastTime;

//do your math

lastTime = currentTime;

More info on what the getFPGATimestamp method does here: http://team2168.org/javadoc/edu/wpi/first/wpilibj/Timer.html#getFPGATimestamp--

Thank you all for your help!

-3098