Quote:
Originally Posted by sircedric4
************************************************** ****
In my .h file:
Jaguar *TurretPIDMotor;
AnalogChannel *TurretPIDPot;
PIDController *turretControl;
In my .cpp file:
In TeleopInit()
Jaguar TurretPIDMotor(3);
AnalogChannel TurretPIDPot(1);
PIDController turretControl(0.1,0.001,0.0, &TurretPIDPot, &TurretPIDMotor);
turretControl.Enable();
In TeleopPeriodic()
TurretGoto is being set from 0-5 using an equation and it is float defined
turretControl->SetSetPoint(TurretGoto);
************************************************** **
|
Change the lines in TeleopInit to:
Code:
turretPIDMotor = new Jaguar(3);
turretPIDPot = new AnalogChannel(1);
turretControl = new PIDController(0,1, 0.001, 0.0, turretPIDPot, turretPIDMotor);
turretControl->Enable();
Note that the ampersands (&) are no long on the 4th and 5th arguments to PIDController.
You were declaring a pointer to all of these classes and then allocating local versions in TeleopInit. The local version were being deleted when TeleopInit returned and the pointers you had in TeleopPeriodic were NULL and causing your program to crash.