Go to Post At first blush, people don't need to know about GP any more than they need to know gear ratios, screw classifications, or LabVIEW. It's about Inspiration. It's about Recognition. It's about Science and Technology. That's all it's For; any more than that is just gravy. - Taylor [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #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
  #2   Spotlight this post!  
Unread 21-02-2012, 08:23
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,113
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
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   Spotlight this post!  
Unread 21-02-2012, 15:43
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
Re: Jittery Autonomous Code {Java}

Tied with:

Timer.delay(.01);
Timer.delay(.02);
Timer.delay(.001);
Timer.delay(.005);

Still no improvment.
  #4   Spotlight this post!  
Unread 21-02-2012, 16:39
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,113
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
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   Spotlight this post!  
Unread 21-02-2012, 16:47
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
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!
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 01:44.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


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