Go to Post After talking with the students on these teams I could see the light in their eyes. These were their robots! Inspired? That would be a definate YES! - Steve W [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 16-12-2009, 16:50
byteit101's Avatar
byteit101 byteit101 is offline
WPILib maintainer (WPI)
AKA: Patrick Plenefisch
no team (The Cat Attack (Formerly))
Team Role: Programmer
 
Join Date: Jan 2009
Rookie Year: 2009
Location: Worcester
Posts: 699
byteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of light
Driverstation Pong!

Yesterday, the programming part of our team had a little fun playing pong on our (still functional!) Driverstation. I had originally written the code coming back from one of our competitions while trying to teach some C++ to a VB programmer, and had never tested it. Once we finished what we were doing yesterday, I happened to notice the project, and decided to test it out. Aside from a few small bugs, it worked! I have the (C++) source attached. This is fun!

to use: create new simpleTemplate example project, and copy DS pong files to it. Build and download. Then switch to the user display on the DS (hold Select down for 1 second). Start pong by pulling Joystick 1's trigger. to reset after winning or loosing, pull joystick 1's trigger. The ball moves in random directions from random locations.

Ideal setup: Driver station on table between 2 people, with joystick 1 on left of DS, joy 2 on right, both backwards (trigger towards front of DS)
Attached Files
File Type: zip DSPong.zip (3.1 KB, 144 views)
__________________
Bubble Wrap: programmers rewards
Watchdog.Kill();
printf("Watchdog is Dead, Celebrate!");
How to make a self aware robot: while (∞) cout<<(sqrt(-∞)/-0);
Previously FRC 451 (The Cat Attack)
Now part of the class of 2016 at WPI & helping on WPILib
  #2   Spotlight this post!  
Unread 17-12-2009, 19:35
Bigcheese Bigcheese is offline
C++0x FTW!
AKA: Michael Spencer
FRC #1771
Team Role: Mentor
 
Join Date: Feb 2008
Rookie Year: 2008
Location: GA
Posts: 36
Bigcheese is a jewel in the roughBigcheese is a jewel in the roughBigcheese is a jewel in the roughBigcheese is a jewel in the rough
Re: Driverstation Pong!

This is quite a cool idea, although I did take a look at your code and found some issues.
  • There are quite a few places where there's no code formatting, making it very difficult to read.
  • The use of a try/catch statement for program flow is bad. There's no reason to do this. Simply use a goto statement if you want to reenter the loop.

Now, to defend the use of goto.
Using an exception is the exact same thing as a goto in this case, except that the try/catch implies something different is going on, and ignores all real exceptions because of the catch(...).

Yes, you could use some extra logic to handle exiting the double loop, but in the end, the simplest, and most readable solution is to have a label directly before the main while, and a goto on win.

Although the best solution would be to split the code up into separate functions such as.
  • Setup
  • WaitForStart
  • Update - Returns a value in {continue, player_1_won, player_2_won}

Then the problem wouldn't be there to begin with .
  #3   Spotlight this post!  
Unread 17-12-2009, 19:45
John G John G is offline
Registered User
FRC #0399 (Eagle Robotics)
Team Role: Programmer
 
Join Date: Nov 2009
Rookie Year: 2009
Location: Lancaster, CA
Posts: 72
John G is on a distinguished road
Re: Driverstation Pong!

cool. At first glance, I thought you were talking about "apple juice" pong. I then imagined trying to play DS pong and how hard it wouold be.
  #4   Spotlight this post!  
Unread 17-12-2009, 19:48
Team1559is1337 Team1559is1337 is offline
Registered User
None #1559
 
Join Date: Jan 2009
Location: NY, Victor
Posts: 5
Team1559is1337 is an unknown quantity at this point
Question Re: Driverstation Pong!

where do you paste the code in the template?
  #5   Spotlight this post!  
Unread 17-12-2009, 20:05
Team1559is1337 Team1559is1337 is offline
Registered User
None #1559
 
Join Date: Jan 2009
Location: NY, Victor
Posts: 5
Team1559is1337 is an unknown quantity at this point
Talking Re: Driverstation Pong!

haha just kidding i just got it. nice code!
  #6   Spotlight this post!  
Unread 17-12-2009, 22:25
byteit101's Avatar
byteit101 byteit101 is offline
WPILib maintainer (WPI)
AKA: Patrick Plenefisch
no team (The Cat Attack (Formerly))
Team Role: Programmer
 
Join Date: Jan 2009
Rookie Year: 2009
Location: Worcester
Posts: 699
byteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of light
Re: Driverstation Pong!

Quote:
Originally Posted by Bigcheese View Post
This is quite a cool idea, although I did take a look at your code and found some issues.
  • There are quite a few places where there's no code formatting, making it very difficult to read.
  • The use of a try/catch statement for program flow is bad. There's no reason to do this. Simply use a goto statement if you want to reenter the loop.

Now, to defend the use of goto.
Using an exception is the exact same thing as a goto in this case, except that the try/catch implies something different is going on, and ignores all real exceptions because of the catch(...).

Yes, you could use some extra logic to handle exiting the double loop, but in the end, the simplest, and most readable solution is to have a label directly before the main while, and a goto on win.

Although the best solution would be to split the code up into separate functions such as.
  • Setup
  • WaitForStart
  • Update - Returns a value in {continue, player_1_won, player_2_won}

Then the problem wouldn't be there to begin with .
I know, Its not ideal (I could improve it a ton), but I did not want to spend too much time designing if statements, remembered about exceptions, and used them. (I did not think of goto until just now, being a very OOPy programmer)
Quote:
Originally Posted by John G View Post
cool. At first glance, I thought you were talking about "apple juice" pong. I then imagined trying to play DS pong and how hard it wouold be.
It is hard, I have a 30-40% hitting rate! (and about half are lost on the first hit)
__________________
Bubble Wrap: programmers rewards
Watchdog.Kill();
printf("Watchdog is Dead, Celebrate!");
How to make a self aware robot: while (∞) cout<<(sqrt(-∞)/-0);
Previously FRC 451 (The Cat Attack)
Now part of the class of 2016 at WPI & helping on WPILib

Last edited by byteit101 : 17-12-2009 at 22:28.
  #7   Spotlight this post!  
Unread 18-12-2009, 00:12
keehun's Avatar
keehun keehun is offline
Team Captain
AKA: Keehun Nam
FRC #2502 (EP Robotics)
Team Role: Leadership
 
Join Date: May 2008
Rookie Year: 2008
Location: Eden Priaire
Posts: 474
keehun has a reputation beyond reputekeehun has a reputation beyond reputekeehun has a reputation beyond reputekeehun has a reputation beyond reputekeehun has a reputation beyond reputekeehun has a reputation beyond reputekeehun has a reputation beyond reputekeehun has a reputation beyond reputekeehun has a reputation beyond reputekeehun has a reputation beyond reputekeehun has a reputation beyond repute
Send a message via AIM to keehun
Re: Driverstation Pong!

Anyone dare to post a picture?
__________________
For by grace you have been saved through faith, and that not of yourselves; it is the gift of God, not of works, lest anyone should boast. -- Ephesians 2:8-9
2010: Quarter Finalist (MN 10,000 Lakes)
2010: Website Award (MN 10,000 Lakes)
2009: Quarter Finalist (MN 10,000 Lakes)
2009: GM Industrial Award (MN 10,000 Lakes)
  #8   Spotlight this post!  
Unread 18-12-2009, 10:35
Rion Atkinson's Avatar
Rion Atkinson Rion Atkinson is offline
The CAD Guy
no team
 
Join Date: Jan 2009
Rookie Year: 2009
Location: Oklahoma City
Posts: 386
Rion Atkinson has a reputation beyond reputeRion Atkinson has a reputation beyond reputeRion Atkinson has a reputation beyond reputeRion Atkinson has a reputation beyond reputeRion Atkinson has a reputation beyond reputeRion Atkinson has a reputation beyond reputeRion Atkinson has a reputation beyond reputeRion Atkinson has a reputation beyond reputeRion Atkinson has a reputation beyond reputeRion Atkinson has a reputation beyond reputeRion Atkinson has a reputation beyond repute
Re: Driverstation Pong!

Just as a random thought. (I have not dared to mess with my team's DS.) I know people have created virtual Driver Stations. Would it be possible to put this game into the Virtual DS?
  #9   Spotlight this post!  
Unread 18-12-2009, 15:12
byteit101's Avatar
byteit101 byteit101 is offline
WPILib maintainer (WPI)
AKA: Patrick Plenefisch
no team (The Cat Attack (Formerly))
Team Role: Programmer
 
Join Date: Jan 2009
Rookie Year: 2009
Location: Worcester
Posts: 699
byteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of light
Re: Driverstation Pong!

Quote:
Originally Posted by Formerly Famous View Post
Just as a random thought. (I have not dared to mess with my team's DS.) I know people have created virtual Driver Stations. Would it be possible to put this game into the Virtual DS?
I think it can display the User Data, so yes.
__________________
Bubble Wrap: programmers rewards
Watchdog.Kill();
printf("Watchdog is Dead, Celebrate!");
How to make a self aware robot: while (∞) cout<<(sqrt(-∞)/-0);
Previously FRC 451 (The Cat Attack)
Now part of the class of 2016 at WPI & helping on WPILib
  #10   Spotlight this post!  
Unread 18-12-2009, 20:03
John G John G is offline
Registered User
FRC #0399 (Eagle Robotics)
Team Role: Programmer
 
Join Date: Nov 2009
Rookie Year: 2009
Location: Lancaster, CA
Posts: 72
John G is on a distinguished road
Re: Driverstation Pong!

Quote:
It is hard, I have a 30-40% hitting rate! (and about half are lost on the first hit)
that's pretty good i guess. we should start up a new game, and devote half of thursday to having a DS pong tournament. -
  #11   Spotlight this post!  
Unread 22-12-2009, 23:35
slavik262's Avatar
slavik262 slavik262 is offline
We do what we must because we can.
AKA: Matt Kline
FRC #0537 (Charger Robotics)
Team Role: Alumni
 
Join Date: Jan 2007
Rookie Year: 2007
Location: Sussex, WI
Posts: 310
slavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to beholdslavik262 is a splendid one to behold
Send a message via AIM to slavik262
Re: Driverstation Pong!

I have a stupid question...

Where are DriverStationLCD.h and DriverStationLCD.cpp coming from? I notice the official WPILib Header, but neither are in the latest version I'm aware of (3.1.1764). Should I be getting updates form somewhere besides the following site?

http://first.wpi.edu/FRC/frcupdates.html
__________________
  #12   Spotlight this post!  
Unread 26-12-2009, 20:12
byteit101's Avatar
byteit101 byteit101 is offline
WPILib maintainer (WPI)
AKA: Patrick Plenefisch
no team (The Cat Attack (Formerly))
Team Role: Programmer
 
Join Date: Jan 2009
Rookie Year: 2009
Location: Worcester
Posts: 699
byteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of light
Re: Driverstation Pong!

Quote:
Originally Posted by slavik262 View Post
I have a stupid question...

Where are DriverStationLCD.h and DriverStationLCD.cpp coming from? I notice the official WPILib Header, but neither are in the latest version I'm aware of (3.1.1764). Should I be getting updates form somewhere besides the following site?

http://first.wpi.edu/FRC/frcupdates.html
The WPI think tank site: http://thinktank.wpi.edu/article/144
__________________
Bubble Wrap: programmers rewards
Watchdog.Kill();
printf("Watchdog is Dead, Celebrate!");
How to make a self aware robot: while (∞) cout<<(sqrt(-∞)/-0);
Previously FRC 451 (The Cat Attack)
Now part of the class of 2016 at WPI & helping on WPILib
  #13   Spotlight this post!  
Unread 16-01-2010, 16:31
byteit101's Avatar
byteit101 byteit101 is offline
WPILib maintainer (WPI)
AKA: Patrick Plenefisch
no team (The Cat Attack (Formerly))
Team Role: Programmer
 
Join Date: Jan 2009
Rookie Year: 2009
Location: Worcester
Posts: 699
byteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of light
Re: Driverstation Pong!

I (finally!) have a video of DS Pong:
http://thecatattack.org/DriverStationPong
I don't know if it will work on the classmate, but I would think so, because it has the status updates in the corner
__________________
Bubble Wrap: programmers rewards
Watchdog.Kill();
printf("Watchdog is Dead, Celebrate!");
How to make a self aware robot: while (∞) cout<<(sqrt(-∞)/-0);
Previously FRC 451 (The Cat Attack)
Now part of the class of 2016 at WPI & helping on WPILib
Closed Thread


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

Similar Threads
Thread Thread Starter Forum Replies Last Post
driverstation outputs agough C/C++ 3 15-02-2009 22:25
mindstorm and pong RX7-bernie General Forum 1 01-03-2007 14:54
Shooting Ping Pong Balls Jeremiah Johnson FIRST Tech Challenge 1 01-05-2006 21:20
pong mechanik Andrew Rudolph Chit-Chat 4 13-10-2004 22:44
Revive a Classic: Pong K. Skontrianos General Forum 6 21-02-2003 16:20


All times are GMT -5. The time now is 13:54.

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