|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
Jittery Autonomous Code {Java}
In autonomous, i try to run the following code:
Code:
try {
encLeft.start();
encRight.start();
encLeft.reset();
encRight.reset();
while (((encLeft.getRaw() > -14797) || (encRight.getRaw() > -14797)) && (this.isAutonomous())) {
//System.out.println("Left:" + encLeft.getRaw() + " Right:" + encRight.getRaw());
if (encLeft.getRaw() < 14797) {
motor_leftFront_J.setX(.5);
motor_leftRear_J.setX(.5);
} else {
motor_leftFront_J.setX(0);
motor_leftRear_J.setX(0);
}
if (encRight.getRaw() < 14797) {
motor_rightFront_J.setX(-.5);
motor_rightRear_J.setX(-.5);
} else {
motor_rightFront_J.setX(0);
motor_rightRear_J.setX(0);
}
}
Timer.delay(.5);
encLeft.reset();
encRight.reset();
}catch(Exception e){
}
~Matt Clark |
|
#2
|
|||||
|
|||||
|
Re: Jittery Autonomous Code {Java}
I have a thought.
Your while() loop is running as fast as it can, with no pauses. It might be starving the communication task, which could result in the hardware occasionally shutting down the motor outputs due to a lack of communication. Put a short wait (ten milliseconds might be good) inside the loop and see if that helps. |
|
#3
|
|||
|
|||
|
Re: Jittery Autonomous Code {Java}
Tied with:
Timer.delay(.01); Timer.delay(.02); Timer.delay(.001); Timer.delay(.005); Still no improvment. |
|
#4
|
|||||
|
|||||
|
Re: Jittery Autonomous Code {Java}
Are the motors being controlled by those Jaguar objects also being controlled by a Drive object? I don't even know if that's possible in Java, but if it is, you could be seeing the Motor Safety keeping the drive motors turned off because you aren't calling a Drive command every 100 milliseconds.
|
|
#5
|
|||
|
|||
|
Re: Jittery Autonomous Code {Java}
Thank you so much!
In my robotInit() I initialized my RobotDrive() that I user later in teleop, and that is what kept stopping the motors. Moved the RobotDrive init to my teleop init and it works perfectly now! |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|