View Single Post
  #3   Spotlight this post!  
Unread 27-11-2016, 12:46
trycatch's Avatar
trycatch trycatch is offline
Registered User
FRC #5858
 
Join Date: Nov 2015
Rookie Year: 2015
Location: AL
Posts: 22
trycatch is an unknown quantity at this point
Re: IterativeRobot, CommandRobot, or SampleRobot for brand new programmers?

Quote:
Originally Posted by virtuald View Post
Constructs such as this: Imagine a naive implementation of making an arm move:

Code:
while arm.isNotInPosition():
    arm.moveToPosition()
As I'm sure you're aware, there are several obvious problems with this:
  • The arm may never be in position (the sensor broke), so your robot keeps moving the arm and does nothing else
  • The robot can't drive while this loop is executing
Oh, I agree completely there. I've taught my kids around the whole "while this button is pressed keep doing whatever that button does" thing already. Handling more complex scenarios (going to a position automatically on a single button press) isn't too difficult either (I personally don't feel, anyway.)

Quote:
In FRC there is no thread killing. If you never return from autonomous, you will never return from autonomous. Timer.delay only sleeps, it does no extra checking.
That is very good to know. I think that's currently my only real issue with SampleRobot, then. Easy to catch in Teleop, as you're going to be in a loop by definition, but requires throwing a lot of "did I get disabled?" in your code to be able to respond to getting disabled / end of autonomous quickly. Hmm.
Reply With Quote