View Single Post
  #66   Spotlight this post!  
Unread 20-03-2007, 17:27
♥♣♠♪'s Avatar
♥♣♠♪ ♥♣♠♪ is offline
DemiOmniGod
FRC #1546 (Chaos Inc.)
Team Role: Programmer
 
Join Date: Feb 2006
Rookie Year: 2005
Location: Baldwin
Posts: 5
♥♣♠♪ will become famous soon enough
Re: Programming tricks (and former trade secrets)

Quote:
Originally Posted by meatmanek View Post
Our team uses an 'abstraction layer' which consists of a bunch of global variables and two functions: abstractIn() and abstractOut().
The global variables are things like driveLeft, driveRight, joyL, joyR, etc.
Our abstraction code takes renaming it one step farther. Rather than using the 0-255 scale where 127 means stop, we shift it down 128 (signed char, rather than unsigned), and we also invert motors where it makes sense. (one side of the drivetrain, any appendages where the motor is 'backwards')

This helps make our code MUCH more readable and configurable, and makes algorithms a bit simpler.

Another trick we did this year was one big state machine for teleoperated mode. In the past, our robot has been nothing more than a glorified remote control car. This year, our robot knows what it's supposed to be doing, with a set of states for each objective, and so the drivers are freed to think more about the game, rather than the robot.
Our code did the abstractions, but to the point where we had #define unsign(x) ((x)-127-((x)==255))
We #defined all the pwms to things like pwmL, pwmR, pwmA, etc.
The worst was when we needed to use two motors to control the wheels on the left and right. pwmL is #defined as (pwm05=pwm06)
__________________
Programming && English !mix

Our website