View Single Post
  #1   Spotlight this post!  
Unread 08-02-2012, 22:51
neal's Avatar
neal neal is offline
Neal
FRC #1777 (Viking Robotics)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2009
Location: United States
Posts: 56
neal is an unknown quantity at this point
Simple test code not working (for jaguar)

We were just trying out all our motors on the new robot. First we just tried with the drive motors, and it worked fine. After that I added other motors as well, and then nothing was working. I got no errors whatsoever. The lights on the jags were just blinking yellow. But even the drive motors stopped working too. So we tried to remove all the other motors and see if the drive motors still work, and it did. So I think the problem is something in the code for the other motors.

Here's my code:

Code:
public class TestBot extends SimpleRobot {
	
	private Gamepad gamepad1, gamepad2, gamepad3, gamepad4;
	private UserMessages uM;
	private Jaguar leftJag, rightJag;
	private SpeedController shooterFeeder, shooter;
	private SpeedController grabber;
	private SpeedController arm;
	private Relay angler;
	private RobotDrive drive;
	
	public void robotInit() {
		
		uM = new UserMessages();
		rightJag = new Jaguar(1);
		leftJag = new Jaguar(2);
		shooterFeeder = new Jaguar(3);
		shooter = new Jaguar(4);
		arm = new Jaguar(5);
		grabber = new Jaguar(6);
		drive = new RobotDrive(leftJag, rightJag);
		angler = new Relay(1);
		
		gamepad1 = new Gamepad(1);
		gamepad2 = new Gamepad(2);
		gamepad3 = new Gamepad(3);
		gamepad4 = new Gamepad(4);
		
		Watchdog.getInstance();
		System.out.println("[robot] Robot Ready!\n");
	}

	public void autonomous() {

		System.out.println("[mode] Autonomous started");
		uM.write(1, "Autonomous Mode");
		
		while (isAutonomous() && isEnabled()) {
			
			getWatchdog().feed();
			
			Timer.delay(0.005);
		}
		
		System.out.println("[mode] Autonomous stopped");
	}

	public void operatorControl() {

		System.out.println("[mode] Tele-op started");
		uM.write(1, "Tele-op Mode");
		
		while (isOperatorControl() && isEnabled()) {
			
			getWatchdog().feed();
			
			drive.tankDrive(gamepad1.getAxis(2), gamepad1.getAxis(5));
			
			grabber.set(gamepad1.getAxis(3));
			
			shooter.set(gamepad2.getAxis(2));
			shooterFeeder.set(gamepad2.getAxis(5));

			if(gamepad1.getButton(3) || gamepad1.getButton(3)) {
				angler.set(Relay.Value.kForward);
			}
			else if(gamepad1.getButton(4) || gamepad1.getButton(4)) {
				angler.set(Relay.Value.kReverse);
			}
			else {
				angler.set(Relay.Value.kOff);
			}
			
			Timer.delay(0.005);
		}
		
		System.out.println("[mode] Tele-op stopped");
	}

}
If I remove all other motors except leftJag, rightJag and drive, it works fine.
We'd really appreciate if someone can figure out the problem so we don't have to test each part one by one on Saturday.

Thanks in advance!
Reply With Quote