Go to Post You should always do CAD no matter how you plan on having parts made. - Garret [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 03-03-2013, 20:31
Mr.Roboto3335's Avatar
Mr.Roboto3335 Mr.Roboto3335 is offline
Wait, What?
AKA: Jimmy
FRC #3335 (Cy-Borgs)
Team Role: Programmer
 
Join Date: Nov 2011
Rookie Year: 2011
Location: Texas
Posts: 47
Mr.Roboto3335 is an unknown quantity at this point
Autonomous Help

I wanted to know how to make a motor wait and then move in autonomous.

Autonomous Code So Far:
Code:
 public void autonomousPeriodic()
    {
        ShooterFront.set(50);
        ShooterBack.set(50);
      //Wanted to add 3 second wait
        servo.setAngle(90);
      //Wanted to add 3 second wait  
        servo.setAngle(180);
      //Wanted to add 3 second wait
        servo.setAngle(90);
      //Wanted to add 3 second wait  
        servo.setAngle(180);
      //Wanted to add 3 second wait  
        servo.setAngle(90);
      //Wanted to add 3 second wait  
        servo.setAngle(180);
    }
__________________
Wait, what?
Reply With Quote
  #2   Spotlight this post!  
Unread 03-03-2013, 23:20
F22Rapture's Avatar
F22Rapture F22Rapture is offline
College Student, Mentor
AKA: Daniel A
FRC #3737 (4H Rotoraptors)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2012
Location: Goldsboro, NC
Posts: 476
F22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant futureF22Rapture has a brilliant future
Re: Autonomous Help

Are you using the Command-Based template? Create a command for each thing you want to do, then string them together with a Command Group.

In RobotMain

Code:
private Command autonomousCommand;

public void autonomousInit() {
        autonomousCommand = new Auton0();    
        autonomousCommand.start();
    }

public void autonomousPeriodic() {
        Scheduler.getInstance().run();
    }
In command group

Code:
public class Auton0 extends CommandGroup {
    
    public Auton0() {
        addSequential(new SetFrontSpeed(50);
        addParallel(new SetBackSpeed(50);
        addSequential(new SetAngle(90));
        addSequential(new WaitCommand(3));
        addSequential(new SetAngle(45));
    
        etc. etc.
    }
__________________
Research is what I’m doing when I don’t know what I’m doing.
- Wernher von Braun
Attending: Raleigh NC Regional

Last edited by F22Rapture : 03-03-2013 at 23:24.
Reply With Quote
  #3   Spotlight this post!  
Unread 04-03-2013, 10:54
Mr.Roboto3335's Avatar
Mr.Roboto3335 Mr.Roboto3335 is offline
Wait, What?
AKA: Jimmy
FRC #3335 (Cy-Borgs)
Team Role: Programmer
 
Join Date: Nov 2011
Rookie Year: 2011
Location: Texas
Posts: 47
Mr.Roboto3335 is an unknown quantity at this point
Re: Autonomous Help

I'm writing in Iterative Template
__________________
Wait, what?
Reply With Quote
  #4   Spotlight this post!  
Unread 04-03-2013, 11:09
tuXguy15's Avatar
tuXguy15 tuXguy15 is offline
Team Mentor
AKA: Devin Kolarac
FRC #2559 (Normality Zero)
 
Join Date: Apr 2012
Rookie Year: 2012
Location: Harrisburg, PA
Posts: 127
tuXguy15 is an unknown quantity at this point
Re: Autonomous Help

Hey maybe this can be some help.

public void autonomousPeriodic()
{
ShooterFront.set(50);
ShooterBack.set(50);
Timer.delay(3.0);
servo.setAngle(90);
Timer.delay(3.0);
servo.setAngle(180);
Timer.delay(3.0);
servo.setAngle(90);
Timer.delay(3.0);
servo.setAngle(180);
Timer.delay(3.0);
servo.setAngle(90);
Timer.delay(3.0);
servo.setAngle(180);
}

The Timer.delay(); sets the amount of time to wait before the execution of the next string of code.
Reply With Quote
  #5   Spotlight this post!  
Unread 04-03-2013, 12:45
notmattlythgoe's Avatar
notmattlythgoe notmattlythgoe is offline
Flywheel Police
AKA: Matthew Lythgoe
FRC #2363 (Triple Helix)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2009
Location: Newport News, VA
Posts: 1,728
notmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond reputenotmattlythgoe has a reputation beyond repute
Re: Autonomous Help

Just as a warning, you currently have 18 seconds of waits for a 15 second autonomous period. Once you get it tested you'll probably want to trim down some of the wait times if you can.
Reply With Quote
  #6   Spotlight this post!  
Unread 04-03-2013, 17:07
Mr.Roboto3335's Avatar
Mr.Roboto3335 Mr.Roboto3335 is offline
Wait, What?
AKA: Jimmy
FRC #3335 (Cy-Borgs)
Team Role: Programmer
 
Join Date: Nov 2011
Rookie Year: 2011
Location: Texas
Posts: 47
Mr.Roboto3335 is an unknown quantity at this point
Re: Autonomous Help

Quote:
Originally Posted by Zer0 View Post
Hey maybe this can be some help.

public void autonomousPeriodic()
{
ShooterFront.set(50);
ShooterBack.set(50);
Timer.delay(3.0);
servo.setAngle(90);
Timer.delay(3.0);
servo.setAngle(180);
Timer.delay(3.0);
servo.setAngle(90);
Timer.delay(3.0);
servo.setAngle(180);
Timer.delay(3.0);
servo.setAngle(90);
Timer.delay(3.0);
servo.setAngle(180);
}

The Timer.delay(); sets the amount of time to wait before the execution of the next string of code.
What if I wanted the Front and Back Shooters motors to move the whole time?
__________________
Wait, what?
Reply With Quote
  #7   Spotlight this post!  
Unread 04-03-2013, 17:18
Team3266Spencer's Avatar
Team3266Spencer Team3266Spencer is offline
Team Captain and Lead Programmer
AKA: Spencer Lanman
FRC #3266 (Robots-R-US)
Team Role: Programmer
 
Join Date: Oct 2011
Rookie Year: 2012
Location: Richmond, Indiana
Posts: 280
Team3266Spencer is an unknown quantity at this point
Re: Autonomous Help

Quote:
Originally Posted by Mr.Roboto3335 View Post
What if I wanted the Front and Back Shooters motors to move the whole time?
They are in this example, they're never set to stop.
__________________
2012: Buckeye Regional, Queen City Regional, Human Player
2013: Queen City Regional, Buckeye Regional, Crossroads Regional
Shooter Operator
2014: Crossroads Regional, Queen City Regional
Catapult Operator
2015: Georgia Southern Classic Regional (Winner), Queen City Regional
Chainsaw Operator
Want to talk? TeamSpeak: team3266.noip.me
Reply With Quote
  #8   Spotlight this post!  
Unread 04-03-2013, 17:26
cgmv123's Avatar
cgmv123 cgmv123 is offline
FRC RI/FLL Field Manager
AKA: Max Vrany
FRC #1306 (BadgerBOTS)
Team Role: College Student
 
Join Date: Jan 2011
Rookie Year: 2011
Location: Madison, WI
Posts: 2,085
cgmv123 has a reputation beyond reputecgmv123 has a reputation beyond reputecgmv123 has a reputation beyond reputecgmv123 has a reputation beyond reputecgmv123 has a reputation beyond reputecgmv123 has a reputation beyond reputecgmv123 has a reputation beyond reputecgmv123 has a reputation beyond reputecgmv123 has a reputation beyond reputecgmv123 has a reputation beyond reputecgmv123 has a reputation beyond repute
Re: Autonomous Help

Quote:
Originally Posted by Mr.Roboto3335 View Post
What if I wanted the Front and Back Shooters motors to move the whole time?
They both will. The delay will leave both at the levels they were set at.
__________________
BadgerBOTS Robotics|@team1306|Facebook: BadgerBOTS
2016 FIRST Championship Tesla Division | 2016 Wisconsin Regional Engineering Inspiration Award

2015 FIRST Championship Carson Division | 2015 Wisconsin Regional Chairman's Award

2013 FIRST Championship Curie Division | 2013 Wisconsin Regional Chairman's Award

2012 FIRST Championship Archimedes Division | 2012 Wisconsin Regional Engineering Inspiration Award, Woodie Flowers Finalist Award (Lead Mentor Ben Senson)

Reply With Quote
  #9   Spotlight this post!  
Unread 04-03-2013, 18:07
tuXguy15's Avatar
tuXguy15 tuXguy15 is offline
Team Mentor
AKA: Devin Kolarac
FRC #2559 (Normality Zero)
 
Join Date: Apr 2012
Rookie Year: 2012
Location: Harrisburg, PA
Posts: 127
tuXguy15 is an unknown quantity at this point
Re: Autonomous Help

It won't stop. It would only stop if you threw ShooterBack.set(0.0); in there some where. Also are you using jaguars for the motor controllers?
Reply With Quote
  #10   Spotlight this post!  
Unread 04-03-2013, 23:01
Joe Ross's Avatar Unsung FIRST Hero
Joe Ross Joe Ross is offline
Registered User
FRC #0330 (Beachbots)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Los Angeles, CA
Posts: 8,590
Joe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond reputeJoe Ross has a reputation beyond repute
Re: Autonomous Help

Quote:
Originally Posted by Zer0 View Post
Hey maybe this can be some help.

public void autonomousPeriodic()
{
ShooterFront.set(50);
ShooterBack.set(50);
Timer.delay(3.0);
servo.setAngle(90);
Timer.delay(3.0);
servo.setAngle(180);
Timer.delay(3.0);
servo.setAngle(90);
Timer.delay(3.0);
servo.setAngle(180);
Timer.delay(3.0);
servo.setAngle(90);
Timer.delay(3.0);
servo.setAngle(180);
}

The Timer.delay(); sets the amount of time to wait before the execution of the next string of code.
This won't work in the iterative framework (but it will in the simple framework). The AutonomousPeriodic needs to execute quickly and then return. Here's an (untested) way to do the same thing, that will work in the iterative framework

Code:
    double startTime;
    public void autonomousInit() {
        startTime = Timer.getFPGATimestamp();
    }
    public void autonomousPeriodic() {
        if ((Timer.getFPGATimestamp() - startTime) < 3000)
        {
            ShooterFront.set(50);
            ShooterBack.set(50);
        }
        else if ((Timer.getFPGATimestamp() - startTime) < 6000)
        {
            servo.setAngle(90);
        }
        else if ((Timer.getFPGATimestamp() - startTime) < 9000)
        {
            servo.setAngle(180);
        }
   }
etc
Reply With Quote
  #11   Spotlight this post!  
Unread 06-03-2013, 11:25
Mr.Roboto3335's Avatar
Mr.Roboto3335 Mr.Roboto3335 is offline
Wait, What?
AKA: Jimmy
FRC #3335 (Cy-Borgs)
Team Role: Programmer
 
Join Date: Nov 2011
Rookie Year: 2011
Location: Texas
Posts: 47
Mr.Roboto3335 is an unknown quantity at this point
Re: Autonomous Help

I will try that and let you know if it works.
__________________
Wait, what?
Reply With Quote
  #12   Spotlight this post!  
Unread 06-03-2013, 22:47
JohnFogarty's Avatar
JohnFogarty JohnFogarty is offline
Trapped under a pile of MECANUMS :P
AKA: @doctorfogarty
FTC #11444 (Garnet Squadron) & FRC#1102 (M'Aiken Magic)
Team Role: Mentor
 
Join Date: Aug 2009
Rookie Year: 2006
Location: SC
Posts: 1,580
JohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond repute
Re: Autonomous Help

I'll send you a copy of my code tomorrow but I use a state machine switch case in which I create a timer instance. Start it. and compare if the timer is greater than 100 microseconds. if it is move to the next case in the switch, reset the timer, start it again, chose the next amount of wait time needed, compare the value of the timer until it is greater than or equal to the new wait time. and repeat. It's easier to understand what I do once you see my code.
__________________
John Fogarty
2010 FTC World Championship Winner & 2013-2014 FRC Orlando Regional Winner
Mentor FRC Team 1102 M'Aiken Magic
"Head Bot Coach" FTC Team 11444 Garnet Squadron
Former Student & Mentor FLL 1102, FTC 1102 & FTC 3864, FRC 1772, FRC 5632
2013 FTC World Championship Guest Speaker
Reply With Quote
  #13   Spotlight this post!  
Unread 09-03-2013, 16:39
tuXguy15's Avatar
tuXguy15 tuXguy15 is offline
Team Mentor
AKA: Devin Kolarac
FRC #2559 (Normality Zero)
 
Join Date: Apr 2012
Rookie Year: 2012
Location: Harrisburg, PA
Posts: 127
tuXguy15 is an unknown quantity at this point
Re: Autonomous Help

It worked for my team last year and this year and we use the Iterative framework. You just have to use up the full 15 seconds or tell it to do nothing when your done executing everything or it will start over.
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 13:17.

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