Quote:
Originally Posted by kingkurry
How do we know if we have regular jaguars or CAN jaguars? Also, if we use jaguars does this mean we actually need to declare 4 jaguar instances to drive the robot? Can we do something like
Code:
public void robotInit() {
RobotDrive robot = new RobotDrive(1,2,3,4);
Joystick left = new Joystick(1);
Joystick right = new Joystick(2);
}
public void teleopPeriodic() {
robot.tankDrive(left.getThrottle(),(-1*right.getThrottle()));
}
or do we need to actually need to create jaguar instances and use them to drive the robot. If so, how would we do this?
|
All jaguars both gray and black can use CAN, it is a diffrent way of sending information to them, instead of using the PWM cables you use a phone like cable. Both get the job done, just more accuracy and additional information about the controller while its running comes with the CAN.
And what I did with the jaguar is create an instance for each jaguar outside of any of the Init's. Then on the RobotInit(), I initialized them along with the drive train.
Code:
public class Team3325 extends IterativeRobot {
CANJaguar leftCANJaguarTop;
CANJaguar leftCANJaguarBottom;
CANJaguar rightCANJaguarTop;
CANJaguar rightCANJaguarBottom;
Joystick inputJoystick;
int leftCanTop = 1;
int leftCanBot = 2;
int rightCanTop = 3;
int rightCanBot = 4;
RobotDrive mechanumDrive;
public void robotInit() {
try {
leftCANJaguarTop = new CANJaguar(leftCanTop);
leftCANJaguarBottom = new CANJaguar(leftCanBot);
rightCANJaguarBottom = new CANJaguar(rightCanBot);
rightCANJaguarTop = new CANJaguar(rightCanTop);
inputJoystick = new Joystick(1);
mechanumDrive = new RobotDrive(leftCANJaguarTop, leftCANJaguarBottom, rightCANJaguarTop, rightCANJaguarBottom);
} catch (Exception e) {
System.out.println(e);
}
}
public void teleopPeriodic() {
try {
mechanumDrive.mecanumDrive_Cartesian(inputJoystick.getX(), inputJoystick.getY(), inputJoystick.getThrottle(), 0.0); //TODO <-- Fix Gyro to proper Param.
} catch (Exception e) {
System.out.println(e);
}
}
}
The code is a little dirty, but it works for testing purposes and can hopefully help you. In your case, if you didn't use CAN, you would have to replace CANJaguar with Jaguar and fix a few of the params respectively.