|
|
|
![]() |
|
|||||||
|
||||||||
|
|
Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Timing, threads, the Field Management System, etc
I understand the basics of how FMS interacts with the robot. It calls the init function when it enters a new phase, and it calls the periodic function periodically while in the phase. I've read that it calls the periodic function every 10 milliseconds, but I don't know if that's correct, and I've never timed it.
Now what I'm wondering is what really happens if you do things that take up a lot of processor time, or perhaps just clock time. For example, if you write in teleopPeriodic() { Thread.sleep(15); } when will the next call be made to teleopPeriodic() be made? 15 milliseconds after the last one? 25 milliseconds? And then there are threads. There are certain things that come up that I know must be multithreaded behind the scenes. (E.g. PIDControllers) Can I set up my own threads? There's a control loop that I am thinking about using, but 10 milliseconds between updates is too slow. If I just launched a thread to take care of that, could I update it much faster? And loops? What if I code an infinite loop in autonomous. autonomousPeriodic() { while (2+2==4) { System.out.println("I am still in autonomous"); } } Will that mean that it will run forever, and teleopInit() will never be called? All right, those are very general questions that could have very complicated answers. What I am really looking for is a document from FIRST/National Instruments/WPI that addresses the issue. In case it matters, we use Java with the Iterative robot model. I probably ought to use the command based robot model, but iterative was actually closer to what I wrote professionally, so that's what I do, and what I have taught since our team switched from Labview. I have now begun wondering if I am projecting my professional code behavior onto Java. Professionally, I wrote code that had to execute in a short time window because it was called periodically in an interrupt service routine. I'm not sure that's how the FMS/robot code actually works, and am wondering what would happen if I spawned a thread in teleopInit() that would go out and read my sensors and update motor speed more often than the default calls to teleopPeriodic(). |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|