Go to Post Ive always wondered about this - if DK has an alter ego, like Clark Kent and Superman - KenWittlief [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 04-19-2013, 11:43 PM
musicalpets musicalpets is offline
Safety Captain/Build
FRC #2658 (Team Pedestrian)
Team Role: Mechanical
 
Join Date: Apr 2013
Rookie Year: 2011
Location: San Diego
Posts: 3
musicalpets is an unknown quantity at this point
Help for a beginner

Hey guys! I'm relatively new to coding and I decided to learn some more before next year.

I've learned mostly simple stuff for "regular" java coding, like if-then-else, while, how to print lines, variables, etc.

How do I apply this to coding a robot?
Reply With Quote
  #2   Spotlight this post!  
Unread 04-19-2013, 11:51 PM
BigJ BigJ is offline
Registered User
AKA: Josh P.
FRC #1675 (Ultimate Protection Squad)
Team Role: Engineer
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Milwaukee, WI
Posts: 943
BigJ has a reputation beyond reputeBigJ has a reputation beyond reputeBigJ has a reputation beyond reputeBigJ has a reputation beyond reputeBigJ has a reputation beyond reputeBigJ has a reputation beyond reputeBigJ has a reputation beyond reputeBigJ has a reputation beyond reputeBigJ has a reputation beyond reputeBigJ has a reputation beyond reputeBigJ has a reputation beyond repute
Re: Help for a beginner

The biggest thing to realize is that programming for a robot has a different mindset most of the time than a desktop application.

Unlike a desktop application you are usually not doing one set of instructions in a set order then exiting the program. You usually have a "control loop". The code should maintain the state of the robot every so often, taking in inputs such as sensors, joysticks, etc, and send outputs such as giving motors power, activating pneumatics, etc.

I would definitely try to build a testing board to play with if you have the materials available to you.

There are a lot of templated things available for you in the WPILib (such as the SimpleRobot, IterativeRobot, and CommandBasedRobot templates). The FRC plugins also come packaged with a multitude of example projects that I suggest poking through and trying to understand.
Reply With Quote
  #3   Spotlight this post!  
Unread 04-20-2013, 11:50 AM
Dinoyan Dinoyan is offline
Registered User
no team
Team Role: Electrical
 
Join Date: Nov 2012
Rookie Year: 2012
Location: Canada
Posts: 62
Dinoyan is an unknown quantity at this point
Re: Help for a beginner

http://wpilib.screenstepslive.com/s/3120/m/7885
Reply With Quote
  #5   Spotlight this post!  
Unread 05-01-2013, 10:29 PM
musicalpets musicalpets is offline
Safety Captain/Build
FRC #2658 (Team Pedestrian)
Team Role: Mechanical
 
Join Date: Apr 2013
Rookie Year: 2011
Location: San Diego
Posts: 3
musicalpets is an unknown quantity at this point
Re: Help for a beginner

Thanks so much for your help! Unfortunately I haven't been able to gain access to a test board, but I've been given permission to use an older robot.

I can get it to move forward autonomously for as long as I want...that's about it. How can I code simple autonomous, like going in a box?
Reply With Quote
  #6   Spotlight this post!  
Unread 05-01-2013, 10:32 PM
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

Are you using the RobotDrive feature or no?
__________________
Reply With Quote
  #7   Spotlight this post!  
Unread 05-01-2013, 10:58 PM
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
  #8   Spotlight this post!  
Unread 05-01-2013, 11:38 PM
musicalpets musicalpets is offline
Safety Captain/Build
FRC #2658 (Team Pedestrian)
Team Role: Mechanical
 
Join Date: Apr 2013
Rookie Year: 2011
Location: San Diego
Posts: 3
musicalpets is an unknown quantity at this point
Re: Help for a beginner

Yes, I'm using RobotDrive.

Thank you for the sample code!

Another quick question- how do I read the API exactly? (This one http://robotics.francisparker.org/javadoc/ ) Yes, I'm very new to this, but I'm determined to become an able coder by the beginning of the upcoming year.
Reply With Quote
  #9   Spotlight this post!  
Unread 05-02-2013, 03:45 PM
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

Don't worry this is my first year doing java for my team and it worked out great. I can try to explain the API to you the best i can. It basically has everything that the wpi library has to help or tell you what features are there and how to use them. Like for jaguar. If you find the jaguar on there it says:
Constructor Summary
Jaguar(int channel)
Constructor that assumes the default digital module.
Jaguar(int slot, int channel)
Constructor that specifies the digital module.
So i dont need to specify a slot when im constructing this. So in my code it is
Jaguar jaguar1 = new "Jaguar(1)"; The quotations dont go in the code they are to show you what the API says to do to construct it.

void set(double speed)
Set the PWM value.

for this i can do if(joystick1.getRawButton(1)) {
jaguar1.set(0.64); //the jaguar values are -1 to 1 and 0 is no output
} else {
jagaur1.set(0.0);
}
I dont know if this helped you at all or not. Hopefully it did.
__________________
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 07:46 AM.

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