Go to Post If it's anything that FIRST's competitive spirit has taught me, its to take the good with the bad. - Mike Schroeder [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 25-01-2011, 22:27
wdell wdell is offline
Registered User
AKA: William Dell
FRC #3999 (Shadetree Mechanics)
Team Role: Mentor
 
Join Date: Jan 2011
Rookie Year: 2010
Location: Killeen, Texas
Posts: 55
wdell has a spectacular aura aboutwdell has a spectacular aura about
Re: Camera Code

I kind of think the spirit of FIRST ethically compels me to share my code, if it will help someone else. That being said, I'm a teacher, so if it can help someone learn I'll share it with them.

I use multiple classes to break the code down into reusable pieces, and spin off threads to allow things like the driver station to take care of themselves. I use a separate class to define autonomous routines (go straight, turn left, turn right, back up, etc.), and then call those methods in autonomous() in a script like fashion, i.e.

Code:
public void autonomous() {
    autodrive.goStraight(8);  // go straight ahead for 8 seconds
    autodrive.turnRight(90);  // turn right 90 degrees
    autodrive.backUp(3);       // back up for 3 seconds
    }
When the AutoDrive class is complete anyone on my team should be able to program an autonomous routine using simple commands, without having to worry about how the program actually accomplishes the task.

The whole thing is modular that way. I use SimpleRobot instead of Iterative: it allows finer control of a multi-threaded model, without the interference of the automatic looping in Iterative. Iterative would eliminate threads, but would also be more monolithic, and therefore less reusable.

Off topic I'm sketching out my camera class, so I'm looking for better (meaning easier to follow) code than the stock examples. Jimmy's looks good, and I can actually read it (well, mostly )
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 13:00.

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