Log in

View Full Version : Java Motor Control Troubles


jo3_sum
14-01-2012, 20:59
My team is having trouble using java. We can't set a regular/not-CAN Jaguar motor controller's speed. It says it can't find the module and port. Are there any simple examples where we can test only 1 motor controller with a joystick? Most of the samples want multiple devices. We are still doing baby steps.

BradAMiller
14-01-2012, 22:31
Make sure that you are using module number 1 for the first digital module regardless of what slot it's in. Also, if you upload your code we can take a look.

Brad

ProgrammerMatt
14-01-2012, 23:06
My team is having trouble using java. We can't set a regular/not-CAN Jaguar motor controller's speed. It says it can't find the module and port. Are there any simple examples where we can test only 1 motor controller with a joystick? Most of the samples want multiple devices. We are still doing baby steps.

Here ill get you going on a simple code.

first thing under your public class put

Joystick joystick1;
Victor motor1;


Under that line put:

public void robotInit {

joystick1 = new Joystick(1);

motor1 = new Victor(1) // the one can be replaced with any PWM port on sidecar.



NOTE: You will have to import the Victor class and Joystick class. you can do this by adding this above your public class:


import edu.wpi.first.wpilibj.Victor;
import edu.wpi.first.wpilibj.Joystick;


After that just simply put this in your operator control


while(isOperatorControl) {

motor1.set(joystick1.getY()); // gets the val from joystick and converts to pwm

}


Yes i do know that you are using Jaguars not Victors but the coding for the two on pwm is practically the same and should get you going good. I suggest your team looks in to using CAN it has so many nice features.

jo3_sum
16-01-2012, 20:42
Sorry, about being vague in the first post. I was in rush.
It turns out we forgot to move the modules from last year's slots after re-imaging.
Then, we used motor_controller = new MotorController(int slot, int channel) instead of motor_controller = new MotorController( int channel).

The motor moves, now. :)