View Single Post
  #6   Spotlight this post!  
Unread 11-02-2009, 12:47
j_johnson j_johnson is offline
Registered User
FRC #0226 (Hammerheads)
Team Role: Mentor
 
Join Date: Jan 2009
Rookie Year: 2003
Location: Shelby Township, MI
Posts: 10
j_johnson is an unknown quantity at this point
Re: Location of WPI Library cpp files attached to Windriver

Another good option for operations like this is to use a pipeline pattern. Our team created a class that inherits from SpeedController and takes another SpeedController as it's output. Inside this class's Set method, it procceses the input and passes the result to the output. This pattern allows you to create classes to perform operations such as rate limiting, traction control, velocity control, etc. to each act individually. You can then chain them together through the constructors as below.

Code:
float accelLimit = .03;
SpeedController leftDriveMotor = new Jaguar(1);
SpeedController leftAccelLimiter = new AccelerationLimiter (leftDriveMotor, accelLimit);
SpeedController leftTractionControl = new TractionControl(leftAccelLimiter);
SpeedController rightDriveMotor = new Jaguar(2);
SpeedController rightAccelLimiter = new AccelerationLimiter (rightDriveMotor, accelLimit);
SpeedController rightTractionControl = new TractionControl(rightAccelLimiter);
m_robotDrive = new RobotDrive(leftTractionControl, rightTractionControl);
This makes it very easy to test each piece individually and then chain them together.
Reply With Quote