Building on last post--
When you push teleop mode on Drive station, IterativeRobot will call teleopInit() and then call teleopPeriodic() every 20ms.
Similarly when you press Autonomous from drive station, it calls autonomousInit() and then autonomousPeriodic() every 20ms after that.
Your autonomousPeriodic() directly calls your drivetrain so you are making that call every 20ms in autonomous. This is why this mode works for you.
Note, you should *never* call any subsytem functionality from anything but a command. You are only asking for trouble.
Your autonomousPeriodic() *should* be:
Code:
public void autonomousPeriodic() {
Scheduler.getInstance().run();
}
You should create a command field in your Robot class
Code:
public class Robot extends IterativeRobot {
Command autonomousCommand;
...
and then you can do something like this in autonomousInit:
Code:
public void autonomousInit() {
// schedule the autonomous command (example)
if (autonomousCommand == null) {
autonomousCommand=new leftStraffe();
}
autonomousCommand.start();
}
Now, when you run autonomous, we simply run the scheduler. The autonomous starts your leftStraffe command (note, java convention is to name classes with a captial so LeftStraffe may be a better name because you will have to look back less to see how you spelled it if you are consistent with your naming conventions), so that command is now being controlled by the scheduler. It will call execute() which in turn will be the appropriate way call your mecanum drive function.