Go to Post C'mon you guys you're all inventors. You guys should be making a portable cryogenic sleep chambers for those long bus trips! You got two weeks before you have to go. Get cracking! - Koko Ed [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
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
  #4   Spotlight this post!  
Unread 01-19-2013, 03:35 PM
BradAMiller BradAMiller is offline
Registered User
AKA: Brad
#0190 ( Gompei and the Herd)
Team Role: Mentor
 
Join Date: Mar 2004
Location: Worcester, MA
Posts: 587
BradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant futureBradAMiller has a brilliant future
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();
    }
If you use RobotBuilder to generate the program code, it will automatically insert this code for you. Otherwise you need to be sure to do it yourself.

Brad
__________________
Brad Miller
Robotics Resource Center
Worcester Polytechnic Institute
Reply With Quote
 


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 07:40 AM.

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