Go to Post If you thought two alliances racing to tip the bridge in auto was exciting, wait until they play autonomous chicken on the center line. :D - Alpha Beta [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 31-01-2012, 20:10
joelg236 joelg236 is offline
4334 Retired Mentor & Alumni
AKA: Joel Gallant
no team
Team Role: Mentor
 
Join Date: Dec 2011
Rookie Year: 2012
Location: Calgary
Posts: 733
joelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond repute
Loop in autonomous carries on into teleop and stops anything from working?

I have teleop working fine when its enabled first, but (My autonomous code is not working yet but thats a separate issue) after enabling autonomous, neither it nor teleop works at all. Also, we have a do while loop set up in autonomous that doesn't actually stop when turned to teleop. Is this a driver station bug or maybe is it the fact I dont have watchdog enabled? Any suggestions?
Code:
   public void autonomousPeriodic(){
        int x = 1;
        do{    
            gyro.reset();

            int i=0;
            while(i<4){    
                drivetrain.drive(0.5,0.0); //START GOING STRAIGHT
                Timer.delay(4.0);
                drivetrain.drive(0.0,0.0); //STOP
                Timer.delay(4.0);
                gyro.reset();
                double angle = 0;
                do {
                    drivetrain.drive(0.0, 0.15); //TURN 
                    Timer.delay(0.5);
                    angle += gyro.getAngle(); //
                    gyro.reset();
                    log("Gyro reads "+angle);
                }while(angle<90); //Keep going in increments of .15 until gyro returns more than 90 degrees
                drivetrain.drive(0.0,0.0); //STOP
                Timer.delay(4.0);
                i++;
            }
        }while(x>0);
    }
That's our autonomous.
Reply With Quote
  #2   Spotlight this post!  
Unread 31-01-2012, 20:26
kgabbott kgabbott is offline
Registered User
FRC #2035
 
Join Date: Jan 2012
Location: Carmel,CA
Posts: 2
kgabbott is an unknown quantity at this point
Re: Loop in autonomous carries on into teleop and stops anything from working?

This is occurring because you enter the do while loop and never reset x to a value less that 0, meaning the code continuously runs through this loop.
Reply With Quote
  #3   Spotlight this post!  
Unread 31-01-2012, 20:51
joelg236 joelg236 is offline
4334 Retired Mentor & Alumni
AKA: Joel Gallant
no team
Team Role: Mentor
 
Join Date: Dec 2011
Rookie Year: 2012
Location: Calgary
Posts: 733
joelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond repute
Re: Loop in autonomous carries on into teleop and stops anything from working?

Funny, we fixed that, and still have the error with our very simple fix.
This does the same thing.

Code:
timer.start();
do{
drivetrain.drive(0.5,0.0);
}while(timer.get()<4);
And yes, we did initialize the timer.
Reply With Quote
  #4   Spotlight this post!  
Unread 31-01-2012, 20:54
neal's Avatar
neal neal is offline
Neal
FRC #1777 (Viking Robotics)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2009
Location: United States
Posts: 56
neal is an unknown quantity at this point
Re: Loop in autonomous carries on into teleop and stops anything from working?

Do this instead:

Code:
while (isAutonomous() && isEnabled()) {
    // Autonomous code
}
Reply With Quote
  #5   Spotlight this post!  
Unread 01-02-2012, 11:49
eddie12390's Avatar
eddie12390 eddie12390 is offline
Registered User
AKA: Eddie
FRC #3260 (SHARP)
Team Role: Programmer
 
Join Date: Jan 2011
Rookie Year: 2011
Location: Pittsburgh
Posts: 285
eddie12390 is a glorious beacon of lighteddie12390 is a glorious beacon of lighteddie12390 is a glorious beacon of lighteddie12390 is a glorious beacon of lighteddie12390 is a glorious beacon of light
Re: Loop in autonomous carries on into teleop and stops anything from working?

do{
drivetrain.drive(0.5,0.0);
}while(timer.get()<4 && isAutonomous());
Reply With Quote
  #6   Spotlight this post!  
Unread 01-02-2012, 16:31
Happy Birthday! Derschatten Derschatten is offline
Registered User
FRC #1203 (Pandemonium)
Team Role: Mentor
 
Join Date: Jan 2008
Rookie Year: 2003
Location: West Babylon
Posts: 31
Derschatten is an unknown quantity at this point
Re: Loop in autonomous carries on into teleop and stops anything from working?

I would suggest doing it the way Neal has wrote it. You can always have if statement or switch statement handling the time base options.
Reply With Quote
  #7   Spotlight this post!  
Unread 02-02-2012, 16:14
joelg236 joelg236 is offline
4334 Retired Mentor & Alumni
AKA: Joel Gallant
no team
Team Role: Mentor
 
Join Date: Dec 2011
Rookie Year: 2012
Location: Calgary
Posts: 733
joelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond reputejoelg236 has a reputation beyond repute
Re: Loop in autonomous carries on into teleop and stops anything from working?

Thanks for the replies guys. What I found out was that the iterative robot class is a completely different concept than simplerobot. I was mistaken in thinking it was just more features.
Reply With Quote
Reply


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 12:47.

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