View Single Post
  #11   Spotlight this post!  
Unread 10-02-2012, 06:59
BurtGummer BurtGummer is offline
Electrical/Mechanical/Programming
FRC #3020
Team Role: Engineer
 
Join Date: Feb 2009
Rookie Year: 2009
Location: Southern CA
Posts: 89
BurtGummer will become famous soon enoughBurtGummer will become famous soon enough
Re: Simple test code not working (for jaguar)

So, you have used code that was like this, with Jaguar types instead of SpeedControllers?

Code:
public class TestBot extends SimpleRobot {
	
	private Joystick gamepad1, gamepad2, gamepad3, gamepad4; // These need to be initialized as joysticks, not gamepads.
	private UserMessages uM;
	private Jaguar leftJag, rightJag;
	private Jaguar shooterFeeder, shooter, grabber, 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(2, 1);   // Constructor wants PWM channels.
		angler = new Relay(1);
		
		gamepad1 = new Joystick(1); // These need to be initialized as joysticks, not gamepads.
		gamepad2 = new Joystick(2);
		gamepad3 = new Joystick(3);
		gamepad4 = new Joystick(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");
	}

}
I fixed several things in your code. It 'should' work now, providing the wiring is correct. I don't normally like writing code for people, so I please ask that you read up on java, and use the provided API to make sure you aren't calling classes that don't exist. I have added comments on the above code for things that I have edited. If you need help on coding, you can PM me as well.

Let me know how the above code works.
__________________
I'm a mentor looking for a home in Southern California! I know Java, C++, electrical and mechanical.

Need Java or C++ help? Send me a PM!
Reply With Quote