Log in

View Full Version : Iterative Robot Template


csshakka
09-03-2010, 00:02
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
09-03-2010, 06:54
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.

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

TubaMorg
09-03-2010, 09:42
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
09-03-2010, 10:17
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
09-03-2010, 10:36
Alright makes much more sense. Thanks a ton everyone. Now its time to code it :).

ideasrule
09-03-2010, 13:40
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.