Go to Post Crushing the box makes it much easier to think outside the box. :D - Matt C [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

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #7   Spotlight this post!  
Unread 01-05-2013, 22:58
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: Help for a beginner

Here is a very stripped down version of our autonomous. This shoots the frisbees.
Code:
    // Int
    int maxShootCount;
    int currShootCount;

    public void autonomousInit() {
        maxShootCount = 6; //Does 6 Shots Just In Case Of Jam
        currShootCount = 0; //Starts At 0 Shots
        systimer.start();
        systimer.reset();
    }
    
    /**
     * This function is called periodically during autonomous
     */
    public void autonomousPeriodic() {
        double currentTime = systimer.get();

        if (currentTime < 3) {
            jaguar3.set(0.64); //Turn on shooter jags
            jaguar4.set(0.64); //Turn on shooter jags
        } else if (currentTime >= 3 && currentTime < 10) {
        if(currShootCount < maxShootCount) //If our current shot count is less than the max(6 shot max) then do the below code
        {
            solenoid3.set(true); //Activate Frisbee Launcher
            solenoid4.set(false); //Activate Frisbee Launcher
            Timer.delay(0.5);
            solenoid3.set(false); //Deactivate Frisbee Launcher
            solenoid4.set(true); //Deactivate Frisbee Launcher
            solenoid5.set(true); //Activate Frisbee Dropper
            solenoid6.set(false); //Activate Frisbee Dropper
            Timer.delay(0.4);
            solenoid5.set(false); //Deactivate Frisbee Dropper
            solenoid6.set(true); //Deactivate Frisbee Dropper
            Timer.delay(0.5);
        }
        currShootCount++; //Add on a count when code cycles through each time until it hits 2 shots
        } else if (currentTime >= 10 && currentTime < 10.5) {
        jaguar3.set(0); //Turn off shooter jags
        jaguar4.set(0); //Turn off shooter jags
        robotDrive.drive(1, 0); //Drive Forward Full Speed
        } else if (currentTime >= 10.5 && currentTime < 11.2) {
        robotDrive.drive(0.0); //Stop driving
        Solenoid7.set(false); //this puts the shooter down
        Solenoid8.set(true); //this puts the shooter down
        } else if (currentTime >= 11.2 && currentTime < 15) {
        solenoid1.set(true); //puts the robot in low gear
        solenoid2.set(false); //puts the robot in low gear
        robotDrive.drive(-1, 0); //Drives backwards full speed
        } else (currentTime = 15) {
        robotDrive.drive(0, 0); //stops driving
        solenoid1.set(false); //puts the robot in high gear for teleop
        solenoid2.set(true); //puts the robot in high gear for teleop
        }
}

Hope this helps you with some ideas. If you need any explanation, I will do the best i can to explain.
__________________
Reply With Quote
 


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 11:37.

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