Author |
Message |
Djacwmwfin Joshamuffin Vampire
Joined: 12 Jun 2007 Posts: 3539
HP: 100 MP: 5 Lives: 0
|
Posted: Thu Jan 24, 2008 6:18 pm
|
|
|
I have successfully programmed one action of the robot my FIRST robotics team is working on. We are team 1723. I have programmed the ball push action. In the game, one way to score points, is to push the ball around the track.
Quote: | /******************************************* *Ball Push Code* *Written by Josh Brown AKA Joshamuffin.* *This program is awesome.* *2008* * *Driver press Right Trigger (p2_sw_trig) to push ball.* *This program also insures that the cycle is completed before restarting.* *******************************************/
//Initialize variables int startAwesomeTime = 20; //This is the time it takes for the panel to move in or out. (40 is a second) int awesomeTime = 0; //This will be used as the first half of the countdown. int awesomeTime2 = 0; //This will be used as the second half of the countdown int awesomeActivation = 0; //This is so the driver doesn't have to hold the trigger to complete the cycle.
if(p2_sw_trig == 1) //Has the trigger been pulled? { awesomeActivation = 1; } printf("awsmAct %3d, p2_sw_trig %3d, awsmTime %3d, awsmTime2 %3d \r" awesomeActivation,p2_sw_trig,awesomeTime,awesomeTime2)
if(awesomeActivation == 1 && awesomeTime > 0) //push out { relay1_fwd = 1; relay2_fwd = 1; relay1_rev = 0; relay2_rev = 0; awesomeTime = awesomeTime - 1; }
if(awesomeTime == 0 && awesomeTime2 > 0) //pull back { relay1_fwd = 0; relay2_fwd = 0; relay1_rev = 1; relay2_rev = 1; awesomeTime2 = awesomeTime2 - 1; }
if(awesomeTime == 0 && awesomeTime2 == 0) //deactivate { relay1_fwd = 0; relay2_fwd = 0; relay1_rev = 0; relay2_rev = 0; awesomeTime = startAwesomeTime; awesomeTime2 = startAwesomeTime; awesomeActivation = 0; }
/******************************************* *End of Ball Push Code* *******************************************/
|
This is in C. I made the comments green. Also, WHY WON'T INDENTIONS WORK!?!?!?
;_; |
|
Back to top |
|
|
ANGRY GOPHER LvKeulen
Joined: 05 Oct 2007 Posts: 653
HP: 95 MP: 10 Lives: 0
|
Posted: Thu Jan 24, 2008 6:32 pm
|
|
|
I'd say it's awesome, but I never understood C, even when I tried. But still, it's awesome, because your variables are awesome too. |
|
Back to top |
|
|
Logic King vg Vampire
Joined: 19 May 2007 Posts: 2032
HP: 90 MP: 10 Lives: 0
|
Posted: Thu Jan 24, 2008 7:05 pm
|
|
|
All I've got is a heck of a lot of: void main () { mav(0,-1000); mav(1,-1000); freeze(2.5); mav(0,1000); ao(); }
It doesn't do much, but it gets the bot out of the opening. (botball) |
|
Back to top |
|
|
Djacwmwfin Joshamuffin Vampire
Joined: 12 Jun 2007 Posts: 3539
HP: 100 MP: 5 Lives: 0
|
Posted: Thu Jan 24, 2008 7:45 pm
|
|
|
LvKeulen wrote: | I'd say it's awesome, but I never understood C, even when I tried. But still, it's awesome, because your variables are awesome too. |
Explanation:
It uses 2 pneumatics tubes to push out this panel thing that pushes the ball.
Also, here is the FIRST website. http://www.usfirst.org/community/frc/default.aspx?id=966
The picture of the bots and the red and blue innertubes is from last year's game. |
|
Back to top |
|
|
Elite Nerr Francis
Joined: 16 Apr 2007 Posts: 6974
HP: 50 MP: 3 Lives: 0
|
Posted: Thu Jan 24, 2008 7:50 pm
|
|
|
a lesson in how not to name your variables |
|
Back to top |
|
|
Goomba Vampire
Joined: 21 Apr 2007 Posts: 2287
HP: 95 MP: 1 Lives: 1
|
Posted: Thu Jan 24, 2008 7:55 pm
|
|
|
Francis wrote: | a lesson in how not to name your variables | Yeah, you want something short and easy to spell for your variables. You don't want to be like "awesome-this awesome-that". You should just be able to get rid of "awesome" and have no problems.
Also, NEVER have "name" and "name2" those get really confusing. |
|
Back to top |
|
|
Djacwmwfin Joshamuffin Vampire
Joined: 12 Jun 2007 Posts: 3539
HP: 100 MP: 5 Lives: 0
|
Posted: Thu Jan 24, 2008 7:57 pm
|
|
|
lol
I named them so that they would not possibly have been used before I programmed it. |
|
Back to top |
|
|
|