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:
James Kuszmaul
2015-07-24 19:19:40 -04:00
parent ef1e81f93e
commit f65e697107
84 changed files with 218 additions and 218 deletions

View File

@@ -40,7 +40,7 @@ void DriveStraight::Interrupted() {
DriveStraightPIDSource::~DriveStraightPIDSource() {}
double DriveStraightPIDSource::PIDGet() const {
double DriveStraightPIDSource::PIDGet() {
return Robot::drivetrain->GetDistance();
}

View File

@@ -25,7 +25,7 @@ private:
class DriveStraightPIDSource: public PIDSource {
public:
virtual ~DriveStraightPIDSource();
double PIDGet() const;
double PIDGet();
};
class DriveStraightPIDOutput: public PIDOutput {

View File

@@ -40,7 +40,7 @@ void SetDistanceToBox::Interrupted() {
SetDistanceToBoxPIDSource::~SetDistanceToBoxPIDSource() {}
double SetDistanceToBoxPIDSource::PIDGet() const {
double SetDistanceToBoxPIDSource::PIDGet() {
return Robot::drivetrain->GetDistanceToObstacle();
}

View File

@@ -25,7 +25,7 @@ private:
class SetDistanceToBoxPIDSource: public PIDSource {
public:
virtual ~SetDistanceToBoxPIDSource();
double PIDGet() const;
double PIDGet();
};
class SetDistanceToBoxPIDOutput: public PIDOutput {

View File

@@ -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)

View File

@@ -28,7 +28,7 @@ public:
private:
Autonomous autonomousCommand;
LiveWindow &lw = LiveWindow::GetInstance();
LiveWindow *lw = LiveWindow::GetInstance();
void RobotInit();
void AutonomousInit();

View File

@@ -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);
}
/**

View File

@@ -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();
}

View File

@@ -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();
/**

View File

@@ -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();
}

View File

@@ -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