View Single Post
  #3   Spotlight this post!  
Unread 19-02-2010, 13:40
Dave Scheck's Avatar
Dave Scheck Dave Scheck is offline
Registered User
FRC #0111 (WildStang)
Team Role: Engineer
 
Join Date: Feb 2003
Rookie Year: 2002
Location: Arlington Heights, IL
Posts: 574
Dave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond repute
Re: Who Has Programmed From Scratch?

Quote:
Originally Posted by apalrd View Post
I can't say much about Killer Bees code(well, actually I can), but Windows says the project directory has 114 files, not including the stuff in Builds
For reference on the C++ side, we're currently at 120 files (.h and .cpp) with 12,146 lines (using a simple wc -l). Last year we had 137 files and 11,015 lines.

Our framework is a bit overkill, but it's definitely a very elegant way to approach the problem. The whole mentality is to isolate the inputs from the outputs and make the class methods simple and straightforward.

In a simple example, lets consider a simple two motor tank drive system controlled by a single joystick in arcade mode. Our robot class would instantiate the following objects

* Gamepad - The gamepad that controls the driving
* WsControllerAxis - One is created for each axis on the gamepad
* WsControllerPolarStick - Takes in two WsControllerAxis objects and creates a polar coordinate system out of it.
* WsControlMethodTank - Takes in a WsControllerPolarStick (as well as any buttons that are needed for driving such as turbo) and converts the inputs to a WsDriveVector (speed and direction)

* SpeedController - One is created for each Victor that we're controlling
* WsSc - Wraps a SpeedController so we can do things like disable or debug
* WsDriveBaseTank - Takes in the two WsSc objects. Uses a WsDriveVector input to calculate the outputs to send to the WsSc (and subsequently the SpeedController)

Then from in the teleop periodic call, we simply do a get on the WsControlMethodTank to get a WsDriveVector and pass that in to the WsDriveBaseTank and away we go.

On the autonomous side, we simply make these same types of calls and reuse the entire drive base objects. In addition, all of our programs run in a common engine that takes simple commands like driveByTime or driveByEncoder. This makes writing programs as simple as defining the steps and calling an addCommand function. Our individual autonomous programs last year didn't have a single line of logic in them. They simply assigned values to the step parameters and called addStep. Since they all derive from the same base class, they all have a run in the base that handles stepping through the commands.