Running motors in auton

How would I program the robot to go forward for ~3 seconds in java then activate a conveyor-belt like system?

public void autonomousPeriodic() {

	try {
	} catch (InterruptedException e) {
		// TODO Auto-generated catch block

Above is what I have right now to just run the robot. I could be wrong but I believe the code is attempting to run all the motors at 1/5 speed for 3 seconds. But all it does upon enabling is a clicking sound and an inch of movement.

A few things going on here.

First, using things like sleep or wait commands to run an autonomous routine is pretty dangerous and not going to work. The code won’t successfully run and you will get a Watchdog error. The reason for this is, if the code were allowed to run, this prevents any control of the movement of the robot for the duration of the sleep command! Other lines of code won’t necessarily run. The Watchdog detects when a periodic loop is taking too long to execute and stops everything when it happens - since that’s way safer than a robot moving uncontrollably.

Additionally, even ignoring the Watchdog, you never tell the motors to stop running, so the AutonomousPeriodic loop would just repeatedly tell them to keep running, indefinitely.

As you may know, Periodic functions run repeatedly, over and over again. So a simple solution for time-based autonomous control is to run a Timer object that starts in AutonomousInit, and then is checked every time AutonomousPeriodic runs. Consider this psuedocode:

Timer autoTimer;

autonomousInit() {

if (autoTimer < 2) {
} else {

This sort of code would successfully run (if all the syntax were right, objects declared, etc). There isn’t a sleep command or a while loop that prevents other code from running, so the Watchdog error won’t trigger, yet it still lets you time autonomous events.

What could be happening (ignoring your Thread.sleep() problems), is that the frontLeft and rearLeft (or vice-versa) are fighting each other. You can test this by running the same code with your robot on blocks and unplug the power to one of the motors. If one motor goes forward and the other goes backward, you have a problem.