View Single Post
  #12   Spotlight this post!  
Unread 27-03-2012, 14:56
MamaSpoldi's Avatar
MamaSpoldi MamaSpoldi is offline
Programming Mentor
AKA: Laura Spoldi
FRC #0230 (Gaelhawks)
Team Role: Engineer
 
Join Date: Jan 2009
Rookie Year: 2007
Location: Shelton, CT
Posts: 306
MamaSpoldi has a brilliant futureMamaSpoldi has a brilliant futureMamaSpoldi has a brilliant futureMamaSpoldi has a brilliant futureMamaSpoldi has a brilliant futureMamaSpoldi has a brilliant futureMamaSpoldi has a brilliant futureMamaSpoldi has a brilliant futureMamaSpoldi has a brilliant futureMamaSpoldi has a brilliant futureMamaSpoldi has a brilliant future
Smile Re: How does your team architect its codebase?

Quote:
Originally Posted by daniel_dsouza View Post
Our team likes dividing our code into classes based upon the functional units of our robot. This year featured a drivetrain, a elevator, a shooter, a bridge lowering device, a control, a (sketch) motion sensor, a constants, and output class and a main class for interfacing logic.

Each class only interfaces in the main class, in order to make bugs easier to debug. This allows our code to be extremely clean, as variables and methods not needed by the main are declared private and hidden in that class.

Having multiple classes also allows us to use Object Orientated Programming, so we could (if we every needed to) create a "new" drivetrain for use in auto or teleop.

The last great thing I can think of at the moment is that we can multitask effectively, especially if each programmer writes one class. Close to the end of build season (when we had an entire robot), all of us (programmers) gather together to write out the main class, taking into account decisions on strategies, and workarounds that the mechanical team needed us to fix in code. Our SVN server deserves a mention somewhere around here.

One thing you would want to be careful about is the overuse of global variables. They certainly have their place, but when you have global variables pointing to global variables, things have gone too far...
Team 230 takes an approach similar to what daniel describes. This year we have classes representing the shooter (which includes the turret control as well), drive train, inertial data sensors (gyros, wheel encoders, accelerometer), the bridge device, and ball gathering. Each of these classes defines an interface [1] to support the various tasks that will be requested by the operator and [2] to provide any information that will be needed by other classes, as well as [3] a service function which is called each time through the main loop of teleop and autonomous to perform multi-step operations. Note that none of the other interface functions are allowed to perform operations which take significant processing time; they simply set a flag to start an operation or turn on a mode and return.

The responsibility for each class is given to a single student programmer so that they maintain that code (with oversight by the programming mentor). This gives each student something that they can work on and be proud of their individual accomplishment as well as being part of the programming team and what we come together to create. More experienced students often handle multiple classes. And ironically enough we also make extensive use of SVN for our source code control as well.

Our TeleOp and Autonomous functions are basically loops which maintain the loop time (required for PID loops and other control systems) and make use of the interface defined by each class to facilitate the operation required... either based on an operator request (like pushing a button on the joystick) or based on the steps defined for the currently selected autonomous mode. Reusing the same class interface functions to perform operations in both modes allows our autonomous to come together very quickly and reliably after the testing is done for teleop.

I don't have a copy of our code anywhere that is accessible on the internet, but would be happy to share a copy with anyone who is interested. Please feel free to PM me.
__________________