Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Java (http://www.chiefdelphi.com/forums/forumdisplay.php?f=184)
-   -   Programming with CAN Jaguars (http://www.chiefdelphi.com/forums/showthread.php?t=101434)

ssirovica 28-01-2012 22:04

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:

CANJaguar motor = new CANJaguar(1); 

Net beans was giving us an error saying we needed a try catch statement.

ProgrammerMatt 29-01-2012 01:09

Re: Programming with CAN Jaguars
 
:) id be happy to


Code:

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());
}

P.S you need the try catch incase it cant find the jaguar id it throws an error

gpetilli 06-02-2012 12:17

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.

dyanoshak 06-02-2012 14:00

Re: Programming with CAN Jaguars
 
Quote:

Originally Posted by gpetilli (Post 1120954)
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.

Yes, it is not recommended that you use 1 because it is the default ID.

The maximum ID number is 63.

-David


All times are GMT -5. The time now is 10:39.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi