mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
Revert changes preventing old user code from compiling.
I'm not 100% sure whether we want these, but they are a quick find and replace to do. Basically, there are two primary things that we have done this summer that break existing user code: -Changing GetInstance() calls to return references instead of pointers. This forces users to change from doing something like LiveWindow::GetInstance()->AddSensor() to LiveWindow::GetInstance().AddSensor(). -Making PIDGet() and related calls const, forcing users to change the function signatures wherever they override them. The GetInstance() calls don't really matter to me either way, especially since there are no real ownership issues going on there, unlike the rest of the smart pointer-related changes. For the const stuff, it is certainly more correct to mandate that user PIDGet() functions be const and the such, but at the same time, I'm not sure that there is any strong need for it, and the errors generated are not the most helpful. While this wouldn't necessarily be an issue for more experienced teams or completely new teams (who don't have any old code to be reusing), it may cause issues for more average teams who aren't familiar with the intricacies of C++ anything. Change-Id: I6e7007982069292ea70e6d0fc8ca40203340df1b
This commit is contained in:
@@ -12,7 +12,7 @@ $classname::$classname() :
|
||||
// Enable() - Enables the PID controller.
|
||||
}
|
||||
|
||||
double $classname::ReturnPIDInput() const
|
||||
double $classname::ReturnPIDInput()
|
||||
{
|
||||
// Return your input value for the PID loop
|
||||
// e.g. a sensor, like a potentiometer:
|
||||
|
||||
@@ -8,7 +8,7 @@ class $classname: public PIDSubsystem
|
||||
{
|
||||
public:
|
||||
$classname();
|
||||
double ReturnPIDInput() const;
|
||||
double ReturnPIDInput();
|
||||
void UsePIDOutput(double output);
|
||||
void InitDefaultCommand();
|
||||
};
|
||||
|
||||
@@ -25,7 +25,7 @@ private:
|
||||
|
||||
void DisabledPeriodic()
|
||||
{
|
||||
Scheduler::GetInstance().Run();
|
||||
Scheduler::GetInstance()->Run();
|
||||
}
|
||||
|
||||
void AutonomousInit()
|
||||
@@ -36,7 +36,7 @@ private:
|
||||
|
||||
void AutonomousPeriodic()
|
||||
{
|
||||
Scheduler::GetInstance().Run();
|
||||
Scheduler::GetInstance()->Run();
|
||||
}
|
||||
|
||||
void TeleopInit()
|
||||
@@ -51,12 +51,12 @@ private:
|
||||
|
||||
void TeleopPeriodic()
|
||||
{
|
||||
Scheduler::GetInstance().Run();
|
||||
Scheduler::GetInstance()->Run();
|
||||
}
|
||||
|
||||
void TestPeriodic()
|
||||
{
|
||||
LiveWindow::GetInstance().Run();
|
||||
LiveWindow::GetInstance()->Run();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ void DriveStraight::Interrupted() {
|
||||
|
||||
|
||||
DriveStraightPIDSource::~DriveStraightPIDSource() {}
|
||||
double DriveStraightPIDSource::PIDGet() const {
|
||||
double DriveStraightPIDSource::PIDGet() {
|
||||
return Robot::drivetrain->GetDistance();
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ private:
|
||||
class DriveStraightPIDSource: public PIDSource {
|
||||
public:
|
||||
virtual ~DriveStraightPIDSource();
|
||||
double PIDGet() const;
|
||||
double PIDGet();
|
||||
};
|
||||
|
||||
class DriveStraightPIDOutput: public PIDOutput {
|
||||
|
||||
@@ -40,7 +40,7 @@ void SetDistanceToBox::Interrupted() {
|
||||
|
||||
|
||||
SetDistanceToBoxPIDSource::~SetDistanceToBoxPIDSource() {}
|
||||
double SetDistanceToBoxPIDSource::PIDGet() const {
|
||||
double SetDistanceToBoxPIDSource::PIDGet() {
|
||||
return Robot::drivetrain->GetDistanceToObstacle();
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ private:
|
||||
class SetDistanceToBoxPIDSource: public PIDSource {
|
||||
public:
|
||||
virtual ~SetDistanceToBoxPIDSource();
|
||||
double PIDGet() const;
|
||||
double PIDGet();
|
||||
};
|
||||
|
||||
class SetDistanceToBoxPIDOutput: public PIDOutput {
|
||||
|
||||
@@ -29,7 +29,7 @@ void Robot::AutonomousInit() {
|
||||
}
|
||||
|
||||
void Robot::AutonomousPeriodic() {
|
||||
Scheduler::GetInstance().Run();
|
||||
Scheduler::GetInstance()->Run();
|
||||
}
|
||||
|
||||
void Robot::TeleopInit() {
|
||||
@@ -42,11 +42,11 @@ void Robot::TeleopInit() {
|
||||
}
|
||||
|
||||
void Robot::TeleopPeriodic() {
|
||||
Scheduler::GetInstance().Run();
|
||||
Scheduler::GetInstance()->Run();
|
||||
}
|
||||
|
||||
void Robot::TestPeriodic() {
|
||||
lw.Run();
|
||||
lw->Run();
|
||||
}
|
||||
|
||||
START_ROBOT_CLASS(Robot)
|
||||
|
||||
@@ -28,7 +28,7 @@ public:
|
||||
|
||||
private:
|
||||
Autonomous autonomousCommand;
|
||||
LiveWindow &lw = LiveWindow::GetInstance();
|
||||
LiveWindow *lw = LiveWindow::GetInstance();
|
||||
|
||||
void RobotInit();
|
||||
void AutonomousInit();
|
||||
|
||||
@@ -23,14 +23,14 @@ DriveTrain::DriveTrain()
|
||||
#endif
|
||||
|
||||
// Let's show everything on the LiveWindow
|
||||
// TODO: LiveWindow::GetInstance().AddActuator("Drive Train", "Front_Left Motor", (Talon) front_left_motor);
|
||||
// TODO: LiveWindow::GetInstance().AddActuator("Drive Train", "Back Left Motor", (Talon) back_left_motor);
|
||||
// TODO: LiveWindow::GetInstance().AddActuator("Drive Train", "Front Right Motor", (Talon) front_right_motor);
|
||||
// TODO: LiveWindow::GetInstance().AddActuator("Drive Train", "Back Right Motor", (Talon) back_right_motor);
|
||||
LiveWindow::GetInstance().AddSensor("Drive Train", "Left Encoder", left_encoder);
|
||||
LiveWindow::GetInstance().AddSensor("Drive Train", "Right Encoder", right_encoder);
|
||||
LiveWindow::GetInstance().AddSensor("Drive Train", "Rangefinder", rangefinder);
|
||||
LiveWindow::GetInstance().AddSensor("Drive Train", "Gyro", gyro);
|
||||
// TODO: LiveWindow::GetInstance()->AddActuator("Drive Train", "Front_Left Motor", (Talon) front_left_motor);
|
||||
// TODO: LiveWindow::GetInstance()->AddActuator("Drive Train", "Back Left Motor", (Talon) back_left_motor);
|
||||
// TODO: LiveWindow::GetInstance()->AddActuator("Drive Train", "Front Right Motor", (Talon) front_right_motor);
|
||||
// TODO: LiveWindow::GetInstance()->AddActuator("Drive Train", "Back Right Motor", (Talon) back_right_motor);
|
||||
LiveWindow::GetInstance()->AddSensor("Drive Train", "Left Encoder", left_encoder);
|
||||
LiveWindow::GetInstance()->AddSensor("Drive Train", "Right Encoder", right_encoder);
|
||||
LiveWindow::GetInstance()->AddSensor("Drive Train", "Rangefinder", rangefinder);
|
||||
LiveWindow::GetInstance()->AddSensor("Drive Train", "Gyro", gyro);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -18,16 +18,16 @@ Elevator::Elevator() : PIDSubsystem("Elevator", kP_real, kI_real, 0.0) {
|
||||
#endif
|
||||
|
||||
// Let's show everything on the LiveWindow
|
||||
// TODO: LiveWindow::GetInstance().AddActuator("Elevator", "Motor", (Victor) motor);
|
||||
// TODO: LiveWindow::GetInstance().AddSensor("Elevator", "Pot", (AnalogPotentiometer) pot);
|
||||
LiveWindow::GetInstance().AddActuator("Elevator", "PID", GetPIDController());
|
||||
// TODO: LiveWindow::GetInstance()->AddActuator("Elevator", "Motor", (Victor) motor);
|
||||
// TODO: LiveWindow::GetInstance()->AddSensor("Elevator", "Pot", (AnalogPotentiometer) pot);
|
||||
LiveWindow::GetInstance()->AddActuator("Elevator", "PID", GetPIDController());
|
||||
}
|
||||
|
||||
void Elevator::Log() {
|
||||
// TODO: SmartDashboard::PutData("Wrist Pot", (AnalogPotentiometer) pot);
|
||||
}
|
||||
|
||||
double Elevator::ReturnPIDInput() const {
|
||||
double Elevator::ReturnPIDInput() {
|
||||
return pot->Get();
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ public:
|
||||
* Use the potentiometer as the PID sensor. This method is automatically
|
||||
* called by the subsystem.
|
||||
*/
|
||||
double ReturnPIDInput() const;
|
||||
double ReturnPIDInput();
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -18,16 +18,16 @@ Wrist::Wrist() : PIDSubsystem("Wrist", kP_real, 0.0, 0.0) {
|
||||
#endif
|
||||
|
||||
// Let's show everything on the LiveWindow
|
||||
// TODO: LiveWindow::GetInstance().AddActuator("Wrist", "Motor", (Victor) motor);
|
||||
// TODO: LiveWindow::GetInstance().AddSensor("Wrist", "Pot", (AnalogPotentiometer) pot);
|
||||
LiveWindow::GetInstance().AddActuator("Wrist", "PID", GetPIDController());
|
||||
// TODO: LiveWindow::GetInstance()->AddActuator("Wrist", "Motor", (Victor) motor);
|
||||
// TODO: LiveWindow::GetInstance()->AddSensor("Wrist", "Pot", (AnalogPotentiometer) pot);
|
||||
LiveWindow::GetInstance()->AddActuator("Wrist", "PID", GetPIDController());
|
||||
}
|
||||
|
||||
void Wrist::Log() {
|
||||
// TODO: SmartDashboard::PutData("Wrist Angle", (AnalogPotentiometer) pot);
|
||||
}
|
||||
|
||||
double Wrist::ReturnPIDInput() const {
|
||||
double Wrist::ReturnPIDInput() {
|
||||
return pot->Get();
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ public:
|
||||
* Use the potentiometer as the PID sensor. This method is automatically
|
||||
* called by the subsystem.
|
||||
*/
|
||||
double ReturnPIDInput() const;
|
||||
double ReturnPIDInput();
|
||||
|
||||
/**
|
||||
* Use the motor as the PID output. This method is automatically called by
|
||||
|
||||
@@ -5,7 +5,7 @@ class Robot: public IterativeRobot
|
||||
|
||||
RobotDrive myRobot; // robot drive system
|
||||
Joystick stick; // only joystick
|
||||
LiveWindow &lw;
|
||||
LiveWindow *lw;
|
||||
int autoLoopCounter;
|
||||
|
||||
public:
|
||||
@@ -47,7 +47,7 @@ private:
|
||||
|
||||
void TestPeriodic()
|
||||
{
|
||||
lw.Run();
|
||||
lw->Run();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ void Robot::AutonomousInit() {
|
||||
}
|
||||
|
||||
void Robot::AutonomousPeriodic() {
|
||||
Scheduler::GetInstance().Run();
|
||||
Scheduler::GetInstance()->Run();
|
||||
Log();
|
||||
}
|
||||
|
||||
@@ -55,12 +55,12 @@ void Robot::TeleopInit() {
|
||||
}
|
||||
|
||||
void Robot::TeleopPeriodic() {
|
||||
Scheduler::GetInstance().Run();
|
||||
Scheduler::GetInstance()->Run();
|
||||
Log();
|
||||
}
|
||||
|
||||
void Robot::TestPeriodic() {
|
||||
LiveWindow::GetInstance().Run();
|
||||
LiveWindow::GetInstance()->Run();
|
||||
}
|
||||
|
||||
void Robot::DisabledInit() {
|
||||
|
||||
@@ -11,9 +11,9 @@ Collector::Collector() :
|
||||
|
||||
// Put everything to the LiveWindow for testing.
|
||||
// XXX: LiveWindow::GetInstance()->AddActuator("Collector", "Roller Motor", (Victor) rollerMotor);
|
||||
LiveWindow::GetInstance().AddSensor("Collector", "Ball Detector", ballDetector);
|
||||
LiveWindow::GetInstance().AddSensor("Collector", "Claw Open Detector", openDetector);
|
||||
LiveWindow::GetInstance().AddActuator("Collector", "Piston", piston);
|
||||
LiveWindow::GetInstance()->AddSensor("Collector", "Ball Detector", ballDetector);
|
||||
LiveWindow::GetInstance()->AddSensor("Collector", "Claw Open Detector", openDetector);
|
||||
LiveWindow::GetInstance()->AddActuator("Collector", "Piston", piston);
|
||||
}
|
||||
|
||||
bool Collector::HasBall() {
|
||||
|
||||
@@ -44,14 +44,14 @@ DriveTrain::DriveTrain()
|
||||
leftEncoder->SetDistancePerPulse((4.0/*in*/*M_PI)/(360.0*12.0/*in/ft*/));
|
||||
#endif
|
||||
|
||||
LiveWindow::GetInstance().AddSensor("DriveTrain", "Right Encoder", rightEncoder);
|
||||
LiveWindow::GetInstance().AddSensor("DriveTrain", "Left Encoder", leftEncoder);
|
||||
LiveWindow::GetInstance()->AddSensor("DriveTrain", "Right Encoder", rightEncoder);
|
||||
LiveWindow::GetInstance()->AddSensor("DriveTrain", "Left Encoder", leftEncoder);
|
||||
|
||||
// Configure gyro
|
||||
#ifdef REAL
|
||||
gyro->SetSensitivity(0.007); // TODO: Handle more gracefully?
|
||||
#endif
|
||||
LiveWindow::GetInstance().AddSensor("DriveTrain", "Gyro", gyro);
|
||||
LiveWindow::GetInstance()->AddSensor("DriveTrain", "Gyro", gyro);
|
||||
}
|
||||
|
||||
void DriveTrain::InitDefaultCommand() {
|
||||
|
||||
@@ -20,16 +20,16 @@ Pivot::Pivot() :
|
||||
#endif
|
||||
|
||||
// Put everything to the LiveWindow for testing.
|
||||
LiveWindow::GetInstance().AddSensor("Pivot", "Upper Limit Switch", upperLimitSwitch);
|
||||
LiveWindow::GetInstance().AddSensor("Pivot", "Lower Limit Switch", lowerLimitSwitch);
|
||||
// XXX: LiveWindow::GetInstance().AddSensor("Pivot", "Pot", (AnalogPotentiometer) pot);
|
||||
// XXX: LiveWindow::GetInstance().AddActuator("Pivot", "Motor", (Victor) motor);
|
||||
LiveWindow::GetInstance().AddActuator("Pivot", "PIDSubsystem Controller", GetPIDController());
|
||||
LiveWindow::GetInstance()->AddSensor("Pivot", "Upper Limit Switch", upperLimitSwitch);
|
||||
LiveWindow::GetInstance()->AddSensor("Pivot", "Lower Limit Switch", lowerLimitSwitch);
|
||||
// XXX: LiveWindow::GetInstance()->AddSensor("Pivot", "Pot", (AnalogPotentiometer) pot);
|
||||
// XXX: LiveWindow::GetInstance()->AddActuator("Pivot", "Motor", (Victor) motor);
|
||||
LiveWindow::GetInstance()->AddActuator("Pivot", "PIDSubsystem Controller", GetPIDController());
|
||||
}
|
||||
|
||||
void InitDefaultCommand() {}
|
||||
|
||||
double Pivot::ReturnPIDInput() const {
|
||||
double Pivot::ReturnPIDInput() {
|
||||
return pot->Get();
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ public:
|
||||
/**
|
||||
* @return The angle read in by the potentiometer
|
||||
*/
|
||||
double ReturnPIDInput() const;
|
||||
double ReturnPIDInput();
|
||||
|
||||
/**
|
||||
* Set the motor speed based off of the PID output
|
||||
|
||||
@@ -8,7 +8,7 @@ Pneumatics::Pneumatics() :
|
||||
compressor = new Compressor(uint8_t(1)); // TODO: (1, 14, 1, 8);
|
||||
#endif
|
||||
|
||||
LiveWindow::GetInstance().AddSensor("Pneumatics", "Pressure Sensor", pressureSensor);
|
||||
LiveWindow::GetInstance()->AddSensor("Pneumatics", "Pressure Sensor", pressureSensor);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -12,10 +12,10 @@ Shooter::Shooter() :
|
||||
{
|
||||
|
||||
// Put everything to the LiveWindow for testing.
|
||||
LiveWindow::GetInstance().AddSensor("Shooter", "Hot Goal Sensor", hotGoalSensor);
|
||||
LiveWindow::GetInstance().AddSensor("Shooter", "Piston1 Reed Switch Front ", piston1ReedSwitchFront);
|
||||
LiveWindow::GetInstance().AddSensor("Shooter", "Piston1 Reed Switch Back ", piston1ReedSwitchBack);
|
||||
LiveWindow::GetInstance().AddActuator("Shooter", "Latch Piston", latchPiston);
|
||||
LiveWindow::GetInstance()->AddSensor("Shooter", "Hot Goal Sensor", hotGoalSensor);
|
||||
LiveWindow::GetInstance()->AddSensor("Shooter", "Piston1 Reed Switch Front ", piston1ReedSwitchFront);
|
||||
LiveWindow::GetInstance()->AddSensor("Shooter", "Piston1 Reed Switch Back ", piston1ReedSwitchBack);
|
||||
LiveWindow::GetInstance()->AddActuator("Shooter", "Latch Piston", latchPiston);
|
||||
}
|
||||
|
||||
void Shooter::InitDefaultCommand()
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
class Robot: public IterativeRobot
|
||||
{
|
||||
private:
|
||||
LiveWindow &lw = LiveWindow::GetInstance();
|
||||
LiveWindow *lw = LiveWindow::GetInstance();
|
||||
|
||||
void RobotInit()
|
||||
{
|
||||
@@ -31,7 +31,7 @@ private:
|
||||
|
||||
void TestPeriodic()
|
||||
{
|
||||
lw.Run();
|
||||
lw->Run();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user