Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Java (http://www.chiefdelphi.com/forums/forumdisplay.php?f=184)
-   -   Iterative Robot Template (http://www.chiefdelphi.com/forums/showthread.php?t=84052)

csshakka 03-09-2010 12:02 AM

Iterative Robot Template
 
This may be a really dumb question that i overlooked the answer to, but should the drive controls in teleop mode go under the teleopContinuous() function or the teleopPeriodic() function. For simplifying purposes, lets say it would be for a standard tank drive robot with a left and right joystick controlling its movement. I guess my main question is where to code most of the controls and how often the periodic function actually is called.

Thanks in advance for help.

EDIT: Also what types of things would go in the disabled functions. Im assuming it would be things like motors to zero power and things like that.

charrisTTI 03-09-2010 06:54 AM

Re: Iterative Robot Template
 
teleopPeriodic is called about every 50ms. This time period is based upon the data rate of new packets coming from the driver station. New joystick information is received about every 50ms, so there is no reason to update the robot drive more frequently, since the data would be exactly the same as the previous data.

So put your call to tank drive in teleoPeriodic.

Code:

    public void teleopPeriodic()
    {
        // feed your watchdog
        Watchdog.getInstance().feed();
        // drive the robot
        this.robotDrive.tankDrive(leftJoystick, rightJoystick);
    }


TubaMorg 03-09-2010 09:42 AM

Re: Iterative Robot Template
 
yes the teleopPeriodic method is the one that makes most sense for competition. You can assume that each of the periodic functions in the iterative robot class are loops.

So the disabled method is good for handling chores you want taken care of before the robot is enabled in either autonomous or teleop. As you stated you can initialize all of your motors, variables, digi i/o, whatever. Also we are using the disabled method to set our autonomous mode. Pulling a trigger on one of our joy sticks will cycle through our auto modes that will be called once autonomous is entered. Yes the program still reads input even though disabled. You just don't get output to the robot.

Joe Ross 03-09-2010 10:17 AM

Re: Iterative Robot Template
 
Quote:

Originally Posted by charrisTTI (Post 934279)
teleopPeriodic is called about every 50ms. This time period is based upon the data rate of new packets coming from the driver station. New joystick information is received about every 50ms, so there is no reason to update the robot drive more frequently, since the data would be exactly the same as the previous data.

It is called at the rate of the new packets coming from the DS. However, that rate is 50hz (every 20ms).

csshakka 03-09-2010 10:36 AM

Re: Iterative Robot Template
 
Alright makes much more sense. Thanks a ton everyone. Now its time to code it :).

ideasrule 03-09-2010 01:40 PM

Re: Iterative Robot Template
 
If you've run drive code on the robot before, I'd strongly suggest testing the code before going into a match. Chances are, no matter how simple the code seems, you'll need to tweak it countless times before getting it to work.


All times are GMT -5. The time now is 08:31 AM.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi