|
|
|
![]() |
|
|||||||
|
||||||||
|
|
Thread Tools | Rate Thread | Display Modes |
|
#4
|
|||
|
|||
|
Re: Can't get a command to run
The initialize() method is called when the command is scheduled. So in your case, when the button is pressed, the command should be scheduled and the initialize() method will be called once. Then the command will loop between the isFinished() and exectute().
To get the scheduler to run it needs to be called repeatedly. The idea is to put a Scheduler.run() into the AutonomousPeriodic() and TeleopPeriodic() methods. This causes it to run every 20ms (once for each driver station data update). Each call to run() will do these things: 1. look for buttons that are pressed or released and schedule commands dependent on them 2. for each of the newly scheduled commands: call the initialize() method 3. for each of the running commands: call the execute() method, then the isFinished() method. These are just run one after another for each command. So it's important to not do any delays or long loops in any of the commands methods or it will cause the other commands to not run or have an unpredictable schedule. So, the bottom line, make sure you have something like this: Code:
public void autonomousPeriodic() {
Scheduler.getInstance().run();
}
public void teleopPeriodic() {
Scheduler.getInstance().run();
}
Brad |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|