If you really have a laggy problem and are trying to figure out what is taking all the time, there are a number of tactics to take. One tactic that can be helpful is getting quantitative values that show "how much time does this part take?" Without a good professional profiler, you can use the 'old school' method of timing...usually you will have a good sense of what's taking all the time - like vision code processing takes a lot of time. Get a value...
I'd suggest something like:
Code:
int loopstart, loopend, videostart, videoend;
while (IsOperatorControl())
{
loopstart = GetUsClock(); // microseconds since startup
[ code code code ]
// start of vision code
videostart = GetUsClock(); // microseconds since startup
ProcessImage();
videoend = GetUsClock(); // microseconds since startup
[ code code code ]
loopend = GetUsClock(); // microseconds since startup
SmartDashboard::PutNumber("LoopTime-ms", (loopend-loopstart)/1000);
SmartDashboard::PutNumber("VideoTime-ms", (videoend-videostart)/1000);
}
The gist here is to get an idea of at least two things -- how long does it take you to loop the loop and how long does your "big possible offender" take to run? In SmartDashboard, you can have these values plotted as a graph rather than as just numbers "flitting" on the dashboard. That helps to see if you have consistent results or if your processing is for some reason sporatic.