View Single Post
  #1   Spotlight this post!  
Unread 21-02-2012, 06:50
tinyclark tinyclark is offline
Registered User
AKA: Matt Clark
FRC #0228
 
Join Date: Jan 2012
Rookie Year: 2007
Location: Wallingford, CT
Posts: 9
tinyclark is an unknown quantity at this point
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){
}
The output this produces is a very jittery running of the code, as if it sends the commands, and then immediately after sends it a stop command, following which it repeats. The teleop code works fine, so i know that it is updating the output frequent enough, and it never catches any errors... Any thoughts? Thanks
~Matt Clark