View Single Post
  #6   Spotlight this post!  
Unread 17-12-2011, 02:03
WizenedEE's Avatar
WizenedEE WizenedEE is offline
Registered User
AKA: Adam
FRC #3238 (Cyborg Ferrets)
Team Role: Leadership
 
Join Date: Jan 2011
Rookie Year: 2010
Location: Anacortes, WA
Posts: 395
WizenedEE is a name known to allWizenedEE is a name known to allWizenedEE is a name known to allWizenedEE is a name known to allWizenedEE is a name known to allWizenedEE is a name known to all
Re: Team 599 Robodox - 2011 Logomotion Code

Well, I'm pretty new to the WPILib, but this is what I would do.

Code:
class Fred2 : public SimpleRobot {
public:
    Fred2();
    ~Fred2();
    void Autonomous();
    void OperatorControl();

private:
    OperatorConsole opCon;

    /*Drivetrain*/
    CANJaguar frontLeftWheelMtr;
    CANJaguar rearLeftWheelMtr;
    CANJaguar frontRightWheelMtr;
    CANJaguar rearRightWheelMtr;
    RobotDrive drivetrain;

    /*Arm*/
    CANJaguar longArmMtr;
    CANJaguar shortArmMtr;
    CANJaguar wristMtr;
    Relay clawRly;

    DigitalInput clawClosedSwitch;
    DigitalInput clawOpenedSwitch;

    /*Deployer*/
    Deployer deployer;

    /*Flippers*/
    Servo flipperReleaseServo;
};

Code:
Fred2::Fred2() :
    /*Drivetrain*/
    frontLeftWheelMtr(frontLeftWheelMtrDevNum),
    rearLeftWheelMtr(rearLeftWheelMtrDevNum),
    frontRightWheelMtr(frontRightWheelMtrDevNum),
    rearRightWheelMtr(rearRightWheelMtrDevNum),
    drivetrain(frontLeftWheelMtr,  rearLeftWheelMtr,
               frontRightWheelMtr, rearRightWheelMtr),

    /*Arm*/
    /*Motors*/
    longArmMtr(longArmMtrDevNum),
    shortArmMtr(shortArmMtrDevNum),
    wristMtr(wristMtrDevNum),
    clawRly(clawRlyChannel),
    /*Sensors*/
    clawClosedSwitch(digitalModuleSlot, clawClosedSwitchChannel),
    clawOpenedSwitch(digitalModuleSlot, clawOpenedSwitchChannel),

    /*Flippers*/
    flipperReleaseServo(digitalModuleSlot, flipperReleaseServoChannel)

{ /*Init Code*/
    drivetrain.SetInvertedMotor(RobotDrive::kFrontLeftMotor,
                                driveMotorInvert[0]);
    drivetrain.SetInvertedMotor(RobotDrive::kRearLeftMotor,
                                driveMotorInvert[1]);
    drivetrain.SetInvertedMotor(RobotDrive::kFrontRightMotor,
                                driveMotorInvert[2]);
    drivetrain.SetInvertedMotor(RobotDrive::kRearRightMotor,
                                driveMotorInvert[3]);
}
I didn't have to rewrite any functions to avoid using new, so I don't really know what you're getting at. I'm just wondering if it's that people don't teach this method (why?) or if there's actually a good reason for it.
Reply With Quote