|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
setX() not working
Not sure if I should post this here or in the Java section...
I was trying to use setX to set a speed of the motor. I set up the speed and position references. But the Jaguar would not do anything (RobotDrive works fine). I did not set PID and am wondering if this could be the problem. Thanks in advance for your help. |
|
#2
|
|||
|
|||
|
Re: setX() not working
Quote:
-Joe |
|
#3
|
||||
|
||||
|
Re: setX() not working
related question: is there a default number of ticks per revolution? I had everything you listed set but that value, and the speed was always reported as 0.0. Tomorrow I'll try setting some arbitrary value (or maybe look up the proper one
). |
|
#4
|
|||
|
|||
|
Re: setX() not working
Quote:
-Joe |
|
#5
|
||||
|
||||
|
Re: setX() not working
Ok, so I set the number of ticks, and setSpeed still does not seem to work. Here's what I've written.
Code:
CANJaguar jag;
public void robotInit() {
try {
jag = new CANJaguar(4);
jag.setPID(1, 1, 0);
jag.setSpeedReference(CANJaguar.SpeedReference.kQuadEncoder);
jag.changeControlMode(CANJaguar.ControlMode.kSpeed);
jag.configEncoderCodesPerRev(100);
jag.enableControl();
} catch (Exception e) {
e.printStackTrace();
}
}
Code:
public void teleopPeriodic() {
try {
jag.setX(10);
System.out.println(jag.getSpeed() + " " + jag.getOutputVoltage() +
" " + jag.getOutputCurrent() + " " +
jag.getTemperature() + " " + jag.isAlive() +
" " + jag.isSafetyEnabled());
} catch (Exception e) {
e.printStackTrace();
}
}
|
|
#6
|
|||
|
|||
|
Re: setX() not working
Quote:
-Joe |
|
#7
|
||||
|
||||
|
Re: setX() not working
I forgot to mention that with 100 ticks per revolution, my test rig reaches a max speed of 900 rpm. I'll try P=100 today, along with many other combinations of constants, and get back to you. Thanks.
|
|
#8
|
||||
|
||||
|
Re: setX() not working
Ok, I found the issue. Instead of doing something like this
Code:
jag2 = new CANJaguar(2); jag2.changeControlMode(CANJaguar.ControlMode.kSpeed); Code:
jag2 = new CANJaguar(2,CANJaguar.ControlMode.kSpeed); |
|
#9
|
|||
|
|||
|
Re: setX() not working
Quote:
setPID() sets the PID constants for the control mode you are in. The original code you posted will work if you move setPID() below changeControlMode(). -Joe |
|
#10
|
|||
|
|||
|
Re: setX() not working
Quote:
A concerned programmer |
|
#11
|
|||
|
|||
|
Re: setX() not working
Quote:
-Joe |
|
#12
|
|||
|
|||
|
Re: setX() not working
So if i plug the laptop into the cRIO port 1 and boot the robot I should get all the println?? How would I run the robot from the driver station then??
|
|
#13
|
||||
|
||||
|
Re: setX() not working
I'm using Ubuntu with Netbeans installed there, and have the driver station running in a virtual machine of Windows XP (Remember that any computer can act as the driver station). The println's go to Netbeans. if you have the driver station on a seperate laptop, simply plug both of them into the D-Link (or put one/both on wireless), and run the code from netbeans to get it to display the output. Make sure no IPs conflict!
Quote:
|
|
#14
|
|||
|
|||
|
Re: setX() not working
DUH I cant believe I didnt think of that before. Thanks so much!
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|