mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-06 03:31:43 +00:00
Fixes warnings thrown by cpplint.py (#154)
* Fixed cpplint.py [runtime/int] warnings * Fixed cpplint.py [readability/casting] warnings * Fixed cpplint.py [readability/namespace] warnings * Fixed cpplint.py [readability/braces] warnings * Fixed cpplint.py [whitespace/braces] warnings * Fixed cpplint.py [runtime/explicit] warnings * Fixed cpplint.py [runtime/printf] warnings * Fixed cpplint.py [readability/inheritance] warnings * Fixed cpplint.py [whitespace/tab] warnings * Fixed cpplint.py [build/storage_class] warnings * Fixed cpplint.py [readability/multiline_comment] warnings * Fixed cpplint.py [whitespace/semicolon] warnings * Fixed cpplint.py [readability/check] warnings * Fixed cpplint.py [runtime/arrays] warnings * Ran format.py
This commit is contained in:
committed by
Peter Johnson
parent
e44a6e227a
commit
0cb288ffba
@@ -59,20 +59,20 @@ class ADXL345_I2C : public Accelerometer, public LiveWindowSendable {
|
||||
ADXL345_I2C& operator=(const ADXL345_I2C&) = delete;
|
||||
|
||||
// Accelerometer interface
|
||||
virtual void SetRange(Range range) override;
|
||||
virtual double GetX() override;
|
||||
virtual double GetY() override;
|
||||
virtual double GetZ() override;
|
||||
void SetRange(Range range) override;
|
||||
double GetX() override;
|
||||
double GetY() override;
|
||||
double GetZ() override;
|
||||
|
||||
virtual double GetAcceleration(Axes axis);
|
||||
virtual AllAxes GetAccelerations();
|
||||
|
||||
virtual std::string GetSmartDashboardType() const override;
|
||||
virtual void InitTable(std::shared_ptr<ITable> subtable) override;
|
||||
virtual void UpdateTable() override;
|
||||
virtual std::shared_ptr<ITable> GetTable() const override;
|
||||
virtual void StartLiveWindowMode() override {}
|
||||
virtual void StopLiveWindowMode() override {}
|
||||
std::string GetSmartDashboardType() const override;
|
||||
void InitTable(std::shared_ptr<ITable> subtable) override;
|
||||
void UpdateTable() override;
|
||||
std::shared_ptr<ITable> GetTable() const override;
|
||||
void StartLiveWindowMode() override {}
|
||||
void StopLiveWindowMode() override {}
|
||||
|
||||
protected:
|
||||
I2C m_i2c;
|
||||
|
||||
@@ -54,27 +54,27 @@ class ADXL345_SPI : public Accelerometer, public LiveWindowSendable {
|
||||
};
|
||||
|
||||
public:
|
||||
ADXL345_SPI(SPI::Port port, Range range = kRange_2G);
|
||||
explicit ADXL345_SPI(SPI::Port port, Range range = kRange_2G);
|
||||
virtual ~ADXL345_SPI() = default;
|
||||
|
||||
ADXL345_SPI(const ADXL345_SPI&) = delete;
|
||||
ADXL345_SPI& operator=(const ADXL345_SPI&) = delete;
|
||||
|
||||
// Accelerometer interface
|
||||
virtual void SetRange(Range range) override;
|
||||
virtual double GetX() override;
|
||||
virtual double GetY() override;
|
||||
virtual double GetZ() override;
|
||||
void SetRange(Range range) override;
|
||||
double GetX() override;
|
||||
double GetY() override;
|
||||
double GetZ() override;
|
||||
|
||||
virtual double GetAcceleration(Axes axis);
|
||||
virtual AllAxes GetAccelerations();
|
||||
|
||||
virtual std::string GetSmartDashboardType() const override;
|
||||
virtual void InitTable(std::shared_ptr<ITable> subtable) override;
|
||||
virtual void UpdateTable() override;
|
||||
virtual std::shared_ptr<ITable> GetTable() const override;
|
||||
virtual void StartLiveWindowMode() override {}
|
||||
virtual void StopLiveWindowMode() override {}
|
||||
std::string GetSmartDashboardType() const override;
|
||||
void InitTable(std::shared_ptr<ITable> subtable) override;
|
||||
void UpdateTable() override;
|
||||
std::shared_ptr<ITable> GetTable() const override;
|
||||
void StartLiveWindowMode() override {}
|
||||
void StopLiveWindowMode() override {}
|
||||
|
||||
protected:
|
||||
SPI m_spi;
|
||||
|
||||
@@ -32,28 +32,28 @@ class ADXL362 : public Accelerometer, public LiveWindowSendable {
|
||||
};
|
||||
|
||||
public:
|
||||
ADXL362(Range range = kRange_2G);
|
||||
ADXL362(SPI::Port port, Range range = kRange_2G);
|
||||
explicit ADXL362(Range range = kRange_2G);
|
||||
explicit ADXL362(SPI::Port port, Range range = kRange_2G);
|
||||
virtual ~ADXL362() = default;
|
||||
|
||||
ADXL362(const ADXL362&) = delete;
|
||||
ADXL362& operator=(const ADXL362&) = delete;
|
||||
|
||||
// Accelerometer interface
|
||||
virtual void SetRange(Range range) override;
|
||||
virtual double GetX() override;
|
||||
virtual double GetY() override;
|
||||
virtual double GetZ() override;
|
||||
void SetRange(Range range) override;
|
||||
double GetX() override;
|
||||
double GetY() override;
|
||||
double GetZ() override;
|
||||
|
||||
virtual double GetAcceleration(Axes axis);
|
||||
virtual AllAxes GetAccelerations();
|
||||
|
||||
virtual std::string GetSmartDashboardType() const override;
|
||||
virtual void InitTable(std::shared_ptr<ITable> subtable) override;
|
||||
virtual void UpdateTable() override;
|
||||
virtual std::shared_ptr<ITable> GetTable() const override;
|
||||
virtual void StartLiveWindowMode() override {}
|
||||
virtual void StopLiveWindowMode() override {}
|
||||
std::string GetSmartDashboardType() const override;
|
||||
void InitTable(std::shared_ptr<ITable> subtable) override;
|
||||
void UpdateTable() override;
|
||||
std::shared_ptr<ITable> GetTable() const override;
|
||||
void StartLiveWindowMode() override {}
|
||||
void StopLiveWindowMode() override {}
|
||||
|
||||
private:
|
||||
SPI m_spi;
|
||||
|
||||
@@ -53,34 +53,34 @@ class AnalogPotentiometer : public Potentiometer, public LiveWindowSendable {
|
||||
*
|
||||
* @return The current position of the potentiometer.
|
||||
*/
|
||||
virtual double Get() const override;
|
||||
double Get() const override;
|
||||
|
||||
/**
|
||||
* Implement the PIDSource interface.
|
||||
*
|
||||
* @return The current reading.
|
||||
*/
|
||||
virtual double PIDGet() override;
|
||||
double PIDGet() override;
|
||||
|
||||
/*
|
||||
* Live Window code, only does anything if live window is activated.
|
||||
*/
|
||||
virtual std::string GetSmartDashboardType() const override;
|
||||
virtual void InitTable(std::shared_ptr<ITable> subtable) override;
|
||||
virtual void UpdateTable() override;
|
||||
virtual std::shared_ptr<ITable> GetTable() const override;
|
||||
std::string GetSmartDashboardType() const override;
|
||||
void InitTable(std::shared_ptr<ITable> subtable) override;
|
||||
void UpdateTable() override;
|
||||
std::shared_ptr<ITable> GetTable() const override;
|
||||
|
||||
/**
|
||||
* AnalogPotentiometers don't have to do anything special when entering the
|
||||
* LiveWindow.
|
||||
*/
|
||||
virtual void StartLiveWindowMode() override {}
|
||||
void StartLiveWindowMode() override {}
|
||||
|
||||
/**
|
||||
* AnalogPotentiometers don't have to do anything special when exiting the
|
||||
* LiveWindow.
|
||||
*/
|
||||
virtual void StopLiveWindowMode() override {}
|
||||
void StopLiveWindowMode() override {}
|
||||
|
||||
private:
|
||||
std::shared_ptr<AnalogInput> m_analog_input;
|
||||
|
||||
@@ -49,10 +49,10 @@ class AnalogTriggerOutput : public DigitalSource {
|
||||
bool Get() const;
|
||||
|
||||
// DigitalSource interface
|
||||
virtual HAL_Handle GetPortHandleForRouting() const override;
|
||||
virtual AnalogTriggerType GetAnalogTriggerTypeForRouting() const override;
|
||||
virtual bool IsAnalogTrigger() const override;
|
||||
virtual uint32_t GetChannel() const override;
|
||||
HAL_Handle GetPortHandleForRouting() const override;
|
||||
AnalogTriggerType GetAnalogTriggerTypeForRouting() const override;
|
||||
bool IsAnalogTrigger() const override;
|
||||
uint32_t GetChannel() const override;
|
||||
|
||||
protected:
|
||||
AnalogTriggerOutput(const AnalogTrigger& trigger,
|
||||
|
||||
@@ -12,4 +12,4 @@ enum class AnalogTriggerType {
|
||||
kState = 1,
|
||||
kRisingPulse = 2,
|
||||
kFallingPulse = 3
|
||||
};
|
||||
};
|
||||
|
||||
@@ -22,21 +22,21 @@ class BuiltInAccelerometer : public Accelerometer,
|
||||
public SensorBase,
|
||||
public LiveWindowSendable {
|
||||
public:
|
||||
BuiltInAccelerometer(Range range = kRange_8G);
|
||||
explicit BuiltInAccelerometer(Range range = kRange_8G);
|
||||
virtual ~BuiltInAccelerometer() = default;
|
||||
|
||||
// Accelerometer interface
|
||||
virtual void SetRange(Range range) override;
|
||||
virtual double GetX() override;
|
||||
virtual double GetY() override;
|
||||
virtual double GetZ() override;
|
||||
void SetRange(Range range) override;
|
||||
double GetX() override;
|
||||
double GetY() override;
|
||||
double GetZ() override;
|
||||
|
||||
virtual std::string GetSmartDashboardType() const override;
|
||||
virtual void InitTable(std::shared_ptr<ITable> subtable) override;
|
||||
virtual void UpdateTable() override;
|
||||
virtual std::shared_ptr<ITable> GetTable() const override;
|
||||
virtual void StartLiveWindowMode() override {}
|
||||
virtual void StopLiveWindowMode() override {}
|
||||
std::string GetSmartDashboardType() const override;
|
||||
void InitTable(std::shared_ptr<ITable> subtable) override;
|
||||
void UpdateTable() override;
|
||||
std::shared_ptr<ITable> GetTable() const override;
|
||||
void StartLiveWindowMode() override {}
|
||||
void StopLiveWindowMode() override {}
|
||||
|
||||
private:
|
||||
std::shared_ptr<ITable> m_table;
|
||||
|
||||
@@ -59,7 +59,7 @@ class CANJaguar : public MotorSafety,
|
||||
uint8_t GetHardwareVersion() const;
|
||||
|
||||
// PIDOutput interface
|
||||
virtual void PIDWrite(float output) override;
|
||||
void PIDWrite(float output) override;
|
||||
|
||||
// Control mode methods
|
||||
void EnableControl(double encoderInitialPosition = 0.0);
|
||||
@@ -94,39 +94,39 @@ class CANJaguar : public MotorSafety,
|
||||
void Set(float value, uint8_t syncGroup);
|
||||
|
||||
// CANSpeedController interface
|
||||
virtual float Get() const override;
|
||||
virtual void Set(float value) override;
|
||||
virtual void Disable() override;
|
||||
virtual void SetP(double p) override;
|
||||
virtual void SetI(double i) override;
|
||||
virtual void SetD(double d) override;
|
||||
virtual void SetPID(double p, double i, double d) override;
|
||||
virtual double GetP() const override;
|
||||
virtual double GetI() const override;
|
||||
virtual double GetD() const override;
|
||||
virtual bool IsModePID(CANSpeedController::ControlMode mode) const override;
|
||||
virtual float GetBusVoltage() const override;
|
||||
virtual float GetOutputVoltage() const override;
|
||||
virtual float GetOutputCurrent() const override;
|
||||
virtual float GetTemperature() const override;
|
||||
virtual double GetPosition() const override;
|
||||
virtual double GetSpeed() const override;
|
||||
virtual bool GetForwardLimitOK() const override;
|
||||
virtual bool GetReverseLimitOK() const override;
|
||||
virtual uint16_t GetFaults() const override;
|
||||
virtual void SetVoltageRampRate(double rampRate) override;
|
||||
virtual uint32_t GetFirmwareVersion() const override;
|
||||
virtual void ConfigNeutralMode(NeutralMode mode) override;
|
||||
virtual void ConfigEncoderCodesPerRev(uint16_t codesPerRev) override;
|
||||
virtual void ConfigPotentiometerTurns(uint16_t turns) override;
|
||||
virtual void ConfigSoftPositionLimits(double forwardLimitPosition,
|
||||
double reverseLimitPosition) override;
|
||||
virtual void DisableSoftPositionLimits() override;
|
||||
virtual void ConfigLimitMode(LimitMode mode) override;
|
||||
virtual void ConfigForwardLimit(double forwardLimitPosition) override;
|
||||
virtual void ConfigReverseLimit(double reverseLimitPosition) override;
|
||||
virtual void ConfigMaxOutputVoltage(double voltage) override;
|
||||
virtual void ConfigFaultTime(float faultTime) override;
|
||||
float Get() const override;
|
||||
void Set(float value) override;
|
||||
void Disable() override;
|
||||
void SetP(double p) override;
|
||||
void SetI(double i) override;
|
||||
void SetD(double d) override;
|
||||
void SetPID(double p, double i, double d) override;
|
||||
double GetP() const override;
|
||||
double GetI() const override;
|
||||
double GetD() const override;
|
||||
bool IsModePID(CANSpeedController::ControlMode mode) const override;
|
||||
float GetBusVoltage() const override;
|
||||
float GetOutputVoltage() const override;
|
||||
float GetOutputCurrent() const override;
|
||||
float GetTemperature() const override;
|
||||
double GetPosition() const override;
|
||||
double GetSpeed() const override;
|
||||
bool GetForwardLimitOK() const override;
|
||||
bool GetReverseLimitOK() const override;
|
||||
uint16_t GetFaults() const override;
|
||||
void SetVoltageRampRate(double rampRate) override;
|
||||
uint32_t GetFirmwareVersion() const override;
|
||||
void ConfigNeutralMode(NeutralMode mode) override;
|
||||
void ConfigEncoderCodesPerRev(uint16_t codesPerRev) override;
|
||||
void ConfigPotentiometerTurns(uint16_t turns) override;
|
||||
void ConfigSoftPositionLimits(double forwardLimitPosition,
|
||||
double reverseLimitPosition) override;
|
||||
void DisableSoftPositionLimits() override;
|
||||
void ConfigLimitMode(LimitMode mode) override;
|
||||
void ConfigForwardLimit(double forwardLimitPosition) override;
|
||||
void ConfigReverseLimit(double reverseLimitPosition) override;
|
||||
void ConfigMaxOutputVoltage(double voltage) override;
|
||||
void ConfigFaultTime(float faultTime) override;
|
||||
virtual void SetControlMode(ControlMode mode);
|
||||
virtual ControlMode GetControlMode() const;
|
||||
|
||||
@@ -142,8 +142,8 @@ class CANJaguar : public MotorSafety,
|
||||
uint8_t GetDeviceID() const;
|
||||
|
||||
// SpeedController overrides
|
||||
virtual void SetInverted(bool isInverted) override;
|
||||
virtual bool GetInverted() const override;
|
||||
void SetInverted(bool isInverted) override;
|
||||
bool GetInverted() const override;
|
||||
|
||||
protected:
|
||||
// Control mode helpers
|
||||
|
||||
@@ -226,47 +226,47 @@ class CANTalon : public MotorSafety,
|
||||
virtual ~CANTalon();
|
||||
|
||||
// PIDOutput interface
|
||||
virtual void PIDWrite(float output) override;
|
||||
void PIDWrite(float output) override;
|
||||
|
||||
// PIDSource interface
|
||||
virtual double PIDGet() override;
|
||||
double PIDGet() override;
|
||||
|
||||
// MotorSafety interface
|
||||
virtual void SetExpiration(float timeout) override;
|
||||
virtual float GetExpiration() const override;
|
||||
virtual bool IsAlive() const override;
|
||||
virtual void StopMotor() override;
|
||||
virtual void SetSafetyEnabled(bool enabled) override;
|
||||
virtual bool IsSafetyEnabled() const override;
|
||||
virtual void GetDescription(std::ostringstream& desc) const override;
|
||||
void SetExpiration(float timeout) override;
|
||||
float GetExpiration() const override;
|
||||
bool IsAlive() const override;
|
||||
void StopMotor() override;
|
||||
void SetSafetyEnabled(bool enabled) override;
|
||||
bool IsSafetyEnabled() const override;
|
||||
void GetDescription(std::ostringstream& desc) const override;
|
||||
|
||||
// CANSpeedController interface
|
||||
virtual float Get() const override;
|
||||
virtual void Set(float value) override;
|
||||
virtual void Reset() override;
|
||||
virtual void SetSetpoint(float value) override;
|
||||
virtual void Disable() override;
|
||||
float Get() const override;
|
||||
void Set(float value) override;
|
||||
void Reset() override;
|
||||
void SetSetpoint(float value) override;
|
||||
void Disable() override;
|
||||
virtual void EnableControl();
|
||||
virtual void Enable() override;
|
||||
virtual void SetP(double p) override;
|
||||
virtual void SetI(double i) override;
|
||||
virtual void SetD(double d) override;
|
||||
void Enable() override;
|
||||
void SetP(double p) override;
|
||||
void SetI(double i) override;
|
||||
void SetD(double d) override;
|
||||
void SetF(double f);
|
||||
void SetIzone(unsigned iz);
|
||||
virtual void SetPID(double p, double i, double d) override;
|
||||
void SetPID(double p, double i, double d) override;
|
||||
virtual void SetPID(double p, double i, double d, double f);
|
||||
virtual double GetP() const override;
|
||||
virtual double GetI() const override;
|
||||
virtual double GetD() const override;
|
||||
double GetP() const override;
|
||||
double GetI() const override;
|
||||
double GetD() const override;
|
||||
virtual double GetF() const;
|
||||
virtual bool IsModePID(CANSpeedController::ControlMode mode) const override;
|
||||
virtual float GetBusVoltage() const override;
|
||||
virtual float GetOutputVoltage() const override;
|
||||
virtual float GetOutputCurrent() const override;
|
||||
virtual float GetTemperature() const override;
|
||||
bool IsModePID(CANSpeedController::ControlMode mode) const override;
|
||||
float GetBusVoltage() const override;
|
||||
float GetOutputVoltage() const override;
|
||||
float GetOutputCurrent() const override;
|
||||
float GetTemperature() const override;
|
||||
void SetPosition(double pos);
|
||||
virtual double GetPosition() const override;
|
||||
virtual double GetSpeed() const override;
|
||||
double GetPosition() const override;
|
||||
double GetSpeed() const override;
|
||||
virtual int GetClosedLoopError() const;
|
||||
virtual void SetAllowableClosedLoopErr(uint32_t allowableCloseLoopError);
|
||||
virtual int GetAnalogIn() const;
|
||||
@@ -290,23 +290,23 @@ class CANTalon : public MotorSafety,
|
||||
virtual int GetPulseWidthRiseToRiseUs() const;
|
||||
virtual FeedbackDeviceStatus IsSensorPresent(
|
||||
FeedbackDevice feedbackDevice) const;
|
||||
virtual bool GetForwardLimitOK() const override;
|
||||
virtual bool GetReverseLimitOK() const override;
|
||||
virtual uint16_t GetFaults() const override;
|
||||
bool GetForwardLimitOK() const override;
|
||||
bool GetReverseLimitOK() const override;
|
||||
uint16_t GetFaults() const override;
|
||||
uint16_t GetStickyFaults() const;
|
||||
void ClearStickyFaults();
|
||||
virtual void SetVoltageRampRate(double rampRate) override;
|
||||
void SetVoltageRampRate(double rampRate) override;
|
||||
virtual void SetVoltageCompensationRampRate(double rampRate);
|
||||
virtual uint32_t GetFirmwareVersion() const override;
|
||||
virtual void ConfigNeutralMode(NeutralMode mode) override;
|
||||
virtual void ConfigEncoderCodesPerRev(uint16_t codesPerRev) override;
|
||||
virtual void ConfigPotentiometerTurns(uint16_t turns) override;
|
||||
virtual void ConfigSoftPositionLimits(double forwardLimitPosition,
|
||||
double reverseLimitPosition) override;
|
||||
virtual void DisableSoftPositionLimits() override;
|
||||
virtual void ConfigLimitMode(LimitMode mode) override;
|
||||
virtual void ConfigForwardLimit(double forwardLimitPosition) override;
|
||||
virtual void ConfigReverseLimit(double reverseLimitPosition) override;
|
||||
uint32_t GetFirmwareVersion() const override;
|
||||
void ConfigNeutralMode(NeutralMode mode) override;
|
||||
void ConfigEncoderCodesPerRev(uint16_t codesPerRev) override;
|
||||
void ConfigPotentiometerTurns(uint16_t turns) override;
|
||||
void ConfigSoftPositionLimits(double forwardLimitPosition,
|
||||
double reverseLimitPosition) override;
|
||||
void DisableSoftPositionLimits() override;
|
||||
void ConfigLimitMode(LimitMode mode) override;
|
||||
void ConfigForwardLimit(double forwardLimitPosition) override;
|
||||
void ConfigReverseLimit(double reverseLimitPosition) override;
|
||||
void ConfigLimitSwitchOverrides(bool bForwardLimitSwitchEn,
|
||||
bool bReverseLimitSwitchEn);
|
||||
void ConfigForwardSoftLimitEnable(bool bForwardSoftLimitEn);
|
||||
@@ -333,7 +333,7 @@ class CANTalon : public MotorSafety,
|
||||
* @param normallyOpen true for normally open. false for normally closed.
|
||||
*/
|
||||
void ConfigRevLimitSwitchNormallyOpen(bool normallyOpen);
|
||||
virtual void ConfigMaxOutputVoltage(double voltage) override;
|
||||
void ConfigMaxOutputVoltage(double voltage) override;
|
||||
void ConfigPeakOutputVoltage(double forwardVoltage, double reverseVoltage);
|
||||
void ConfigNominalOutputVoltage(double forwardVoltage, double reverseVoltage);
|
||||
/**
|
||||
@@ -349,7 +349,7 @@ class CANTalon : public MotorSafety,
|
||||
void ConfigSetParameter(uint32_t paramEnum, double value);
|
||||
bool GetParameter(uint32_t paramEnum, double& dvalue) const;
|
||||
|
||||
virtual void ConfigFaultTime(float faultTime) override;
|
||||
void ConfigFaultTime(float faultTime) override;
|
||||
virtual void SetControlMode(ControlMode mode);
|
||||
void SetFeedbackDevice(FeedbackDevice device);
|
||||
void SetStatusFrameRateMs(StatusFrameRate stateFrame, int periodMs);
|
||||
@@ -449,8 +449,8 @@ class CANTalon : public MotorSafety,
|
||||
std::shared_ptr<ITable> GetTable() const override;
|
||||
|
||||
// SpeedController overrides
|
||||
virtual void SetInverted(bool isInverted) override;
|
||||
virtual bool GetInverted() const override;
|
||||
void SetInverted(bool isInverted) override;
|
||||
bool GetInverted() const override;
|
||||
|
||||
private:
|
||||
// Values for various modes as is sent in the CAN packets for the Talon.
|
||||
|
||||
@@ -94,7 +94,7 @@ class Counter : public SensorBase,
|
||||
void UpdateTable() override;
|
||||
void StartLiveWindowMode() override;
|
||||
void StopLiveWindowMode() override;
|
||||
virtual std::string GetSmartDashboardType() const override;
|
||||
std::string GetSmartDashboardType() const override;
|
||||
void InitTable(std::shared_ptr<ITable> subTable) override;
|
||||
std::shared_ptr<ITable> GetTable() const override;
|
||||
|
||||
|
||||
@@ -32,9 +32,9 @@ class DigitalInput : public DigitalSource, public LiveWindowSendable {
|
||||
uint32_t GetChannel() const override;
|
||||
|
||||
// Digital Source Interface
|
||||
virtual HAL_Handle GetPortHandleForRouting() const override;
|
||||
virtual AnalogTriggerType GetAnalogTriggerTypeForRouting() const override;
|
||||
virtual bool IsAnalogTrigger() const override;
|
||||
HAL_Handle GetPortHandleForRouting() const override;
|
||||
AnalogTriggerType GetAnalogTriggerTypeForRouting() const override;
|
||||
bool IsAnalogTrigger() const override;
|
||||
|
||||
void UpdateTable();
|
||||
void StartLiveWindowMode();
|
||||
|
||||
@@ -36,12 +36,12 @@ class DigitalOutput : public DigitalSource,
|
||||
void UpdateDutyCycle(float dutyCycle);
|
||||
|
||||
// Digital Source Interface
|
||||
virtual HAL_Handle GetPortHandleForRouting() const override;
|
||||
virtual AnalogTriggerType GetAnalogTriggerTypeForRouting() const override;
|
||||
virtual bool IsAnalogTrigger() const override;
|
||||
HAL_Handle GetPortHandleForRouting() const override;
|
||||
AnalogTriggerType GetAnalogTriggerTypeForRouting() const override;
|
||||
bool IsAnalogTrigger() const override;
|
||||
|
||||
virtual void ValueChanged(ITable* source, llvm::StringRef key,
|
||||
std::shared_ptr<nt::Value> value, bool isNew);
|
||||
void ValueChanged(ITable* source, llvm::StringRef key,
|
||||
std::shared_ptr<nt::Value> value, bool isNew) override;
|
||||
void UpdateTable();
|
||||
void StartLiveWindowMode();
|
||||
void StopLiveWindowMode();
|
||||
|
||||
@@ -21,12 +21,12 @@ class GearTooth : public Counter {
|
||||
public:
|
||||
/// 55 uSec for threshold
|
||||
static constexpr double kGearToothThreshold = 55e-6;
|
||||
GearTooth(uint32_t channel, bool directionSensitive = false);
|
||||
GearTooth(DigitalSource* source, bool directionSensitive = false);
|
||||
GearTooth(std::shared_ptr<DigitalSource> source,
|
||||
bool directionSensitive = false);
|
||||
explicit GearTooth(uint32_t channel, bool directionSensitive = false);
|
||||
explicit GearTooth(DigitalSource* source, bool directionSensitive = false);
|
||||
explicit GearTooth(std::shared_ptr<DigitalSource> source,
|
||||
bool directionSensitive = false);
|
||||
virtual ~GearTooth() = default;
|
||||
void EnableDirectionSensing(bool directionSensitive);
|
||||
|
||||
virtual std::string GetSmartDashboardType() const override;
|
||||
std::string GetSmartDashboardType() const override;
|
||||
};
|
||||
|
||||
@@ -72,19 +72,19 @@ class Joystick : public GenericHID, public ErrorBase {
|
||||
uint32_t GetAxisChannel(AxisType axis) const;
|
||||
void SetAxisChannel(AxisType axis, uint32_t channel);
|
||||
|
||||
virtual float GetX(JoystickHand hand = kRightHand) const override;
|
||||
virtual float GetY(JoystickHand hand = kRightHand) const override;
|
||||
virtual float GetZ() const override;
|
||||
virtual float GetTwist() const override;
|
||||
virtual float GetThrottle() const override;
|
||||
float GetX(JoystickHand hand = kRightHand) const override;
|
||||
float GetY(JoystickHand hand = kRightHand) const override;
|
||||
float GetZ() const override;
|
||||
float GetTwist() const override;
|
||||
float GetThrottle() const override;
|
||||
virtual float GetAxis(AxisType axis) const;
|
||||
float GetRawAxis(uint32_t axis) const override;
|
||||
|
||||
virtual bool GetTrigger(JoystickHand hand = kRightHand) const override;
|
||||
virtual bool GetTop(JoystickHand hand = kRightHand) const override;
|
||||
virtual bool GetBumper(JoystickHand hand = kRightHand) const override;
|
||||
virtual bool GetRawButton(uint32_t button) const override;
|
||||
virtual int GetPOV(uint32_t pov = 0) const override;
|
||||
bool GetTrigger(JoystickHand hand = kRightHand) const override;
|
||||
bool GetTop(JoystickHand hand = kRightHand) const override;
|
||||
bool GetBumper(JoystickHand hand = kRightHand) const override;
|
||||
bool GetRawButton(uint32_t button) const override;
|
||||
int GetPOV(uint32_t pov = 0) const override;
|
||||
bool GetButton(ButtonType button) const;
|
||||
static Joystick* GetStickForPort(uint32_t port);
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ class MotorSafety;
|
||||
|
||||
class MotorSafetyHelper : public ErrorBase {
|
||||
public:
|
||||
MotorSafetyHelper(MotorSafety* safeObject);
|
||||
explicit MotorSafetyHelper(MotorSafety* safeObject);
|
||||
~MotorSafetyHelper();
|
||||
void Feed();
|
||||
void SetExpiration(float expirationTime);
|
||||
|
||||
@@ -43,8 +43,8 @@ class PWM : public SensorBase,
|
||||
|
||||
explicit PWM(uint32_t channel);
|
||||
virtual ~PWM();
|
||||
virtual void SetRaw(unsigned short value);
|
||||
virtual unsigned short GetRaw() const;
|
||||
virtual void SetRaw(uint16_t value);
|
||||
virtual uint16_t GetRaw() const;
|
||||
virtual void SetPosition(float pos);
|
||||
virtual float GetPosition() const;
|
||||
virtual void SetSpeed(float speed);
|
||||
|
||||
@@ -16,15 +16,15 @@
|
||||
class PWMSpeedController : public SafePWM, public SpeedController {
|
||||
public:
|
||||
virtual ~PWMSpeedController() = default;
|
||||
virtual void Set(float value) override;
|
||||
virtual float Get() const override;
|
||||
virtual void Disable() override;
|
||||
virtual void StopMotor() override;
|
||||
void Set(float value) override;
|
||||
float Get() const override;
|
||||
void Disable() override;
|
||||
void StopMotor() override;
|
||||
|
||||
virtual void PIDWrite(float output) override;
|
||||
void PIDWrite(float output) override;
|
||||
|
||||
virtual void SetInverted(bool isInverted) override;
|
||||
virtual bool GetInverted() const override;
|
||||
void SetInverted(bool isInverted) override;
|
||||
bool GetInverted() const override;
|
||||
|
||||
protected:
|
||||
explicit PWMSpeedController(uint32_t channel);
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
class PowerDistributionPanel : public SensorBase, public LiveWindowSendable {
|
||||
public:
|
||||
PowerDistributionPanel();
|
||||
PowerDistributionPanel(uint8_t module);
|
||||
explicit PowerDistributionPanel(uint8_t module);
|
||||
|
||||
double GetVoltage() const;
|
||||
double GetTemperature() const;
|
||||
|
||||
@@ -37,7 +37,7 @@ class Relay : public MotorSafety,
|
||||
enum Value { kOff, kOn, kForward, kReverse };
|
||||
enum Direction { kBothDirections, kForwardOnly, kReverseOnly };
|
||||
|
||||
Relay(uint32_t channel, Direction direction = kBothDirections);
|
||||
explicit Relay(uint32_t channel, Direction direction = kBothDirections);
|
||||
virtual ~Relay();
|
||||
|
||||
void Set(Value value);
|
||||
|
||||
@@ -22,7 +22,7 @@ class DigitalInput;
|
||||
class SPI : public SensorBase {
|
||||
public:
|
||||
enum Port { kOnboardCS0, kOnboardCS1, kOnboardCS2, kOnboardCS3, kMXP };
|
||||
SPI(Port SPIport);
|
||||
explicit SPI(Port SPIport);
|
||||
virtual ~SPI();
|
||||
|
||||
SPI(const SPI&) = delete;
|
||||
|
||||
@@ -27,8 +27,8 @@ class SolenoidBase : public SensorBase {
|
||||
|
||||
protected:
|
||||
explicit SolenoidBase(uint8_t pcmID);
|
||||
const static int m_maxModules = 63;
|
||||
const static int m_maxPorts = 8;
|
||||
static const int m_maxModules = 63;
|
||||
static const int m_maxPorts = 8;
|
||||
// static void* m_ports[m_maxModules][m_maxPorts];
|
||||
uint8_t m_moduleNumber; ///< Slot number where the module is plugged into
|
||||
/// the chassis.
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
class ColorImage : public ImageBase {
|
||||
public:
|
||||
ColorImage(ImageType type);
|
||||
explicit ColorImage(ImageType type);
|
||||
virtual ~ColorImage() = default;
|
||||
BinaryImage* ThresholdRGB(int redLow, int redHigh, int greenLow,
|
||||
int greenHigh, int blueLow, int blueHigh);
|
||||
|
||||
@@ -15,6 +15,6 @@
|
||||
class HSLImage : public ColorImage {
|
||||
public:
|
||||
HSLImage();
|
||||
HSLImage(const char* fileName);
|
||||
explicit HSLImage(const char* fileName);
|
||||
virtual ~HSLImage() = default;
|
||||
};
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
class ImageBase : public ErrorBase {
|
||||
public:
|
||||
ImageBase(ImageType type);
|
||||
explicit ImageBase(ImageType type);
|
||||
virtual ~ImageBase();
|
||||
virtual void Write(const char* fileName);
|
||||
int GetHeight();
|
||||
|
||||
@@ -15,6 +15,6 @@
|
||||
class RGBImage : public ColorImage {
|
||||
public:
|
||||
RGBImage();
|
||||
RGBImage(const char* fileName);
|
||||
explicit RGBImage(const char* fileName);
|
||||
virtual ~RGBImage() = default;
|
||||
};
|
||||
|
||||
@@ -53,8 +53,8 @@ double ADXL345_I2C::GetZ() { return GetAcceleration(kAxis_Z); }
|
||||
*/
|
||||
double ADXL345_I2C::GetAcceleration(ADXL345_I2C::Axes axis) {
|
||||
int16_t rawAccel = 0;
|
||||
m_i2c.Read(kDataRegister + (uint8_t)axis, sizeof(rawAccel),
|
||||
(uint8_t*)&rawAccel);
|
||||
m_i2c.Read(kDataRegister + static_cast<uint8_t>(axis), sizeof(rawAccel),
|
||||
reinterpret_cast<uint8_t*>(&rawAccel));
|
||||
return rawAccel * kGsPerLSB;
|
||||
}
|
||||
|
||||
@@ -67,7 +67,8 @@ double ADXL345_I2C::GetAcceleration(ADXL345_I2C::Axes axis) {
|
||||
ADXL345_I2C::AllAxes ADXL345_I2C::GetAccelerations() {
|
||||
AllAxes data = AllAxes();
|
||||
int16_t rawData[3];
|
||||
m_i2c.Read(kDataRegister, sizeof(rawData), (uint8_t*)rawData);
|
||||
m_i2c.Read(kDataRegister, sizeof(rawData),
|
||||
reinterpret_cast<uint8_t*>(rawData));
|
||||
|
||||
data.XAxis = rawData[0] * kGsPerLSB;
|
||||
data.YAxis = rawData[1] * kGsPerLSB;
|
||||
|
||||
@@ -133,8 +133,8 @@ void ADXRS450_Gyro::Reset() { m_spi.ResetAccumulator(); }
|
||||
* integration of the returned rate from the gyro.
|
||||
*/
|
||||
float ADXRS450_Gyro::GetAngle() const {
|
||||
return (float)(m_spi.GetAccumulatorValue() * kDegreePerSecondPerLSB *
|
||||
kSamplePeriod);
|
||||
return static_cast<float>(m_spi.GetAccumulatorValue() *
|
||||
kDegreePerSecondPerLSB * kSamplePeriod);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -145,5 +145,6 @@ float ADXRS450_Gyro::GetAngle() const {
|
||||
* @return the current rate in degrees per second
|
||||
*/
|
||||
double ADXRS450_Gyro::GetRate() const {
|
||||
return (double)m_spi.GetAccumulatorLastValue() * kDegreePerSecondPerLSB;
|
||||
return static_cast<double>(m_spi.GetAccumulatorLastValue()) *
|
||||
kDegreePerSecondPerLSB;
|
||||
}
|
||||
|
||||
@@ -343,58 +343,58 @@ void CANJaguar::PIDWrite(float output) {
|
||||
}
|
||||
|
||||
uint8_t CANJaguar::packPercentage(uint8_t* buffer, double value) {
|
||||
int16_t intValue = (int16_t)(value * 32767.0);
|
||||
*((int16_t*)buffer) = swap16(intValue);
|
||||
int16_t intValue = static_cast<int16_t>(value * 32767.0);
|
||||
*reinterpret_cast<int16_t*>(buffer) = swap16(intValue);
|
||||
return sizeof(int16_t);
|
||||
}
|
||||
|
||||
uint8_t CANJaguar::packFXP8_8(uint8_t* buffer, double value) {
|
||||
int16_t intValue = (int16_t)(value * 256.0);
|
||||
*((int16_t*)buffer) = swap16(intValue);
|
||||
int16_t intValue = static_cast<int16_t>(value * 256.0);
|
||||
*reinterpret_cast<int16_t*>(buffer) = swap16(intValue);
|
||||
return sizeof(int16_t);
|
||||
}
|
||||
|
||||
uint8_t CANJaguar::packFXP16_16(uint8_t* buffer, double value) {
|
||||
int32_t intValue = (int32_t)(value * 65536.0);
|
||||
*((int32_t*)buffer) = swap32(intValue);
|
||||
int32_t intValue = static_cast<int32_t>(value * 65536.0);
|
||||
*reinterpret_cast<int32_t*>(buffer) = swap32(intValue);
|
||||
return sizeof(int32_t);
|
||||
}
|
||||
|
||||
uint8_t CANJaguar::packint16_t(uint8_t* buffer, int16_t value) {
|
||||
*((int16_t*)buffer) = swap16(value);
|
||||
*reinterpret_cast<int16_t*>(buffer) = swap16(value);
|
||||
return sizeof(int16_t);
|
||||
}
|
||||
|
||||
uint8_t CANJaguar::packint32_t(uint8_t* buffer, int32_t value) {
|
||||
*((int32_t*)buffer) = swap32(value);
|
||||
*reinterpret_cast<int32_t*>(buffer) = swap32(value);
|
||||
return sizeof(int32_t);
|
||||
}
|
||||
|
||||
double CANJaguar::unpackPercentage(uint8_t* buffer) const {
|
||||
int16_t value = *((int16_t*)buffer);
|
||||
int16_t value = *reinterpret_cast<int16_t*>(buffer);
|
||||
value = swap16(value);
|
||||
return value / 32767.0;
|
||||
}
|
||||
|
||||
double CANJaguar::unpackFXP8_8(uint8_t* buffer) const {
|
||||
int16_t value = *((int16_t*)buffer);
|
||||
int16_t value = *reinterpret_cast<int16_t*>(buffer);
|
||||
value = swap16(value);
|
||||
return value / 256.0;
|
||||
}
|
||||
|
||||
double CANJaguar::unpackFXP16_16(uint8_t* buffer) const {
|
||||
int32_t value = *((int32_t*)buffer);
|
||||
int32_t value = *reinterpret_cast<int32_t*>(buffer);
|
||||
value = swap32(value);
|
||||
return value / 65536.0;
|
||||
}
|
||||
|
||||
int16_t CANJaguar::unpackint16_t(uint8_t* buffer) const {
|
||||
int16_t value = *((int16_t*)buffer);
|
||||
int16_t value = *reinterpret_cast<int16_t*>(buffer);
|
||||
return swap16(value);
|
||||
}
|
||||
|
||||
int32_t CANJaguar::unpackint32_t(uint8_t* buffer) const {
|
||||
int32_t value = *((int32_t*)buffer);
|
||||
int32_t value = *reinterpret_cast<int32_t*>(buffer);
|
||||
return swap32(value);
|
||||
}
|
||||
|
||||
@@ -552,7 +552,7 @@ void CANJaguar::verify() {
|
||||
// If the Jaguar lost power, everything should be considered unverified.
|
||||
if (getMessage(LM_API_STATUS_POWER, CAN_MSGID_FULL_M, dataBuffer,
|
||||
&dataSize)) {
|
||||
bool powerCycled = (bool)dataBuffer[0];
|
||||
bool powerCycled = static_cast<bool>(dataBuffer[0]);
|
||||
|
||||
if (powerCycled) {
|
||||
// Clear the power cycled bit
|
||||
@@ -667,13 +667,13 @@ void CANJaguar::verify() {
|
||||
if (!m_pVerified) {
|
||||
uint32_t message = 0;
|
||||
|
||||
if (m_controlMode == kSpeed)
|
||||
if (m_controlMode == kSpeed) {
|
||||
message = LM_API_SPD_PC;
|
||||
else if (m_controlMode == kPosition)
|
||||
} else if (m_controlMode == kPosition) {
|
||||
message = LM_API_POS_PC;
|
||||
else if (m_controlMode == kCurrent)
|
||||
} else if (m_controlMode == kCurrent) {
|
||||
message = LM_API_ICTRL_PC;
|
||||
else {
|
||||
} else {
|
||||
wpi_setWPIErrorWithContext(
|
||||
IncompatibleMode,
|
||||
"PID constants only apply in Speed, Position, and Current mode");
|
||||
@@ -697,13 +697,13 @@ void CANJaguar::verify() {
|
||||
if (!m_iVerified) {
|
||||
uint32_t message = 0;
|
||||
|
||||
if (m_controlMode == kSpeed)
|
||||
if (m_controlMode == kSpeed) {
|
||||
message = LM_API_SPD_IC;
|
||||
else if (m_controlMode == kPosition)
|
||||
} else if (m_controlMode == kPosition) {
|
||||
message = LM_API_POS_IC;
|
||||
else if (m_controlMode == kCurrent)
|
||||
} else if (m_controlMode == kCurrent) {
|
||||
message = LM_API_ICTRL_IC;
|
||||
else {
|
||||
} else {
|
||||
wpi_setWPIErrorWithContext(
|
||||
IncompatibleMode,
|
||||
"PID constants only apply in Speed, Position, and Current mode");
|
||||
@@ -727,13 +727,13 @@ void CANJaguar::verify() {
|
||||
if (!m_dVerified) {
|
||||
uint32_t message = 0;
|
||||
|
||||
if (m_controlMode == kSpeed)
|
||||
if (m_controlMode == kSpeed) {
|
||||
message = LM_API_SPD_DC;
|
||||
else if (m_controlMode == kPosition)
|
||||
} else if (m_controlMode == kPosition) {
|
||||
message = LM_API_POS_DC;
|
||||
else if (m_controlMode == kCurrent)
|
||||
} else if (m_controlMode == kCurrent) {
|
||||
message = LM_API_ICTRL_DC;
|
||||
else {
|
||||
} else {
|
||||
wpi_setWPIErrorWithContext(
|
||||
IncompatibleMode,
|
||||
"PID constants only apply in Speed, Position, and Current mode");
|
||||
@@ -807,9 +807,9 @@ void CANJaguar::verify() {
|
||||
&dataSize)) {
|
||||
LimitMode mode = (LimitMode)dataBuffer[0];
|
||||
|
||||
if (mode == m_limitMode)
|
||||
if (mode == m_limitMode) {
|
||||
m_limitModeVerified = true;
|
||||
else {
|
||||
} else {
|
||||
// It's wrong - set it again
|
||||
ConfigLimitMode(m_limitMode);
|
||||
}
|
||||
@@ -824,9 +824,9 @@ void CANJaguar::verify() {
|
||||
&dataSize)) {
|
||||
double limit = unpackFXP16_16(dataBuffer);
|
||||
|
||||
if (FXP16_EQ(limit, m_forwardLimit))
|
||||
if (FXP16_EQ(limit, m_forwardLimit)) {
|
||||
m_forwardLimitVerified = true;
|
||||
else {
|
||||
} else {
|
||||
// It's wrong - set it again
|
||||
ConfigForwardLimit(m_forwardLimit);
|
||||
}
|
||||
@@ -841,9 +841,9 @@ void CANJaguar::verify() {
|
||||
&dataSize)) {
|
||||
double limit = unpackFXP16_16(dataBuffer);
|
||||
|
||||
if (FXP16_EQ(limit, m_reverseLimit))
|
||||
if (FXP16_EQ(limit, m_reverseLimit)) {
|
||||
m_reverseLimitVerified = true;
|
||||
else {
|
||||
} else {
|
||||
// It's wrong - set it again
|
||||
ConfigReverseLimit(m_reverseLimit);
|
||||
}
|
||||
@@ -861,9 +861,9 @@ void CANJaguar::verify() {
|
||||
// The returned max output voltage is sometimes slightly higher or
|
||||
// lower than what was sent. This should not trigger resending
|
||||
// the message.
|
||||
if (std::abs(voltage - m_maxOutputVoltage) < 0.1)
|
||||
if (std::abs(voltage - m_maxOutputVoltage) < 0.1) {
|
||||
m_maxOutputVoltageVerified = true;
|
||||
else {
|
||||
} else {
|
||||
// It's wrong - set it again
|
||||
ConfigMaxOutputVoltage(m_maxOutputVoltage);
|
||||
}
|
||||
@@ -879,9 +879,9 @@ void CANJaguar::verify() {
|
||||
&dataSize)) {
|
||||
double rate = unpackPercentage(dataBuffer);
|
||||
|
||||
if (FXP16_EQ(rate, m_voltageRampRate))
|
||||
if (FXP16_EQ(rate, m_voltageRampRate)) {
|
||||
m_voltageRampRateVerified = true;
|
||||
else {
|
||||
} else {
|
||||
// It's wrong - set it again
|
||||
SetVoltageRampRate(m_voltageRampRate);
|
||||
}
|
||||
@@ -894,9 +894,9 @@ void CANJaguar::verify() {
|
||||
&dataSize)) {
|
||||
double rate = unpackFXP8_8(dataBuffer);
|
||||
|
||||
if (FXP8_EQ(rate, m_voltageRampRate))
|
||||
if (FXP8_EQ(rate, m_voltageRampRate)) {
|
||||
m_voltageRampRateVerified = true;
|
||||
else {
|
||||
} else {
|
||||
// It's wrong - set it again
|
||||
SetVoltageRampRate(m_voltageRampRate);
|
||||
}
|
||||
@@ -912,9 +912,9 @@ void CANJaguar::verify() {
|
||||
&dataSize)) {
|
||||
uint16_t faultTime = unpackint16_t(dataBuffer);
|
||||
|
||||
if ((uint16_t)(m_faultTime * 1000.0) == faultTime)
|
||||
if ((uint16_t)(m_faultTime * 1000.0) == faultTime) {
|
||||
m_faultTimeVerified = true;
|
||||
else {
|
||||
} else {
|
||||
// It's wrong - set it again
|
||||
ConfigFaultTime(m_faultTime);
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@ float CANTalon::Get() const {
|
||||
case kFollower:
|
||||
default:
|
||||
m_impl->GetAppliedThrottle(value);
|
||||
return (float)value / 1023.0;
|
||||
return static_cast<float>(value) / 1023.0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -156,11 +156,11 @@ void CANTalon::Set(float value) {
|
||||
status = CTR_OKAY;
|
||||
} break;
|
||||
case CANSpeedController::kFollower: {
|
||||
status = m_impl->SetDemand((int)value);
|
||||
status = m_impl->SetDemand(static_cast<int>(value));
|
||||
} break;
|
||||
case CANSpeedController::kVoltage: {
|
||||
// Voltage is an 8.8 fixed point number.
|
||||
int volts = int((m_isInverted ? -value : value) * 256);
|
||||
int volts = static_cast<int>((m_isInverted ? -value : value) * 256);
|
||||
status = m_impl->SetDemand(volts);
|
||||
} break;
|
||||
case CANSpeedController::kSpeed:
|
||||
@@ -177,7 +177,7 @@ void CANTalon::Set(float value) {
|
||||
status = m_impl->SetDemand(milliamperes);
|
||||
} break;
|
||||
case CANSpeedController::kMotionProfile: {
|
||||
status = m_impl->SetDemand((int)value);
|
||||
status = m_impl->SetDemand(static_cast<int>(value));
|
||||
} break;
|
||||
default:
|
||||
wpi_setWPIErrorWithContext(
|
||||
@@ -216,7 +216,7 @@ void CANTalon::Reset() {
|
||||
* for more information).
|
||||
*/
|
||||
void CANTalon::Disable() {
|
||||
m_impl->SetModeSelect((int)CANTalon::kDisabled);
|
||||
m_impl->SetModeSelect(static_cast<int>(CANTalon::kDisabled));
|
||||
m_controlEnabled = false;
|
||||
}
|
||||
|
||||
@@ -358,7 +358,8 @@ void CANTalon::SetFeedbackDevice(FeedbackDevice feedbackDevice) {
|
||||
*/
|
||||
m_feedbackDevice = feedbackDevice;
|
||||
/* pass feedback to actual CAN frame */
|
||||
CTR_Code status = m_impl->SetFeedbackDeviceSelect((int)feedbackDevice);
|
||||
CTR_Code status =
|
||||
m_impl->SetFeedbackDeviceSelect(static_cast<int>(feedbackDevice));
|
||||
if (status != CTR_OKAY) {
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
@@ -368,7 +369,8 @@ void CANTalon::SetFeedbackDevice(FeedbackDevice feedbackDevice) {
|
||||
* Select the feedback device to use in closed-loop
|
||||
*/
|
||||
void CANTalon::SetStatusFrameRateMs(StatusFrameRate stateFrame, int periodMs) {
|
||||
CTR_Code status = m_impl->SetStatusFrameRate((int)stateFrame, periodMs);
|
||||
CTR_Code status =
|
||||
m_impl->SetStatusFrameRate(static_cast<int>(stateFrame), periodMs);
|
||||
if (status != CTR_OKAY) {
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
@@ -518,7 +520,7 @@ float CANTalon::GetBusVoltage() const {
|
||||
float CANTalon::GetOutputVoltage() const {
|
||||
int throttle11;
|
||||
CTR_Code status = m_impl->GetAppliedThrottle(throttle11);
|
||||
float voltage = GetBusVoltage() * (float(throttle11) / 1023.0);
|
||||
float voltage = GetBusVoltage() * (static_cast<float>(throttle11) / 1023.0);
|
||||
if (status != CTR_OKAY) {
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
@@ -1086,7 +1088,8 @@ void CANTalon::SetVoltageRampRate(double rampRate) {
|
||||
Talon's throttle ramp is in dThrot/d10ms. 1023 is full fwd, -1023 is
|
||||
full rev. */
|
||||
double rampRatedThrotPer10ms = (rampRate * 1023.0 / 12.0) / 100;
|
||||
CTR_Code status = m_impl->SetRampThrottle((int)rampRatedThrotPer10ms);
|
||||
CTR_Code status =
|
||||
m_impl->SetRampThrottle(static_cast<int>(rampRatedThrotPer10ms));
|
||||
if (status != CTR_OKAY) {
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
@@ -1180,8 +1183,8 @@ void CANTalon::ConfigNeutralMode(NeutralMode mode) {
|
||||
CTR_Code status = CTR_OKAY;
|
||||
switch (mode) {
|
||||
default:
|
||||
case kNeutralMode_Jumper: /* use default setting in flash based on
|
||||
webdash/BrakeCal button selection */
|
||||
case kNeutralMode_Jumper:
|
||||
// use default setting in flash based on webdash/BrakeCal button selection
|
||||
status = m_impl->SetOverrideBrakeType(
|
||||
CanTalonSRX::kBrakeOverride_UseDefaultsFromFlash);
|
||||
break;
|
||||
@@ -1347,8 +1350,9 @@ void CANTalon::ConfigLimitMode(LimitMode mode) {
|
||||
}
|
||||
break;
|
||||
|
||||
case kLimitMode_SrxDisableSwitchInputs: /** disable both limit switches and
|
||||
soft limits */
|
||||
case kLimitMode_SrxDisableSwitchInputs:
|
||||
// disable both limit switches and soft limits
|
||||
|
||||
/* turn on both limits. SRX has individual enables and polarity for each
|
||||
* limit switch.*/
|
||||
status = m_impl->SetForwardSoftEnable(false);
|
||||
@@ -1586,7 +1590,7 @@ void CANTalon::ApplyControlMode(CANSpeedController::ControlMode mode) {
|
||||
break;
|
||||
}
|
||||
// Keep the talon disabled until Set() is called.
|
||||
CTR_Code status = m_impl->SetModeSelect((int)kDisabled);
|
||||
CTR_Code status = m_impl->SetModeSelect(static_cast<int>(kDisabled));
|
||||
if (status != CTR_OKAY) {
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
@@ -1647,14 +1651,13 @@ double CANTalon::GetNativeUnitsPerRotationScalar(
|
||||
CTR_Code status = CTR_OKAY;
|
||||
double retval = 0;
|
||||
switch (devToLookup) {
|
||||
case QuadEncoder: { /* When caller wants to lookup Quadrature, the QEI may
|
||||
* be in 1x if the selected feedback is edge counter.
|
||||
* Additionally if the quadrature source is the CTRE Mag
|
||||
* encoder, then the CPR is known.
|
||||
* This is nice in that the calling app does not require
|
||||
* knowing the CPR at all.
|
||||
* So do both checks here.
|
||||
*/
|
||||
case QuadEncoder: {
|
||||
/* When caller wants to lookup Quadrature, the QEI may be in 1x if the
|
||||
* selected feedback is edge counter. Additionally if the quadrature
|
||||
* source is the CTRE Mag encoder, then the CPR is known. This is nice in
|
||||
* that the calling app does not require knowing the CPR at all. So do
|
||||
* both checks here.
|
||||
*/
|
||||
int32_t qeiPulsePerCount = 4; /* default to 4x */
|
||||
switch (m_feedbackDevice) {
|
||||
case CtreMagEncoder_Relative:
|
||||
@@ -1669,8 +1672,8 @@ double CANTalon::GetNativeUnitsPerRotationScalar(
|
||||
qeiPulsePerCount = 1;
|
||||
break;
|
||||
case QuadEncoder: /* Talon's QEI is 4x */
|
||||
default: /* pulse width and everything else, assume its regular quad
|
||||
use. */
|
||||
default:
|
||||
// pulse width and everything else, assume its regular quad use.
|
||||
break;
|
||||
}
|
||||
if (scalingAvail) {
|
||||
@@ -1710,7 +1713,8 @@ double CANTalon::GetNativeUnitsPerRotationScalar(
|
||||
* bottom of this func.
|
||||
*/
|
||||
} else {
|
||||
retval = (double)kNativeAdcUnitsPerRotation / m_numPotTurns;
|
||||
retval =
|
||||
static_cast<double>(kNativeAdcUnitsPerRotation) / m_numPotTurns;
|
||||
scalingAvail = true;
|
||||
}
|
||||
break;
|
||||
@@ -1746,11 +1750,11 @@ double CANTalon::GetNativeUnitsPerRotationScalar(
|
||||
int32_t CANTalon::ScaleRotationsToNativeUnits(FeedbackDevice devToLookup,
|
||||
double fullRotations) const {
|
||||
/* first assume we don't have config info, prep the default return */
|
||||
int32_t retval = (int32_t)fullRotations;
|
||||
int32_t retval = static_cast<int32_t>(fullRotations);
|
||||
/* retrieve scaling info */
|
||||
double scalar = GetNativeUnitsPerRotationScalar(devToLookup);
|
||||
/* apply scalar if its available */
|
||||
if (scalar > 0) retval = (int32_t)(fullRotations * scalar);
|
||||
if (scalar > 0) retval = static_cast<int32_t>(fullRotations * scalar);
|
||||
return retval;
|
||||
}
|
||||
|
||||
@@ -1768,11 +1772,13 @@ int32_t CANTalon::ScaleRotationsToNativeUnits(FeedbackDevice devToLookup,
|
||||
int32_t CANTalon::ScaleVelocityToNativeUnits(FeedbackDevice devToLookup,
|
||||
double rpm) const {
|
||||
/* first assume we don't have config info, prep the default return */
|
||||
int32_t retval = (int32_t)rpm;
|
||||
int32_t retval = static_cast<int32_t>(rpm);
|
||||
/* retrieve scaling info */
|
||||
double scalar = GetNativeUnitsPerRotationScalar(devToLookup);
|
||||
/* apply scalar if its available */
|
||||
if (scalar > 0) retval = (int32_t)(rpm * kMinutesPer100msUnit * scalar);
|
||||
if (scalar > 0) {
|
||||
retval = static_cast<int32_t>(rpm * kMinutesPer100msUnit * scalar);
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
@@ -1789,11 +1795,11 @@ int32_t CANTalon::ScaleVelocityToNativeUnits(FeedbackDevice devToLookup,
|
||||
double CANTalon::ScaleNativeUnitsToRotations(FeedbackDevice devToLookup,
|
||||
int32_t nativePos) const {
|
||||
/* first assume we don't have config info, prep the default return */
|
||||
double retval = (double)nativePos;
|
||||
double retval = static_cast<double>(nativePos);
|
||||
/* retrieve scaling info */
|
||||
double scalar = GetNativeUnitsPerRotationScalar(devToLookup);
|
||||
/* apply scalar if its available */
|
||||
if (scalar > 0) retval = ((double)nativePos) / scalar;
|
||||
if (scalar > 0) retval = static_cast<double>(nativePos) / scalar;
|
||||
return retval;
|
||||
}
|
||||
|
||||
@@ -1810,12 +1816,12 @@ double CANTalon::ScaleNativeUnitsToRotations(FeedbackDevice devToLookup,
|
||||
double CANTalon::ScaleNativeUnitsToRpm(FeedbackDevice devToLookup,
|
||||
int32_t nativeVel) const {
|
||||
/* first assume we don't have config info, prep the default return */
|
||||
double retval = (double)nativeVel;
|
||||
double retval = static_cast<double>(nativeVel);
|
||||
/* retrieve scaling info */
|
||||
double scalar = GetNativeUnitsPerRotationScalar(devToLookup);
|
||||
/* apply scalar if its available */
|
||||
if (scalar > 0)
|
||||
retval = (double)(nativeVel) / (scalar * kMinutesPer100msUnit);
|
||||
retval = static_cast<double>(nativeVel) / (scalar * kMinutesPer100msUnit);
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
||||
@@ -41,9 +41,9 @@ CameraServer::CameraServer()
|
||||
|
||||
void CameraServer::FreeImageData(
|
||||
std::tuple<uint8_t*, unsigned int, unsigned int, bool> imageData) {
|
||||
if (std::get<3>(imageData))
|
||||
if (std::get<3>(imageData)) {
|
||||
imaqDispose(std::get<0>(imageData));
|
||||
else if (std::get<0>(imageData) != nullptr) {
|
||||
} else if (std::get<0>(imageData) != nullptr) {
|
||||
std::lock_guard<priority_recursive_mutex> lock(m_imageMutex);
|
||||
m_dataPool.push_back(std::get<0>(imageData));
|
||||
}
|
||||
@@ -59,9 +59,9 @@ void CameraServer::SetImageData(uint8_t* data, unsigned int size,
|
||||
|
||||
void CameraServer::SetImage(Image const* image) {
|
||||
unsigned int dataSize = 0;
|
||||
uint8_t* data =
|
||||
(uint8_t*)imaqFlatten(image, IMAQ_FLATTEN_IMAGE, IMAQ_COMPRESSION_JPEG,
|
||||
10 * m_quality, &dataSize);
|
||||
uint8_t* data = reinterpret_cast<uint8_t*>(
|
||||
imaqFlatten(image, IMAQ_FLATTEN_IMAGE, IMAQ_COMPRESSION_JPEG,
|
||||
10 * m_quality, &dataSize));
|
||||
|
||||
// If we're using a HW camera, then find the start of the data
|
||||
bool hwClient;
|
||||
|
||||
@@ -210,7 +210,7 @@ int DriverStation::GetJoystickType(uint32_t stick) const {
|
||||
return -1;
|
||||
}
|
||||
std::lock_guard<priority_mutex> lock(m_joystickDataMutex);
|
||||
return (int)m_joystickDescriptor[stick].type;
|
||||
return static_cast<int>(m_joystickDescriptor[stick].type);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -225,7 +225,7 @@ bool DriverStation::GetJoystickIsXbox(uint32_t stick) const {
|
||||
return false;
|
||||
}
|
||||
std::lock_guard<priority_mutex> lock(m_joystickDataMutex);
|
||||
return (bool)m_joystickDescriptor[stick].isXbox;
|
||||
return static_cast<bool>(m_joystickDescriptor[stick].isXbox);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -214,7 +214,6 @@ void Encoder::Reset() {
|
||||
int32_t status = 0;
|
||||
HAL_ResetEncoder(m_encoder, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -582,9 +582,9 @@ std::string PIDController::GetSmartDashboardType() const {
|
||||
return "PIDController";
|
||||
}
|
||||
|
||||
void PIDController::InitTable(std::shared_ptr<ITable> table) {
|
||||
void PIDController::InitTable(std::shared_ptr<ITable> subtable) {
|
||||
if (m_table != nullptr) m_table->RemoveTableListener(this);
|
||||
m_table = table;
|
||||
m_table = subtable;
|
||||
if (m_table != nullptr) {
|
||||
m_table->PutNumber(kP, GetP());
|
||||
m_table->PutNumber(kI, GetI());
|
||||
|
||||
@@ -231,7 +231,7 @@ float PWM::GetSpeed() const {
|
||||
*
|
||||
* @param value Raw PWM value.
|
||||
*/
|
||||
void PWM::SetRaw(unsigned short value) {
|
||||
void PWM::SetRaw(uint16_t value) {
|
||||
if (StatusIsFatal()) return;
|
||||
|
||||
int32_t status = 0;
|
||||
@@ -246,11 +246,11 @@ void PWM::SetRaw(unsigned short value) {
|
||||
*
|
||||
* @return Raw PWM control value.
|
||||
*/
|
||||
unsigned short PWM::GetRaw() const {
|
||||
uint16_t PWM::GetRaw() const {
|
||||
if (StatusIsFatal()) return 0;
|
||||
|
||||
int32_t status = 0;
|
||||
unsigned short value = HAL_GetPWMRaw(m_handle, &status);
|
||||
uint16_t value = HAL_GetPWMRaw(m_handle, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
|
||||
return value;
|
||||
|
||||
@@ -49,8 +49,9 @@ void SPI::SetClockRate(double hz) { HAL_SetSPISpeed(m_port, hz); }
|
||||
*/
|
||||
void SPI::SetMSBFirst() {
|
||||
m_msbFirst = true;
|
||||
HAL_SetSPIOpts(m_port, (int)m_msbFirst, (int)m_sampleOnTrailing,
|
||||
(int)m_clk_idle_high);
|
||||
HAL_SetSPIOpts(m_port, static_cast<int>(m_msbFirst),
|
||||
static_cast<int>(m_sampleOnTrailing),
|
||||
static_cast<int>(m_clk_idle_high));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -59,8 +60,9 @@ void SPI::SetMSBFirst() {
|
||||
*/
|
||||
void SPI::SetLSBFirst() {
|
||||
m_msbFirst = false;
|
||||
HAL_SetSPIOpts(m_port, (int)m_msbFirst, (int)m_sampleOnTrailing,
|
||||
(int)m_clk_idle_high);
|
||||
HAL_SetSPIOpts(m_port, static_cast<int>(m_msbFirst),
|
||||
static_cast<int>(m_sampleOnTrailing),
|
||||
static_cast<int>(m_clk_idle_high));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -69,8 +71,9 @@ void SPI::SetLSBFirst() {
|
||||
*/
|
||||
void SPI::SetSampleDataOnFalling() {
|
||||
m_sampleOnTrailing = true;
|
||||
HAL_SetSPIOpts(m_port, (int)m_msbFirst, (int)m_sampleOnTrailing,
|
||||
(int)m_clk_idle_high);
|
||||
HAL_SetSPIOpts(m_port, static_cast<int>(m_msbFirst),
|
||||
static_cast<int>(m_sampleOnTrailing),
|
||||
static_cast<int>(m_clk_idle_high));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -79,8 +82,9 @@ void SPI::SetSampleDataOnFalling() {
|
||||
*/
|
||||
void SPI::SetSampleDataOnRising() {
|
||||
m_sampleOnTrailing = false;
|
||||
HAL_SetSPIOpts(m_port, (int)m_msbFirst, (int)m_sampleOnTrailing,
|
||||
(int)m_clk_idle_high);
|
||||
HAL_SetSPIOpts(m_port, static_cast<int>(m_msbFirst),
|
||||
static_cast<int>(m_sampleOnTrailing),
|
||||
static_cast<int>(m_clk_idle_high));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -89,8 +93,9 @@ void SPI::SetSampleDataOnRising() {
|
||||
*/
|
||||
void SPI::SetClockActiveLow() {
|
||||
m_clk_idle_high = true;
|
||||
HAL_SetSPIOpts(m_port, (int)m_msbFirst, (int)m_sampleOnTrailing,
|
||||
(int)m_clk_idle_high);
|
||||
HAL_SetSPIOpts(m_port, static_cast<int>(m_msbFirst),
|
||||
static_cast<int>(m_sampleOnTrailing),
|
||||
static_cast<int>(m_clk_idle_high));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -99,8 +104,9 @@ void SPI::SetClockActiveLow() {
|
||||
*/
|
||||
void SPI::SetClockActiveHigh() {
|
||||
m_clk_idle_high = false;
|
||||
HAL_SetSPIOpts(m_port, (int)m_msbFirst, (int)m_sampleOnTrailing,
|
||||
(int)m_clk_idle_high);
|
||||
HAL_SetSPIOpts(m_port, static_cast<int>(m_msbFirst),
|
||||
static_cast<int>(m_sampleOnTrailing),
|
||||
static_cast<int>(m_clk_idle_high));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -153,8 +159,9 @@ int32_t SPI::Read(bool initiate, uint8_t* dataReceived, uint8_t size) {
|
||||
auto dataToSend = new uint8_t[size];
|
||||
std::memset(dataToSend, 0, size);
|
||||
retVal = HAL_TransactionSPI(m_port, dataToSend, dataReceived, size);
|
||||
} else
|
||||
} else {
|
||||
retVal = HAL_ReadSPI(m_port, dataReceived, size);
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@@ -192,9 +199,9 @@ void SPI::InitAccumulator(double period, uint32_t cmd, uint8_t xfer_size,
|
||||
uint8_t data_shift, uint8_t data_size, bool is_signed,
|
||||
bool big_endian) {
|
||||
int32_t status = 0;
|
||||
HAL_InitSPIAccumulator(m_port, (uint32_t)(period * 1e6), cmd, xfer_size,
|
||||
valid_mask, valid_value, data_shift, data_size,
|
||||
is_signed, big_endian, &status);
|
||||
HAL_InitSPIAccumulator(m_port, static_cast<uint32_t>(period * 1e6), cmd,
|
||||
xfer_size, valid_mask, valid_value, data_shift,
|
||||
data_size, is_signed, big_endian, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
|
||||
@@ -83,7 +83,8 @@ void Servo::SetAngle(float degrees) {
|
||||
degrees = kMaxServoAngle;
|
||||
}
|
||||
|
||||
SetPosition(((float)(degrees - kMinServoAngle)) / GetServoAngleRange());
|
||||
SetPosition(static_cast<float>(degrees - kMinServoAngle) /
|
||||
GetServoAngleRange());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -95,7 +96,8 @@ void Servo::SetAngle(float degrees) {
|
||||
* @return The angle in degrees to which the servo is set.
|
||||
*/
|
||||
float Servo::GetAngle() const {
|
||||
return (float)GetPosition() * GetServoAngleRange() + kMinServoAngle;
|
||||
return static_cast<float>(GetPosition()) * GetServoAngleRange() +
|
||||
kMinServoAngle;
|
||||
}
|
||||
|
||||
void Servo::ValueChanged(ITable* source, llvm::StringRef key,
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
* the SOS flag explanation.
|
||||
*/
|
||||
unsigned int USBCamera::GetJpegSize(void* buffer, unsigned int buffSize) {
|
||||
uint8_t* data = (uint8_t*)buffer;
|
||||
uint8_t* data = static_cast<uint8_t*>(buffer);
|
||||
if (!wpi_assert(data[0] == 0xff && data[1] == 0xd8)) return 0;
|
||||
unsigned int pos = 2;
|
||||
while (pos < buffSize) {
|
||||
@@ -201,7 +201,8 @@ void USBCamera::UpdateSettings() {
|
||||
IMAQdxValueTypeF64, &minv);
|
||||
SAFE_IMAQ_CALL(IMAQdxGetAttributeMaximum, m_id, ATTR_EX_VALUE,
|
||||
IMAQdxValueTypeF64, &maxv);
|
||||
double val = minv + ((maxv - minv) * ((double)m_exposureValue / 100.0));
|
||||
double val =
|
||||
minv + (maxv - minv) * (static_cast<double>(m_exposureValue) / 100.0);
|
||||
SAFE_IMAQ_CALL(IMAQdxSetAttribute, m_id, ATTR_EX_VALUE,
|
||||
IMAQdxValueTypeF64, val);
|
||||
}
|
||||
@@ -215,7 +216,8 @@ void USBCamera::UpdateSettings() {
|
||||
IMAQdxValueTypeF64, &minv);
|
||||
SAFE_IMAQ_CALL(IMAQdxGetAttributeMaximum, m_id, ATTR_BR_VALUE,
|
||||
IMAQdxValueTypeF64, &maxv);
|
||||
double val = minv + ((maxv - minv) * ((double)m_brightness / 100.0));
|
||||
double val =
|
||||
minv + (maxv - minv) * (static_cast<double>(m_brightness) / 100.0);
|
||||
SAFE_IMAQ_CALL(IMAQdxSetAttribute, m_id, ATTR_BR_VALUE, IMAQdxValueTypeF64,
|
||||
val);
|
||||
|
||||
|
||||
@@ -133,9 +133,8 @@ int AxisCamera::CopyJPEG(char** destImage, unsigned int& destImageSize,
|
||||
|
||||
if (m_imageData.size() == 0) return 0; // if no source image
|
||||
|
||||
if (destImageBufferSize <
|
||||
m_imageData.size()) // if current destination buffer too small
|
||||
{
|
||||
// if current destination buffer too small
|
||||
if (destImageBufferSize < m_imageData.size()) {
|
||||
if (*destImage != nullptr) delete[] * destImage;
|
||||
destImageBufferSize = m_imageData.size() + kImageBufferAllocationIncrement;
|
||||
*destImage = new char[destImageBufferSize];
|
||||
@@ -148,7 +147,7 @@ int AxisCamera::CopyJPEG(char** destImage, unsigned int& destImageSize,
|
||||
|
||||
std::copy(m_imageData.begin(), m_imageData.end(), *destImage);
|
||||
destImageSize = m_imageData.size();
|
||||
;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -45,8 +45,7 @@ void SetDebugFlag(DebugOutputType flag) { dprintfFlag = flag; }
|
||||
*
|
||||
* @param tempString The format string.
|
||||
*/
|
||||
void dprintf(const char* tempString, ...) /* Variable argument list */
|
||||
{
|
||||
void dprintf(const char* tempString, ...) {
|
||||
va_list args; /* Input argument list */
|
||||
int line_number; /* Line number passed in argument */
|
||||
int type;
|
||||
@@ -166,7 +165,7 @@ void dprintf(const char* tempString, ...) /* Variable argument list */
|
||||
* @return The normalized position from -1 to +1
|
||||
*/
|
||||
double RangeToNormalized(double position, int range) {
|
||||
return (((position * 2.0) / (double)range) - 1.0);
|
||||
return position * 2.0 / static_cast<double>(range) - 1.0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -179,11 +178,11 @@ double RangeToNormalized(double position, int range) {
|
||||
*/
|
||||
float NormalizeToRange(float normalizedValue, float minRange, float maxRange) {
|
||||
float range = maxRange - minRange;
|
||||
float temp = (float)((normalizedValue / 2.0) + 0.5) * range;
|
||||
float temp = static_cast<float>(normalizedValue / 2.0 + 0.5) * range;
|
||||
return (temp + minRange);
|
||||
}
|
||||
float NormalizeToRange(float normalizedValue) {
|
||||
return (float)((normalizedValue / 2.0) + 0.5);
|
||||
return static_cast<float>(normalizedValue / 2.0 + 0.5);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -274,7 +273,8 @@ void panInit(double period) {
|
||||
void panForTarget(Servo* panServo) { panForTarget(panServo, 0.0); }
|
||||
|
||||
void panForTarget(Servo* panServo, double sinStart) {
|
||||
float normalizedSinPosition = (float)SinPosition(nullptr, sinStart);
|
||||
float normalizedSinPosition =
|
||||
static_cast<float>(SinPosition(nullptr, sinStart));
|
||||
float newServoPosition = NormalizeToRange(normalizedSinPosition);
|
||||
panServo->Set(newServoPosition);
|
||||
// ShowActivity ("pan x: normalized %f newServoPosition = %f" ,
|
||||
@@ -295,8 +295,8 @@ void panForTarget(Servo* panServo, double sinStart) {
|
||||
**/
|
||||
int processFile(char* inputFile, char* outputString, int lineNumber) {
|
||||
FILE* infile;
|
||||
const int stringSize = 80; // max size of one line in file
|
||||
char inputStr[stringSize];
|
||||
const int kStringSize = 80; // max size of one line in file
|
||||
char inputStr[kStringSize];
|
||||
inputStr[0] = '\0';
|
||||
int lineCount = 0;
|
||||
|
||||
@@ -308,16 +308,16 @@ int processFile(char* inputFile, char* outputString, int lineNumber) {
|
||||
}
|
||||
|
||||
while (!std::feof(infile)) {
|
||||
if (std::fgets(inputStr, stringSize, infile) != nullptr) {
|
||||
if (std::fgets(inputStr, kStringSize, infile) != nullptr) {
|
||||
// Skip empty lines
|
||||
if (emptyString(inputStr)) continue;
|
||||
// Skip comment lines
|
||||
if (inputStr[0] == '#' || inputStr[0] == '!') continue;
|
||||
|
||||
lineCount++;
|
||||
if (lineNumber == 0)
|
||||
if (lineNumber == 0) {
|
||||
continue;
|
||||
else {
|
||||
} else {
|
||||
if (lineCount == lineNumber) break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -157,7 +157,7 @@ bool BinaryImage::ParticleMeasurement(int particleNumber,
|
||||
double resultDouble;
|
||||
bool success =
|
||||
ParticleMeasurement(particleNumber, whatToMeasure, &resultDouble);
|
||||
*result = (int)resultDouble;
|
||||
*result = static_cast<int>(resultDouble);
|
||||
return success;
|
||||
}
|
||||
|
||||
@@ -184,7 +184,7 @@ bool BinaryImage::ParticleMeasurement(int particleNumber,
|
||||
|
||||
// Normalizes to [-1,1]
|
||||
double BinaryImage::NormalizeFromRange(double position, int range) {
|
||||
return (position * 2.0 / (double)range) - 1.0;
|
||||
return position * 2.0 / static_cast<double>(range) - 1.0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -57,8 +57,7 @@ int frcDispose(void* object) { return imaqDispose(object); }
|
||||
* @return On success: 1. On failure: 0. To get extended error information, call
|
||||
* GetLastError().
|
||||
*/
|
||||
int frcDispose(const char* functionName, ...) /* Variable argument list */
|
||||
{
|
||||
int frcDispose(const char* functionName, ...) {
|
||||
va_list disposalPtrList; /* Input argument list */
|
||||
void* disposalPtr; /* For iteration */
|
||||
int success, returnValue = 1;
|
||||
@@ -281,7 +280,9 @@ ColorHistogramReport* frcColorHistogram(const Image* image, int numClasses,
|
||||
|
||||
ColorHistogramReport* frcColorHistogram(const Image* image, int numClasses,
|
||||
ColorMode mode, Image* mask) {
|
||||
return imaqColorHistogram2((Image*)image, numClasses, mode, nullptr, mask);
|
||||
return imaqColorHistogram2(
|
||||
const_cast<Image*>(reinterpret_cast<const Image*>(image)), numClasses,
|
||||
mode, nullptr, mask);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -451,14 +452,14 @@ int frcParticleAnalysis(Image* image, int particleNumber,
|
||||
if (!success) {
|
||||
return success;
|
||||
}
|
||||
par->center_mass_x = (int)returnDouble; // pixel
|
||||
par->center_mass_x = static_cast<int>(returnDouble); // pixel
|
||||
|
||||
success = imaqMeasureParticle(image, particleNumber, 0,
|
||||
IMAQ_MT_CENTER_OF_MASS_Y, &returnDouble);
|
||||
if (!success) {
|
||||
return success;
|
||||
}
|
||||
par->center_mass_y = (int)returnDouble; // pixel
|
||||
par->center_mass_y = static_cast<int>(returnDouble); // pixel
|
||||
|
||||
/* particle size statistics */
|
||||
success = imaqMeasureParticle(image, particleNumber, 0, IMAQ_MT_AREA,
|
||||
@@ -473,28 +474,28 @@ int frcParticleAnalysis(Image* image, int particleNumber,
|
||||
if (!success) {
|
||||
return success;
|
||||
}
|
||||
par->boundingRect.top = (int)returnDouble;
|
||||
par->boundingRect.top = static_cast<int>(returnDouble);
|
||||
|
||||
success = imaqMeasureParticle(image, particleNumber, 0,
|
||||
IMAQ_MT_BOUNDING_RECT_LEFT, &returnDouble);
|
||||
if (!success) {
|
||||
return success;
|
||||
}
|
||||
par->boundingRect.left = (int)returnDouble;
|
||||
par->boundingRect.left = static_cast<int>(returnDouble);
|
||||
|
||||
success = imaqMeasureParticle(image, particleNumber, 0,
|
||||
IMAQ_MT_BOUNDING_RECT_HEIGHT, &returnDouble);
|
||||
if (!success) {
|
||||
return success;
|
||||
}
|
||||
par->boundingRect.height = (int)returnDouble;
|
||||
par->boundingRect.height = static_cast<int>(returnDouble);
|
||||
|
||||
success = imaqMeasureParticle(image, particleNumber, 0,
|
||||
IMAQ_MT_BOUNDING_RECT_WIDTH, &returnDouble);
|
||||
if (!success) {
|
||||
return success;
|
||||
}
|
||||
par->boundingRect.width = (int)returnDouble;
|
||||
par->boundingRect.width = static_cast<int>(returnDouble);
|
||||
|
||||
/* particle quality statistics */
|
||||
success = imaqMeasureParticle(image, particleNumber, 0,
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
class InternalButton : public Button {
|
||||
public:
|
||||
InternalButton() = default;
|
||||
InternalButton(bool inverted);
|
||||
explicit InternalButton(bool inverted);
|
||||
virtual ~InternalButton() = default;
|
||||
|
||||
void SetInverted(bool inverted);
|
||||
|
||||
@@ -39,9 +39,9 @@ class Trigger : public Sendable {
|
||||
void CancelWhenActive(Command* command);
|
||||
void ToggleWhenActive(Command* command);
|
||||
|
||||
virtual void InitTable(std::shared_ptr<ITable> table);
|
||||
virtual std::shared_ptr<ITable> GetTable() const;
|
||||
virtual std::string GetSmartDashboardType() const;
|
||||
void InitTable(std::shared_ptr<ITable> subtable) override;
|
||||
std::shared_ptr<ITable> GetTable() const override;
|
||||
std::string GetSmartDashboardType() const override;
|
||||
|
||||
protected:
|
||||
std::shared_ptr<ITable> m_table;
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
template <class T>
|
||||
class CircularBuffer {
|
||||
public:
|
||||
CircularBuffer(size_t size);
|
||||
explicit CircularBuffer(size_t size);
|
||||
|
||||
void PushFront(T value);
|
||||
void PushBack(T value);
|
||||
|
||||
@@ -52,8 +52,8 @@ class Command : public ErrorBase, public NamedSendable, public ITableListener {
|
||||
|
||||
public:
|
||||
Command();
|
||||
Command(const std::string& name);
|
||||
Command(double timeout);
|
||||
explicit Command(const std::string& name);
|
||||
explicit Command(double timeout);
|
||||
Command(const std::string& name, double timeout);
|
||||
virtual ~Command();
|
||||
double TimeSinceInitialized() const;
|
||||
@@ -167,12 +167,12 @@ class Command : public ErrorBase, public NamedSendable, public ITableListener {
|
||||
static int m_commandCounter;
|
||||
|
||||
public:
|
||||
virtual std::string GetName() const;
|
||||
virtual void InitTable(std::shared_ptr<ITable> table);
|
||||
virtual std::shared_ptr<ITable> GetTable() const;
|
||||
virtual std::string GetSmartDashboardType() const;
|
||||
virtual void ValueChanged(ITable* source, llvm::StringRef key,
|
||||
std::shared_ptr<nt::Value> value, bool isNew);
|
||||
std::string GetName() const override;
|
||||
void InitTable(std::shared_ptr<ITable> subtable) override;
|
||||
std::shared_ptr<ITable> GetTable() const override;
|
||||
std::string GetSmartDashboardType() const override;
|
||||
void ValueChanged(ITable* source, llvm::StringRef key,
|
||||
std::shared_ptr<nt::Value> value, bool isNew) override;
|
||||
|
||||
protected:
|
||||
std::shared_ptr<ITable> m_table;
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
class CommandGroup : public Command {
|
||||
public:
|
||||
CommandGroup() = default;
|
||||
CommandGroup(const std::string& name);
|
||||
explicit CommandGroup(const std::string& name);
|
||||
virtual ~CommandGroup() = default;
|
||||
|
||||
void AddSequential(Command* command);
|
||||
|
||||
@@ -51,6 +51,6 @@ class PIDCommand : public Command, public PIDOutput, public PIDSource {
|
||||
std::shared_ptr<PIDController> m_controller;
|
||||
|
||||
public:
|
||||
virtual void InitTable(std::shared_ptr<ITable> table);
|
||||
virtual std::string GetSmartDashboardType() const;
|
||||
void InitTable(std::shared_ptr<ITable> subtable) override;
|
||||
std::string GetSmartDashboardType() const override;
|
||||
};
|
||||
|
||||
@@ -66,6 +66,6 @@ class PIDSubsystem : public Subsystem, public PIDOutput, public PIDSource {
|
||||
std::shared_ptr<PIDController> m_controller;
|
||||
|
||||
public:
|
||||
virtual void InitTable(std::shared_ptr<ITable> table);
|
||||
virtual std::string GetSmartDashboardType() const;
|
||||
void InitTable(std::shared_ptr<ITable> subtable) override;
|
||||
std::string GetSmartDashboardType() const override;
|
||||
};
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
class PrintCommand : public Command {
|
||||
public:
|
||||
PrintCommand(const std::string& message);
|
||||
explicit PrintCommand(const std::string& message);
|
||||
virtual ~PrintCommand() = default;
|
||||
|
||||
protected:
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
class StartCommand : public Command {
|
||||
public:
|
||||
StartCommand(Command* commandToStart);
|
||||
explicit StartCommand(Command* commandToStart);
|
||||
virtual ~StartCommand() = default;
|
||||
|
||||
protected:
|
||||
|
||||
@@ -18,7 +18,7 @@ class Subsystem : public ErrorBase, public NamedSendable {
|
||||
friend class Scheduler;
|
||||
|
||||
public:
|
||||
Subsystem(const std::string& name);
|
||||
explicit Subsystem(const std::string& name);
|
||||
virtual ~Subsystem() = default;
|
||||
|
||||
void SetDefaultCommand(Command* command);
|
||||
@@ -37,10 +37,10 @@ class Subsystem : public ErrorBase, public NamedSendable {
|
||||
bool m_initializedDefaultCommand = false;
|
||||
|
||||
public:
|
||||
virtual std::string GetName() const;
|
||||
virtual void InitTable(std::shared_ptr<ITable> table);
|
||||
virtual std::shared_ptr<ITable> GetTable() const;
|
||||
virtual std::string GetSmartDashboardType() const;
|
||||
std::string GetName() const override;
|
||||
void InitTable(std::shared_ptr<ITable> subtable) override;
|
||||
std::shared_ptr<ITable> GetTable() const override;
|
||||
std::string GetSmartDashboardType() const override;
|
||||
|
||||
protected:
|
||||
std::shared_ptr<ITable> m_table;
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
class WaitCommand : public Command {
|
||||
public:
|
||||
WaitCommand(double timeout);
|
||||
explicit WaitCommand(double timeout);
|
||||
WaitCommand(const std::string& name, double timeout);
|
||||
virtual ~WaitCommand() = default;
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
class WaitForChildren : public Command {
|
||||
public:
|
||||
WaitForChildren(double timeout);
|
||||
explicit WaitForChildren(double timeout);
|
||||
WaitForChildren(const std::string& name, double timeout);
|
||||
virtual ~WaitForChildren() = default;
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
class WaitUntilCommand : public Command {
|
||||
public:
|
||||
WaitUntilCommand(double time);
|
||||
explicit WaitUntilCommand(double time);
|
||||
WaitUntilCommand(const std::string& name, double time);
|
||||
virtual ~WaitUntilCommand() = default;
|
||||
|
||||
|
||||
@@ -15,13 +15,13 @@
|
||||
*/
|
||||
class Filter : public PIDSource {
|
||||
public:
|
||||
Filter(std::shared_ptr<PIDSource> source);
|
||||
explicit Filter(std::shared_ptr<PIDSource> source);
|
||||
virtual ~Filter() = default;
|
||||
|
||||
// PIDSource interface
|
||||
virtual void SetPIDSourceType(PIDSourceType pidSource) override;
|
||||
void SetPIDSourceType(PIDSourceType pidSource) override;
|
||||
PIDSourceType GetPIDSourceType() const;
|
||||
virtual double PIDGet() override = 0;
|
||||
double PIDGet() override = 0;
|
||||
|
||||
/**
|
||||
* Returns the current filter estimate without also inserting new data as
|
||||
|
||||
@@ -50,15 +50,15 @@ class PIDController : public LiveWindowSendable,
|
||||
virtual void SetContinuous(bool continuous = true);
|
||||
virtual void SetInputRange(float minimumInput, float maximumInput);
|
||||
virtual void SetOutputRange(float minimumOutput, float maximumOutput);
|
||||
virtual void SetPID(double p, double i, double d) override;
|
||||
void SetPID(double p, double i, double d) override;
|
||||
virtual void SetPID(double p, double i, double d, double f);
|
||||
virtual double GetP() const override;
|
||||
virtual double GetI() const override;
|
||||
virtual double GetD() const override;
|
||||
double GetP() const override;
|
||||
double GetI() const override;
|
||||
double GetD() const override;
|
||||
virtual double GetF() const;
|
||||
|
||||
virtual void SetSetpoint(float setpoint) override;
|
||||
virtual double GetSetpoint() const override;
|
||||
void SetSetpoint(float setpoint) override;
|
||||
double GetSetpoint() const override;
|
||||
double GetDeltaSetpoint() const;
|
||||
|
||||
virtual float GetError() const;
|
||||
@@ -73,13 +73,13 @@ class PIDController : public LiveWindowSendable,
|
||||
virtual void SetToleranceBuffer(unsigned buf = 1);
|
||||
virtual bool OnTarget() const;
|
||||
|
||||
virtual void Enable() override;
|
||||
virtual void Disable() override;
|
||||
virtual bool IsEnabled() const override;
|
||||
void Enable() override;
|
||||
void Disable() override;
|
||||
bool IsEnabled() const override;
|
||||
|
||||
virtual void Reset() override;
|
||||
void Reset() override;
|
||||
|
||||
virtual void InitTable(std::shared_ptr<ITable> table) override;
|
||||
void InitTable(std::shared_ptr<ITable> subtable) override;
|
||||
|
||||
protected:
|
||||
PIDSource* m_pidInput;
|
||||
@@ -141,12 +141,11 @@ class PIDController : public LiveWindowSendable,
|
||||
void Initialize(float p, float i, float d, float f, PIDSource* source,
|
||||
PIDOutput* output, float period = 0.05);
|
||||
|
||||
virtual std::shared_ptr<ITable> GetTable() const override;
|
||||
virtual std::string GetSmartDashboardType() const override;
|
||||
virtual void ValueChanged(ITable* source, llvm::StringRef key,
|
||||
std::shared_ptr<nt::Value> value,
|
||||
bool isNew) override;
|
||||
virtual void UpdateTable() override;
|
||||
virtual void StartLiveWindowMode() override;
|
||||
virtual void StopLiveWindowMode() override;
|
||||
std::shared_ptr<ITable> GetTable() const override;
|
||||
std::string GetSmartDashboardType() const override;
|
||||
void ValueChanged(ITable* source, llvm::StringRef key,
|
||||
std::shared_ptr<nt::Value> value, bool isNew) override;
|
||||
void UpdateTable() override;
|
||||
void StartLiveWindowMode() override;
|
||||
void StopLiveWindowMode() override;
|
||||
};
|
||||
|
||||
@@ -34,9 +34,9 @@ class SendableChooser : public Sendable {
|
||||
void AddDefault(const std::string& name, void* object);
|
||||
void* GetSelected();
|
||||
|
||||
virtual void InitTable(std::shared_ptr<ITable> subtable);
|
||||
virtual std::shared_ptr<ITable> GetTable() const;
|
||||
virtual std::string GetSmartDashboardType() const;
|
||||
void InitTable(std::shared_ptr<ITable> subtable) override;
|
||||
std::shared_ptr<ITable> GetTable() const override;
|
||||
std::string GetSmartDashboardType() const override;
|
||||
|
||||
private:
|
||||
std::string m_defaultChoice;
|
||||
|
||||
@@ -23,5 +23,5 @@ class Potentiometer : public PIDSource {
|
||||
*/
|
||||
virtual double Get() const = 0;
|
||||
|
||||
virtual void SetPIDSourceType(PIDSourceType pidSource) override;
|
||||
void SetPIDSourceType(PIDSourceType pidSource) override;
|
||||
};
|
||||
|
||||
@@ -14,15 +14,13 @@
|
||||
#include "Buttons/ToggleButtonScheduler.h"
|
||||
|
||||
bool Trigger::Grab() {
|
||||
if (Get())
|
||||
if (Get()) {
|
||||
return true;
|
||||
else if (m_table != nullptr) {
|
||||
// if (m_table->isConnected())//TODO is connected on button?
|
||||
} else if (m_table != nullptr) {
|
||||
return m_table->GetBoolean("pressed", false);
|
||||
/*else
|
||||
return false;*/
|
||||
} else
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void Trigger::WhenActive(Command* command) {
|
||||
@@ -52,8 +50,8 @@ void Trigger::ToggleWhenActive(Command* command) {
|
||||
|
||||
std::string Trigger::GetSmartDashboardType() const { return "Button"; }
|
||||
|
||||
void Trigger::InitTable(std::shared_ptr<ITable> table) {
|
||||
m_table = table;
|
||||
void Trigger::InitTable(std::shared_ptr<ITable> subtable) {
|
||||
m_table = subtable;
|
||||
if (m_table != nullptr) {
|
||||
m_table->PutBoolean("pressed", Get());
|
||||
}
|
||||
|
||||
@@ -392,9 +392,9 @@ std::string Command::GetName() const { return m_name; }
|
||||
|
||||
std::string Command::GetSmartDashboardType() const { return "Command"; }
|
||||
|
||||
void Command::InitTable(std::shared_ptr<ITable> table) {
|
||||
void Command::InitTable(std::shared_ptr<ITable> subtable) {
|
||||
if (m_table != nullptr) m_table->RemoveTableListener(this);
|
||||
m_table = table;
|
||||
m_table = subtable;
|
||||
if (m_table != nullptr) {
|
||||
m_table->PutString(kName, GetName());
|
||||
m_table->PutBoolean(kRunning, IsRunning());
|
||||
|
||||
@@ -66,7 +66,8 @@ double PIDCommand::GetSetpoint() const { return m_controller->GetSetpoint(); }
|
||||
double PIDCommand::GetPosition() { return ReturnPIDInput(); }
|
||||
|
||||
std::string PIDCommand::GetSmartDashboardType() const { return "PIDCommand"; }
|
||||
void PIDCommand::InitTable(std::shared_ptr<ITable> table) {
|
||||
m_controller->InitTable(table);
|
||||
Command::InitTable(table);
|
||||
|
||||
void PIDCommand::InitTable(std::shared_ptr<ITable> subtable) {
|
||||
m_controller->InitTable(subtable);
|
||||
Command::InitTable(subtable);
|
||||
}
|
||||
|
||||
@@ -239,7 +239,8 @@ void PIDSubsystem::PIDWrite(float output) { UsePIDOutput(output); }
|
||||
double PIDSubsystem::PIDGet() { return ReturnPIDInput(); }
|
||||
|
||||
std::string PIDSubsystem::GetSmartDashboardType() const { return "PIDCommand"; }
|
||||
void PIDSubsystem::InitTable(std::shared_ptr<ITable> table) {
|
||||
m_controller->InitTable(table);
|
||||
Subsystem::InitTable(table);
|
||||
|
||||
void PIDSubsystem::InitTable(std::shared_ptr<ITable> subtable) {
|
||||
m_controller->InitTable(subtable);
|
||||
Subsystem::InitTable(subtable);
|
||||
}
|
||||
|
||||
@@ -225,7 +225,7 @@ void Scheduler::UpdateTable() {
|
||||
toCancel = new_toCancel->GetDoubleArray();
|
||||
else
|
||||
toCancel.resize(0);
|
||||
// m_table->RetrieveValue("Ids", *ids);
|
||||
// m_table->RetrieveValue("Ids", *ids);
|
||||
|
||||
// cancel commands that have had the cancel buttons pressed
|
||||
// on the SmartDashboad
|
||||
|
||||
@@ -129,8 +129,8 @@ std::string Subsystem::GetName() const { return m_name; }
|
||||
|
||||
std::string Subsystem::GetSmartDashboardType() const { return "Subsystem"; }
|
||||
|
||||
void Subsystem::InitTable(std::shared_ptr<ITable> table) {
|
||||
m_table = table;
|
||||
void Subsystem::InitTable(std::shared_ptr<ITable> subtable) {
|
||||
m_table = subtable;
|
||||
if (m_table != nullptr) {
|
||||
if (m_defaultCommand != nullptr) {
|
||||
m_table->PutBoolean("hasDefault", true);
|
||||
|
||||
@@ -36,7 +36,8 @@ class AnalogPotentiometer : public Potentiometer, public LiveWindowSendable {
|
||||
* @param offset The offset to add to the scaled value for controlling the
|
||||
* zero value
|
||||
*/
|
||||
AnalogPotentiometer(int channel, double scale = 1.0, double offset = 0.0);
|
||||
explicit AnalogPotentiometer(int channel, double scale = 1.0,
|
||||
double offset = 0.0);
|
||||
|
||||
AnalogPotentiometer(AnalogInput* input, double scale = 1.0,
|
||||
double offset = 0.0);
|
||||
@@ -58,27 +59,27 @@ class AnalogPotentiometer : public Potentiometer, public LiveWindowSendable {
|
||||
*
|
||||
* @return The current reading.
|
||||
*/
|
||||
virtual double PIDGet() override;
|
||||
double PIDGet() override;
|
||||
|
||||
/*
|
||||
* Live Window code, only does anything if live window is activated.
|
||||
*/
|
||||
virtual std::string GetSmartDashboardType() const override;
|
||||
virtual void InitTable(std::shared_ptr<ITable> subtable) override;
|
||||
virtual void UpdateTable() override;
|
||||
virtual std::shared_ptr<ITable> GetTable() const override;
|
||||
std::string GetSmartDashboardType() const override;
|
||||
void InitTable(std::shared_ptr<ITable> subtable) override;
|
||||
void UpdateTable() override;
|
||||
std::shared_ptr<ITable> GetTable() const override;
|
||||
|
||||
/**
|
||||
* AnalogPotentiometers don't have to do anything special when entering the
|
||||
* LiveWindow.
|
||||
*/
|
||||
virtual void StartLiveWindowMode() override {}
|
||||
void StartLiveWindowMode() override {}
|
||||
|
||||
/**
|
||||
* AnalogPotentiometers don't have to do anything special when exiting the
|
||||
* LiveWindow.
|
||||
*/
|
||||
virtual void StopLiveWindowMode() override {}
|
||||
void StopLiveWindowMode() override {}
|
||||
|
||||
private:
|
||||
double m_scale, m_offset;
|
||||
|
||||
@@ -80,7 +80,7 @@ class Counter : public SensorBase,
|
||||
void UpdateTable() override;
|
||||
void StartLiveWindowMode() override;
|
||||
void StopLiveWindowMode() override;
|
||||
virtual std::string GetSmartDashboardType() const override;
|
||||
std::string GetSmartDashboardType() const override;
|
||||
void InitTable(std::shared_ptr<ITable> subTable) override;
|
||||
std::shared_ptr<ITable> GetTable() const override;
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ class DriverStation : public SensorBase, public RobotStateInterface {
|
||||
|
||||
float GetStickAxis(uint32_t stick, uint32_t axis);
|
||||
bool GetStickButton(uint32_t stick, uint32_t button);
|
||||
short GetStickButtons(uint32_t stick);
|
||||
int16_t GetStickButtons(uint32_t stick);
|
||||
|
||||
float GetAnalogIn(uint32_t channel);
|
||||
bool GetDigitalIn(uint32_t channel);
|
||||
|
||||
@@ -22,5 +22,5 @@ class Jaguar : public SafePWM, public SpeedController {
|
||||
virtual float Get() const;
|
||||
virtual void Disable();
|
||||
|
||||
virtual void PIDWrite(float output) override;
|
||||
void PIDWrite(float output) override;
|
||||
};
|
||||
|
||||
@@ -50,19 +50,19 @@ class Joystick : public GenericHID, public ErrorBase {
|
||||
uint32_t GetAxisChannel(AxisType axis);
|
||||
void SetAxisChannel(AxisType axis, uint32_t channel);
|
||||
|
||||
virtual float GetX(JoystickHand hand = kRightHand) const override;
|
||||
virtual float GetY(JoystickHand hand = kRightHand) const override;
|
||||
virtual float GetZ() const override;
|
||||
virtual float GetTwist() const override;
|
||||
virtual float GetThrottle() const override;
|
||||
float GetX(JoystickHand hand = kRightHand) const override;
|
||||
float GetY(JoystickHand hand = kRightHand) const override;
|
||||
float GetZ() const override;
|
||||
float GetTwist() const override;
|
||||
float GetThrottle() const override;
|
||||
virtual float GetAxis(AxisType axis) const;
|
||||
float GetRawAxis(uint32_t axis) const override;
|
||||
|
||||
virtual bool GetTrigger(JoystickHand hand = kRightHand) const override;
|
||||
virtual bool GetTop(JoystickHand hand = kRightHand) const override;
|
||||
virtual bool GetBumper(JoystickHand hand = kRightHand) const override;
|
||||
virtual bool GetRawButton(uint32_t button) const override;
|
||||
virtual int GetPOV(uint32_t pov = 1) const override;
|
||||
bool GetTrigger(JoystickHand hand = kRightHand) const override;
|
||||
bool GetTop(JoystickHand hand = kRightHand) const override;
|
||||
bool GetBumper(JoystickHand hand = kRightHand) const override;
|
||||
bool GetRawButton(uint32_t button) const override;
|
||||
int GetPOV(uint32_t pov = 1) const override;
|
||||
bool GetButton(ButtonType button) const;
|
||||
static Joystick* GetStickForPort(uint32_t port);
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ class MotorSafety;
|
||||
|
||||
class MotorSafetyHelper : public ErrorBase {
|
||||
public:
|
||||
MotorSafetyHelper(MotorSafety* safeObject);
|
||||
explicit MotorSafetyHelper(MotorSafety* safeObject);
|
||||
~MotorSafetyHelper();
|
||||
void Feed();
|
||||
void SetExpiration(float expirationTime);
|
||||
|
||||
@@ -43,7 +43,7 @@ class PWM : public SensorBase,
|
||||
|
||||
explicit PWM(uint32_t channel);
|
||||
virtual ~PWM();
|
||||
virtual void SetRaw(unsigned short value);
|
||||
virtual void SetRaw(uint16_t value);
|
||||
void SetPeriodMultiplier(PeriodMultiplier mult);
|
||||
void EnableDeadbandElimination(bool eliminateDeadband);
|
||||
void SetBounds(int32_t max, int32_t deadbandMax, int32_t center,
|
||||
|
||||
@@ -39,7 +39,7 @@ class Relay : public MotorSafety,
|
||||
enum Value { kOff, kOn, kForward, kReverse };
|
||||
enum Direction { kBothDirections, kForwardOnly, kReverseOnly };
|
||||
|
||||
Relay(uint32_t channel, Direction direction = kBothDirections);
|
||||
explicit Relay(uint32_t channel, Direction direction = kBothDirections);
|
||||
virtual ~Relay();
|
||||
|
||||
void Set(Value value);
|
||||
|
||||
@@ -22,5 +22,5 @@ class Talon : public SafePWM, public SpeedController {
|
||||
virtual float Get() const;
|
||||
virtual void Disable();
|
||||
|
||||
virtual void PIDWrite(float output) override;
|
||||
void PIDWrite(float output) override;
|
||||
};
|
||||
|
||||
@@ -22,5 +22,5 @@ class Victor : public SafePWM, public SpeedController {
|
||||
virtual float Get() const;
|
||||
virtual void Disable();
|
||||
|
||||
virtual void PIDWrite(float output) override;
|
||||
void PIDWrite(float output) override;
|
||||
};
|
||||
|
||||
@@ -24,7 +24,7 @@ class SimContinuousOutput {
|
||||
float speed;
|
||||
|
||||
public:
|
||||
SimContinuousOutput(std::string topic);
|
||||
explicit SimContinuousOutput(std::string topic);
|
||||
|
||||
/**
|
||||
* Set the output value.
|
||||
|
||||
@@ -14,7 +14,7 @@ using namespace gazebo;
|
||||
|
||||
class SimDigitalInput {
|
||||
public:
|
||||
SimDigitalInput(std::string topic);
|
||||
explicit SimDigitalInput(std::string topic);
|
||||
|
||||
/**
|
||||
* @return The value of the potentiometer.
|
||||
|
||||
@@ -15,7 +15,7 @@ using namespace gazebo;
|
||||
|
||||
class SimEncoder {
|
||||
public:
|
||||
SimEncoder(std::string topic);
|
||||
explicit SimEncoder(std::string topic);
|
||||
|
||||
void Reset();
|
||||
void Start();
|
||||
|
||||
@@ -14,7 +14,7 @@ using namespace gazebo;
|
||||
|
||||
class SimFloatInput {
|
||||
public:
|
||||
SimFloatInput(std::string topic);
|
||||
explicit SimFloatInput(std::string topic);
|
||||
|
||||
/**
|
||||
* @return The value of the potentiometer.
|
||||
|
||||
@@ -14,7 +14,7 @@ using namespace gazebo;
|
||||
|
||||
class SimGyro {
|
||||
public:
|
||||
SimGyro(std::string topic);
|
||||
explicit SimGyro(std::string topic);
|
||||
|
||||
void Reset();
|
||||
double GetAngle();
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#include "AnalogGyro.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include <sstream>
|
||||
|
||||
#include "LiveWindow/LiveWindow.h"
|
||||
#include "Timer.h"
|
||||
@@ -32,9 +32,9 @@ const float AnalogGyro::kDefaultVoltsPerDegreePerSecond = 0.007;
|
||||
void AnalogGyro::InitAnalogGyro(int channel) {
|
||||
SetPIDSourceType(PIDSourceType::kDisplacement);
|
||||
|
||||
char buffer[50];
|
||||
int n = std::sprintf(buffer, "analog/%d", channel);
|
||||
impl = new SimGyro(buffer);
|
||||
std::stringstream ss;
|
||||
ss << "analog/" << channel;
|
||||
impl = new SimGyro(ss.str());
|
||||
|
||||
LiveWindow::GetInstance()->AddSensor("AnalogGyro", channel, this);
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#include "AnalogInput.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include <sstream>
|
||||
|
||||
#include "LiveWindow/LiveWindow.h"
|
||||
#include "WPIErrors.h"
|
||||
@@ -17,11 +17,10 @@
|
||||
*
|
||||
* @param channel The channel number to represent.
|
||||
*/
|
||||
AnalogInput::AnalogInput(uint32_t channel) {
|
||||
m_channel = channel;
|
||||
char buffer[50];
|
||||
int n = std::sprintf(buffer, "analog/%d", channel);
|
||||
m_impl = new SimFloatInput(buffer);
|
||||
AnalogInput::AnalogInput(uint32_t channel) : m_channel(channel) {
|
||||
std::stringstream ss;
|
||||
ss << "analog/" << channel;
|
||||
m_impl = new SimFloatInput(ss.str());
|
||||
|
||||
LiveWindow::GetInstance()->AddSensor("AnalogInput", channel, this);
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#include "DigitalInput.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include <sstream>
|
||||
|
||||
#include "WPIErrors.h"
|
||||
|
||||
@@ -17,11 +17,10 @@
|
||||
*
|
||||
* @param channel The digital channel (1..14).
|
||||
*/
|
||||
DigitalInput::DigitalInput(uint32_t channel) {
|
||||
char buf[64];
|
||||
m_channel = channel;
|
||||
int n = std::sprintf(buf, "dio/%d", channel);
|
||||
m_impl = new SimDigitalInput(buf);
|
||||
DigitalInput::DigitalInput(uint32_t channel) : m_channel(channel) {
|
||||
std::stringstream ss;
|
||||
ss << "dio/" << channel;
|
||||
m_impl = new SimDigitalInput(ss.str());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -35,10 +35,10 @@ DoubleSolenoid::DoubleSolenoid(uint8_t moduleNumber, uint32_t forwardChannel,
|
||||
forwardChannel = channel;
|
||||
m_reversed = true;
|
||||
}
|
||||
char buffer[50];
|
||||
int n = std::sprintf(buffer, "pneumatic/%d/%d/%d/%d", moduleNumber,
|
||||
forwardChannel, moduleNumber, reverseChannel);
|
||||
m_impl = new SimContinuousOutput(buffer);
|
||||
std::stringstream ss;
|
||||
ss << "pneumatic/" << moduleNumber << "/" << forwardChannel << "/"
|
||||
<< moduleNumber << "/" << reverseChannel;
|
||||
m_impl = new SimContinuousOutput(ss.str());
|
||||
|
||||
LiveWindow::GetInstance()->AddActuator("DoubleSolenoid", moduleNumber,
|
||||
forwardChannel, this);
|
||||
|
||||
@@ -128,13 +128,13 @@ bool DriverStation::GetStickButton(uint32_t stick, uint32_t button) {
|
||||
* @param stick The joystick to read.
|
||||
* @return The state of the buttons on the joystick.
|
||||
*/
|
||||
short DriverStation::GetStickButtons(uint32_t stick) {
|
||||
int16_t DriverStation::GetStickButtons(uint32_t stick) {
|
||||
if (stick < 0 || stick >= 6) {
|
||||
wpi_setWPIErrorWithContext(ParameterOutOfRange,
|
||||
"stick must be between 0 and 5");
|
||||
return false;
|
||||
}
|
||||
short btns = 0, btnid;
|
||||
int16_t btns = 0, btnid;
|
||||
|
||||
std::unique_lock<std::recursive_mutex> lock(m_joystickMutex);
|
||||
msgs::FRCJoystickPtr joy = joysticks[stick];
|
||||
@@ -147,7 +147,7 @@ short DriverStation::GetStickButtons(uint32_t stick) {
|
||||
}
|
||||
|
||||
// 5V divided by 10 bits
|
||||
#define kDSAnalogInScaling ((float)(5.0 / 1023.0))
|
||||
#define kDSAnalogInScaling (static_cast<float>(5.0 / 1023.0))
|
||||
|
||||
/**
|
||||
* Get an analog voltage from the Driver Station.
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#include "Encoder.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include <sstream>
|
||||
|
||||
#include "LiveWindow/LiveWindow.h"
|
||||
#include "Resource.h"
|
||||
@@ -51,9 +51,9 @@ void Encoder::InitEncoder(int32_t channelA, int32_t channelB,
|
||||
} else {
|
||||
m_reverseDirection = reverseDirection;
|
||||
}
|
||||
char buffer[50];
|
||||
int n = std::sprintf(buffer, "dio/%d/%d", channelA, channelB);
|
||||
impl = new SimEncoder(buffer);
|
||||
std::stringstream ss;
|
||||
ss << "dio/" << channelA << "/" << channelB;
|
||||
impl = new SimEncoder(ss.str());
|
||||
impl->Start();
|
||||
}
|
||||
|
||||
|
||||
@@ -82,8 +82,9 @@ void Notifier::UpdateAlarm() {}
|
||||
*/
|
||||
void Notifier::ProcessQueue(uint32_t mask, void* params) {
|
||||
Notifier* current;
|
||||
while (true) // keep processing past events until no more
|
||||
{
|
||||
|
||||
// keep processing events until no more
|
||||
while (true) {
|
||||
{
|
||||
std::lock_guard<priority_recursive_mutex> sync(queueMutex);
|
||||
double currentTime = GetClock();
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
|
||||
#include "PWM.h"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include "Utility.h"
|
||||
#include "WPIErrors.h"
|
||||
|
||||
@@ -26,16 +28,16 @@ const int32_t PWM::kPwmDisabled = 0;
|
||||
* port
|
||||
*/
|
||||
PWM::PWM(uint32_t channel) {
|
||||
char buf[64];
|
||||
std::stringstream ss;
|
||||
|
||||
if (!CheckPWMChannel(channel)) {
|
||||
std::snprintf(buf, 64, "PWM Channel %d", channel);
|
||||
wpi_setWPIErrorWithContext(ChannelIndexOutOfRange, buf);
|
||||
ss << "PWM Channel " << channel;
|
||||
wpi_setWPIErrorWithContext(ChannelIndexOutOfRange, ss.str());
|
||||
return;
|
||||
}
|
||||
|
||||
std::sprintf(buf, "pwm/%d", channel);
|
||||
impl = new SimContinuousOutput(buf);
|
||||
ss << "pwm/" << channel;
|
||||
impl = new SimContinuousOutput(ss.str());
|
||||
m_channel = channel;
|
||||
m_eliminateDeadband = false;
|
||||
|
||||
@@ -189,7 +191,7 @@ float PWM::GetSpeed() const {
|
||||
*
|
||||
* @param value Raw PWM value.
|
||||
*/
|
||||
void PWM::SetRaw(unsigned short value) {
|
||||
void PWM::SetRaw(uint16_t value) {
|
||||
wpi_assert(value == kPwmDisabled);
|
||||
impl->Set(0);
|
||||
}
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
|
||||
#include "Relay.h"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include "LiveWindow/LiveWindow.h"
|
||||
#include "MotorSafetyHelper.h"
|
||||
#include "WPIErrors.h"
|
||||
@@ -22,21 +24,21 @@
|
||||
*/
|
||||
Relay::Relay(uint32_t channel, Relay::Direction direction)
|
||||
: m_channel(channel), m_direction(direction) {
|
||||
char buf[64];
|
||||
std::stringstream ss;
|
||||
if (!SensorBase::CheckRelayChannel(m_channel)) {
|
||||
std::snprintf(buf, 64, "Relay Channel %d", m_channel);
|
||||
wpi_setWPIErrorWithContext(ChannelIndexOutOfRange, buf);
|
||||
ss << "Relay Channel " << m_channel;
|
||||
wpi_setWPIErrorWithContext(ChannelIndexOutOfRange, ss.str());
|
||||
return;
|
||||
}
|
||||
|
||||
m_safetyHelper = std::make_unique<MotorSafetyHelper>(this);
|
||||
m_safetyHelper->SetSafetyEnabled(false);
|
||||
|
||||
std::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.
|
||||
ss << "relay/" << m_channel;
|
||||
impl = new SimContinuousOutput(ss.str()); // 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);
|
||||
go_pos = go_neg = false;
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#include "Solenoid.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include <sstream>
|
||||
|
||||
#include "LiveWindow/LiveWindow.h"
|
||||
#include "WPIErrors.h"
|
||||
@@ -27,9 +27,9 @@ Solenoid::Solenoid(uint32_t channel) : Solenoid(1, channel) {}
|
||||
* @param channel The channel on the solenoid module to control (1..8).
|
||||
*/
|
||||
Solenoid::Solenoid(uint8_t moduleNumber, uint32_t channel) {
|
||||
char buffer[50];
|
||||
int n = std::sprintf(buffer, "pneumatic/%d/%d", moduleNumber, channel);
|
||||
m_impl = new SimContinuousOutput(buffer);
|
||||
std::stringstream ss;
|
||||
ss << "pneumatic/" << moduleNumber << "/" << channel;
|
||||
m_impl = new SimContinuousOutput(ss.str());
|
||||
|
||||
LiveWindow::GetInstance()->AddActuator("Solenoid", moduleNumber, channel,
|
||||
this);
|
||||
|
||||
@@ -24,7 +24,7 @@ void time_callback(const msgs::ConstFloat64Ptr& msg) {
|
||||
time_wait.notify_all();
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace wpilib
|
||||
|
||||
/**
|
||||
* Pause the task for a specified time.
|
||||
|
||||
@@ -40,8 +40,8 @@ void wpi_suspendOnAssertEnabled(bool enabled) {
|
||||
static void wpi_handleTracing() {
|
||||
// if (stackTraceEnabled)
|
||||
// {
|
||||
// std::printf("\n-----------<Stack Trace>----------------\n");
|
||||
// printCurrentStackTrace();
|
||||
// std::printf("\n-----------<Stack Trace>----------------\n");
|
||||
// printCurrentStackTrace();
|
||||
// }
|
||||
std::printf("\n");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user