Robot() { #if BUILD_VERSION == COMPETITION liftMotor = new CANTalon(CHAN_LIFT_MOTOR); liftMotor2 = new CANTalon(CHAN_LIFT_MOTOR2); #else liftMotor = new CANJaguar(CHAN_LIFT_MOTOR); liftMotor2 = new CANJaguar(CHAN_LIFT_MOTOR2); #endif liftEncoder = new Encoder(CHAN_LIFT_ENCODER_A, CHAN_LIFT_ENCODER_B, false, Encoder::EncodingType::k4X); liftEncoder->SetDistancePerPulse(LIFT_ENCODER_DIST_PER_PULSE); liftEncoder->SetPIDSourceParameter(liftEncoder->kDistance); #if BUILD_VERSION == COMPETITION liftEncoder->SetReverseDirection(true); #endif controlLift = new PIDController(PID_P, PID_I, PID_D, liftEncoder, liftMotor); controlLift->SetContinuous(true); //treat input to controller as continuous; true by default controlLift->SetOutputRange(PID_OUT_MIN, PID_OUT_MAX); controlLift->Disable(); //do not enable until in holding position mode controlLift2 = new PIDController(PID_P, PID_I, PID_D, liftEncoder, liftMotor2); controlLift2->SetContinuous(true); //treat input to controller as continuous; true by default controlLift2->SetOutputRange(PID_OUT_MIN, PID_OUT_MAX); controlLift2->Disable(); //do not enable until in holding position mode liftLimitSwitchMin = new DigitalInput(CHAN_LIFT_LOW_LS); liftLimitSwitchMax = new DigitalInput(CHAN_LIFT_HIGH_LS); joystick = new Joystick(CHAN_JS); }
FECLift() { theTimer = new Timer(); //initialized the jag theJag = new Jaguar(JAGPORT); fakeEncoder = new Encoder(6,6,6,7,fakeEncoder->k4X); theEncoder = new Encoder(ENCODERSLOTA, ENCODERCHANNELA, ENCODERSLOTB, ENCODERCHANNELB, false, theEncoder->k4X); #if RATE theEncoder->SetPIDSourceParameter(Encoder::kRate); #else theEncoder->SetPIDSourceParameter(Encoder::kDistance); #endif theEncoder->SetDistancePerPulse(DISTANCE_PER_PULSE); driverStation = DriverStation::GetInstance(); theLift = new PIDController(P,I,D,theEncoder,theJag); GetWatchdog().SetExpiration(.3); decel = false; done = false; writing = true; closed = false; initFile(); }