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

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

View File

@@ -8,7 +8,7 @@ class $classname: public PIDSubsystem
{
public:
$classname();
double ReturnPIDInput() const;
double ReturnPIDInput();
void UsePIDOutput(double output);
void InitDefaultCommand();
};

View File

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

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -32,7 +32,7 @@ class PIDCommand : public Command, public PIDOutput, public PIDSource {
virtual void PIDWrite(float output);
// PIDSource interface
virtual double PIDGet() const;
virtual double PIDGet();
protected:
std::shared_ptr<PIDController> GetPIDController() const;
@@ -41,9 +41,9 @@ class PIDCommand : public Command, public PIDOutput, public PIDSource {
virtual void _End();
void SetSetpoint(double setpoint);
double GetSetpoint() const;
double GetPosition() const;
double GetPosition();
virtual double ReturnPIDInput() const = 0;
virtual double ReturnPIDInput() = 0;
virtual void UsePIDOutput(double output) = 0;
private:

View File

@@ -45,7 +45,7 @@ class PIDSubsystem : public Subsystem, public PIDOutput, public PIDSource {
virtual void PIDWrite(float output);
// PIDSource interface
virtual double PIDGet() const;
virtual double PIDGet();
void SetSetpoint(double setpoint);
void SetSetpointRelative(double deltaSetpoint);
void SetInputRange(float minimumInput, float maximumInput);
@@ -61,7 +61,7 @@ class PIDSubsystem : public Subsystem, public PIDOutput, public PIDSource {
protected:
std::shared_ptr<PIDController> GetPIDController();
virtual double ReturnPIDInput() const = 0;
virtual double ReturnPIDInput() = 0;
virtual void UsePIDOutput(double output) = 0;
private:

View File

@@ -27,7 +27,7 @@ class Subsystem;
class Scheduler : public ErrorBase, public NamedSendable {
public:
static Scheduler &GetInstance();
static Scheduler *GetInstance();
void AddCommand(Command *command);
void AddButton(ButtonScheduler *button);

View File

@@ -30,7 +30,7 @@ struct LiveWindowComponent {
*/
class LiveWindow {
public:
static LiveWindow &GetInstance();
static LiveWindow *GetInstance();
void Run();
#if !defined(_MSC_VER)
[[deprecated(
@@ -90,7 +90,7 @@ class LiveWindow {
std::shared_ptr<ITable> m_liveWindowTable;
std::shared_ptr<ITable> m_statusTable;
Scheduler &m_scheduler;
Scheduler *m_scheduler;
bool m_enabled = false;
bool m_firstTime = true;

View File

@@ -18,7 +18,7 @@ class PIDSource {
public:
virtual void SetPIDSourceType(PIDSourceType pidSource);
PIDSourceType GetPIDSourceType() const;
virtual double PIDGet() const = 0;
virtual double PIDGet() = 0;
protected:
PIDSourceType m_pidSource = PIDSourceType::kDisplacement;

View File

@@ -12,4 +12,4 @@
ButtonScheduler::ButtonScheduler(bool last, Trigger *button, Command *orders)
: m_pressedLast(last), m_button(button), m_command(orders) {}
void ButtonScheduler::Start() { Scheduler::GetInstance().AddButton(this); }
void ButtonScheduler::Start() { Scheduler::GetInstance()->AddButton(this); }

View File

@@ -152,7 +152,7 @@ void Command::Start() {
CommandIllegalUse,
"Can not start a command that is part of a command group");
Scheduler::GetInstance().AddCommand(this);
Scheduler::GetInstance()->AddCommand(this);
}
/**

View File

@@ -50,7 +50,7 @@ void PIDCommand::SetSetpointRelative(double deltaSetpoint) {
void PIDCommand::PIDWrite(float output) { UsePIDOutput(output); }
double PIDCommand::PIDGet() const { return ReturnPIDInput(); }
double PIDCommand::PIDGet() { return ReturnPIDInput(); }
std::shared_ptr<PIDController> PIDCommand::GetPIDController() const {
return m_controller;
@@ -62,7 +62,7 @@ void PIDCommand::SetSetpoint(double setpoint) {
double PIDCommand::GetSetpoint() const { return m_controller->GetSetpoint(); }
double PIDCommand::GetPosition() const { return ReturnPIDInput(); }
double PIDCommand::GetPosition() { return ReturnPIDInput(); }
std::string PIDCommand::GetSmartDashboardType() const { return "PIDCommand"; }
void PIDCommand::InitTable(std::shared_ptr<ITable> table) {

View File

@@ -216,7 +216,7 @@ double PIDSubsystem::GetRate() { return ReturnPIDInput(); }
void PIDSubsystem::PIDWrite(float output) { UsePIDOutput(output); }
double PIDSubsystem::PIDGet() const { return ReturnPIDInput(); }
double PIDSubsystem::PIDGet() { return ReturnPIDInput(); }
std::string PIDSubsystem::GetSmartDashboardType() const { return "PIDCommand"; }
void PIDSubsystem::InitTable(std::shared_ptr<ITable> table) {

View File

@@ -23,9 +23,9 @@ Scheduler::Scheduler() {
* Returns the {@link Scheduler}, creating it if one does not exist.
* @return the {@link Scheduler}
*/
Scheduler &Scheduler::GetInstance() {
Scheduler *Scheduler::GetInstance() {
static Scheduler instance;
return instance;
return &instance;
}
void Scheduler::SetEnabled(bool enabled) { m_enabled = enabled; }

View File

@@ -17,7 +17,7 @@
*/
Subsystem::Subsystem(const std::string &name) {
m_name = name;
Scheduler::GetInstance().RegisterSubsystem(this);
Scheduler::GetInstance()->RegisterSubsystem(this);
}
/**
* Initialize the default command for this subsystem

View File

@@ -9,9 +9,9 @@
* regardless of
* how many times GetInstance is called.
*/
LiveWindow &LiveWindow::GetInstance() {
LiveWindow *LiveWindow::GetInstance() {
static LiveWindow instance;
return instance;
return &instance;
}
/**
@@ -34,8 +34,8 @@ void LiveWindow::SetEnabled(bool enabled) {
InitializeLiveWindowComponents();
m_firstTime = false;
}
m_scheduler.SetEnabled(false);
m_scheduler.RemoveAll();
m_scheduler->SetEnabled(false);
m_scheduler->RemoveAll();
for (auto& elem : m_components) {
elem.first->StartLiveWindowMode();
}
@@ -43,7 +43,7 @@ void LiveWindow::SetEnabled(bool enabled) {
for (auto& elem : m_components) {
elem.first->StopLiveWindowMode();
}
m_scheduler.SetEnabled(true);
m_scheduler->SetEnabled(true);
}
m_enabled = enabled;
m_statusTable->PutBoolean("LW Enabled", m_enabled);

View File

@@ -38,7 +38,7 @@ class AnalogAccelerometer : public SensorBase,
float GetAcceleration() const;
void SetSensitivity(float sensitivity);
void SetZero(float zero);
double PIDGet() const override;
double PIDGet() override;
void UpdateTable() override;
void StartLiveWindowMode() override;

View File

@@ -67,7 +67,7 @@ class AnalogInput : public SensorBase,
static void SetSampleRate(float samplesPerSecond);
static float GetSampleRate();
double PIDGet() const override;
double PIDGet() override;
void UpdateTable() override;
void StartLiveWindowMode() override;

View File

@@ -61,7 +61,7 @@ class AnalogPotentiometer : public Potentiometer, public LiveWindowSendable {
*
* @return The current reading.
*/
virtual double PIDGet() const override;
virtual double PIDGet() override;
/*
* Live Window code, only does anything if live window is activated.

View File

@@ -50,7 +50,7 @@ class CANTalon : public MotorSafety,
virtual void PIDWrite(float output) override;
// PIDSource interface
virtual double PIDGet() const override;
virtual double PIDGet() override;
// MotorSafety interface
virtual void SetExpiration(float timeout) override;

View File

@@ -83,7 +83,7 @@ class Encoder : public SensorBase,
void SetReverseDirection(bool reverseDirection);
void SetSamplesToAverage(int samplesToAverage);
int GetSamplesToAverage() const;
double PIDGet() const override;
double PIDGet() override;
void SetIndexSource(uint32_t channel, IndexingType type = kResetOnRisingEdge);
[[deprecated("Raw pointers are deprecated; use references instead.")]]

View File

@@ -53,7 +53,7 @@ class Gyro : public SensorBase, public PIDSource, public LiveWindowSendable {
void InitGyro();
// PIDSource interface
double PIDGet() const override;
double PIDGet() override;
void UpdateTable() override;
void StartLiveWindowMode() override;

View File

@@ -69,7 +69,7 @@ class Ultrasonic : public SensorBase,
bool IsEnabled() const { return m_enabled; }
void SetEnabled(bool enable) { m_enabled = enable; }
double PIDGet() const override;
double PIDGet() override;
void SetPIDSourceType(PIDSourceType pidSource) override;
void SetDistanceUnits(DistanceUnit units);
DistanceUnit GetDistanceUnits() const;

View File

@@ -30,7 +30,7 @@ ADXL345_I2C::ADXL345_I2C(Port port, Range range) : I2C(port, kAddress) {
HALReport(HALUsageReporting::kResourceType_ADXL345,
HALUsageReporting::kADXL345_I2C, 0);
LiveWindow::GetInstance().AddSensor("ADXL345_I2C", port, this);
LiveWindow::GetInstance()->AddSensor("ADXL345_I2C", port, this);
}
/** {@inheritdoc} */

View File

@@ -39,7 +39,7 @@ ADXL345_SPI::ADXL345_SPI(SPI::Port port, ADXL345_SPI::Range range) : SPI(port) {
HALReport(HALUsageReporting::kResourceType_ADXL345,
HALUsageReporting::kADXL345_SPI);
LiveWindow::GetInstance().AddSensor("ADXL345_SPI", port, this);
LiveWindow::GetInstance()->AddSensor("ADXL345_SPI", port, this);
}
/** {@inheritdoc} */

View File

@@ -16,7 +16,7 @@
void AnalogAccelerometer::InitAccelerometer() {
HALReport(HALUsageReporting::kResourceType_Accelerometer,
m_analogInput->GetChannel());
LiveWindow::GetInstance().AddSensor("Accelerometer",
LiveWindow::GetInstance()->AddSensor("Accelerometer",
m_analogInput->GetChannel(), this);
}
@@ -110,7 +110,7 @@ void AnalogAccelerometer::SetZero(float zero) { m_zeroGVoltage = zero; }
*
* @return The current acceleration in Gs.
*/
double AnalogAccelerometer::PIDGet() const { return GetAcceleration(); }
double AnalogAccelerometer::PIDGet() { return GetAcceleration(); }
void AnalogAccelerometer::UpdateTable() {
if (m_table != nullptr) {

View File

@@ -47,7 +47,7 @@ AnalogInput::AnalogInput(uint32_t channel) {
m_port = initializeAnalogInputPort(port, &status);
wpi_setErrorWithContext(status, getHALErrorMessage(status));
LiveWindow::GetInstance().AddSensor("AnalogInput", channel, this);
LiveWindow::GetInstance()->AddSensor("AnalogInput", channel, this);
HALReport(HALUsageReporting::kResourceType_AnalogChannel, channel);
}
@@ -394,7 +394,7 @@ float AnalogInput::GetSampleRate() {
*
* @return The average voltage.
*/
double AnalogInput::PIDGet() const {
double AnalogInput::PIDGet() {
if (StatusIsFatal()) return 0.0;
return GetAverageVoltage();
}

View File

@@ -42,7 +42,7 @@ AnalogOutput::AnalogOutput(uint32_t channel) {
m_port = initializeAnalogOutputPort(port, &status);
wpi_setErrorWithContext(status, getHALErrorMessage(status));
LiveWindow::GetInstance().AddActuator("AnalogOutput", m_channel, this);
LiveWindow::GetInstance()->AddActuator("AnalogOutput", m_channel, this);
HALReport(HALUsageReporting::kResourceType_AnalogOutput, m_channel);
}

View File

@@ -66,7 +66,7 @@ double AnalogPotentiometer::Get() const {
*
* @return The current reading.
*/
double AnalogPotentiometer::PIDGet() const { return Get(); }
double AnalogPotentiometer::PIDGet() { return Get(); }
/**
* @return the Smart Dashboard Type

View File

@@ -18,7 +18,7 @@ BuiltInAccelerometer::BuiltInAccelerometer(Range range) {
HALReport(HALUsageReporting::kResourceType_Accelerometer, 0, 0,
"Built-in accelerometer");
LiveWindow::GetInstance().AddSensor((std::string) "BuiltInAccel", 0, this);
LiveWindow::GetInstance()->AddSensor((std::string) "BuiltInAccel", 0, this);
}
/** {@inheritdoc} */

View File

@@ -147,7 +147,7 @@ void CANJaguar::InitCANJaguar() {
}
HALReport(HALUsageReporting::kResourceType_CANJaguar, m_deviceNumber,
m_controlMode);
LiveWindow::GetInstance().AddActuator("CANJaguar", m_deviceNumber, this);
LiveWindow::GetInstance()->AddActuator("CANJaguar", m_deviceNumber, this);
}
/**

View File

@@ -70,7 +70,7 @@ void CANTalon::PIDWrite(float output) {
*
* @return The current sensor value of the Talon.
*/
double CANTalon::PIDGet() const { return Get(); }
double CANTalon::PIDGet() { return Get(); }
/**
* Gets the current status of the Talon (usually a sensor value).

View File

@@ -33,7 +33,7 @@ DigitalInput::DigitalInput(uint32_t channel) {
allocateDIO(m_digital_ports[channel], true, &status);
wpi_setErrorWithContext(status, getHALErrorMessage(status));
LiveWindow::GetInstance().AddSensor("DigitalInput", channel, this);
LiveWindow::GetInstance()->AddSensor("DigitalInput", channel, this);
HALReport(HALUsageReporting::kResourceType_DigitalInput, channel);
}

View File

@@ -79,7 +79,7 @@ DoubleSolenoid::DoubleSolenoid(uint8_t moduleNumber, uint32_t forwardChannel,
m_moduleNumber);
HALReport(HALUsageReporting::kResourceType_Solenoid, m_reverseChannel,
m_moduleNumber);
LiveWindow::GetInstance().AddActuator("DoubleSolenoid", m_moduleNumber,
LiveWindow::GetInstance()->AddActuator("DoubleSolenoid", m_moduleNumber,
m_forwardChannel, this);
}

View File

@@ -69,7 +69,7 @@ void Encoder::InitEncoder(bool reverseDirection, EncodingType encodingType) {
}
HALReport(HALUsageReporting::kResourceType_Encoder, m_index, encodingType);
LiveWindow::GetInstance().AddSensor("Encoder",
LiveWindow::GetInstance()->AddSensor("Encoder",
m_aSource->GetChannelForRouting(), this);
}
@@ -480,7 +480,7 @@ int Encoder::GetSamplesToAverage() const {
*
* @return The current value of the selected source parameter.
*/
double Encoder::PIDGet() const {
double Encoder::PIDGet() {
if (StatusIsFatal()) return 0.0;
switch (GetPIDSourceType()) {
case PIDSourceType::kDisplacement:

View File

@@ -30,7 +30,7 @@ void GearTooth::EnableDirectionSensing(bool directionSensitive) {
GearTooth::GearTooth(uint32_t channel, bool directionSensitive)
: Counter(channel) {
EnableDirectionSensing(directionSensitive);
LiveWindow::GetInstance().AddSensor("GearTooth", channel, this);
LiveWindow::GetInstance()->AddSensor("GearTooth", channel, this);
}
/**

View File

@@ -65,7 +65,7 @@ void Gyro::InitGyro() {
SetPIDSourceType(PIDSourceType::kDisplacement);
HALReport(HALUsageReporting::kResourceType_Gyro, m_analog->GetChannel());
LiveWindow::GetInstance().AddSensor("Gyro", m_analog->GetChannel(), this);
LiveWindow::GetInstance()->AddSensor("Gyro", m_analog->GetChannel(), this);
}
/**
@@ -195,7 +195,7 @@ void Gyro::SetDeadband(float volts) {
*
* @return The PIDOutput (angle or rate, defaults to angle)
*/
double Gyro::PIDGet() const {
double Gyro::PIDGet() {
switch (GetPIDSourceType()) {
case PIDSourceType::kRate:
return GetRate();

View File

@@ -31,7 +31,7 @@ void IterativeRobot::StartCompetition() {
HALReport(HALUsageReporting::kResourceType_Framework,
HALUsageReporting::kFramework_Iterative);
LiveWindow &lw = LiveWindow::GetInstance();
LiveWindow *lw = LiveWindow::GetInstance();
// first and one-time initialization
SmartDashboard::init();
NetworkTable::GetTable("LiveWindow")
@@ -46,14 +46,14 @@ void IterativeRobot::StartCompetition() {
HALNetworkCommunicationObserveUserProgramStarting();
// loop forever, calling the appropriate mode-dependent function
lw.SetEnabled(false);
lw->SetEnabled(false);
while (true) {
// Call the appropriate function depending upon the current robot mode
if (IsDisabled()) {
// call DisabledInit() if we are now just entering disabled mode from
// either a different mode or from power-on
if (!m_disabledInitialized) {
lw.SetEnabled(false);
lw->SetEnabled(false);
DisabledInit();
m_disabledInitialized = true;
// reset the initialization flags for the other modes
@@ -67,7 +67,7 @@ void IterativeRobot::StartCompetition() {
// call AutonomousInit() if we are now just entering autonomous mode from
// either a different mode or from power-on
if (!m_autonomousInitialized) {
lw.SetEnabled(false);
lw->SetEnabled(false);
AutonomousInit();
m_autonomousInitialized = true;
// reset the initialization flags for the other modes
@@ -81,7 +81,7 @@ void IterativeRobot::StartCompetition() {
// call TestInit() if we are now just entering test mode from
// either a different mode or from power-on
if (!m_testInitialized) {
lw.SetEnabled(true);
lw->SetEnabled(true);
TestInit();
m_testInitialized = true;
// reset the initialization flags for the other modes
@@ -95,14 +95,14 @@ void IterativeRobot::StartCompetition() {
// call TeleopInit() if we are now just entering teleop mode from
// either a different mode or from power-on
if (!m_teleopInitialized) {
lw.SetEnabled(false);
lw->SetEnabled(false);
TeleopInit();
m_teleopInitialized = true;
// reset the initialization flags for the other modes
m_disabledInitialized = false;
m_autonomousInitialized = false;
m_testInitialized = false;
Scheduler::GetInstance().SetEnabled(true);
Scheduler::GetInstance()->SetEnabled(true);
}
HALNetworkCommunicationObserveUserProgramTeleop();
TeleopPeriodic();

View File

@@ -30,7 +30,7 @@ Jaguar::Jaguar(uint32_t channel) : SafePWM(channel) {
SetZeroLatch();
HALReport(HALUsageReporting::kResourceType_Jaguar, GetChannel());
LiveWindow::GetInstance().AddActuator("Jaguar", GetChannel(), this);
LiveWindow::GetInstance()->AddActuator("Jaguar", GetChannel(), this);
}
/**

View File

@@ -62,7 +62,7 @@ Relay::Relay(uint32_t channel, Relay::Direction direction)
setRelayReverse(m_relay_ports[m_channel], false, &status);
wpi_setErrorWithContext(status, getHALErrorMessage(status));
LiveWindow::GetInstance().AddActuator("Relay", 1, m_channel, this);
LiveWindow::GetInstance()->AddActuator("Relay", 1, m_channel, this);
}
/**

View File

@@ -101,7 +101,7 @@ void SampleRobot::RobotMain() { m_robotMainOverridden = false; }
* robot to be enabled again.
*/
void SampleRobot::StartCompetition() {
LiveWindow &lw = LiveWindow::GetInstance();
LiveWindow *lw = LiveWindow::GetInstance();
HALReport(HALUsageReporting::kResourceType_Framework,
HALUsageReporting::kFramework_Simple);
@@ -115,7 +115,7 @@ void SampleRobot::StartCompetition() {
if (!m_robotMainOverridden) {
// first and one-time initialization
lw.SetEnabled(false);
lw->SetEnabled(false);
RobotInit();
while (true) {
@@ -130,12 +130,12 @@ void SampleRobot::StartCompetition() {
m_ds.InAutonomous(false);
while (IsAutonomous() && IsEnabled()) m_ds.WaitForData();
} else if (IsTest()) {
lw.SetEnabled(true);
lw->SetEnabled(true);
m_ds.InTest(true);
Test();
m_ds.InTest(false);
while (IsTest() && IsEnabled()) m_ds.WaitForData();
lw.SetEnabled(false);
lw->SetEnabled(false);
} else {
m_ds.InOperatorControl(true);
OperatorControl();

View File

@@ -48,7 +48,7 @@ Solenoid::Solenoid(uint8_t moduleNumber, uint32_t channel)
return;
}
LiveWindow::GetInstance().AddActuator("Solenoid", m_moduleNumber, m_channel,
LiveWindow::GetInstance()->AddActuator("Solenoid", m_moduleNumber, m_channel,
this);
HALReport(HALUsageReporting::kResourceType_Solenoid, m_channel,
m_moduleNumber);

View File

@@ -35,7 +35,7 @@ Talon::Talon(uint32_t channel) : SafePWM(channel) {
SetZeroLatch();
HALReport(HALUsageReporting::kResourceType_Talon, GetChannel());
LiveWindow::GetInstance().AddActuator("Talon", GetChannel(), this);
LiveWindow::GetInstance()->AddActuator("Talon", GetChannel(), this);
}
/**

View File

@@ -34,7 +34,7 @@ TalonSRX::TalonSRX(uint32_t channel) : SafePWM(channel) {
SetZeroLatch();
HALReport(HALUsageReporting::kResourceType_TalonSRX, GetChannel());
LiveWindow::GetInstance().AddActuator("TalonSRX", GetChannel(), this);
LiveWindow::GetInstance()->AddActuator("TalonSRX", GetChannel(), this);
}
/**

View File

@@ -81,7 +81,7 @@ void Ultrasonic::Initialize() {
static int instances = 0;
instances++;
HALReport(HALUsageReporting::kResourceType_Ultrasonic, instances);
LiveWindow::GetInstance().AddSensor("Ultrasonic",
LiveWindow::GetInstance()->AddSensor("Ultrasonic",
m_echoChannel->GetChannel(), this);
}
@@ -305,7 +305,7 @@ double Ultrasonic::GetRangeMM() const { return GetRangeInches() * 25.4; }
*
* @return The range in DistanceUnit
*/
double Ultrasonic::PIDGet() const {
double Ultrasonic::PIDGet() {
switch (m_units) {
case Ultrasonic::kInches:
return GetRangeInches();

View File

@@ -35,7 +35,7 @@ Victor::Victor(uint32_t channel) : SafePWM(channel) {
SetRaw(m_centerPwm);
SetZeroLatch();
LiveWindow::GetInstance().AddActuator("Victor", GetChannel(), this);
LiveWindow::GetInstance()->AddActuator("Victor", GetChannel(), this);
HALReport(HALUsageReporting::kResourceType_Victor, GetChannel());
}

View File

@@ -39,7 +39,7 @@ VictorSP::VictorSP(uint32_t channel) : SafePWM(channel) {
SetZeroLatch();
HALReport(HALUsageReporting::kResourceType_VictorSP, GetChannel());
LiveWindow::GetInstance().AddActuator("VictorSP", GetChannel(), this);
LiveWindow::GetInstance()->AddActuator("VictorSP", GetChannel(), this);
}
/**

View File

@@ -30,7 +30,7 @@ class TestEnvironment : public testing::Environment {
station returns that the robot is enabled, to ensure that tests
will be able to run on the hardware. */
HALNetworkCommunicationObserveUserProgramStarting();
LiveWindow::GetInstance().SetEnabled(false);
LiveWindow::GetInstance()->SetEnabled(false);
std::cout << "Waiting for enable" << std::endl;

View File

@@ -18,7 +18,7 @@ class CommandTest : public testing::Test {
protected:
virtual void SetUp() override {
RobotState::SetImplementation(DriverStation::GetInstance());
Scheduler::GetInstance().SetEnabled(true);
Scheduler::GetInstance()->SetEnabled(true);
}
/**
@@ -30,7 +30,7 @@ class CommandTest : public testing::Test {
* is called outside of the
* scope of the test.
*/
void TeardownScheduler() { Scheduler::GetInstance().ResetAll(); }
void TeardownScheduler() { Scheduler::GetInstance()->ResetAll(); }
void AssertCommandState(MockCommand &command, int initialize, int execute,
int isFinished, int end, int interrupted) {
@@ -72,24 +72,24 @@ TEST_F(CommandTest, ParallelCommands) {
commandGroup.Start();
AssertCommandState(command1, 0, 0, 0, 0, 0);
AssertCommandState(command2, 0, 0, 0, 0, 0);
Scheduler::GetInstance().Run();
Scheduler::GetInstance()->Run();
AssertCommandState(command1, 0, 0, 0, 0, 0);
AssertCommandState(command2, 0, 0, 0, 0, 0);
Scheduler::GetInstance().Run();
Scheduler::GetInstance()->Run();
AssertCommandState(command1, 1, 1, 1, 0, 0);
AssertCommandState(command2, 1, 1, 1, 0, 0);
Scheduler::GetInstance().Run();
Scheduler::GetInstance()->Run();
AssertCommandState(command1, 1, 2, 2, 0, 0);
AssertCommandState(command2, 1, 2, 2, 0, 0);
command1.SetHasFinished(true);
Scheduler::GetInstance().Run();
Scheduler::GetInstance()->Run();
AssertCommandState(command1, 1, 3, 3, 1, 0);
AssertCommandState(command2, 1, 3, 3, 0, 0);
Scheduler::GetInstance().Run();
Scheduler::GetInstance()->Run();
AssertCommandState(command1, 1, 3, 3, 1, 0);
AssertCommandState(command2, 1, 4, 4, 0, 0);
command2.SetHasFinished(true);
Scheduler::GetInstance().Run();
Scheduler::GetInstance()->Run();
AssertCommandState(command1, 1, 3, 3, 1, 0);
AssertCommandState(command2, 1, 5, 5, 1, 0);
@@ -102,17 +102,17 @@ TEST_F(CommandTest, RunAndTerminate) {
MockCommand command;
command.Start();
AssertCommandState(command, 0, 0, 0, 0, 0);
Scheduler::GetInstance().Run();
Scheduler::GetInstance()->Run();
AssertCommandState(command, 0, 0, 0, 0, 0);
Scheduler::GetInstance().Run();
Scheduler::GetInstance()->Run();
AssertCommandState(command, 1, 1, 1, 0, 0);
Scheduler::GetInstance().Run();
Scheduler::GetInstance()->Run();
AssertCommandState(command, 1, 2, 2, 0, 0);
command.SetHasFinished(true);
AssertCommandState(command, 1, 2, 2, 0, 0);
Scheduler::GetInstance().Run();
Scheduler::GetInstance()->Run();
AssertCommandState(command, 1, 3, 3, 1, 0);
Scheduler::GetInstance().Run();
Scheduler::GetInstance()->Run();
AssertCommandState(command, 1, 3, 3, 1, 0);
TeardownScheduler();
@@ -122,19 +122,19 @@ TEST_F(CommandTest, RunAndCancel) {
MockCommand command;
command.Start();
AssertCommandState(command, 0, 0, 0, 0, 0);
Scheduler::GetInstance().Run();
Scheduler::GetInstance()->Run();
AssertCommandState(command, 0, 0, 0, 0, 0);
Scheduler::GetInstance().Run();
Scheduler::GetInstance()->Run();
AssertCommandState(command, 1, 1, 1, 0, 0);
Scheduler::GetInstance().Run();
Scheduler::GetInstance()->Run();
AssertCommandState(command, 1, 2, 2, 0, 0);
Scheduler::GetInstance().Run();
Scheduler::GetInstance()->Run();
AssertCommandState(command, 1, 3, 3, 0, 0);
command.Cancel();
AssertCommandState(command, 1, 3, 3, 0, 0);
Scheduler::GetInstance().Run();
Scheduler::GetInstance()->Run();
AssertCommandState(command, 1, 3, 3, 0, 1);
Scheduler::GetInstance().Run();
Scheduler::GetInstance()->Run();
AssertCommandState(command, 1, 3, 3, 0, 1);
TeardownScheduler();
@@ -165,34 +165,34 @@ TEST_F(CommandTest, ThreeCommandOnSubSystem) {
AssertCommandState(command2, 0, 0, 0, 0, 0);
AssertCommandState(command3, 0, 0, 0, 0, 0);
Scheduler::GetInstance().Run();
Scheduler::GetInstance()->Run();
AssertCommandState(command1, 0, 0, 0, 0, 0);
AssertCommandState(command2, 0, 0, 0, 0, 0);
AssertCommandState(command3, 0, 0, 0, 0, 0);
Scheduler::GetInstance().Run();
Scheduler::GetInstance()->Run();
AssertCommandState(command1, 1, 1, 1, 0, 0);
AssertCommandState(command2, 0, 0, 0, 0, 0);
AssertCommandState(command3, 0, 0, 0, 0, 0);
Wait(1); // command 1 timeout
Scheduler::GetInstance().Run();
Scheduler::GetInstance()->Run();
AssertCommandState(command1, 1, 1, 1, 0, 1);
AssertCommandState(command2, 1, 1, 1, 0, 0);
AssertCommandState(command3, 0, 0, 0, 0, 0);
Scheduler::GetInstance().Run();
Scheduler::GetInstance()->Run();
AssertCommandState(command1, 1, 1, 1, 0, 1);
AssertCommandState(command2, 1, 2, 2, 0, 0);
AssertCommandState(command3, 0, 0, 0, 0, 0);
Wait(2); // command 2 timeout
Scheduler::GetInstance().Run();
Scheduler::GetInstance()->Run();
AssertCommandState(command1, 1, 1, 1, 0, 1);
AssertCommandState(command2, 1, 2, 2, 0, 1);
AssertCommandState(command3, 1, 1, 1, 0, 0);
Scheduler::GetInstance().Run();
Scheduler::GetInstance()->Run();
AssertCommandState(command1, 1, 1, 1, 0, 1);
AssertCommandState(command2, 1, 2, 2, 0, 1);
AssertCommandState(command3, 1, 2, 2, 0, 0);
@@ -201,12 +201,12 @@ TEST_F(CommandTest, ThreeCommandOnSubSystem) {
AssertCommandState(command2, 1, 2, 2, 0, 1);
AssertCommandState(command3, 1, 2, 2, 0, 0);
Scheduler::GetInstance().Run();
Scheduler::GetInstance()->Run();
AssertCommandState(command1, 1, 1, 1, 0, 1);
AssertCommandState(command2, 1, 2, 2, 0, 1);
AssertCommandState(command3, 1, 3, 3, 1, 0);
Scheduler::GetInstance().Run();
Scheduler::GetInstance()->Run();
AssertCommandState(command1, 1, 1, 1, 0, 1);
AssertCommandState(command2, 1, 2, 2, 0, 1);
AssertCommandState(command3, 1, 3, 3, 1, 0);
@@ -230,19 +230,19 @@ TEST_F(CommandTest, OneCommandSupersedingAnotherBecauseOfDependencies) {
AssertCommandState(command1, 0, 0, 0, 0, 0);
AssertCommandState(command2, 0, 0, 0, 0, 0);
Scheduler::GetInstance().Run();
Scheduler::GetInstance()->Run();
AssertCommandState(command1, 0, 0, 0, 0, 0);
AssertCommandState(command2, 0, 0, 0, 0, 0);
Scheduler::GetInstance().Run();
Scheduler::GetInstance()->Run();
AssertCommandState(command1, 1, 1, 1, 0, 0);
AssertCommandState(command2, 0, 0, 0, 0, 0);
Scheduler::GetInstance().Run();
Scheduler::GetInstance()->Run();
AssertCommandState(command1, 1, 2, 2, 0, 0);
AssertCommandState(command2, 0, 0, 0, 0, 0);
Scheduler::GetInstance().Run();
Scheduler::GetInstance()->Run();
AssertCommandState(command1, 1, 3, 3, 0, 0);
AssertCommandState(command2, 0, 0, 0, 0, 0);
@@ -250,19 +250,19 @@ TEST_F(CommandTest, OneCommandSupersedingAnotherBecauseOfDependencies) {
AssertCommandState(command1, 1, 3, 3, 0, 0);
AssertCommandState(command2, 0, 0, 0, 0, 0);
Scheduler::GetInstance().Run();
Scheduler::GetInstance()->Run();
AssertCommandState(command1, 1, 4, 4, 0, 1);
AssertCommandState(command2, 0, 0, 0, 0, 0);
Scheduler::GetInstance().Run();
Scheduler::GetInstance()->Run();
AssertCommandState(command1, 1, 4, 4, 0, 1);
AssertCommandState(command2, 1, 1, 1, 0, 0);
Scheduler::GetInstance().Run();
Scheduler::GetInstance()->Run();
AssertCommandState(command1, 1, 4, 4, 0, 1);
AssertCommandState(command2, 1, 2, 2, 0, 0);
Scheduler::GetInstance().Run();
Scheduler::GetInstance()->Run();
AssertCommandState(command1, 1, 4, 4, 0, 1);
AssertCommandState(command2, 1, 3, 3, 0, 0);
@@ -287,19 +287,19 @@ TEST_F(CommandTest,
AssertCommandState(command1, 0, 0, 0, 0, 0);
AssertCommandState(command2, 0, 0, 0, 0, 0);
Scheduler::GetInstance().Run();
Scheduler::GetInstance()->Run();
AssertCommandState(command1, 0, 0, 0, 0, 0);
AssertCommandState(command2, 0, 0, 0, 0, 0);
Scheduler::GetInstance().Run();
Scheduler::GetInstance()->Run();
AssertCommandState(command1, 1, 1, 1, 0, 0);
AssertCommandState(command2, 0, 0, 0, 0, 0);
Scheduler::GetInstance().Run();
Scheduler::GetInstance()->Run();
AssertCommandState(command1, 1, 2, 2, 0, 0);
AssertCommandState(command2, 0, 0, 0, 0, 0);
Scheduler::GetInstance().Run();
Scheduler::GetInstance()->Run();
AssertCommandState(command1, 1, 3, 3, 0, 0);
AssertCommandState(command2, 0, 0, 0, 0, 0);
@@ -307,7 +307,7 @@ TEST_F(CommandTest,
AssertCommandState(command1, 1, 3, 3, 0, 0);
AssertCommandState(command2, 0, 0, 0, 0, 0);
Scheduler::GetInstance().Run();
Scheduler::GetInstance()->Run();
AssertCommandState(command1, 1, 4, 4, 0, 0);
AssertCommandState(command2, 0, 0, 0, 0, 0);
@@ -331,18 +331,18 @@ TEST_F(CommandTest, TwoSecondTimeout) {
command.Start();
AssertCommandState(command, 0, 0, 0, 0, 0);
Scheduler::GetInstance().Run();
Scheduler::GetInstance()->Run();
AssertCommandState(command, 0, 0, 0, 0, 0);
Scheduler::GetInstance().Run();
Scheduler::GetInstance()->Run();
AssertCommandState(command, 1, 1, 1, 0, 0);
Scheduler::GetInstance().Run();
Scheduler::GetInstance()->Run();
AssertCommandState(command, 1, 2, 2, 0, 0);
Scheduler::GetInstance().Run();
Scheduler::GetInstance()->Run();
AssertCommandState(command, 1, 3, 3, 0, 0);
Wait(2);
Scheduler::GetInstance().Run();
Scheduler::GetInstance()->Run();
AssertCommandState(command, 1, 4, 4, 1, 0);
Scheduler::GetInstance().Run();
Scheduler::GetInstance()->Run();
AssertCommandState(command, 1, 4, 4, 1, 0);
TeardownScheduler();
@@ -359,35 +359,35 @@ TEST_F(CommandTest, DefaultCommandWhereTheInteruptingCommandEndsItself) {
subsystem.Init(&defaultCommand);
AssertCommandState(defaultCommand, 0, 0, 0, 0, 0);
Scheduler::GetInstance().Run();
Scheduler::GetInstance()->Run();
AssertCommandState(defaultCommand, 0, 0, 0, 0, 0);
Scheduler::GetInstance().Run();
Scheduler::GetInstance()->Run();
AssertCommandState(defaultCommand, 1, 1, 1, 0, 0);
Scheduler::GetInstance().Run();
Scheduler::GetInstance()->Run();
AssertCommandState(defaultCommand, 1, 2, 2, 0, 0);
anotherCommand.Start();
AssertCommandState(defaultCommand, 1, 2, 2, 0, 0);
AssertCommandState(anotherCommand, 0, 0, 0, 0, 0);
Scheduler::GetInstance().Run();
Scheduler::GetInstance()->Run();
AssertCommandState(defaultCommand, 1, 3, 3, 0, 1);
AssertCommandState(anotherCommand, 0, 0, 0, 0, 0);
Scheduler::GetInstance().Run();
Scheduler::GetInstance()->Run();
AssertCommandState(defaultCommand, 1, 3, 3, 0, 1);
AssertCommandState(anotherCommand, 1, 1, 1, 0, 0);
Scheduler::GetInstance().Run();
Scheduler::GetInstance()->Run();
AssertCommandState(defaultCommand, 1, 3, 3, 0, 1);
AssertCommandState(anotherCommand, 1, 2, 2, 0, 0);
anotherCommand.SetHasFinished(true);
AssertCommandState(defaultCommand, 1, 3, 3, 0, 1);
AssertCommandState(anotherCommand, 1, 2, 2, 0, 0);
Scheduler::GetInstance().Run();
Scheduler::GetInstance()->Run();
AssertCommandState(defaultCommand, 1, 3, 3, 0, 1);
AssertCommandState(anotherCommand, 1, 3, 3, 1, 0);
Scheduler::GetInstance().Run();
Scheduler::GetInstance()->Run();
AssertCommandState(defaultCommand, 2, 4, 4, 0, 1);
AssertCommandState(anotherCommand, 1, 3, 3, 1, 0);
Scheduler::GetInstance().Run();
Scheduler::GetInstance()->Run();
AssertCommandState(defaultCommand, 2, 5, 5, 0, 1);
AssertCommandState(anotherCommand, 1, 3, 3, 1, 0);
@@ -405,35 +405,35 @@ TEST_F(CommandTest, DefaultCommandsInterruptingCommandCanceled) {
subsystem.Init(&defaultCommand);
subsystem.InitDefaultCommand();
AssertCommandState(defaultCommand, 0, 0, 0, 0, 0);
Scheduler::GetInstance().Run();
Scheduler::GetInstance()->Run();
AssertCommandState(defaultCommand, 0, 0, 0, 0, 0);
Scheduler::GetInstance().Run();
Scheduler::GetInstance()->Run();
AssertCommandState(defaultCommand, 1, 1, 1, 0, 0);
Scheduler::GetInstance().Run();
Scheduler::GetInstance()->Run();
AssertCommandState(defaultCommand, 1, 2, 2, 0, 0);
anotherCommand.Start();
AssertCommandState(defaultCommand, 1, 2, 2, 0, 0);
AssertCommandState(anotherCommand, 0, 0, 0, 0, 0);
Scheduler::GetInstance().Run();
Scheduler::GetInstance()->Run();
AssertCommandState(defaultCommand, 1, 3, 3, 0, 1);
AssertCommandState(anotherCommand, 0, 0, 0, 0, 0);
Scheduler::GetInstance().Run();
Scheduler::GetInstance()->Run();
AssertCommandState(defaultCommand, 1, 3, 3, 0, 1);
AssertCommandState(anotherCommand, 1, 1, 1, 0, 0);
Scheduler::GetInstance().Run();
Scheduler::GetInstance()->Run();
AssertCommandState(defaultCommand, 1, 3, 3, 0, 1);
AssertCommandState(anotherCommand, 1, 2, 2, 0, 0);
anotherCommand.Cancel();
AssertCommandState(defaultCommand, 1, 3, 3, 0, 1);
AssertCommandState(anotherCommand, 1, 2, 2, 0, 0);
Scheduler::GetInstance().Run();
Scheduler::GetInstance()->Run();
AssertCommandState(defaultCommand, 1, 3, 3, 0, 1);
AssertCommandState(anotherCommand, 1, 2, 2, 0, 1);
Scheduler::GetInstance().Run();
Scheduler::GetInstance()->Run();
AssertCommandState(defaultCommand, 2, 4, 4, 0, 1);
AssertCommandState(anotherCommand, 1, 2, 2, 0, 1);
Scheduler::GetInstance().Run();
Scheduler::GetInstance()->Run();
AssertCommandState(defaultCommand, 2, 5, 5, 0, 1);
AssertCommandState(anotherCommand, 1, 2, 2, 0, 1);

View File

@@ -37,7 +37,7 @@ public:
uint32_t GetChannel() const;
double PIDGet() const override;
double PIDGet() override;
void UpdateTable() override;
void StartLiveWindowMode() override;

View File

@@ -51,7 +51,7 @@ public:
*
* @return The current reading.
*/
virtual double PIDGet() const override;
virtual double PIDGet() override;
/*

View File

@@ -54,7 +54,7 @@ public:
void SetSamplesToAverage(int samplesToAverage);
int GetSamplesToAverage() const;
void SetPIDSourceType(PIDSourceType pidSource);
double PIDGet() const override;
double PIDGet() override;
void UpdateTable() override;
void StartLiveWindowMode() override;

View File

@@ -42,7 +42,7 @@ public:
// PIDSource interface
void SetPIDSourceType(PIDSourceType pidSource) override;
double PIDGet() const override;
double PIDGet() override;
void UpdateTable() override;
void StartLiveWindowMode() override;

View File

@@ -20,7 +20,7 @@ AnalogInput::AnalogInput(uint32_t channel)
int n = sprintf(buffer, "analog/%d", channel);
m_impl = new SimFloatInput(buffer);
LiveWindow::GetInstance().AddSensor("AnalogInput", channel, this);
LiveWindow::GetInstance()->AddSensor("AnalogInput", channel, this);
}
/**
@@ -59,7 +59,7 @@ uint32_t AnalogInput::GetChannel() const
*
* @return The average voltage.
*/
double AnalogInput::PIDGet() const
double AnalogInput::PIDGet()
{
return GetAverageVoltage();
}

View File

@@ -46,7 +46,7 @@ double AnalogPotentiometer::Get() const {
*
* @return The current reading.
*/
double AnalogPotentiometer::PIDGet() const {
double AnalogPotentiometer::PIDGet() {
return Get();
}

View File

@@ -39,7 +39,7 @@ DoubleSolenoid::DoubleSolenoid(uint8_t moduleNumber, uint32_t forwardChannel, ui
forwardChannel, moduleNumber, reverseChannel);
m_impl = new SimContinuousOutput(buffer);
LiveWindow::GetInstance().AddActuator("DoubleSolenoid", moduleNumber,
LiveWindow::GetInstance()->AddActuator("DoubleSolenoid", moduleNumber,
forwardChannel, this);
}

View File

@@ -35,7 +35,7 @@ void Encoder::InitEncoder(int channelA, int channelB, bool reverseDirection, Enc
int32_t index = 0;
m_distancePerPulse = 1.0;
LiveWindow::GetInstance().AddSensor("Encoder", channelA, this);
LiveWindow::GetInstance()->AddSensor("Encoder", channelA, this);
if (channelB < channelA) { // Swap ports
int channel = channelB;
@@ -318,7 +318,7 @@ void Encoder::SetPIDSourceType(PIDSourceType pidSource)
*
* @return The current value of the selected source parameter.
*/
double Encoder::PIDGet() const
double Encoder::PIDGet()
{
switch (m_pidSource)
{

View File

@@ -31,7 +31,7 @@ void Gyro::InitGyro(int channel)
int n = sprintf(buffer, "analog/%d", channel);
impl = new SimGyro(buffer);
LiveWindow::GetInstance().AddSensor("Gyro", channel, this);
LiveWindow::GetInstance()->AddSensor("Gyro", channel, this);
}
/**
@@ -93,7 +93,7 @@ void Gyro::SetPIDSourceType(PIDSourceType pidSource)
*
* @return The angle in degrees.
*/
double Gyro::PIDGet() const
double Gyro::PIDGet()
{
switch(GetPIDSourceType()){
case PIDSourceType::kRate:

View File

@@ -71,14 +71,14 @@ double IterativeRobot::GetLoopsPerSec()
*/
void IterativeRobot::StartCompetition()
{
LiveWindow &lw = LiveWindow::GetInstance();
LiveWindow *lw = LiveWindow::GetInstance();
// first and one-time initialization
SmartDashboard::init();
NetworkTable::GetTable("LiveWindow")->GetSubTable("~STATUS~")->PutBoolean("LW Enabled", false);
RobotInit();
// loop forever, calling the appropriate mode-dependent function
lw.SetEnabled(false);
lw->SetEnabled(false);
while (true)
{
// Call the appropriate function depending upon the current robot mode
@@ -88,7 +88,7 @@ void IterativeRobot::StartCompetition()
// either a different mode or from power-on
if(!m_disabledInitialized)
{
lw.SetEnabled(false);
lw->SetEnabled(false);
DisabledInit();
m_disabledInitialized = true;
// reset the initialization flags for the other modes
@@ -108,7 +108,7 @@ void IterativeRobot::StartCompetition()
// either a different mode or from power-on
if(!m_autonomousInitialized)
{
lw.SetEnabled(false);
lw->SetEnabled(false);
AutonomousInit();
m_autonomousInitialized = true;
// reset the initialization flags for the other modes
@@ -128,7 +128,7 @@ void IterativeRobot::StartCompetition()
// either a different mode or from power-on
if(!m_testInitialized)
{
lw.SetEnabled(true);
lw->SetEnabled(true);
TestInit();
m_testInitialized = true;
// reset the initialization flags for the other modes
@@ -148,14 +148,14 @@ void IterativeRobot::StartCompetition()
// either a different mode or from power-on
if(!m_teleopInitialized)
{
lw.SetEnabled(false);
lw->SetEnabled(false);
TeleopInit();
m_teleopInitialized = true;
// reset the initialization flags for the other modes
m_disabledInitialized = false;
m_autonomousInitialized = false;
m_testInitialized = false;
Scheduler::GetInstance().SetEnabled(true);
Scheduler::GetInstance()->SetEnabled(true);
}
if (NextPeriodReady())
{

View File

@@ -27,7 +27,7 @@ Jaguar::Jaguar(uint32_t channel) : SafePWM(channel)
SetPeriodMultiplier(kPeriodMultiplier_1X);
SetRaw(m_centerPwm);
LiveWindow::GetInstance().AddActuator("Jaguar", GetChannel(), this);
LiveWindow::GetInstance()->AddActuator("Jaguar", GetChannel(), this);
}
/**

View File

@@ -32,7 +32,7 @@ Relay::Relay(uint32_t channel, Relay::Direction direction)
sprintf(buf, "relay/%d", m_channel);
impl = new SimContinuousOutput(buf); // TODO: Allow two different relays (targetting the different halves of a relay) to be combined to control one motor.
LiveWindow::GetInstance().AddActuator("Relay", 1, m_channel, this);
LiveWindow::GetInstance()->AddActuator("Relay", 1, m_channel, this);
go_pos = go_neg = false;
}

View File

@@ -107,7 +107,7 @@ void SampleRobot::RobotMain()
*/
void SampleRobot::StartCompetition()
{
LiveWindow &lw = LiveWindow::GetInstance();
LiveWindow *lw = LiveWindow::GetInstance();
SmartDashboard::init();
NetworkTable::GetTable("LiveWindow")->GetSubTable("~STATUS~")->PutBoolean("LW Enabled", false);
@@ -117,7 +117,7 @@ void SampleRobot::StartCompetition()
if (!m_robotMainOverridden)
{
// first and one-time initialization
lw.SetEnabled(false);
lw->SetEnabled(false);
RobotInit();
while (true)
@@ -138,12 +138,12 @@ void SampleRobot::StartCompetition()
}
else if (IsTest())
{
lw.SetEnabled(true);
lw->SetEnabled(true);
m_ds.InTest(true);
Test();
m_ds.InTest(false);
while (IsTest() && IsEnabled()) sleep(1); //m_ds.WaitForData();
lw.SetEnabled(false);
while (IsTest() && IsEnabled()) sleep(1); //m_ds.WaitForData();
lw->SetEnabled(false);
}
else
{

View File

@@ -28,7 +28,7 @@ Solenoid::Solenoid(uint8_t moduleNumber, uint32_t channel)
int n = sprintf(buffer, "pneumatic/%d/%d", moduleNumber, channel);
m_impl = new SimContinuousOutput(buffer);
LiveWindow::GetInstance().AddActuator("Solenoid", moduleNumber, channel,
LiveWindow::GetInstance()->AddActuator("Solenoid", moduleNumber, channel,
this);
}

View File

@@ -31,7 +31,7 @@ Talon::Talon(uint32_t channel) : SafePWM(channel)
SetPeriodMultiplier(kPeriodMultiplier_2X);
SetRaw(m_centerPwm);
LiveWindow::GetInstance().AddActuator("Talon", GetChannel(), this);
LiveWindow::GetInstance()->AddActuator("Talon", GetChannel(), this);
}
/**

View File

@@ -33,7 +33,7 @@ Victor::Victor(uint32_t channel) : SafePWM(channel)
SetPeriodMultiplier(kPeriodMultiplier_2X);
SetRaw(m_centerPwm);
LiveWindow::GetInstance().AddActuator("Victor", GetChannel(), this);
LiveWindow::GetInstance()->AddActuator("Victor", GetChannel(), this);
}
/**