|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
Re: CodeProblem
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.
|
|
#2
|
|||
|
|||
|
Re: CodeProblem
Quote:
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()! |
|
#3
|
|||
|
|||
|
Okay so I tried moving the
Scheduler.run() Button button1 = new JoystickButton(joystick, 1), button2 = new JoystickButton(joystick, 2), button3 = new JoystickButton(joystick, 3), button4 = new JoystickButton(joystick, 4), button5 = new JoystickButton(joystick, 5), button6 = new JoystickButton(joystick, 6), button7 = new JoystickButton(joystick, 7), button8 = new JoystickButton(joystick, 8), button9 = new JoystickButton(joystick, 9), button10 = new JoystickButton(joystick, 10), button11 = new JoystickButton(joystick , 11); code to both outside of the whole code and the robot int and the program fails to recognize that button1.whenPressed(new ElevatorOff()); button2.whenPressed(new ElevatorOn()); button3.whenPressed(new ElevatorReverse()); button4.whenPressed(new ArmsOut()); button5.whenPressed(new ArmsIn()); button6.whenPressed(new ArmsVerticalIn()); button7.whenPressed(new ArmsVarticalOut()); button8.whenPressed(new BlueLightShow()); button9.whenPressed(new LigthShowOn()); button10.whenPressed(new RedLightShow()); button11.whenPressed(new LightShowEnd()); is connected it comes up with a syntax error that the button1 - button11 is not defined. |
|
#4
|
|||
|
|||
|
Re: CodeProblem
If any of your commands require parameters then that could be why nothing is happening. As for declaring the buttons, that should be in the constructor of your OI file.
|
|
#5
|
|||
|
|||
|
Re: CodeProblem
The Template I am using dose not have a OI section is there another way around it?
|
|
#6
|
|||
|
|||
|
Re: CodeProblem
I don't know if it's possible to create one. You could try creating a new robot template to see if it has an OI and try to make one based off of that....
|
|
#7
|
|||
|
|||
|
Re: CodeProblem
You don't have to do it there, though. As long as they are declared somewhere before you enter your teleop periodic loop, it will work.
|
|
#8
|
|||
|
|||
|
Re: CodeProblem
Quote:
![]() |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|