|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
Programming with CAN Jaguars
We have decided to switch over from PWM control of the Jaguars on our robot to CAN. Unfortunately I have know idea how to program with CAN Jaguars in Java.
Can you please provide some basic sample code with initialization, and a set method? Thanks, Sasha P.S. When we first began with this declaration: PHP Code:
|
|
#2
|
|||
|
|||
|
Re: Programming with CAN Jaguars
id be happy toCode:
CANJaguar motor1, motor2, motor3, motor4;
RobotDrive myrobot;
Joystick left, right;
public void robotInit() {
try {
motor1 = new CANJaguar(1); // ID number of jaguar
motor2 = new CANJaguar(2);
motor3 = new CANJaguar(3);
motor4 = new CANJaguar(4);
} catch (CANTimeoutException ex) {
ex.printStackTrace();
}
myrobot = new RobotDrive(motor1,motor2,motor3,motor4);
left = new JoyStick(1);
right = new JoyStick(2);
}
public void autonomous() {
}
public void operatorControl() {
while(isOperatorControl()) {
myrobot.tankDrive(left.getY(), right.getY());
}
|
|
#3
|
|||
|
|||
|
Re: Programming with CAN Jaguars
Keep in mind that it is strongly suggested not to use ID = 1 (and I think the max ID is 16 but would have to look it up). You could number your motors 2,3,4,5 for example. The ID numbers need to be set in the jaguars using the BDC-Comm software on a PC with a serial port connected to the input side of a black jaguar.
|
|
#4
|
|||
|
|||
|
Re: Programming with CAN Jaguars
Quote:
The maximum ID number is 63. -David |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|