Thread: Camera Code
View Single Post
  #1   Spotlight this post!  
Unread 25-01-2011, 22:41
mwtidd's Avatar
mwtidd mwtidd is offline
Registered User
AKA: mike
FRC #0319 (Big Bad Bob)
Team Role: Mentor
 
Join Date: Feb 2005
Rookie Year: 2003
Location: Boston, MA
Posts: 714
mwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond reputemwtidd has a reputation beyond repute
Re: Camera Code

Quote:
Originally Posted by wdell View Post
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 )
Dell, if you look at my code I use a similar structure. Reusable is a critical element. However our team has found that the series maneuvers is not sufficient so I have created a similar structure that utilizes a tree (pass, fail, timeout).

Also thank you for joining the initiative. Autonomous has been lacking in FIRST teams, so I agree it is the responsibility of successful teams to lead the endeavorer and stay open source
__________________
"Never let your schooling interfere with your education" -Mark Twain
Reply With Quote