Go to Post A Red Ryder 200-shot carbine Range model air rifle!!! - dlavery [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Spotlight this post!  
Unread 08-03-2016, 13:12
David Lame David Lame is offline
Registered User
FRC #0247
 
Join Date: Feb 2015
Location: Berkley, MI
Posts: 88
David Lame is a jewel in the roughDavid Lame is a jewel in the roughDavid Lame is a jewel in the roughDavid Lame is a jewel in the rough
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
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 20:06.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi