Thread: CodeProblem
View Single Post
  #2   Spotlight this post!  
Unread 16-02-2015, 10:22
one_each one_each is offline
Registered User
FRC #4057 (KB Bots)
Team Role: Mentor
 
Join Date: Jun 2012
Rookie Year: 2012
Location: Klamath Falls, Or
Posts: 25
one_each is an unknown quantity at this point
Re: CodeProblem

Quote:
Originally Posted by Oblarg View Post
I don't see any Scheduler.run() call in your teleop periodic code. Without that, there is nothing to call the commands that you have assigned to buttons.
This is the most likely cause of the problem. I would create a second project just to see what the default code does.

In the teleopPeriodic() method, you are creating Button objects then calling the whenPressed() methods. Next, the teleopPeriodic() ends and those objects go away (Garbage Collected). While this might work (I have not tested) if you add the Scheduler.run() call, it is a waste of time and effort for the roboRio.

Instead, I would recommend making the Button objects as member fields (just move the Button button1 ... ; statement outside of all methods) and moving the whenPressed() method calls to teleopInit(). Don't forget to add back the call to Scheduler.run()!