Log in

View Full Version : Robot Scan Time


FancyGerald
19-01-2016, 17:34
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.

Landonh12
19-01-2016, 17:50
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).

rzoeller
19-01-2016, 17:51
In LabVIEW you can set custom loop times

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.

FancyGerald
19-01-2016, 17:56
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.

Landonh12
19-01-2016, 17:59
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?

FancyGerald
19-01-2016, 18:07
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;
}

otherguy
19-01-2016, 19:28
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--

mynameistoe
19-01-2016, 20:05
Thank you all for your help!

-3098