mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
Replaced floats with doubles (#355)
This makes our APIs more consistent. With optimizations enabled, doubles are just as efficient as floats on ARMv7, so we should take advantage of the extra precision.
This commit is contained in:
committed by
Peter Johnson
parent
7bcd243ec3
commit
69422dc063
@@ -87,13 +87,13 @@ void HAL_SetupAnalogGyro(HAL_GyroHandle handle, int32_t* status) {
|
||||
if (*status != 0) return;
|
||||
HAL_SetAnalogOversampleBits(gyro->handle, kOversampleBits, status);
|
||||
if (*status != 0) return;
|
||||
float sampleRate =
|
||||
double sampleRate =
|
||||
kSamplesPerSecond * (1 << (kAverageBits + kOversampleBits));
|
||||
HAL_SetAnalogSampleRate(sampleRate, status);
|
||||
if (*status != 0) return;
|
||||
Wait(0.1);
|
||||
|
||||
HAL_SetAnalogGyroDeadband(handle, 0.0f, status);
|
||||
HAL_SetAnalogGyroDeadband(handle, 0.0, status);
|
||||
if (*status != 0) return;
|
||||
}
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@ HAL_Bool HAL_CheckAnalogInputChannel(int32_t channel) {
|
||||
*/
|
||||
void HAL_SetAnalogSampleRate(double samplesPerSecond, int32_t* status) {
|
||||
// TODO: This will change when variable size scan lists are implemented.
|
||||
// TODO: Need float comparison with epsilon.
|
||||
// TODO: Need double comparison with epsilon.
|
||||
// wpi_assert(!sampleRateSet || GetSampleRate() == samplesPerSecond);
|
||||
initializeAnalog(status);
|
||||
if (*status != 0) return;
|
||||
|
||||
@@ -80,7 +80,7 @@ int32_t getAnalogNumChannelsToActivate(int32_t* status) {
|
||||
*/
|
||||
void setAnalogSampleRate(double samplesPerSecond, int32_t* status) {
|
||||
// TODO: This will change when variable size scan lists are implemented.
|
||||
// TODO: Need float comparison with epsilon.
|
||||
// TODO: Need double comparison with epsilon.
|
||||
// wpi_assert(!sampleRateSet || GetSampleRate() == samplesPerSecond);
|
||||
analogSampleRateSet = true;
|
||||
|
||||
|
||||
@@ -45,11 +45,11 @@ constexpr int32_t kExpectedLoopTiming = 40;
|
||||
* scaling is implemented as an output squelch to get longer periods for old
|
||||
* devices.
|
||||
*/
|
||||
constexpr float kDefaultPwmPeriod = 5.05;
|
||||
constexpr double kDefaultPwmPeriod = 5.05;
|
||||
/**
|
||||
* kDefaultPwmCenter is the PWM range center in ms
|
||||
*/
|
||||
constexpr float kDefaultPwmCenter = 1.5;
|
||||
constexpr double kDefaultPwmCenter = 1.5;
|
||||
/**
|
||||
* kDefaultPWMStepsDown is the number of PWM steps below the centerpoint
|
||||
*/
|
||||
|
||||
@@ -100,16 +100,16 @@ int32_t HAL_GetJoystickAxes(int32_t joystickNum, HAL_JoystickAxes* axes) {
|
||||
joystickNum, reinterpret_cast<JoystickAxes_t*>(&axesInt),
|
||||
HAL_kMaxJoystickAxes);
|
||||
|
||||
// copy integer values to float values
|
||||
// copy integer values to double values
|
||||
axes->count = axesInt.count;
|
||||
// current scaling is -128 to 127, can easily be patched in the future by
|
||||
// changing this function.
|
||||
for (int32_t i = 0; i < axesInt.count; i++) {
|
||||
int8_t value = axesInt.axes[i];
|
||||
if (value < 0) {
|
||||
axes->axes[i] = value / 128.0f;
|
||||
axes->axes[i] = value / 128.0;
|
||||
} else {
|
||||
axes->axes[i] = value / 127.0f;
|
||||
axes->axes[i] = value / 127.0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ class ADXRS450_Gyro : public GyroBase {
|
||||
explicit ADXRS450_Gyro(SPI::Port port);
|
||||
virtual ~ADXRS450_Gyro() = default;
|
||||
|
||||
float GetAngle() const override;
|
||||
double GetAngle() const override;
|
||||
double GetRate() const override;
|
||||
void Reset() override;
|
||||
void Calibrate() override;
|
||||
|
||||
@@ -32,9 +32,9 @@ class AnalogAccelerometer : public SensorBase,
|
||||
explicit AnalogAccelerometer(std::shared_ptr<AnalogInput> channel);
|
||||
virtual ~AnalogAccelerometer() = default;
|
||||
|
||||
float GetAcceleration() const;
|
||||
void SetSensitivity(float sensitivity);
|
||||
void SetZero(float zero);
|
||||
double GetAcceleration() const;
|
||||
void SetSensitivity(double sensitivity);
|
||||
void SetZero(double zero);
|
||||
double PIDGet() override;
|
||||
|
||||
void UpdateTable() override;
|
||||
@@ -48,8 +48,8 @@ class AnalogAccelerometer : public SensorBase,
|
||||
void InitAccelerometer();
|
||||
|
||||
std::shared_ptr<AnalogInput> m_analogInput;
|
||||
float m_voltsPerG = 1.0;
|
||||
float m_zeroGVoltage = 2.5;
|
||||
double m_voltsPerG = 1.0;
|
||||
double m_zeroGVoltage = 2.5;
|
||||
|
||||
std::shared_ptr<ITable> m_table;
|
||||
};
|
||||
|
||||
@@ -33,23 +33,23 @@ class AnalogGyro : public GyroBase {
|
||||
public:
|
||||
static const int kOversampleBits = 10;
|
||||
static const int kAverageBits = 0;
|
||||
static constexpr float kSamplesPerSecond = 50.0;
|
||||
static constexpr float kCalibrationSampleTime = 5.0;
|
||||
static constexpr float kDefaultVoltsPerDegreePerSecond = 0.007;
|
||||
static constexpr double kSamplesPerSecond = 50.0;
|
||||
static constexpr double kCalibrationSampleTime = 5.0;
|
||||
static constexpr double kDefaultVoltsPerDegreePerSecond = 0.007;
|
||||
|
||||
explicit AnalogGyro(int channel);
|
||||
explicit AnalogGyro(AnalogInput* channel);
|
||||
explicit AnalogGyro(std::shared_ptr<AnalogInput> channel);
|
||||
AnalogGyro(int channel, int center, float offset);
|
||||
AnalogGyro(std::shared_ptr<AnalogInput> channel, int center, float offset);
|
||||
AnalogGyro(int channel, int center, double offset);
|
||||
AnalogGyro(std::shared_ptr<AnalogInput> channel, int center, double offset);
|
||||
virtual ~AnalogGyro();
|
||||
|
||||
float GetAngle() const override;
|
||||
double GetAngle() const override;
|
||||
double GetRate() const override;
|
||||
virtual int GetCenter() const;
|
||||
virtual float GetOffset() const;
|
||||
void SetSensitivity(float voltsPerDegreePerSecond);
|
||||
void SetDeadband(float volts);
|
||||
virtual double GetOffset() const;
|
||||
void SetSensitivity(double voltsPerDegreePerSecond);
|
||||
void SetDeadband(double volts);
|
||||
void Reset() override;
|
||||
virtual void InitGyro();
|
||||
void Calibrate() override;
|
||||
|
||||
@@ -46,8 +46,8 @@ class AnalogInput : public SensorBase,
|
||||
int GetValue() const;
|
||||
int GetAverageValue() const;
|
||||
|
||||
float GetVoltage() const;
|
||||
float GetAverageVoltage() const;
|
||||
double GetVoltage() const;
|
||||
double GetAverageVoltage() const;
|
||||
|
||||
int GetChannel() const;
|
||||
|
||||
@@ -69,8 +69,8 @@ class AnalogInput : public SensorBase,
|
||||
int64_t GetAccumulatorCount() const;
|
||||
void GetAccumulatorOutput(int64_t& value, int64_t& count) const;
|
||||
|
||||
static void SetSampleRate(float samplesPerSecond);
|
||||
static float GetSampleRate();
|
||||
static void SetSampleRate(double samplesPerSecond);
|
||||
static double GetSampleRate();
|
||||
|
||||
double PIDGet() override;
|
||||
|
||||
|
||||
@@ -26,8 +26,8 @@ class AnalogOutput : public SensorBase, public LiveWindowSendable {
|
||||
explicit AnalogOutput(int channel);
|
||||
virtual ~AnalogOutput();
|
||||
|
||||
void SetVoltage(float voltage);
|
||||
float GetVoltage() const;
|
||||
void SetVoltage(double voltage);
|
||||
double GetVoltage() const;
|
||||
|
||||
void UpdateTable() override;
|
||||
void StartLiveWindowMode() override;
|
||||
|
||||
@@ -25,7 +25,7 @@ class AnalogTrigger : public SensorBase {
|
||||
explicit AnalogTrigger(AnalogInput* channel);
|
||||
virtual ~AnalogTrigger();
|
||||
|
||||
void SetLimitsVoltage(float lower, float upper);
|
||||
void SetLimitsVoltage(double lower, double upper);
|
||||
void SetLimitsRaw(int lower, int upper);
|
||||
void SetAveraged(bool useAveragedValue);
|
||||
void SetFiltered(bool useFilteredValue);
|
||||
|
||||
@@ -63,8 +63,8 @@ class CANSpeedController : public SpeedController {
|
||||
kLimitMode_SrxDisableSwitchInputs = 2,
|
||||
};
|
||||
|
||||
virtual float Get() const = 0;
|
||||
virtual void Set(float value) = 0;
|
||||
virtual double Get() const = 0;
|
||||
virtual void Set(double value) = 0;
|
||||
virtual void StopMotor() = 0;
|
||||
virtual void Disable() = 0;
|
||||
virtual void SetP(double p) = 0;
|
||||
@@ -74,10 +74,10 @@ class CANSpeedController : public SpeedController {
|
||||
virtual double GetP() const = 0;
|
||||
virtual double GetI() const = 0;
|
||||
virtual double GetD() const = 0;
|
||||
virtual float GetBusVoltage() const = 0;
|
||||
virtual float GetOutputVoltage() const = 0;
|
||||
virtual float GetOutputCurrent() const = 0;
|
||||
virtual float GetTemperature() const = 0;
|
||||
virtual double GetBusVoltage() const = 0;
|
||||
virtual double GetOutputVoltage() const = 0;
|
||||
virtual double GetOutputCurrent() const = 0;
|
||||
virtual double GetTemperature() const = 0;
|
||||
virtual double GetPosition() const = 0;
|
||||
virtual double GetSpeed() const = 0;
|
||||
virtual bool GetForwardLimitOK() const = 0;
|
||||
@@ -95,7 +95,7 @@ class CANSpeedController : public SpeedController {
|
||||
virtual void ConfigForwardLimit(double forwardLimitPosition) = 0;
|
||||
virtual void ConfigReverseLimit(double reverseLimitPosition) = 0;
|
||||
virtual void ConfigMaxOutputVoltage(double voltage) = 0;
|
||||
virtual void ConfigFaultTime(float faultTime) = 0;
|
||||
virtual void ConfigFaultTime(double faultTime) = 0;
|
||||
// Hold off on interface until we figure out ControlMode enums.
|
||||
// virtual void SetControlMode(ControlMode mode) = 0;
|
||||
// virtual ControlMode GetControlMode() const = 0;
|
||||
|
||||
@@ -34,7 +34,7 @@ class Compressor : public SensorBase,
|
||||
|
||||
bool GetPressureSwitchValue() const;
|
||||
|
||||
float GetCompressorCurrent() const;
|
||||
double GetCompressorCurrent() const;
|
||||
|
||||
void SetClosedLoopControl(bool on);
|
||||
bool GetClosedLoopControl() const;
|
||||
|
||||
@@ -11,18 +11,18 @@ namespace frc {
|
||||
|
||||
class ControllerPower {
|
||||
public:
|
||||
static float GetInputVoltage();
|
||||
static float GetInputCurrent();
|
||||
static float GetVoltage3V3();
|
||||
static float GetCurrent3V3();
|
||||
static double GetInputVoltage();
|
||||
static double GetInputCurrent();
|
||||
static double GetVoltage3V3();
|
||||
static double GetCurrent3V3();
|
||||
static bool GetEnabled3V3();
|
||||
static int GetFaultCount3V3();
|
||||
static float GetVoltage5V();
|
||||
static float GetCurrent5V();
|
||||
static double GetVoltage5V();
|
||||
static double GetCurrent5V();
|
||||
static bool GetEnabled5V();
|
||||
static int GetFaultCount5V();
|
||||
static float GetVoltage6V();
|
||||
static float GetCurrent6V();
|
||||
static double GetVoltage6V();
|
||||
static double GetCurrent6V();
|
||||
static bool GetEnabled6V();
|
||||
static int GetFaultCount6V();
|
||||
};
|
||||
|
||||
@@ -77,7 +77,7 @@ class Counter : public SensorBase,
|
||||
void SetUpDownCounterMode();
|
||||
void SetExternalDirectionMode();
|
||||
void SetSemiPeriodMode(bool highSemiPeriod);
|
||||
void SetPulseLengthMode(float threshold);
|
||||
void SetPulseLengthMode(double threshold);
|
||||
|
||||
void SetReverseDirection(bool reverseDirection);
|
||||
|
||||
|
||||
@@ -32,12 +32,12 @@ class DigitalOutput : public DigitalSource,
|
||||
void Set(bool value);
|
||||
bool Get() const;
|
||||
int GetChannel() const override;
|
||||
void Pulse(float length);
|
||||
void Pulse(double length);
|
||||
bool IsPulsing() const;
|
||||
void SetPWMRate(float rate);
|
||||
void EnablePWM(float initialDutyCycle);
|
||||
void SetPWMRate(double rate);
|
||||
void EnablePWM(double initialDutyCycle);
|
||||
void DisablePWM();
|
||||
void UpdateDutyCycle(float dutyCycle);
|
||||
void UpdateDutyCycle(double dutyCycle);
|
||||
|
||||
// Digital Source Interface
|
||||
HAL_Handle GetPortHandleForRouting() const override;
|
||||
|
||||
@@ -39,7 +39,7 @@ class DriverStation : public SensorBase, public RobotStateInterface {
|
||||
|
||||
static const int kJoystickPorts = 6;
|
||||
|
||||
float GetStickAxis(int stick, int axis);
|
||||
double GetStickAxis(int stick, int axis);
|
||||
int GetStickPOV(int stick, int pov);
|
||||
int GetStickButtons(int stick) const;
|
||||
bool GetStickButton(int stick, int button);
|
||||
@@ -69,7 +69,7 @@ class DriverStation : public SensorBase, public RobotStateInterface {
|
||||
void WaitForData();
|
||||
bool WaitForData(double timeout);
|
||||
double GetMatchTime() const;
|
||||
float GetBatteryVoltage() const;
|
||||
double GetBatteryVoltage() const;
|
||||
|
||||
/** Only to be used to tell the Driver Station what code you claim to be
|
||||
* executing for diagnostic purposes only
|
||||
|
||||
@@ -69,10 +69,10 @@ class Encoder : public SensorBase,
|
||||
bool GetStopped() const override;
|
||||
bool GetDirection() const override;
|
||||
|
||||
float GetDistance() const;
|
||||
float GetRate() const;
|
||||
void SetMinRate(float minRate);
|
||||
void SetDistancePerPulse(float distancePerPulse);
|
||||
double GetDistance() const;
|
||||
double GetRate() const;
|
||||
void SetMinRate(double minRate);
|
||||
void SetDistancePerPulse(double distancePerPulse);
|
||||
void SetReverseDirection(bool reverseDirection);
|
||||
void SetSamplesToAverage(int samplesToAverage);
|
||||
int GetSamplesToAverage() const;
|
||||
@@ -97,7 +97,7 @@ class Encoder : public SensorBase,
|
||||
private:
|
||||
void InitEncoder(bool reverseDirection, EncodingType encodingType);
|
||||
|
||||
float DecodingScaleFactor() const;
|
||||
double DecodingScaleFactor() const;
|
||||
|
||||
std::shared_ptr<DigitalSource> m_aSource; // the A phase of the quad encoder
|
||||
std::shared_ptr<DigitalSource> m_bSource; // the B phase of the quad encoder
|
||||
|
||||
@@ -35,7 +35,7 @@ class InterruptableSensorBase : public SensorBase {
|
||||
virtual void
|
||||
CancelInterrupts(); ///< Free up the underlying chipobject functions.
|
||||
virtual WaitResult WaitForInterrupt(
|
||||
float timeout,
|
||||
double timeout,
|
||||
bool ignorePrevious = true); ///< Synchronus version.
|
||||
virtual void
|
||||
EnableInterrupts(); ///< Enable interrupts - after finishing setup.
|
||||
|
||||
@@ -15,8 +15,8 @@ namespace frc {
|
||||
|
||||
class MotorSafety {
|
||||
public:
|
||||
virtual void SetExpiration(float timeout) = 0;
|
||||
virtual float GetExpiration() const = 0;
|
||||
virtual void SetExpiration(double timeout) = 0;
|
||||
virtual double GetExpiration() const = 0;
|
||||
virtual bool IsAlive() const = 0;
|
||||
virtual void StopMotor() = 0;
|
||||
virtual void SetSafetyEnabled(bool enabled) = 0;
|
||||
|
||||
@@ -21,8 +21,8 @@ class MotorSafetyHelper : public ErrorBase {
|
||||
explicit MotorSafetyHelper(MotorSafety* safeObject);
|
||||
~MotorSafetyHelper();
|
||||
void Feed();
|
||||
void SetExpiration(float expirationTime);
|
||||
float GetExpiration() const;
|
||||
void SetExpiration(double expirationTime);
|
||||
double GetExpiration() const;
|
||||
bool IsAlive() const;
|
||||
void Check();
|
||||
void SetSafetyEnabled(bool enabled);
|
||||
|
||||
@@ -48,16 +48,16 @@ class PWM : public SensorBase,
|
||||
virtual ~PWM();
|
||||
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);
|
||||
virtual float GetSpeed() const;
|
||||
virtual void SetPosition(double pos);
|
||||
virtual double GetPosition() const;
|
||||
virtual void SetSpeed(double speed);
|
||||
virtual double GetSpeed() const;
|
||||
virtual void SetDisabled();
|
||||
void SetPeriodMultiplier(PeriodMultiplier mult);
|
||||
void SetZeroLatch();
|
||||
void EnableDeadbandElimination(bool eliminateDeadband);
|
||||
void SetBounds(float max, float deadbandMax, float center, float deadbandMin,
|
||||
float min);
|
||||
void SetBounds(double max, double deadbandMax, double center,
|
||||
double deadbandMin, double min);
|
||||
void SetRawBounds(int max, int deadbandMax, int center, int deadbandMin,
|
||||
int min);
|
||||
void GetRawBounds(int32_t* max, int32_t* deadbandMax, int32_t* center,
|
||||
|
||||
@@ -18,12 +18,12 @@ namespace frc {
|
||||
class PWMSpeedController : public SafePWM, public SpeedController {
|
||||
public:
|
||||
virtual ~PWMSpeedController() = default;
|
||||
void Set(float value) override;
|
||||
float Get() const override;
|
||||
void Set(double value) override;
|
||||
double Get() const override;
|
||||
void Disable() override;
|
||||
void StopMotor() override;
|
||||
|
||||
void PIDWrite(float output) override;
|
||||
void PIDWrite(double output) override;
|
||||
|
||||
void SetInverted(bool isInverted) override;
|
||||
bool GetInverted() const override;
|
||||
|
||||
@@ -24,12 +24,12 @@ class PowerDistributionPanel : public SensorBase, public LiveWindowSendable {
|
||||
PowerDistributionPanel();
|
||||
explicit PowerDistributionPanel(int module);
|
||||
|
||||
float GetVoltage() const;
|
||||
float GetTemperature() const;
|
||||
float GetCurrent(int channel) const;
|
||||
float GetTotalCurrent() const;
|
||||
float GetTotalPower() const;
|
||||
float GetTotalEnergy() const;
|
||||
double GetVoltage() const;
|
||||
double GetTemperature() const;
|
||||
double GetCurrent(int channel) const;
|
||||
double GetTotalCurrent() const;
|
||||
double GetTotalPower() const;
|
||||
double GetTotalEnergy() const;
|
||||
void ResetTotalEnergy();
|
||||
void ClearStickyFaults();
|
||||
|
||||
|
||||
@@ -47,8 +47,8 @@ class Relay : public MotorSafety,
|
||||
Value Get() const;
|
||||
int GetChannel() const;
|
||||
|
||||
void SetExpiration(float timeout) override;
|
||||
float GetExpiration() const override;
|
||||
void SetExpiration(double timeout) override;
|
||||
double GetExpiration() const override;
|
||||
bool IsAlive() const override;
|
||||
void StopMotor() override;
|
||||
bool IsSafetyEnabled() const override;
|
||||
|
||||
@@ -58,7 +58,7 @@ class RobotDrive : public MotorSafety, public ErrorBase {
|
||||
RobotDrive(const RobotDrive&) = delete;
|
||||
RobotDrive& operator=(const RobotDrive&) = delete;
|
||||
|
||||
void Drive(float outputMagnitude, float curve);
|
||||
void Drive(double outputMagnitude, double curve);
|
||||
void TankDrive(GenericHID* leftStick, GenericHID* rightStick,
|
||||
bool squaredInputs = true);
|
||||
void TankDrive(GenericHID& leftStick, GenericHID& rightStick,
|
||||
@@ -67,7 +67,8 @@ class RobotDrive : public MotorSafety, public ErrorBase {
|
||||
int rightAxis, bool squaredInputs = true);
|
||||
void TankDrive(GenericHID& leftStick, int leftAxis, GenericHID& rightStick,
|
||||
int rightAxis, bool squaredInputs = true);
|
||||
void TankDrive(float leftValue, float rightValue, bool squaredInputs = true);
|
||||
void TankDrive(double leftValue, double rightValue,
|
||||
bool squaredInputs = true);
|
||||
void ArcadeDrive(GenericHID* stick, bool squaredInputs = true);
|
||||
void ArcadeDrive(GenericHID& stick, bool squaredInputs = true);
|
||||
void ArcadeDrive(GenericHID* moveStick, int moveChannel,
|
||||
@@ -76,19 +77,19 @@ class RobotDrive : public MotorSafety, public ErrorBase {
|
||||
void ArcadeDrive(GenericHID& moveStick, int moveChannel,
|
||||
GenericHID& rotateStick, int rotateChannel,
|
||||
bool squaredInputs = true);
|
||||
void ArcadeDrive(float moveValue, float rotateValue,
|
||||
void ArcadeDrive(double moveValue, double rotateValue,
|
||||
bool squaredInputs = true);
|
||||
void MecanumDrive_Cartesian(float x, float y, float rotation,
|
||||
float gyroAngle = 0.0);
|
||||
void MecanumDrive_Polar(float magnitude, float direction, float rotation);
|
||||
void HolonomicDrive(float magnitude, float direction, float rotation);
|
||||
virtual void SetLeftRightMotorOutputs(float leftOutput, float rightOutput);
|
||||
void MecanumDrive_Cartesian(double x, double y, double rotation,
|
||||
double gyroAngle = 0.0);
|
||||
void MecanumDrive_Polar(double magnitude, double direction, double rotation);
|
||||
void HolonomicDrive(double magnitude, double direction, double rotation);
|
||||
virtual void SetLeftRightMotorOutputs(double leftOutput, double rightOutput);
|
||||
void SetInvertedMotor(MotorType motor, bool isInverted);
|
||||
void SetSensitivity(float sensitivity);
|
||||
void SetSensitivity(double sensitivity);
|
||||
void SetMaxOutput(double maxOutput);
|
||||
|
||||
void SetExpiration(float timeout) override;
|
||||
float GetExpiration() const override;
|
||||
void SetExpiration(double timeout) override;
|
||||
double GetExpiration() const override;
|
||||
bool IsAlive() const override;
|
||||
void StopMotor() override;
|
||||
bool IsSafetyEnabled() const override;
|
||||
@@ -97,12 +98,12 @@ class RobotDrive : public MotorSafety, public ErrorBase {
|
||||
|
||||
protected:
|
||||
void InitRobotDrive();
|
||||
float Limit(float num);
|
||||
double Limit(double num);
|
||||
void Normalize(double* wheelSpeeds);
|
||||
void RotateVector(double& x, double& y, double angle);
|
||||
|
||||
static const int kMaxNumberOfMotors = 4;
|
||||
float m_sensitivity = 0.5;
|
||||
double m_sensitivity = 0.5;
|
||||
double m_maxOutput = 1.0;
|
||||
std::shared_ptr<SpeedController> m_frontLeftMotor;
|
||||
std::shared_ptr<SpeedController> m_frontRightMotor;
|
||||
|
||||
@@ -28,15 +28,15 @@ class SafePWM : public PWM, public MotorSafety {
|
||||
explicit SafePWM(int channel);
|
||||
virtual ~SafePWM() = default;
|
||||
|
||||
void SetExpiration(float timeout);
|
||||
float GetExpiration() const;
|
||||
void SetExpiration(double timeout);
|
||||
double GetExpiration() const;
|
||||
bool IsAlive() const;
|
||||
void StopMotor();
|
||||
bool IsSafetyEnabled() const;
|
||||
void SetSafetyEnabled(bool enabled);
|
||||
void GetDescription(std::ostringstream& desc) const;
|
||||
|
||||
virtual void SetSpeed(float speed);
|
||||
virtual void SetSpeed(double speed);
|
||||
|
||||
private:
|
||||
std::unique_ptr<MotorSafetyHelper> m_safetyHelper;
|
||||
|
||||
@@ -61,7 +61,7 @@ class SerialPort : public ErrorBase {
|
||||
int GetBytesReceived();
|
||||
int Read(char* buffer, int count);
|
||||
int Write(const std::string& buffer, int count);
|
||||
void SetTimeout(float timeout);
|
||||
void SetTimeout(double timeout);
|
||||
void SetReadBufferSize(int size);
|
||||
void SetWriteBufferSize(int size);
|
||||
void SetWriteBufferMode(WriteBufferMode mode);
|
||||
|
||||
@@ -26,13 +26,13 @@ class Servo : public SafePWM {
|
||||
public:
|
||||
explicit Servo(int channel);
|
||||
virtual ~Servo();
|
||||
void Set(float value);
|
||||
void Set(double value);
|
||||
void SetOffline();
|
||||
float Get() const;
|
||||
void SetAngle(float angle);
|
||||
float GetAngle() const;
|
||||
static float GetMaxAngle() { return kMaxServoAngle; }
|
||||
static float GetMinAngle() { return kMinServoAngle; }
|
||||
double Get() const;
|
||||
void SetAngle(double angle);
|
||||
double GetAngle() const;
|
||||
static double GetMaxAngle() { return kMaxServoAngle; }
|
||||
static double GetMinAngle() { return kMinServoAngle; }
|
||||
|
||||
void ValueChanged(ITable* source, llvm::StringRef key,
|
||||
std::shared_ptr<nt::Value> value, bool isNew) override;
|
||||
@@ -46,13 +46,13 @@ class Servo : public SafePWM {
|
||||
std::shared_ptr<ITable> m_table;
|
||||
|
||||
private:
|
||||
float GetServoAngleRange() const { return kMaxServoAngle - kMinServoAngle; }
|
||||
double GetServoAngleRange() const { return kMaxServoAngle - kMinServoAngle; }
|
||||
|
||||
static constexpr float kMaxServoAngle = 180.0;
|
||||
static constexpr float kMinServoAngle = 0.0;
|
||||
static constexpr double kMaxServoAngle = 180.0;
|
||||
static constexpr double kMinServoAngle = 0.0;
|
||||
|
||||
static constexpr float kDefaultMaxServoPWM = 2.4;
|
||||
static constexpr float kDefaultMinServoPWM = .6;
|
||||
static constexpr double kDefaultMaxServoPWM = 2.4;
|
||||
static constexpr double kDefaultMinServoPWM = .6;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
|
||||
@@ -22,14 +22,14 @@ class SpeedController : public PIDOutput {
|
||||
*
|
||||
* @param speed The speed to set. Value should be between -1.0 and 1.0.
|
||||
*/
|
||||
virtual void Set(float speed) = 0;
|
||||
virtual void Set(double speed) = 0;
|
||||
|
||||
/**
|
||||
* Common interface for getting the current set speed of a speed controller.
|
||||
*
|
||||
* @return The current set speed. Value is between -1.0 and 1.0.
|
||||
*/
|
||||
virtual float Get() const = 0;
|
||||
virtual double Get() const = 0;
|
||||
|
||||
/**
|
||||
* Common interface for inverting direction of a speed controller.
|
||||
|
||||
@@ -137,9 +137,8 @@ void ADXRS450_Gyro::Reset() { m_spi.ResetAccumulator(); }
|
||||
* @return the current heading of the robot in degrees. This heading is based on
|
||||
* integration of the returned rate from the gyro.
|
||||
*/
|
||||
float ADXRS450_Gyro::GetAngle() const {
|
||||
return static_cast<float>(m_spi.GetAccumulatorValue() *
|
||||
kDegreePerSecondPerLSB * kSamplePeriod);
|
||||
double ADXRS450_Gyro::GetAngle() const {
|
||||
return m_spi.GetAccumulatorValue() * kDegreePerSecondPerLSB * kSamplePeriod;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -81,7 +81,7 @@ AnalogAccelerometer::AnalogAccelerometer(std::shared_ptr<AnalogInput> channel)
|
||||
*
|
||||
* @return The current acceleration of the sensor in Gs.
|
||||
*/
|
||||
float AnalogAccelerometer::GetAcceleration() const {
|
||||
double AnalogAccelerometer::GetAcceleration() const {
|
||||
return (m_analogInput->GetAverageVoltage() - m_zeroGVoltage) / m_voltsPerG;
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ float AnalogAccelerometer::GetAcceleration() const {
|
||||
*
|
||||
* @param sensitivity The sensitivity of accelerometer in Volts per G.
|
||||
*/
|
||||
void AnalogAccelerometer::SetSensitivity(float sensitivity) {
|
||||
void AnalogAccelerometer::SetSensitivity(double sensitivity) {
|
||||
m_voltsPerG = sensitivity;
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ void AnalogAccelerometer::SetSensitivity(float sensitivity) {
|
||||
*
|
||||
* @param zero The zero G voltage.
|
||||
*/
|
||||
void AnalogAccelerometer::SetZero(float zero) { m_zeroGVoltage = zero; }
|
||||
void AnalogAccelerometer::SetZero(double zero) { m_zeroGVoltage = zero; }
|
||||
|
||||
/**
|
||||
* Get the Acceleration for the PID Source parent.
|
||||
|
||||
@@ -19,9 +19,9 @@ using namespace frc;
|
||||
|
||||
const int AnalogGyro::kOversampleBits;
|
||||
const int AnalogGyro::kAverageBits;
|
||||
constexpr float AnalogGyro::kSamplesPerSecond;
|
||||
constexpr float AnalogGyro::kCalibrationSampleTime;
|
||||
constexpr float AnalogGyro::kDefaultVoltsPerDegreePerSecond;
|
||||
constexpr double AnalogGyro::kSamplesPerSecond;
|
||||
constexpr double AnalogGyro::kCalibrationSampleTime;
|
||||
constexpr double AnalogGyro::kDefaultVoltsPerDegreePerSecond;
|
||||
|
||||
/**
|
||||
* Gyro constructor using the Analog Input channel number.
|
||||
@@ -78,7 +78,7 @@ AnalogGyro::AnalogGyro(std::shared_ptr<AnalogInput> channel)
|
||||
* value.
|
||||
* @param offset Preset uncalibrated value to use as the gyro offset.
|
||||
*/
|
||||
AnalogGyro::AnalogGyro(int channel, int center, float offset) {
|
||||
AnalogGyro::AnalogGyro(int channel, int center, double offset) {
|
||||
m_analog = std::make_shared<AnalogInput>(channel);
|
||||
InitGyro();
|
||||
int32_t status = 0;
|
||||
@@ -104,7 +104,7 @@ AnalogGyro::AnalogGyro(int channel, int center, float offset) {
|
||||
* connected to.
|
||||
*/
|
||||
AnalogGyro::AnalogGyro(std::shared_ptr<AnalogInput> channel, int center,
|
||||
float offset)
|
||||
double offset)
|
||||
: m_analog(channel) {
|
||||
if (channel == nullptr) {
|
||||
wpi_setWPIError(NullParameter);
|
||||
@@ -198,10 +198,10 @@ void AnalogGyro::Calibrate() {
|
||||
* @return the current heading of the robot in degrees. This heading is based on
|
||||
* integration of the returned rate from the gyro.
|
||||
*/
|
||||
float AnalogGyro::GetAngle() const {
|
||||
if (StatusIsFatal()) return 0.f;
|
||||
double AnalogGyro::GetAngle() const {
|
||||
if (StatusIsFatal()) return 0.0;
|
||||
int32_t status = 0;
|
||||
float value = HAL_GetAnalogGyroAngle(m_gyroHandle, &status);
|
||||
double value = HAL_GetAnalogGyroAngle(m_gyroHandle, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
return value;
|
||||
}
|
||||
@@ -227,10 +227,10 @@ double AnalogGyro::GetRate() const {
|
||||
*
|
||||
* @return the current offset value
|
||||
*/
|
||||
float AnalogGyro::GetOffset() const {
|
||||
double AnalogGyro::GetOffset() const {
|
||||
if (StatusIsFatal()) return 0.0;
|
||||
int32_t status = 0;
|
||||
float value = HAL_GetAnalogGyroOffset(m_gyroHandle, &status);
|
||||
double value = HAL_GetAnalogGyroOffset(m_gyroHandle, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
return value;
|
||||
}
|
||||
@@ -258,7 +258,7 @@ int AnalogGyro::GetCenter() const {
|
||||
*
|
||||
* @param voltsPerDegreePerSecond The sensitivity in Volts/degree/second
|
||||
*/
|
||||
void AnalogGyro::SetSensitivity(float voltsPerDegreePerSecond) {
|
||||
void AnalogGyro::SetSensitivity(double voltsPerDegreePerSecond) {
|
||||
int32_t status = 0;
|
||||
HAL_SetAnalogGyroVoltsPerDegreePerSecond(m_gyroHandle,
|
||||
voltsPerDegreePerSecond, &status);
|
||||
@@ -274,7 +274,7 @@ void AnalogGyro::SetSensitivity(float voltsPerDegreePerSecond) {
|
||||
*
|
||||
* @param volts The size of the deadband in volts
|
||||
*/
|
||||
void AnalogGyro::SetDeadband(float volts) {
|
||||
void AnalogGyro::SetDeadband(double volts) {
|
||||
if (StatusIsFatal()) return;
|
||||
int32_t status = 0;
|
||||
HAL_SetAnalogGyroDeadband(m_gyroHandle, volts, &status);
|
||||
|
||||
@@ -107,10 +107,10 @@ int AnalogInput::GetAverageValue() const {
|
||||
*
|
||||
* @return A scaled sample straight from this channel.
|
||||
*/
|
||||
float AnalogInput::GetVoltage() const {
|
||||
if (StatusIsFatal()) return 0.0f;
|
||||
double AnalogInput::GetVoltage() const {
|
||||
if (StatusIsFatal()) return 0.0;
|
||||
int32_t status = 0;
|
||||
float voltage = HAL_GetAnalogVoltage(m_port, &status);
|
||||
double voltage = HAL_GetAnalogVoltage(m_port, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
return voltage;
|
||||
}
|
||||
@@ -129,10 +129,10 @@ float AnalogInput::GetVoltage() const {
|
||||
* @return A scaled sample from the output of the oversample and average engine
|
||||
* for this channel.
|
||||
*/
|
||||
float AnalogInput::GetAverageVoltage() const {
|
||||
if (StatusIsFatal()) return 0.0f;
|
||||
double AnalogInput::GetAverageVoltage() const {
|
||||
if (StatusIsFatal()) return 0.0;
|
||||
int32_t status = 0;
|
||||
float voltage = HAL_GetAnalogAverageVoltage(m_port, &status);
|
||||
double voltage = HAL_GetAnalogAverageVoltage(m_port, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
return voltage;
|
||||
}
|
||||
@@ -293,9 +293,9 @@ void AnalogInput::ResetAccumulator() {
|
||||
if (!StatusIsFatal()) {
|
||||
// Wait until the next sample, so the next call to GetAccumulator*()
|
||||
// won't have old values.
|
||||
const float sampleTime = 1.0f / GetSampleRate();
|
||||
const float overSamples = 1 << GetOversampleBits();
|
||||
const float averageSamples = 1 << GetAverageBits();
|
||||
const double sampleTime = 1.0 / GetSampleRate();
|
||||
const double overSamples = 1 << GetOversampleBits();
|
||||
const double averageSamples = 1 << GetAverageBits();
|
||||
Wait(sampleTime * overSamples * averageSamples);
|
||||
}
|
||||
}
|
||||
@@ -385,7 +385,7 @@ void AnalogInput::GetAccumulatorOutput(int64_t& value, int64_t& count) const {
|
||||
*
|
||||
* @param samplesPerSecond The number of samples per second.
|
||||
*/
|
||||
void AnalogInput::SetSampleRate(float samplesPerSecond) {
|
||||
void AnalogInput::SetSampleRate(double samplesPerSecond) {
|
||||
int32_t status = 0;
|
||||
HAL_SetAnalogSampleRate(samplesPerSecond, &status);
|
||||
wpi_setGlobalErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
@@ -396,9 +396,9 @@ void AnalogInput::SetSampleRate(float samplesPerSecond) {
|
||||
*
|
||||
* @return Sample rate.
|
||||
*/
|
||||
float AnalogInput::GetSampleRate() {
|
||||
double AnalogInput::GetSampleRate() {
|
||||
int32_t status = 0;
|
||||
float sampleRate = HAL_GetAnalogSampleRate(&status);
|
||||
double sampleRate = HAL_GetAnalogSampleRate(&status);
|
||||
wpi_setGlobalErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
return sampleRate;
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ AnalogOutput::~AnalogOutput() { HAL_FreeAnalogOutputPort(m_port); }
|
||||
*
|
||||
* @param voltage The output value in Volts, from 0.0 to +5.0
|
||||
*/
|
||||
void AnalogOutput::SetVoltage(float voltage) {
|
||||
void AnalogOutput::SetVoltage(double voltage) {
|
||||
int32_t status = 0;
|
||||
HAL_SetAnalogOutput(m_port, voltage, &status);
|
||||
|
||||
@@ -75,9 +75,9 @@ void AnalogOutput::SetVoltage(float voltage) {
|
||||
*
|
||||
* @return The value in Volts, from 0.0 to +5.0
|
||||
*/
|
||||
float AnalogOutput::GetVoltage() const {
|
||||
double AnalogOutput::GetVoltage() const {
|
||||
int32_t status = 0;
|
||||
float voltage = HAL_GetAnalogOutput(m_port, &status);
|
||||
double voltage = HAL_GetAnalogOutput(m_port, &status);
|
||||
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ void AnalogTrigger::SetLimitsRaw(int lower, int upper) {
|
||||
* @param lower The lower limit of the trigger in Volts.
|
||||
* @param upper The upper limit of the trigger in Volts.
|
||||
*/
|
||||
void AnalogTrigger::SetLimitsVoltage(float lower, float upper) {
|
||||
void AnalogTrigger::SetLimitsVoltage(double lower, double upper) {
|
||||
if (StatusIsFatal()) return;
|
||||
int32_t status = 0;
|
||||
HAL_SetAnalogTriggerLimitsVoltage(m_trigger, lower, upper, &status);
|
||||
|
||||
@@ -89,10 +89,10 @@ bool Compressor::GetPressureSwitchValue() const {
|
||||
*
|
||||
* @return The current through the compressor, in amps
|
||||
*/
|
||||
float Compressor::GetCompressorCurrent() const {
|
||||
double Compressor::GetCompressorCurrent() const {
|
||||
if (StatusIsFatal()) return 0;
|
||||
int32_t status = 0;
|
||||
float value;
|
||||
double value;
|
||||
|
||||
value = HAL_GetCompressorCurrent(m_compressorHandle, &status);
|
||||
|
||||
|
||||
@@ -20,9 +20,9 @@ using namespace frc;
|
||||
*
|
||||
* @return The controller input voltage value in Volts
|
||||
*/
|
||||
float ControllerPower::GetInputVoltage() {
|
||||
double ControllerPower::GetInputVoltage() {
|
||||
int32_t status = 0;
|
||||
float retVal = HAL_GetVinVoltage(&status);
|
||||
double retVal = HAL_GetVinVoltage(&status);
|
||||
wpi_setGlobalErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
return retVal;
|
||||
}
|
||||
@@ -32,9 +32,9 @@ float ControllerPower::GetInputVoltage() {
|
||||
*
|
||||
* @return The controller input current value in Amps
|
||||
*/
|
||||
float ControllerPower::GetInputCurrent() {
|
||||
double ControllerPower::GetInputCurrent() {
|
||||
int32_t status = 0;
|
||||
float retVal = HAL_GetVinCurrent(&status);
|
||||
double retVal = HAL_GetVinCurrent(&status);
|
||||
wpi_setGlobalErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
return retVal;
|
||||
}
|
||||
@@ -44,9 +44,9 @@ float ControllerPower::GetInputCurrent() {
|
||||
*
|
||||
* @return The controller 6V rail voltage value in Volts
|
||||
*/
|
||||
float ControllerPower::GetVoltage6V() {
|
||||
double ControllerPower::GetVoltage6V() {
|
||||
int32_t status = 0;
|
||||
float retVal = HAL_GetUserVoltage6V(&status);
|
||||
double retVal = HAL_GetUserVoltage6V(&status);
|
||||
wpi_setGlobalErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
return retVal;
|
||||
}
|
||||
@@ -56,9 +56,9 @@ float ControllerPower::GetVoltage6V() {
|
||||
*
|
||||
* @return The controller 6V rail output current value in Amps
|
||||
*/
|
||||
float ControllerPower::GetCurrent6V() {
|
||||
double ControllerPower::GetCurrent6V() {
|
||||
int32_t status = 0;
|
||||
float retVal = HAL_GetUserCurrent6V(&status);
|
||||
double retVal = HAL_GetUserCurrent6V(&status);
|
||||
wpi_setGlobalErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
return retVal;
|
||||
}
|
||||
@@ -94,9 +94,9 @@ int ControllerPower::GetFaultCount6V() {
|
||||
*
|
||||
* @return The controller 5V rail voltage value in Volts
|
||||
*/
|
||||
float ControllerPower::GetVoltage5V() {
|
||||
double ControllerPower::GetVoltage5V() {
|
||||
int32_t status = 0;
|
||||
float retVal = HAL_GetUserVoltage5V(&status);
|
||||
double retVal = HAL_GetUserVoltage5V(&status);
|
||||
wpi_setGlobalErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
return retVal;
|
||||
}
|
||||
@@ -106,9 +106,9 @@ float ControllerPower::GetVoltage5V() {
|
||||
*
|
||||
* @return The controller 5V rail output current value in Amps
|
||||
*/
|
||||
float ControllerPower::GetCurrent5V() {
|
||||
double ControllerPower::GetCurrent5V() {
|
||||
int32_t status = 0;
|
||||
float retVal = HAL_GetUserCurrent5V(&status);
|
||||
double retVal = HAL_GetUserCurrent5V(&status);
|
||||
wpi_setGlobalErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
return retVal;
|
||||
}
|
||||
@@ -144,9 +144,9 @@ int ControllerPower::GetFaultCount5V() {
|
||||
*
|
||||
* @return The controller 3.3V rail voltage value in Volts
|
||||
*/
|
||||
float ControllerPower::GetVoltage3V3() {
|
||||
double ControllerPower::GetVoltage3V3() {
|
||||
int32_t status = 0;
|
||||
float retVal = HAL_GetUserVoltage3V3(&status);
|
||||
double retVal = HAL_GetUserVoltage3V3(&status);
|
||||
wpi_setGlobalErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
return retVal;
|
||||
}
|
||||
@@ -156,9 +156,9 @@ float ControllerPower::GetVoltage3V3() {
|
||||
*
|
||||
* @return The controller 3.3V rail output current value in Amps
|
||||
*/
|
||||
float ControllerPower::GetCurrent3V3() {
|
||||
double ControllerPower::GetCurrent3V3() {
|
||||
int32_t status = 0;
|
||||
float retVal = HAL_GetUserCurrent3V3(&status);
|
||||
double retVal = HAL_GetUserCurrent3V3(&status);
|
||||
wpi_setGlobalErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
return retVal;
|
||||
}
|
||||
|
||||
@@ -446,7 +446,7 @@ void Counter::SetSemiPeriodMode(bool highSemiPeriod) {
|
||||
* @param threshold The pulse length beyond which the counter counts the
|
||||
* opposite direction. Units are seconds.
|
||||
*/
|
||||
void Counter::SetPulseLengthMode(float threshold) {
|
||||
void Counter::SetPulseLengthMode(double threshold) {
|
||||
if (StatusIsFatal()) return;
|
||||
int32_t status = 0;
|
||||
HAL_SetCounterPulseLengthMode(m_counter, threshold, &status);
|
||||
|
||||
@@ -102,7 +102,7 @@ int DigitalOutput::GetChannel() const { return m_channel; }
|
||||
*
|
||||
* @param length The pulselength in seconds
|
||||
*/
|
||||
void DigitalOutput::Pulse(float length) {
|
||||
void DigitalOutput::Pulse(double length) {
|
||||
if (StatusIsFatal()) return;
|
||||
|
||||
int32_t status = 0;
|
||||
@@ -134,7 +134,7 @@ bool DigitalOutput::IsPulsing() const {
|
||||
*
|
||||
* @param rate The frequency to output all digital output PWM signals.
|
||||
*/
|
||||
void DigitalOutput::SetPWMRate(float rate) {
|
||||
void DigitalOutput::SetPWMRate(double rate) {
|
||||
if (StatusIsFatal()) return;
|
||||
|
||||
int32_t status = 0;
|
||||
@@ -155,7 +155,7 @@ void DigitalOutput::SetPWMRate(float rate) {
|
||||
*
|
||||
* @param initialDutyCycle The duty-cycle to start generating. [0..1]
|
||||
*/
|
||||
void DigitalOutput::EnablePWM(float initialDutyCycle) {
|
||||
void DigitalOutput::EnablePWM(double initialDutyCycle) {
|
||||
if (m_pwmGenerator != HAL_kInvalidHandle) return;
|
||||
|
||||
int32_t status = 0;
|
||||
@@ -202,7 +202,7 @@ void DigitalOutput::DisablePWM() {
|
||||
*
|
||||
* @param dutyCycle The duty-cycle to change to. [0..1]
|
||||
*/
|
||||
void DigitalOutput::UpdateDutyCycle(float dutyCycle) {
|
||||
void DigitalOutput::UpdateDutyCycle(double dutyCycle) {
|
||||
if (StatusIsFatal()) return;
|
||||
|
||||
int32_t status = 0;
|
||||
|
||||
@@ -79,7 +79,7 @@ void DriverStation::ReportError(bool is_error, int32_t code,
|
||||
* @param axis The analog axis value to read from the joystick.
|
||||
* @return The value of the axis on the joystick.
|
||||
*/
|
||||
float DriverStation::GetStickAxis(int stick, int axis) {
|
||||
double DriverStation::GetStickAxis(int stick, int axis) {
|
||||
if (stick >= kJoystickPorts) {
|
||||
wpi_setWPIError(BadJoystickIndex);
|
||||
return 0;
|
||||
@@ -94,7 +94,7 @@ float DriverStation::GetStickAxis(int stick, int axis) {
|
||||
else
|
||||
ReportJoystickUnpluggedWarning(
|
||||
"Joystick Axis missing, check if all controllers are plugged in");
|
||||
return 0.0f;
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
return m_joystickAxes[stick].axes[axis];
|
||||
@@ -518,9 +518,9 @@ double DriverStation::GetMatchTime() const {
|
||||
*
|
||||
* @return The battery voltage in Volts.
|
||||
*/
|
||||
float DriverStation::GetBatteryVoltage() const {
|
||||
double DriverStation::GetBatteryVoltage() const {
|
||||
int32_t status = 0;
|
||||
float voltage = HAL_GetVinVoltage(&status);
|
||||
double voltage = HAL_GetVinVoltage(&status);
|
||||
wpi_setErrorWithContext(status, "getVinVoltage");
|
||||
|
||||
return voltage;
|
||||
|
||||
@@ -296,10 +296,10 @@ bool Encoder::GetDirection() const {
|
||||
* The scale needed to convert a raw counter value into a number of encoder
|
||||
* pulses.
|
||||
*/
|
||||
float Encoder::DecodingScaleFactor() const {
|
||||
double Encoder::DecodingScaleFactor() const {
|
||||
if (StatusIsFatal()) return 0.0;
|
||||
int32_t status = 0;
|
||||
float val = HAL_GetEncoderDecodingScaleFactor(m_encoder, &status);
|
||||
double val = HAL_GetEncoderDecodingScaleFactor(m_encoder, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
return val;
|
||||
}
|
||||
@@ -310,10 +310,10 @@ float Encoder::DecodingScaleFactor() const {
|
||||
* @return The distance driven since the last reset as scaled by the value from
|
||||
* SetDistancePerPulse().
|
||||
*/
|
||||
float Encoder::GetDistance() const {
|
||||
double Encoder::GetDistance() const {
|
||||
if (StatusIsFatal()) return 0.0;
|
||||
int32_t status = 0;
|
||||
float value = HAL_GetEncoderDistance(m_encoder, &status);
|
||||
double value = HAL_GetEncoderDistance(m_encoder, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
return value;
|
||||
}
|
||||
@@ -326,10 +326,10 @@ float Encoder::GetDistance() const {
|
||||
*
|
||||
* @return The current rate of the encoder.
|
||||
*/
|
||||
float Encoder::GetRate() const {
|
||||
double Encoder::GetRate() const {
|
||||
if (StatusIsFatal()) return 0.0;
|
||||
int32_t status = 0;
|
||||
float value = HAL_GetEncoderRate(m_encoder, &status);
|
||||
double value = HAL_GetEncoderRate(m_encoder, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
return value;
|
||||
}
|
||||
@@ -340,7 +340,7 @@ float Encoder::GetRate() const {
|
||||
* @param minRate The minimum rate. The units are in distance per second as
|
||||
* scaled by the value from SetDistancePerPulse().
|
||||
*/
|
||||
void Encoder::SetMinRate(float minRate) {
|
||||
void Encoder::SetMinRate(double minRate) {
|
||||
if (StatusIsFatal()) return;
|
||||
int32_t status = 0;
|
||||
HAL_SetEncoderMinRate(m_encoder, minRate, &status);
|
||||
@@ -364,7 +364,7 @@ void Encoder::SetMinRate(float minRate) {
|
||||
* @param distancePerPulse The scale factor that will be used to convert pulses
|
||||
* to useful units.
|
||||
*/
|
||||
void Encoder::SetDistancePerPulse(float distancePerPulse) {
|
||||
void Encoder::SetDistancePerPulse(double distancePerPulse) {
|
||||
if (StatusIsFatal()) return;
|
||||
int32_t status = 0;
|
||||
HAL_SetEncoderDistancePerPulse(m_encoder, distancePerPulse, &status);
|
||||
|
||||
@@ -22,7 +22,7 @@ GenericHID::GenericHID(int port) : m_ds(DriverStation::GetInstance()) {
|
||||
* @param axis The axis to read, starting at 0.
|
||||
* @return The value of the axis.
|
||||
*/
|
||||
float GenericHID::GetRawAxis(int axis) const {
|
||||
double GenericHID::GetRawAxis(int axis) const {
|
||||
return m_ds.GetStickAxis(m_port, axis);
|
||||
}
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@ void InterruptableSensorBase::CancelInterrupts() {
|
||||
* @return What interrupts fired
|
||||
*/
|
||||
InterruptableSensorBase::WaitResult InterruptableSensorBase::WaitForInterrupt(
|
||||
float timeout, bool ignorePrevious) {
|
||||
double timeout, bool ignorePrevious) {
|
||||
if (StatusIsFatal()) return InterruptableSensorBase::kTimeout;
|
||||
wpi_assert(m_interrupt != HAL_kInvalidHandle);
|
||||
int32_t status = 0;
|
||||
|
||||
@@ -90,7 +90,7 @@ Joystick* Joystick::GetStickForPort(int port) {
|
||||
* @param hand This parameter is ignored for the Joystick class and is only
|
||||
* here to complete the GenericHID interface.
|
||||
*/
|
||||
float Joystick::GetX(JoystickHand hand) const {
|
||||
double Joystick::GetX(JoystickHand hand) const {
|
||||
return GetRawAxis(m_axes[kXAxis]);
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ float Joystick::GetX(JoystickHand hand) const {
|
||||
* @param hand This parameter is ignored for the Joystick class and is only
|
||||
* here to complete the GenericHID interface.
|
||||
*/
|
||||
float Joystick::GetY(JoystickHand hand) const {
|
||||
double Joystick::GetY(JoystickHand hand) const {
|
||||
return GetRawAxis(m_axes[kYAxis]);
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ float Joystick::GetY(JoystickHand hand) const {
|
||||
*
|
||||
* This depends on the mapping of the joystick connected to the current port.
|
||||
*/
|
||||
float Joystick::GetZ(JoystickHand hand) const {
|
||||
double Joystick::GetZ(JoystickHand hand) const {
|
||||
return GetRawAxis(m_axes[kZAxis]);
|
||||
}
|
||||
|
||||
@@ -120,14 +120,14 @@ float Joystick::GetZ(JoystickHand hand) const {
|
||||
*
|
||||
* This depends on the mapping of the joystick connected to the current port.
|
||||
*/
|
||||
float Joystick::GetTwist() const { return GetRawAxis(m_axes[kTwistAxis]); }
|
||||
double Joystick::GetTwist() const { return GetRawAxis(m_axes[kTwistAxis]); }
|
||||
|
||||
/**
|
||||
* Get the throttle value of the current joystick.
|
||||
*
|
||||
* This depends on the mapping of the joystick connected to the current port.
|
||||
*/
|
||||
float Joystick::GetThrottle() const {
|
||||
double Joystick::GetThrottle() const {
|
||||
return GetRawAxis(m_axes[kThrottleAxis]);
|
||||
}
|
||||
|
||||
@@ -141,7 +141,7 @@ float Joystick::GetThrottle() const {
|
||||
* @param axis The axis to read.
|
||||
* @return The value of the axis.
|
||||
*/
|
||||
float Joystick::GetAxis(AxisType axis) const {
|
||||
double Joystick::GetAxis(AxisType axis) const {
|
||||
switch (axis) {
|
||||
case kXAxis:
|
||||
return this->GetX();
|
||||
@@ -253,7 +253,7 @@ void Joystick::SetAxisChannel(AxisType axis, int channel) {
|
||||
*
|
||||
* @return The magnitude of the direction vector
|
||||
*/
|
||||
float Joystick::GetMagnitude() const {
|
||||
double Joystick::GetMagnitude() const {
|
||||
return std::sqrt(std::pow(GetX(), 2) + std::pow(GetY(), 2));
|
||||
}
|
||||
|
||||
@@ -263,7 +263,7 @@ float Joystick::GetMagnitude() const {
|
||||
*
|
||||
* @return The direction of the vector in radians
|
||||
*/
|
||||
float Joystick::GetDirectionRadians() const {
|
||||
double Joystick::GetDirectionRadians() const {
|
||||
return std::atan2(GetX(), -GetY());
|
||||
}
|
||||
|
||||
@@ -276,6 +276,6 @@ float Joystick::GetDirectionRadians() const {
|
||||
*
|
||||
* @return The direction of the vector in degrees
|
||||
*/
|
||||
float Joystick::GetDirectionDegrees() const {
|
||||
double Joystick::GetDirectionDegrees() const {
|
||||
return (180 / std::acos(-1)) * GetDirectionRadians();
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ void MotorSafetyHelper::Feed() {
|
||||
* Set the expiration time for the corresponding motor safety object.
|
||||
* @param expirationTime The timeout value in seconds.
|
||||
*/
|
||||
void MotorSafetyHelper::SetExpiration(float expirationTime) {
|
||||
void MotorSafetyHelper::SetExpiration(double expirationTime) {
|
||||
std::lock_guard<priority_recursive_mutex> sync(m_syncMutex);
|
||||
m_expiration = expirationTime;
|
||||
}
|
||||
@@ -68,7 +68,7 @@ void MotorSafetyHelper::SetExpiration(float expirationTime) {
|
||||
* Retrieve the timeout value for the corresponding motor safety object.
|
||||
* @return the timeout value in seconds.
|
||||
*/
|
||||
float MotorSafetyHelper::GetExpiration() const {
|
||||
double MotorSafetyHelper::GetExpiration() const {
|
||||
std::lock_guard<priority_recursive_mutex> sync(m_syncMutex);
|
||||
return m_expiration;
|
||||
}
|
||||
|
||||
@@ -36,9 +36,9 @@ static const std::string kEnabled = "enabled";
|
||||
* effects calculations of the integral and differental terms.
|
||||
* The default is 50ms.
|
||||
*/
|
||||
PIDController::PIDController(float Kp, float Ki, float Kd, PIDSource* source,
|
||||
PIDOutput* output, float period)
|
||||
: PIDController(Kp, Ki, Kd, 0.0f, source, output, period) {}
|
||||
PIDController::PIDController(double Kp, double Ki, double Kd, PIDSource* source,
|
||||
PIDOutput* output, double period)
|
||||
: PIDController(Kp, Ki, Kd, 0.0, source, output, period) {}
|
||||
|
||||
/**
|
||||
* Allocate a PID object with the given constants for P, I, D.
|
||||
@@ -52,9 +52,9 @@ PIDController::PIDController(float Kp, float Ki, float Kd, PIDSource* source,
|
||||
* effects calculations of the integral and differental terms.
|
||||
* The default is 50ms.
|
||||
*/
|
||||
PIDController::PIDController(float Kp, float Ki, float Kd, float Kf,
|
||||
PIDController::PIDController(double Kp, double Ki, double Kd, double Kf,
|
||||
PIDSource* source, PIDOutput* output,
|
||||
float period) {
|
||||
double period) {
|
||||
m_controlLoop = std::make_unique<Notifier>(&PIDController::Calculate, this);
|
||||
|
||||
m_P = Kp;
|
||||
@@ -101,8 +101,8 @@ void PIDController::Calculate() {
|
||||
|
||||
if (enabled) {
|
||||
std::lock_guard<priority_recursive_mutex> sync(m_mutex);
|
||||
float input = pidInput->PIDGet();
|
||||
float result;
|
||||
double input = pidInput->PIDGet();
|
||||
double result;
|
||||
PIDOutput* pidOutput;
|
||||
|
||||
m_error = GetContinuousError(m_setpoint - input);
|
||||
@@ -284,7 +284,7 @@ double PIDController::GetF() const {
|
||||
*
|
||||
* @return the latest calculated output
|
||||
*/
|
||||
float PIDController::Get() const {
|
||||
double PIDController::Get() const {
|
||||
std::lock_guard<priority_recursive_mutex> sync(m_mutex);
|
||||
return m_result;
|
||||
}
|
||||
@@ -309,7 +309,7 @@ void PIDController::SetContinuous(bool continuous) {
|
||||
* @param minimumInput the minimum value expected from the input
|
||||
* @param maximumInput the maximum value expected from the output
|
||||
*/
|
||||
void PIDController::SetInputRange(float minimumInput, float maximumInput) {
|
||||
void PIDController::SetInputRange(double minimumInput, double maximumInput) {
|
||||
{
|
||||
std::lock_guard<priority_recursive_mutex> sync(m_mutex);
|
||||
m_minimumInput = minimumInput;
|
||||
@@ -325,7 +325,7 @@ void PIDController::SetInputRange(float minimumInput, float maximumInput) {
|
||||
* @param minimumOutput the minimum value to write to the output
|
||||
* @param maximumOutput the maximum value to write to the output
|
||||
*/
|
||||
void PIDController::SetOutputRange(float minimumOutput, float maximumOutput) {
|
||||
void PIDController::SetOutputRange(double minimumOutput, double maximumOutput) {
|
||||
std::lock_guard<priority_recursive_mutex> sync(m_mutex);
|
||||
m_minimumOutput = minimumOutput;
|
||||
m_maximumOutput = maximumOutput;
|
||||
@@ -338,7 +338,7 @@ void PIDController::SetOutputRange(float minimumOutput, float maximumOutput) {
|
||||
*
|
||||
* @param setpoint the desired setpoint
|
||||
*/
|
||||
void PIDController::SetSetpoint(float setpoint) {
|
||||
void PIDController::SetSetpoint(double setpoint) {
|
||||
{
|
||||
std::lock_guard<priority_recursive_mutex> sync(m_mutex);
|
||||
|
||||
@@ -388,7 +388,7 @@ double PIDController::GetDeltaSetpoint() const {
|
||||
*
|
||||
* @return the current error
|
||||
*/
|
||||
float PIDController::GetError() const {
|
||||
double PIDController::GetError() const {
|
||||
double setpoint = GetSetpoint();
|
||||
{
|
||||
std::lock_guard<priority_recursive_mutex> sync(m_mutex);
|
||||
@@ -419,8 +419,8 @@ PIDSourceType PIDController::GetPIDSourceType() const {
|
||||
*
|
||||
* @return the average error
|
||||
*/
|
||||
float PIDController::GetAvgError() const {
|
||||
float avgError = 0;
|
||||
double PIDController::GetAvgError() const {
|
||||
double avgError = 0;
|
||||
{
|
||||
std::lock_guard<priority_recursive_mutex> sync(m_mutex);
|
||||
// Don't divide by zero.
|
||||
@@ -435,7 +435,7 @@ float PIDController::GetAvgError() const {
|
||||
*
|
||||
* @param percentage error which is tolerable
|
||||
*/
|
||||
void PIDController::SetTolerance(float percent) {
|
||||
void PIDController::SetTolerance(double percent) {
|
||||
std::lock_guard<priority_recursive_mutex> sync(m_mutex);
|
||||
m_toleranceType = kPercentTolerance;
|
||||
m_tolerance = percent;
|
||||
@@ -447,7 +447,7 @@ void PIDController::SetTolerance(float percent) {
|
||||
*
|
||||
* @param percentage error which is tolerable
|
||||
*/
|
||||
void PIDController::SetAbsoluteTolerance(float absTolerance) {
|
||||
void PIDController::SetAbsoluteTolerance(double absTolerance) {
|
||||
std::lock_guard<priority_recursive_mutex> sync(m_mutex);
|
||||
m_toleranceType = kAbsoluteTolerance;
|
||||
m_tolerance = absTolerance;
|
||||
@@ -459,7 +459,7 @@ void PIDController::SetAbsoluteTolerance(float absTolerance) {
|
||||
*
|
||||
* @param percentage error which is tolerable
|
||||
*/
|
||||
void PIDController::SetPercentTolerance(float percent) {
|
||||
void PIDController::SetPercentTolerance(double percent) {
|
||||
std::lock_guard<priority_recursive_mutex> sync(m_mutex);
|
||||
m_toleranceType = kPercentTolerance;
|
||||
m_tolerance = percent;
|
||||
|
||||
@@ -100,8 +100,8 @@ void PWM::EnableDeadbandElimination(bool eliminateDeadband) {
|
||||
* @param deadbandMin The low end of the deadband pulse width in ms
|
||||
* @param min The minimum pulse width in ms
|
||||
*/
|
||||
void PWM::SetBounds(float max, float deadbandMax, float center,
|
||||
float deadbandMin, float min) {
|
||||
void PWM::SetBounds(double max, double deadbandMax, double center,
|
||||
double deadbandMin, double min) {
|
||||
if (StatusIsFatal()) return;
|
||||
int32_t status = 0;
|
||||
HAL_SetPWMConfig(m_handle, max, deadbandMax, center, deadbandMin, min,
|
||||
@@ -162,7 +162,7 @@ void PWM::GetRawBounds(int* max, int* deadbandMax, int* center,
|
||||
*
|
||||
* @param pos The position to set the servo between 0.0 and 1.0.
|
||||
*/
|
||||
void PWM::SetPosition(float pos) {
|
||||
void PWM::SetPosition(double pos) {
|
||||
if (StatusIsFatal()) return;
|
||||
int32_t status = 0;
|
||||
HAL_SetPWMPosition(m_handle, pos, &status);
|
||||
@@ -179,10 +179,10 @@ void PWM::SetPosition(float pos) {
|
||||
*
|
||||
* @return The position the servo is set to between 0.0 and 1.0.
|
||||
*/
|
||||
float PWM::GetPosition() const {
|
||||
double PWM::GetPosition() const {
|
||||
if (StatusIsFatal()) return 0.0;
|
||||
int32_t status = 0;
|
||||
float position = HAL_GetPWMPosition(m_handle, &status);
|
||||
double position = HAL_GetPWMPosition(m_handle, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
return position;
|
||||
}
|
||||
@@ -200,7 +200,7 @@ float PWM::GetPosition() const {
|
||||
*
|
||||
* @param speed The speed to set the speed controller between -1.0 and 1.0.
|
||||
*/
|
||||
void PWM::SetSpeed(float speed) {
|
||||
void PWM::SetSpeed(double speed) {
|
||||
if (StatusIsFatal()) return;
|
||||
int32_t status = 0;
|
||||
HAL_SetPWMSpeed(m_handle, speed, &status);
|
||||
@@ -219,10 +219,10 @@ void PWM::SetSpeed(float speed) {
|
||||
*
|
||||
* @return The most recently set speed between -1.0 and 1.0.
|
||||
*/
|
||||
float PWM::GetSpeed() const {
|
||||
double PWM::GetSpeed() const {
|
||||
if (StatusIsFatal()) return 0.0;
|
||||
int32_t status = 0;
|
||||
float speed = HAL_GetPWMSpeed(m_handle, &status);
|
||||
double speed = HAL_GetPWMSpeed(m_handle, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
return speed;
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ PWMSpeedController::PWMSpeedController(int channel) : SafePWM(channel) {}
|
||||
*
|
||||
* @param speed The speed value between -1.0 and 1.0 to set.
|
||||
*/
|
||||
void PWMSpeedController::Set(float speed) {
|
||||
void PWMSpeedController::Set(double speed) {
|
||||
SetSpeed(m_isInverted ? -speed : speed);
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ void PWMSpeedController::Set(float speed) {
|
||||
*
|
||||
* @return The most recently set value for the PWM between -1.0 and 1.0.
|
||||
*/
|
||||
float PWMSpeedController::Get() const { return GetSpeed(); }
|
||||
double PWMSpeedController::Get() const { return GetSpeed(); }
|
||||
|
||||
/**
|
||||
* Common interface for disabling a motor.
|
||||
@@ -63,7 +63,7 @@ bool PWMSpeedController::GetInverted() const { return m_isInverted; }
|
||||
*
|
||||
* @param output Write out the PWM value as was found in the PIDController
|
||||
*/
|
||||
void PWMSpeedController::PIDWrite(float output) { Set(output); }
|
||||
void PWMSpeedController::PIDWrite(double output) { Set(output); }
|
||||
|
||||
/**
|
||||
* Common interface to stop the motor until Set is called again.
|
||||
|
||||
@@ -36,11 +36,11 @@ PowerDistributionPanel::PowerDistributionPanel(int module) : m_module(module) {
|
||||
*
|
||||
* @return The voltage of the PDP in volts
|
||||
*/
|
||||
float PowerDistributionPanel::GetVoltage() const {
|
||||
double PowerDistributionPanel::GetVoltage() const {
|
||||
if (StatusIsFatal()) return 0;
|
||||
int32_t status = 0;
|
||||
|
||||
float voltage = HAL_GetPDPVoltage(m_module, &status);
|
||||
double voltage = HAL_GetPDPVoltage(m_module, &status);
|
||||
|
||||
if (status) {
|
||||
wpi_setWPIErrorWithContext(Timeout, "");
|
||||
@@ -54,11 +54,11 @@ float PowerDistributionPanel::GetVoltage() const {
|
||||
*
|
||||
* @return The temperature of the PDP in degrees Celsius
|
||||
*/
|
||||
float PowerDistributionPanel::GetTemperature() const {
|
||||
double PowerDistributionPanel::GetTemperature() const {
|
||||
if (StatusIsFatal()) return 0;
|
||||
int32_t status = 0;
|
||||
|
||||
float temperature = HAL_GetPDPTemperature(m_module, &status);
|
||||
double temperature = HAL_GetPDPTemperature(m_module, &status);
|
||||
|
||||
if (status) {
|
||||
wpi_setWPIErrorWithContext(Timeout, "");
|
||||
@@ -72,7 +72,7 @@ float PowerDistributionPanel::GetTemperature() const {
|
||||
*
|
||||
* @return The current of one of the PDP channels (channels 0-15) in Amperes
|
||||
*/
|
||||
float PowerDistributionPanel::GetCurrent(int channel) const {
|
||||
double PowerDistributionPanel::GetCurrent(int channel) const {
|
||||
if (StatusIsFatal()) return 0;
|
||||
int32_t status = 0;
|
||||
|
||||
@@ -82,7 +82,7 @@ float PowerDistributionPanel::GetCurrent(int channel) const {
|
||||
wpi_setWPIErrorWithContext(ChannelIndexOutOfRange, buf.str());
|
||||
}
|
||||
|
||||
float current = HAL_GetPDPChannelCurrent(m_module, channel, &status);
|
||||
double current = HAL_GetPDPChannelCurrent(m_module, channel, &status);
|
||||
|
||||
if (status) {
|
||||
wpi_setWPIErrorWithContext(Timeout, "");
|
||||
@@ -96,11 +96,11 @@ float PowerDistributionPanel::GetCurrent(int channel) const {
|
||||
*
|
||||
* @return The the total current drawn from the PDP channels in Amperes
|
||||
*/
|
||||
float PowerDistributionPanel::GetTotalCurrent() const {
|
||||
double PowerDistributionPanel::GetTotalCurrent() const {
|
||||
if (StatusIsFatal()) return 0;
|
||||
int32_t status = 0;
|
||||
|
||||
float current = HAL_GetPDPTotalCurrent(m_module, &status);
|
||||
double current = HAL_GetPDPTotalCurrent(m_module, &status);
|
||||
|
||||
if (status) {
|
||||
wpi_setWPIErrorWithContext(Timeout, "");
|
||||
@@ -114,11 +114,11 @@ float PowerDistributionPanel::GetTotalCurrent() const {
|
||||
*
|
||||
* @return The the total power drawn from the PDP channels in Watts
|
||||
*/
|
||||
float PowerDistributionPanel::GetTotalPower() const {
|
||||
double PowerDistributionPanel::GetTotalPower() const {
|
||||
if (StatusIsFatal()) return 0;
|
||||
int32_t status = 0;
|
||||
|
||||
float power = HAL_GetPDPTotalPower(m_module, &status);
|
||||
double power = HAL_GetPDPTotalPower(m_module, &status);
|
||||
|
||||
if (status) {
|
||||
wpi_setWPIErrorWithContext(Timeout, "");
|
||||
@@ -132,11 +132,11 @@ float PowerDistributionPanel::GetTotalPower() const {
|
||||
*
|
||||
* @return The the total energy drawn from the PDP channels in Joules
|
||||
*/
|
||||
float PowerDistributionPanel::GetTotalEnergy() const {
|
||||
double PowerDistributionPanel::GetTotalEnergy() const {
|
||||
if (StatusIsFatal()) return 0;
|
||||
int32_t status = 0;
|
||||
|
||||
float energy = HAL_GetPDPTotalEnergy(m_module, &status);
|
||||
double energy = HAL_GetPDPTotalEnergy(m_module, &status);
|
||||
|
||||
if (status) {
|
||||
wpi_setWPIErrorWithContext(Timeout, "");
|
||||
|
||||
@@ -94,7 +94,7 @@ double Preferences::GetDouble(llvm::StringRef key, double defaultValue) {
|
||||
* @return either the value in the table, or the defaultValue
|
||||
*/
|
||||
float Preferences::GetFloat(llvm::StringRef key, float defaultValue) {
|
||||
return static_cast<float>(m_table->GetNumber(key, defaultValue));
|
||||
return m_table->GetNumber(key, defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -214,7 +214,7 @@ int Relay::GetChannel() const { return m_channel; }
|
||||
* Set the expiration time for the Relay object
|
||||
* @param timeout The timeout (in seconds) for this relay object
|
||||
*/
|
||||
void Relay::SetExpiration(float timeout) {
|
||||
void Relay::SetExpiration(double timeout) {
|
||||
m_safetyHelper->SetExpiration(timeout);
|
||||
}
|
||||
|
||||
@@ -222,7 +222,7 @@ void Relay::SetExpiration(float timeout) {
|
||||
* Return the expiration time for the relay object.
|
||||
* @return The expiration time value.
|
||||
*/
|
||||
float Relay::GetExpiration() const { return m_safetyHelper->GetExpiration(); }
|
||||
double Relay::GetExpiration() const { return m_safetyHelper->GetExpiration(); }
|
||||
|
||||
/**
|
||||
* Check if the relay object is currently alive or stopped due to a timeout.
|
||||
|
||||
@@ -214,8 +214,8 @@ RobotDrive::RobotDrive(std::shared_ptr<SpeedController> frontLeftMotor,
|
||||
* Conversely, turn radius r = -ln(curve)*w for a given value of curve and
|
||||
* wheelbase w.
|
||||
*/
|
||||
void RobotDrive::Drive(float outputMagnitude, float curve) {
|
||||
float leftOutput, rightOutput;
|
||||
void RobotDrive::Drive(double outputMagnitude, double curve) {
|
||||
double leftOutput, rightOutput;
|
||||
static bool reported = false;
|
||||
if (!reported) {
|
||||
HAL_Report(HALUsageReporting::kResourceType_RobotDrive, GetNumMotors(),
|
||||
@@ -224,14 +224,14 @@ void RobotDrive::Drive(float outputMagnitude, float curve) {
|
||||
}
|
||||
|
||||
if (curve < 0) {
|
||||
float value = std::log(-curve);
|
||||
float ratio = (value - m_sensitivity) / (value + m_sensitivity);
|
||||
double value = std::log(-curve);
|
||||
double ratio = (value - m_sensitivity) / (value + m_sensitivity);
|
||||
if (ratio == 0) ratio = .0000000001;
|
||||
leftOutput = outputMagnitude / ratio;
|
||||
rightOutput = outputMagnitude;
|
||||
} else if (curve > 0) {
|
||||
float value = std::log(curve);
|
||||
float ratio = (value - m_sensitivity) / (value + m_sensitivity);
|
||||
double value = std::log(curve);
|
||||
double ratio = (value - m_sensitivity) / (value + m_sensitivity);
|
||||
if (ratio == 0) ratio = .0000000001;
|
||||
leftOutput = outputMagnitude;
|
||||
rightOutput = outputMagnitude / ratio;
|
||||
@@ -303,7 +303,7 @@ void RobotDrive::TankDrive(GenericHID& leftStick, int leftAxis,
|
||||
* @param leftValue The value of the left stick.
|
||||
* @param rightValue The value of the right stick.
|
||||
*/
|
||||
void RobotDrive::TankDrive(float leftValue, float rightValue,
|
||||
void RobotDrive::TankDrive(double leftValue, double rightValue,
|
||||
bool squaredInputs) {
|
||||
static bool reported = false;
|
||||
if (!reported) {
|
||||
@@ -387,8 +387,8 @@ void RobotDrive::ArcadeDrive(GenericHID& stick, bool squaredInputs) {
|
||||
void RobotDrive::ArcadeDrive(GenericHID* moveStick, int moveAxis,
|
||||
GenericHID* rotateStick, int rotateAxis,
|
||||
bool squaredInputs) {
|
||||
float moveValue = moveStick->GetRawAxis(moveAxis);
|
||||
float rotateValue = rotateStick->GetRawAxis(rotateAxis);
|
||||
double moveValue = moveStick->GetRawAxis(moveAxis);
|
||||
double rotateValue = rotateStick->GetRawAxis(rotateAxis);
|
||||
|
||||
ArcadeDrive(moveValue, rotateValue, squaredInputs);
|
||||
}
|
||||
@@ -412,8 +412,8 @@ void RobotDrive::ArcadeDrive(GenericHID* moveStick, int moveAxis,
|
||||
void RobotDrive::ArcadeDrive(GenericHID& moveStick, int moveAxis,
|
||||
GenericHID& rotateStick, int rotateAxis,
|
||||
bool squaredInputs) {
|
||||
float moveValue = moveStick.GetRawAxis(moveAxis);
|
||||
float rotateValue = rotateStick.GetRawAxis(rotateAxis);
|
||||
double moveValue = moveStick.GetRawAxis(moveAxis);
|
||||
double rotateValue = rotateStick.GetRawAxis(rotateAxis);
|
||||
|
||||
ArcadeDrive(moveValue, rotateValue, squaredInputs);
|
||||
}
|
||||
@@ -427,7 +427,7 @@ void RobotDrive::ArcadeDrive(GenericHID& moveStick, int moveAxis,
|
||||
* @param rotateValue The value to use for the rotate right/left
|
||||
* @param squaredInputs If set, increases the sensitivity at low speeds
|
||||
*/
|
||||
void RobotDrive::ArcadeDrive(float moveValue, float rotateValue,
|
||||
void RobotDrive::ArcadeDrive(double moveValue, double rotateValue,
|
||||
bool squaredInputs) {
|
||||
static bool reported = false;
|
||||
if (!reported) {
|
||||
@@ -437,8 +437,8 @@ void RobotDrive::ArcadeDrive(float moveValue, float rotateValue,
|
||||
}
|
||||
|
||||
// local variables to hold the computed PWM values for the motors
|
||||
float leftMotorOutput;
|
||||
float rightMotorOutput;
|
||||
double leftMotorOutput;
|
||||
double rightMotorOutput;
|
||||
|
||||
moveValue = Limit(moveValue);
|
||||
rotateValue = Limit(rotateValue);
|
||||
@@ -499,8 +499,8 @@ void RobotDrive::ArcadeDrive(float moveValue, float rotateValue,
|
||||
* @param gyroAngle The current angle reading from the gyro. Use this to
|
||||
* implement field-oriented controls.
|
||||
*/
|
||||
void RobotDrive::MecanumDrive_Cartesian(float x, float y, float rotation,
|
||||
float gyroAngle) {
|
||||
void RobotDrive::MecanumDrive_Cartesian(double x, double y, double rotation,
|
||||
double gyroAngle) {
|
||||
static bool reported = false;
|
||||
if (!reported) {
|
||||
HAL_Report(HALUsageReporting::kResourceType_RobotDrive, GetNumMotors(),
|
||||
@@ -548,8 +548,8 @@ void RobotDrive::MecanumDrive_Cartesian(float x, float y, float rotation,
|
||||
* @param rotation The rate of rotation for the robot that is completely
|
||||
* independent of the magnitute or direction. [-1.0..1.0]
|
||||
*/
|
||||
void RobotDrive::MecanumDrive_Polar(float magnitude, float direction,
|
||||
float rotation) {
|
||||
void RobotDrive::MecanumDrive_Polar(double magnitude, double direction,
|
||||
double rotation) {
|
||||
static bool reported = false;
|
||||
if (!reported) {
|
||||
HAL_Report(HALUsageReporting::kResourceType_RobotDrive, GetNumMotors(),
|
||||
@@ -592,8 +592,8 @@ void RobotDrive::MecanumDrive_Polar(float magnitude, float direction,
|
||||
* @param rotation The rate of rotation for the robot that is completely
|
||||
* independent of the magnitude or direction. [-1.0..1.0]
|
||||
*/
|
||||
void RobotDrive::HolonomicDrive(float magnitude, float direction,
|
||||
float rotation) {
|
||||
void RobotDrive::HolonomicDrive(double magnitude, double direction,
|
||||
double rotation) {
|
||||
MecanumDrive_Polar(magnitude, direction, rotation);
|
||||
}
|
||||
|
||||
@@ -607,7 +607,8 @@ void RobotDrive::HolonomicDrive(float magnitude, float direction,
|
||||
* @param leftOutput The speed to send to the left side of the robot.
|
||||
* @param rightOutput The speed to send to the right side of the robot.
|
||||
*/
|
||||
void RobotDrive::SetLeftRightMotorOutputs(float leftOutput, float rightOutput) {
|
||||
void RobotDrive::SetLeftRightMotorOutputs(double leftOutput,
|
||||
double rightOutput) {
|
||||
wpi_assert(m_rearLeftMotor != nullptr && m_rearRightMotor != nullptr);
|
||||
|
||||
if (m_frontLeftMotor != nullptr)
|
||||
@@ -624,7 +625,7 @@ void RobotDrive::SetLeftRightMotorOutputs(float leftOutput, float rightOutput) {
|
||||
/**
|
||||
* Limit motor values to the -1.0 to +1.0 range.
|
||||
*/
|
||||
float RobotDrive::Limit(float num) {
|
||||
double RobotDrive::Limit(double num) {
|
||||
if (num > 1.0) {
|
||||
return 1.0;
|
||||
}
|
||||
@@ -702,7 +703,7 @@ void RobotDrive::SetInvertedMotor(MotorType motor, bool isInverted) {
|
||||
* @param sensitivity Effectively sets the turning sensitivity (or turn radius
|
||||
* for a given value)
|
||||
*/
|
||||
void RobotDrive::SetSensitivity(float sensitivity) {
|
||||
void RobotDrive::SetSensitivity(double sensitivity) {
|
||||
m_sensitivity = sensitivity;
|
||||
}
|
||||
|
||||
@@ -715,11 +716,11 @@ void RobotDrive::SetSensitivity(float sensitivity) {
|
||||
*/
|
||||
void RobotDrive::SetMaxOutput(double maxOutput) { m_maxOutput = maxOutput; }
|
||||
|
||||
void RobotDrive::SetExpiration(float timeout) {
|
||||
void RobotDrive::SetExpiration(double timeout) {
|
||||
m_safetyHelper->SetExpiration(timeout);
|
||||
}
|
||||
|
||||
float RobotDrive::GetExpiration() const {
|
||||
double RobotDrive::GetExpiration() const {
|
||||
return m_safetyHelper->GetExpiration();
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ SafePWM::SafePWM(int channel) : PWM(channel) {
|
||||
*
|
||||
* @param timeout The timeout (in seconds) for this motor object
|
||||
*/
|
||||
void SafePWM::SetExpiration(float timeout) {
|
||||
void SafePWM::SetExpiration(double timeout) {
|
||||
m_safetyHelper->SetExpiration(timeout);
|
||||
}
|
||||
|
||||
@@ -34,7 +34,9 @@ void SafePWM::SetExpiration(float timeout) {
|
||||
*
|
||||
* @returns The expiration time value.
|
||||
*/
|
||||
float SafePWM::GetExpiration() const { return m_safetyHelper->GetExpiration(); }
|
||||
double SafePWM::GetExpiration() const {
|
||||
return m_safetyHelper->GetExpiration();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the PWM object is currently alive or stopped due to a timeout.
|
||||
@@ -84,7 +86,7 @@ void SafePWM::GetDescription(std::ostringstream& desc) const {
|
||||
*
|
||||
* @param speed Value to pass to the PWM class
|
||||
*/
|
||||
void SafePWM::SetSpeed(float speed) {
|
||||
void SafePWM::SetSpeed(double speed) {
|
||||
PWM::SetSpeed(speed);
|
||||
m_safetyHelper->Feed();
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ SerialPort::SerialPort(int baudRate, Port port, int dataBits,
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
|
||||
// Set the default timeout to 5 seconds.
|
||||
SetTimeout(5.0f);
|
||||
SetTimeout(5.0);
|
||||
|
||||
// Don't wait until the buffer is full to transmit.
|
||||
SetWriteBufferMode(kFlushOnAccess);
|
||||
@@ -150,7 +150,7 @@ int SerialPort::Write(const std::string& buffer, int count) {
|
||||
*
|
||||
* @param timeout The number of seconds to to wait for I/O.
|
||||
*/
|
||||
void SerialPort::SetTimeout(float timeout) {
|
||||
void SerialPort::SetTimeout(double timeout) {
|
||||
int32_t status = 0;
|
||||
HAL_SetSerialTimeout(m_port, timeout, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
|
||||
@@ -11,11 +11,11 @@
|
||||
|
||||
using namespace frc;
|
||||
|
||||
constexpr float Servo::kMaxServoAngle;
|
||||
constexpr float Servo::kMinServoAngle;
|
||||
constexpr double Servo::kMaxServoAngle;
|
||||
constexpr double Servo::kMinServoAngle;
|
||||
|
||||
constexpr float Servo::kDefaultMaxServoPWM;
|
||||
constexpr float Servo::kDefaultMinServoPWM;
|
||||
constexpr double Servo::kDefaultMaxServoPWM;
|
||||
constexpr double Servo::kDefaultMinServoPWM;
|
||||
|
||||
/**
|
||||
* @param channel The PWM channel to which the servo is attached. 0-9 are
|
||||
@@ -45,7 +45,7 @@ Servo::~Servo() {
|
||||
*
|
||||
* @param value Position from 0.0 to 1.0.
|
||||
*/
|
||||
void Servo::Set(float value) { SetPosition(value); }
|
||||
void Servo::Set(double value) { SetPosition(value); }
|
||||
|
||||
/**
|
||||
* Set the servo to offline.
|
||||
@@ -62,7 +62,7 @@ void Servo::SetOffline() { SetRaw(0); }
|
||||
*
|
||||
* @return Position from 0.0 to 1.0.
|
||||
*/
|
||||
float Servo::Get() const { return GetPosition(); }
|
||||
double Servo::Get() const { return GetPosition(); }
|
||||
|
||||
/**
|
||||
* Set the servo angle.
|
||||
@@ -78,15 +78,14 @@ float Servo::Get() const { return GetPosition(); }
|
||||
*
|
||||
* @param degrees The angle in degrees to set the servo.
|
||||
*/
|
||||
void Servo::SetAngle(float degrees) {
|
||||
void Servo::SetAngle(double degrees) {
|
||||
if (degrees < kMinServoAngle) {
|
||||
degrees = kMinServoAngle;
|
||||
} else if (degrees > kMaxServoAngle) {
|
||||
degrees = kMaxServoAngle;
|
||||
}
|
||||
|
||||
SetPosition(static_cast<float>(degrees - kMinServoAngle) /
|
||||
GetServoAngleRange());
|
||||
SetPosition((degrees - kMinServoAngle) / GetServoAngleRange());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -97,9 +96,8 @@ void Servo::SetAngle(float degrees) {
|
||||
*
|
||||
* @return The angle in degrees to which the servo is set.
|
||||
*/
|
||||
float Servo::GetAngle() const {
|
||||
return static_cast<float>(GetPosition()) * GetServoAngleRange() +
|
||||
kMinServoAngle;
|
||||
double Servo::GetAngle() const {
|
||||
return GetPosition() * GetServoAngleRange() + kMinServoAngle;
|
||||
}
|
||||
|
||||
void Servo::ValueChanged(ITable* source, llvm::StringRef key,
|
||||
|
||||
@@ -31,7 +31,7 @@ XboxController::XboxController(int port)
|
||||
*
|
||||
* @param hand Side of controller whose value should be returned.
|
||||
*/
|
||||
float XboxController::GetX(JoystickHand hand) const {
|
||||
double XboxController::GetX(JoystickHand hand) const {
|
||||
if (hand == kLeftHand) {
|
||||
return GetRawAxis(0);
|
||||
} else {
|
||||
@@ -44,7 +44,7 @@ float XboxController::GetX(JoystickHand hand) const {
|
||||
*
|
||||
* @param hand Side of controller whose value should be returned.
|
||||
*/
|
||||
float XboxController::GetY(JoystickHand hand) const {
|
||||
double XboxController::GetY(JoystickHand hand) const {
|
||||
if (hand == kLeftHand) {
|
||||
return GetRawAxis(1);
|
||||
} else {
|
||||
@@ -84,7 +84,7 @@ bool XboxController::GetStickButton(JoystickHand hand) const {
|
||||
*
|
||||
* @param hand Side of controller whose value should be returned.
|
||||
*/
|
||||
float XboxController::GetTriggerAxis(JoystickHand hand) const {
|
||||
double XboxController::GetTriggerAxis(JoystickHand hand) const {
|
||||
if (hand == kLeftHand) {
|
||||
return GetRawAxis(2);
|
||||
} else {
|
||||
|
||||
@@ -32,7 +32,7 @@ class PIDCommand : public Command, public PIDOutput, public PIDSource {
|
||||
void SetSetpointRelative(double deltaSetpoint);
|
||||
|
||||
// PIDOutput interface
|
||||
virtual void PIDWrite(float output);
|
||||
virtual void PIDWrite(double output);
|
||||
|
||||
// PIDSource interface
|
||||
virtual double PIDGet();
|
||||
|
||||
@@ -42,20 +42,20 @@ class PIDSubsystem : public Subsystem, public PIDOutput, public PIDSource {
|
||||
void Disable();
|
||||
|
||||
// PIDOutput interface
|
||||
virtual void PIDWrite(float output);
|
||||
virtual void PIDWrite(double output);
|
||||
|
||||
// PIDSource interface
|
||||
virtual double PIDGet();
|
||||
void SetSetpoint(double setpoint);
|
||||
void SetSetpointRelative(double deltaSetpoint);
|
||||
void SetInputRange(float minimumInput, float maximumInput);
|
||||
void SetOutputRange(float minimumOutput, float maximumOutput);
|
||||
void SetInputRange(double minimumInput, double maximumInput);
|
||||
void SetOutputRange(double minimumOutput, double maximumOutput);
|
||||
double GetSetpoint();
|
||||
double GetPosition();
|
||||
double GetRate();
|
||||
|
||||
virtual void SetAbsoluteTolerance(float absValue);
|
||||
virtual void SetPercentTolerance(float percent);
|
||||
virtual void SetAbsoluteTolerance(double absValue);
|
||||
virtual void SetPercentTolerance(double percent);
|
||||
virtual bool OnTarget() const;
|
||||
|
||||
protected:
|
||||
|
||||
@@ -47,9 +47,9 @@ class GenericHID {
|
||||
explicit GenericHID(int port);
|
||||
virtual ~GenericHID() = default;
|
||||
|
||||
virtual float GetX(JoystickHand hand = kRightHand) const = 0;
|
||||
virtual float GetY(JoystickHand hand = kRightHand) const = 0;
|
||||
virtual float GetRawAxis(int axis) const;
|
||||
virtual double GetX(JoystickHand hand = kRightHand) const = 0;
|
||||
virtual double GetY(JoystickHand hand = kRightHand) const = 0;
|
||||
virtual double GetRawAxis(int axis) const;
|
||||
|
||||
bool GetRawButton(int button) const;
|
||||
|
||||
|
||||
@@ -58,21 +58,21 @@ class Joystick : public JoystickBase, public ErrorBase {
|
||||
int GetAxisChannel(AxisType axis) const;
|
||||
void SetAxisChannel(AxisType axis, int channel);
|
||||
|
||||
float GetX(JoystickHand hand = kRightHand) const override;
|
||||
float GetY(JoystickHand hand = kRightHand) const override;
|
||||
float GetZ(JoystickHand hand = kRightHand) const override;
|
||||
float GetTwist() const override;
|
||||
float GetThrottle() const override;
|
||||
virtual float GetAxis(AxisType axis) const;
|
||||
double GetX(JoystickHand hand = kRightHand) const override;
|
||||
double GetY(JoystickHand hand = kRightHand) const override;
|
||||
double GetZ(JoystickHand hand = kRightHand) const override;
|
||||
double GetTwist() const override;
|
||||
double GetThrottle() const override;
|
||||
virtual double GetAxis(AxisType axis) const;
|
||||
|
||||
bool GetTrigger(JoystickHand hand = kRightHand) const override;
|
||||
bool GetTop(JoystickHand hand = kRightHand) const override;
|
||||
bool GetButton(ButtonType button) const;
|
||||
static Joystick* GetStickForPort(int port);
|
||||
|
||||
virtual float GetMagnitude() const;
|
||||
virtual float GetDirectionRadians() const;
|
||||
virtual float GetDirectionDegrees() const;
|
||||
virtual double GetMagnitude() const;
|
||||
virtual double GetDirectionRadians() const;
|
||||
virtual double GetDirectionDegrees() const;
|
||||
|
||||
int GetAxisType(int axis) const;
|
||||
|
||||
|
||||
@@ -19,9 +19,9 @@ class JoystickBase : public GenericHID {
|
||||
explicit JoystickBase(int port);
|
||||
virtual ~JoystickBase() = default;
|
||||
|
||||
virtual float GetZ(JoystickHand hand = kRightHand) const = 0;
|
||||
virtual float GetTwist() const = 0;
|
||||
virtual float GetThrottle() const = 0;
|
||||
virtual double GetZ(JoystickHand hand = kRightHand) const = 0;
|
||||
virtual double GetTwist() const = 0;
|
||||
virtual double GetThrottle() const = 0;
|
||||
|
||||
virtual bool GetTrigger(JoystickHand hand = kRightHand) const = 0;
|
||||
virtual bool GetTop(JoystickHand hand = kRightHand) const = 0;
|
||||
|
||||
@@ -39,19 +39,19 @@ class PIDController : public LiveWindowSendable,
|
||||
public PIDInterface,
|
||||
public ITableListener {
|
||||
public:
|
||||
PIDController(float p, float i, float d, PIDSource* source, PIDOutput* output,
|
||||
float period = 0.05);
|
||||
PIDController(float p, float i, float d, float f, PIDSource* source,
|
||||
PIDOutput* output, float period = 0.05);
|
||||
PIDController(double p, double i, double d, PIDSource* source,
|
||||
PIDOutput* output, double period = 0.05);
|
||||
PIDController(double p, double i, double d, double f, PIDSource* source,
|
||||
PIDOutput* output, double period = 0.05);
|
||||
virtual ~PIDController();
|
||||
|
||||
PIDController(const PIDController&) = delete;
|
||||
PIDController& operator=(const PIDController) = delete;
|
||||
|
||||
virtual float Get() const;
|
||||
virtual double Get() const;
|
||||
virtual void SetContinuous(bool continuous = true);
|
||||
virtual void SetInputRange(float minimumInput, float maximumInput);
|
||||
virtual void SetOutputRange(float minimumOutput, float maximumOutput);
|
||||
virtual void SetInputRange(double minimumInput, double maximumInput);
|
||||
virtual void SetOutputRange(double minimumOutput, double maximumOutput);
|
||||
void SetPID(double p, double i, double d) override;
|
||||
virtual void SetPID(double p, double i, double d, double f);
|
||||
double GetP() const override;
|
||||
@@ -59,19 +59,19 @@ class PIDController : public LiveWindowSendable,
|
||||
double GetD() const override;
|
||||
virtual double GetF() const;
|
||||
|
||||
void SetSetpoint(float setpoint) override;
|
||||
void SetSetpoint(double setpoint) override;
|
||||
double GetSetpoint() const override;
|
||||
double GetDeltaSetpoint() const;
|
||||
|
||||
virtual float GetError() const;
|
||||
virtual float GetAvgError() const;
|
||||
virtual double GetError() const;
|
||||
virtual double GetAvgError() const;
|
||||
|
||||
virtual void SetPIDSourceType(PIDSourceType pidSource);
|
||||
virtual PIDSourceType GetPIDSourceType() const;
|
||||
|
||||
virtual void SetTolerance(float percent);
|
||||
virtual void SetAbsoluteTolerance(float absValue);
|
||||
virtual void SetPercentTolerance(float percentValue);
|
||||
virtual void SetTolerance(double percent);
|
||||
virtual void SetAbsoluteTolerance(double absValue);
|
||||
virtual void SetPercentTolerance(double percentValue);
|
||||
virtual void SetToleranceBuffer(int buf = 1);
|
||||
virtual bool OnTarget() const;
|
||||
|
||||
@@ -94,27 +94,27 @@ class PIDController : public LiveWindowSendable,
|
||||
|
||||
private:
|
||||
// factor for "proportional" control
|
||||
float m_P;
|
||||
double m_P;
|
||||
// factor for "integral" control
|
||||
float m_I;
|
||||
double m_I;
|
||||
// factor for "derivative" control
|
||||
float m_D;
|
||||
double m_D;
|
||||
// factor for "feed forward" control
|
||||
float m_F;
|
||||
double m_F;
|
||||
// |maximum output|
|
||||
float m_maximumOutput = 1.0;
|
||||
double m_maximumOutput = 1.0;
|
||||
// |minimum output|
|
||||
float m_minimumOutput = -1.0;
|
||||
double m_minimumOutput = -1.0;
|
||||
// maximum input - limit setpoint to this
|
||||
float m_maximumInput = 0;
|
||||
double m_maximumInput = 0;
|
||||
// minimum input - limit setpoint to this
|
||||
float m_minimumInput = 0;
|
||||
double m_minimumInput = 0;
|
||||
// do the endpoints wrap around? eg. Absolute encoder
|
||||
bool m_continuous = false;
|
||||
// is the pid controller enabled
|
||||
bool m_enabled = false;
|
||||
// the prior error (used to compute velocity)
|
||||
float m_prevError = 0;
|
||||
double m_prevError = 0;
|
||||
// the sum of the errors for use in the integral calc
|
||||
double m_totalError = 0;
|
||||
enum {
|
||||
@@ -124,12 +124,12 @@ class PIDController : public LiveWindowSendable,
|
||||
} m_toleranceType = kNoTolerance;
|
||||
|
||||
// the percetage or absolute error that is considered on target.
|
||||
float m_tolerance = 0.05;
|
||||
float m_setpoint = 0;
|
||||
float m_prevSetpoint = 0;
|
||||
float m_error = 0;
|
||||
float m_result = 0;
|
||||
float m_period;
|
||||
double m_tolerance = 0.05;
|
||||
double m_setpoint = 0;
|
||||
double m_prevSetpoint = 0;
|
||||
double m_error = 0;
|
||||
double m_result = 0;
|
||||
double m_period;
|
||||
|
||||
// Length of buffer for averaging for tolerances.
|
||||
std::atomic<unsigned> m_bufLength{1};
|
||||
|
||||
@@ -19,7 +19,7 @@ class PIDInterface : public Controller {
|
||||
virtual double GetI() const = 0;
|
||||
virtual double GetD() const = 0;
|
||||
|
||||
virtual void SetSetpoint(float setpoint) = 0;
|
||||
virtual void SetSetpoint(double setpoint) = 0;
|
||||
virtual double GetSetpoint() const = 0;
|
||||
|
||||
virtual void Enable() = 0;
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace frc {
|
||||
*/
|
||||
class PIDOutput {
|
||||
public:
|
||||
virtual void PIDWrite(float output) = 0;
|
||||
virtual void PIDWrite(double output) = 0;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
|
||||
@@ -31,13 +31,13 @@ class XboxController : public GamepadBase, public ErrorBase {
|
||||
XboxController(const XboxController&) = delete;
|
||||
XboxController& operator=(const XboxController&) = delete;
|
||||
|
||||
float GetX(JoystickHand hand) const override;
|
||||
float GetY(JoystickHand hand) const override;
|
||||
double GetX(JoystickHand hand) const override;
|
||||
double GetY(JoystickHand hand) const override;
|
||||
|
||||
bool GetBumper(JoystickHand hand) const override;
|
||||
bool GetStickButton(JoystickHand hand) const override;
|
||||
|
||||
virtual float GetTriggerAxis(JoystickHand hand) const;
|
||||
virtual double GetTriggerAxis(JoystickHand hand) const;
|
||||
|
||||
bool GetAButton() const;
|
||||
bool GetBButton() const;
|
||||
|
||||
@@ -45,7 +45,7 @@ class Gyro {
|
||||
* @return the current heading of the robot in degrees. This heading is based
|
||||
* on integration of the returned rate from the gyro.
|
||||
*/
|
||||
virtual float GetAngle() const = 0;
|
||||
virtual double GetAngle() const = 0;
|
||||
|
||||
/**
|
||||
* Return the rate of rotation of the gyro
|
||||
|
||||
@@ -51,7 +51,7 @@ void PIDCommand::SetSetpointRelative(double deltaSetpoint) {
|
||||
SetSetpoint(GetSetpoint() + deltaSetpoint);
|
||||
}
|
||||
|
||||
void PIDCommand::PIDWrite(float output) { UsePIDOutput(output); }
|
||||
void PIDCommand::PIDWrite(double output) { UsePIDOutput(output); }
|
||||
|
||||
double PIDCommand::PIDGet() { return ReturnPIDInput(); }
|
||||
|
||||
|
||||
@@ -172,7 +172,7 @@ double PIDSubsystem::GetSetpoint() { return m_controller->GetSetpoint(); }
|
||||
* @param minimumInput the minimum value expected from the input
|
||||
* @param maximumInput the maximum value expected from the output
|
||||
*/
|
||||
void PIDSubsystem::SetInputRange(float minimumInput, float maximumInput) {
|
||||
void PIDSubsystem::SetInputRange(double minimumInput, double maximumInput) {
|
||||
m_controller->SetInputRange(minimumInput, maximumInput);
|
||||
}
|
||||
|
||||
@@ -182,7 +182,7 @@ void PIDSubsystem::SetInputRange(float minimumInput, float maximumInput) {
|
||||
* @param minimumOutput the minimum value to write to the output
|
||||
* @param maximumOutput the maximum value to write to the output
|
||||
*/
|
||||
void PIDSubsystem::SetOutputRange(float minimumOutput, float maximumOutput) {
|
||||
void PIDSubsystem::SetOutputRange(double minimumOutput, double maximumOutput) {
|
||||
m_controller->SetOutputRange(minimumOutput, maximumOutput);
|
||||
}
|
||||
|
||||
@@ -192,7 +192,7 @@ void PIDSubsystem::SetOutputRange(float minimumOutput, float maximumOutput) {
|
||||
*
|
||||
* @param absValue absolute error which is tolerable
|
||||
*/
|
||||
void PIDSubsystem::SetAbsoluteTolerance(float absValue) {
|
||||
void PIDSubsystem::SetAbsoluteTolerance(double absValue) {
|
||||
m_controller->SetAbsoluteTolerance(absValue);
|
||||
}
|
||||
|
||||
@@ -201,7 +201,7 @@ void PIDSubsystem::SetAbsoluteTolerance(float absValue) {
|
||||
*
|
||||
* @param percent percentage error which is tolerable
|
||||
*/
|
||||
void PIDSubsystem::SetPercentTolerance(float percent) {
|
||||
void PIDSubsystem::SetPercentTolerance(double percent) {
|
||||
m_controller->SetPercentTolerance(percent);
|
||||
}
|
||||
|
||||
@@ -236,7 +236,7 @@ double PIDSubsystem::GetPosition() { return ReturnPIDInput(); }
|
||||
*/
|
||||
double PIDSubsystem::GetRate() { return ReturnPIDInput(); }
|
||||
|
||||
void PIDSubsystem::PIDWrite(float output) { UsePIDOutput(output); }
|
||||
void PIDSubsystem::PIDWrite(double output) { UsePIDOutput(output); }
|
||||
|
||||
double PIDSubsystem::PIDGet() { return ReturnPIDInput(); }
|
||||
|
||||
|
||||
@@ -33,13 +33,13 @@ class AnalogGyro : public GyroBase {
|
||||
public:
|
||||
static const int kOversampleBits;
|
||||
static const int kAverageBits;
|
||||
static const float kSamplesPerSecond;
|
||||
static const float kCalibrationSampleTime;
|
||||
static const float kDefaultVoltsPerDegreePerSecond;
|
||||
static const double kSamplesPerSecond;
|
||||
static const double kCalibrationSampleTime;
|
||||
static const double kDefaultVoltsPerDegreePerSecond;
|
||||
|
||||
explicit AnalogGyro(int channel);
|
||||
virtual ~AnalogGyro() = default;
|
||||
float GetAngle() const;
|
||||
double GetAngle() const;
|
||||
void Calibrate() override;
|
||||
double GetRate() const;
|
||||
void Reset();
|
||||
|
||||
@@ -40,8 +40,8 @@ class AnalogInput : public SensorBase,
|
||||
explicit AnalogInput(int channel);
|
||||
virtual ~AnalogInput() = default;
|
||||
|
||||
float GetVoltage() const;
|
||||
float GetAverageVoltage() const;
|
||||
double GetVoltage() const;
|
||||
double GetAverageVoltage() const;
|
||||
|
||||
int GetChannel() const;
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ class Counter : public SensorBase,
|
||||
void SetUpDownCounterMode();
|
||||
void SetExternalDirectionMode();
|
||||
void SetSemiPeriodMode(bool highSemiPeriod);
|
||||
void SetPulseLengthMode(float threshold);
|
||||
void SetPulseLengthMode(double threshold);
|
||||
|
||||
void SetReverseDirection(bool reverseDirection);
|
||||
|
||||
|
||||
@@ -48,11 +48,11 @@ class DriverStation : public SensorBase, public RobotStateInterface {
|
||||
static const int kJoystickPorts = 4;
|
||||
static const int kJoystickAxes = 6;
|
||||
|
||||
float GetStickAxis(int stick, int axis);
|
||||
double GetStickAxis(int stick, int axis);
|
||||
bool GetStickButton(int stick, int button);
|
||||
int16_t GetStickButtons(int stick);
|
||||
|
||||
float GetAnalogIn(int channel);
|
||||
double GetAnalogIn(int channel);
|
||||
bool GetDigitalIn(int channel);
|
||||
void SetDigitalOut(int channel, bool value);
|
||||
bool GetDigitalOut(int channel);
|
||||
@@ -70,7 +70,7 @@ class DriverStation : public SensorBase, public RobotStateInterface {
|
||||
void WaitForData();
|
||||
bool WaitForData(double timeout);
|
||||
double GetMatchTime() const;
|
||||
float GetBatteryVoltage() const;
|
||||
double GetBatteryVoltage() const;
|
||||
uint16_t GetTeamNumber() const;
|
||||
|
||||
void IncrementUpdateNumber() { m_updateNumber++; }
|
||||
@@ -115,7 +115,7 @@ class DriverStation : public SensorBase, public RobotStateInterface {
|
||||
static DriverStation* m_instance;
|
||||
static int m_updateNumber;
|
||||
///< TODO: Get rid of this and use the semaphore signaling
|
||||
static const float kUpdatePeriod;
|
||||
static const double kUpdatePeriod;
|
||||
|
||||
void stateCallback(const gazebo::msgs::ConstDriverStationPtr& msg);
|
||||
void joystickCallback(const gazebo::msgs::ConstFRCJoystickPtr& msg, int i);
|
||||
|
||||
@@ -20,11 +20,11 @@ class Jaguar : public SafePWM, public SpeedController {
|
||||
public:
|
||||
explicit Jaguar(int channel);
|
||||
virtual ~Jaguar() = default;
|
||||
virtual void Set(float value);
|
||||
virtual float Get() const;
|
||||
virtual void Set(double value);
|
||||
virtual double Get() const;
|
||||
virtual void Disable();
|
||||
|
||||
void PIDWrite(float output) override;
|
||||
void PIDWrite(double output) override;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
|
||||
@@ -15,8 +15,8 @@ namespace frc {
|
||||
|
||||
class MotorSafety {
|
||||
public:
|
||||
virtual void SetExpiration(float timeout) = 0;
|
||||
virtual float GetExpiration() const = 0;
|
||||
virtual void SetExpiration(double timeout) = 0;
|
||||
virtual double GetExpiration() const = 0;
|
||||
virtual bool IsAlive() const = 0;
|
||||
virtual void StopMotor() = 0;
|
||||
virtual void SetSafetyEnabled(bool enabled) = 0;
|
||||
|
||||
@@ -21,8 +21,8 @@ class MotorSafetyHelper : public ErrorBase {
|
||||
explicit MotorSafetyHelper(MotorSafety* safeObject);
|
||||
~MotorSafetyHelper();
|
||||
void Feed();
|
||||
void SetExpiration(float expirationTime);
|
||||
float GetExpiration() const;
|
||||
void SetExpiration(double expirationTime);
|
||||
double GetExpiration() const;
|
||||
bool IsAlive() const;
|
||||
void Check();
|
||||
void SetSafetyEnabled(bool enabled);
|
||||
|
||||
@@ -74,21 +74,21 @@ class PWM : public SensorBase,
|
||||
* scaling is implemented as an output squelch to get longer periods for old
|
||||
* devices.
|
||||
*/
|
||||
static const float kDefaultPwmPeriod;
|
||||
static const double kDefaultPwmPeriod;
|
||||
/**
|
||||
* kDefaultPwmCenter is the PWM range center in ms
|
||||
*/
|
||||
static const float kDefaultPwmCenter;
|
||||
static const double kDefaultPwmCenter;
|
||||
/**
|
||||
* kDefaultPWMStepsDown is the number of PWM steps below the centerpoint
|
||||
*/
|
||||
static const int kDefaultPwmStepsDown;
|
||||
static const int kPwmDisabled;
|
||||
|
||||
virtual void SetPosition(float pos);
|
||||
virtual float GetPosition() const;
|
||||
virtual void SetSpeed(float speed);
|
||||
virtual float GetSpeed() const;
|
||||
virtual void SetPosition(double pos);
|
||||
virtual double GetPosition() const;
|
||||
virtual void SetSpeed(double speed);
|
||||
virtual double GetSpeed() const;
|
||||
|
||||
bool m_eliminateDeadband;
|
||||
int m_centerPwm;
|
||||
|
||||
@@ -49,8 +49,8 @@ class Relay : public MotorSafety,
|
||||
Value Get() const;
|
||||
int GetChannel() const;
|
||||
|
||||
void SetExpiration(float timeout) override;
|
||||
float GetExpiration() const override;
|
||||
void SetExpiration(double timeout) override;
|
||||
double GetExpiration() const override;
|
||||
bool IsAlive() const override;
|
||||
void StopMotor() override;
|
||||
bool IsSafetyEnabled() const override;
|
||||
|
||||
@@ -61,7 +61,7 @@ class RobotDrive : public MotorSafety, public ErrorBase {
|
||||
RobotDrive(const RobotDrive&) = delete;
|
||||
RobotDrive& operator=(const RobotDrive&) = delete;
|
||||
|
||||
void Drive(float outputMagnitude, float curve);
|
||||
void Drive(double outputMagnitude, double curve);
|
||||
void TankDrive(GenericHID* leftStick, GenericHID* rightStick,
|
||||
bool squaredInputs = true);
|
||||
void TankDrive(GenericHID& leftStick, GenericHID& rightStick,
|
||||
@@ -70,7 +70,8 @@ class RobotDrive : public MotorSafety, public ErrorBase {
|
||||
int rightAxis, bool squaredInputs = true);
|
||||
void TankDrive(GenericHID& leftStick, int leftAxis, GenericHID& rightStick,
|
||||
int rightAxis, bool squaredInputs = true);
|
||||
void TankDrive(float leftValue, float rightValue, bool squaredInputs = true);
|
||||
void TankDrive(double leftValue, double rightValue,
|
||||
bool squaredInputs = true);
|
||||
void ArcadeDrive(GenericHID* stick, bool squaredInputs = true);
|
||||
void ArcadeDrive(GenericHID& stick, bool squaredInputs = true);
|
||||
void ArcadeDrive(GenericHID* moveStick, int moveChannel,
|
||||
@@ -79,19 +80,19 @@ class RobotDrive : public MotorSafety, public ErrorBase {
|
||||
void ArcadeDrive(GenericHID& moveStick, int moveChannel,
|
||||
GenericHID& rotateStick, int rotateChannel,
|
||||
bool squaredInputs = true);
|
||||
void ArcadeDrive(float moveValue, float rotateValue,
|
||||
void ArcadeDrive(double moveValue, double rotateValue,
|
||||
bool squaredInputs = true);
|
||||
void MecanumDrive_Cartesian(float x, float y, float rotation,
|
||||
float gyroAngle = 0.0);
|
||||
void MecanumDrive_Polar(float magnitude, float direction, float rotation);
|
||||
void HolonomicDrive(float magnitude, float direction, float rotation);
|
||||
virtual void SetLeftRightMotorOutputs(float leftOutput, float rightOutput);
|
||||
void MecanumDrive_Cartesian(double x, double y, double rotation,
|
||||
double gyroAngle = 0.0);
|
||||
void MecanumDrive_Polar(double magnitude, double direction, double rotation);
|
||||
void HolonomicDrive(double magnitude, double direction, double rotation);
|
||||
virtual void SetLeftRightMotorOutputs(double leftOutput, double rightOutput);
|
||||
void SetInvertedMotor(MotorType motor, bool isInverted);
|
||||
void SetSensitivity(float sensitivity);
|
||||
void SetSensitivity(double sensitivity);
|
||||
void SetMaxOutput(double maxOutput);
|
||||
|
||||
void SetExpiration(float timeout) override;
|
||||
float GetExpiration() const override;
|
||||
void SetExpiration(double timeout) override;
|
||||
double GetExpiration() const override;
|
||||
bool IsAlive() const override;
|
||||
void StopMotor() override;
|
||||
bool IsSafetyEnabled() const override;
|
||||
@@ -100,14 +101,14 @@ class RobotDrive : public MotorSafety, public ErrorBase {
|
||||
|
||||
protected:
|
||||
void InitRobotDrive();
|
||||
float Limit(float num);
|
||||
double Limit(double num);
|
||||
void Normalize(double* wheelSpeeds);
|
||||
void RotateVector(double& x, double& y, double angle);
|
||||
|
||||
static const int kMaxNumberOfMotors = 4;
|
||||
|
||||
int m_invertedMotors[kMaxNumberOfMotors] = {1, 1, 1, 1};
|
||||
float m_sensitivity = 0.5;
|
||||
double m_sensitivity = 0.5;
|
||||
double m_maxOutput = 1.0;
|
||||
bool m_deleteSpeedControllers;
|
||||
std::shared_ptr<SpeedController> m_frontLeftMotor;
|
||||
|
||||
@@ -28,15 +28,15 @@ class SafePWM : public PWM, public MotorSafety {
|
||||
explicit SafePWM(int channel);
|
||||
virtual ~SafePWM() = default;
|
||||
|
||||
void SetExpiration(float timeout);
|
||||
float GetExpiration() const;
|
||||
void SetExpiration(double timeout);
|
||||
double GetExpiration() const;
|
||||
bool IsAlive() const;
|
||||
void StopMotor();
|
||||
bool IsSafetyEnabled() const;
|
||||
void SetSafetyEnabled(bool enabled);
|
||||
void GetDescription(std::ostringstream& desc) const;
|
||||
|
||||
virtual void SetSpeed(float speed);
|
||||
virtual void SetSpeed(double speed);
|
||||
|
||||
private:
|
||||
std::unique_ptr<MotorSafetyHelper> m_safetyHelper;
|
||||
|
||||
@@ -22,13 +22,13 @@ class SpeedController : public PIDOutput {
|
||||
*
|
||||
* @param speed The speed to set. Value should be between -1.0 and 1.0.
|
||||
*/
|
||||
virtual void Set(float speed) = 0;
|
||||
virtual void Set(double speed) = 0;
|
||||
/**
|
||||
* Common interface for getting the current set speed of a speed controller.
|
||||
*
|
||||
* @return The current set speed. Value is between -1.0 and 1.0.
|
||||
*/
|
||||
virtual float Get() const = 0;
|
||||
virtual double Get() const = 0;
|
||||
/**
|
||||
* Common interface for disabling a motor.
|
||||
*/
|
||||
|
||||
@@ -20,11 +20,11 @@ class Talon : public SafePWM, public SpeedController {
|
||||
public:
|
||||
explicit Talon(int channel);
|
||||
virtual ~Talon() = default;
|
||||
virtual void Set(float value);
|
||||
virtual float Get() const;
|
||||
virtual void Set(double value);
|
||||
virtual double Get() const;
|
||||
virtual void Disable();
|
||||
|
||||
void PIDWrite(float output) override;
|
||||
void PIDWrite(double output) override;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
|
||||
@@ -20,11 +20,11 @@ class Victor : public SafePWM, public SpeedController {
|
||||
public:
|
||||
explicit Victor(int channel);
|
||||
virtual ~Victor() = default;
|
||||
virtual void Set(float value);
|
||||
virtual float Get() const;
|
||||
virtual void Set(double value);
|
||||
virtual double Get() const;
|
||||
virtual void Disable();
|
||||
|
||||
void PIDWrite(float output) override;
|
||||
void PIDWrite(double output) override;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace frc {
|
||||
class SimContinuousOutput {
|
||||
private:
|
||||
gazebo::transport::PublisherPtr pub;
|
||||
float speed;
|
||||
double speed;
|
||||
|
||||
public:
|
||||
explicit SimContinuousOutput(std::string topic);
|
||||
@@ -37,12 +37,12 @@ class SimContinuousOutput {
|
||||
*
|
||||
* @param value The value between -1.0 and 1.0 to set.
|
||||
*/
|
||||
void Set(float value);
|
||||
void Set(double value);
|
||||
|
||||
/**
|
||||
* @return The most recently set value.
|
||||
*/
|
||||
float Get();
|
||||
double Get();
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
|
||||
@@ -17,9 +17,9 @@ using namespace frc;
|
||||
|
||||
const int AnalogGyro::kOversampleBits = 10;
|
||||
const int AnalogGyro::kAverageBits = 0;
|
||||
const float AnalogGyro::kSamplesPerSecond = 50.0;
|
||||
const float AnalogGyro::kCalibrationSampleTime = 5.0;
|
||||
const float AnalogGyro::kDefaultVoltsPerDegreePerSecond = 0.007;
|
||||
const double AnalogGyro::kSamplesPerSecond = 50.0;
|
||||
const double AnalogGyro::kCalibrationSampleTime = 5.0;
|
||||
const double AnalogGyro::kDefaultVoltsPerDegreePerSecond = 0.007;
|
||||
|
||||
/**
|
||||
* Initialize the gyro.
|
||||
@@ -71,7 +71,7 @@ void AnalogGyro::Calibrate() { Reset(); }
|
||||
* @return the current heading of the robot in degrees. This heading is based on
|
||||
* integration of the returned rate from the gyro.
|
||||
*/
|
||||
float AnalogGyro::GetAngle() const { return impl->GetAngle(); }
|
||||
double AnalogGyro::GetAngle() const { return impl->GetAngle(); }
|
||||
|
||||
/**
|
||||
* Return the rate of rotation of the gyro
|
||||
|
||||
@@ -35,7 +35,7 @@ AnalogInput::AnalogInput(int channel) : m_channel(channel) {
|
||||
*
|
||||
* @return A scaled sample straight from this channel.
|
||||
*/
|
||||
float AnalogInput::GetVoltage() const { return m_impl->Get(); }
|
||||
double AnalogInput::GetVoltage() const { return m_impl->Get(); }
|
||||
|
||||
/**
|
||||
* Get a scaled sample from the output of the oversample and average engine for
|
||||
@@ -49,7 +49,7 @@ float AnalogInput::GetVoltage() const { return m_impl->Get(); }
|
||||
* @return A scaled sample from the output of the oversample and average engine
|
||||
* for this channel.
|
||||
*/
|
||||
float AnalogInput::GetAverageVoltage() const { return m_impl->Get(); }
|
||||
double AnalogInput::GetAverageVoltage() const { return m_impl->Get(); }
|
||||
|
||||
/**
|
||||
* Get the channel number.
|
||||
|
||||
@@ -20,7 +20,7 @@ using namespace frc;
|
||||
const int DriverStation::kBatteryChannel;
|
||||
const int DriverStation::kJoystickPorts;
|
||||
const int DriverStation::kJoystickAxes;
|
||||
const float DriverStation::kUpdatePeriod = 0.02;
|
||||
const double DriverStation::kUpdatePeriod = 0.02;
|
||||
int DriverStation::m_updateNumber = 0;
|
||||
|
||||
/**
|
||||
@@ -66,7 +66,7 @@ DriverStation& DriverStation::GetInstance() {
|
||||
*
|
||||
* @return The battery voltage.
|
||||
*/
|
||||
float DriverStation::GetBatteryVoltage() const {
|
||||
double DriverStation::GetBatteryVoltage() const {
|
||||
return 12.0; // 12 volts all the time!
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ float DriverStation::GetBatteryVoltage() const {
|
||||
* @param axis The analog axis value to read from the joystick.
|
||||
* @return The value of the axis on the joystick.
|
||||
*/
|
||||
float DriverStation::GetStickAxis(int stick, int axis) {
|
||||
double DriverStation::GetStickAxis(int stick, int axis) {
|
||||
if (axis < 0 || axis > (kJoystickAxes - 1)) {
|
||||
wpi_setWPIError(BadJoystickAxis);
|
||||
return 0.0;
|
||||
@@ -147,7 +147,7 @@ int16_t DriverStation::GetStickButtons(int stick) {
|
||||
}
|
||||
|
||||
// 5V divided by 10 bits
|
||||
#define kDSAnalogInScaling (static_cast<float>(5.0 / 1023.0))
|
||||
#define kDSAnalogInScaling (5.0 / 1023.0)
|
||||
|
||||
/**
|
||||
* Get an analog voltage from the Driver Station.
|
||||
@@ -161,7 +161,7 @@ int16_t DriverStation::GetStickButtons(int stick) {
|
||||
* Valid range is 1 - 4.
|
||||
* @return The analog voltage on the input.
|
||||
*/
|
||||
float DriverStation::GetAnalogIn(int channel) {
|
||||
double DriverStation::GetAnalogIn(int channel) {
|
||||
wpi_setWPIErrorWithContext(UnsupportedInSimulation, "GetAnalogIn");
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ GenericHID::GenericHID(int port) : m_ds(DriverStation::GetInstance()) {
|
||||
* @param axis The axis to read, starting at 0.
|
||||
* @return The value of the axis.
|
||||
*/
|
||||
float GenericHID::GetRawAxis(int axis) const {
|
||||
double GenericHID::GetRawAxis(int axis) const {
|
||||
return m_ds.GetStickAxis(m_port, axis);
|
||||
}
|
||||
|
||||
|
||||
@@ -39,14 +39,14 @@ Jaguar::Jaguar(int channel) : SafePWM(channel) {
|
||||
*
|
||||
* @param speed The speed value between -1.0 and 1.0 to set.
|
||||
*/
|
||||
void Jaguar::Set(float speed) { SetSpeed(speed); }
|
||||
void Jaguar::Set(double speed) { SetSpeed(speed); }
|
||||
|
||||
/**
|
||||
* Get the recently set value of the PWM.
|
||||
*
|
||||
* @return The most recently set value for the PWM between -1.0 and 1.0.
|
||||
*/
|
||||
float Jaguar::Get() const { return GetSpeed(); }
|
||||
double Jaguar::Get() const { return GetSpeed(); }
|
||||
|
||||
/**
|
||||
* Common interface for disabling a motor.
|
||||
@@ -58,4 +58,4 @@ void Jaguar::Disable() { SetRaw(kPwmDisabled); }
|
||||
*
|
||||
* @param output Write out the PWM value as was found in the PIDController
|
||||
*/
|
||||
void Jaguar::PIDWrite(float output) { Set(output); }
|
||||
void Jaguar::PIDWrite(double output) { Set(output); }
|
||||
|
||||
@@ -87,7 +87,7 @@ Joystick* Joystick::GetStickForPort(int port) {
|
||||
* @param hand This parameter is ignored for the Joystick class and is only
|
||||
* here to complete the GenericHID interface.
|
||||
*/
|
||||
float Joystick::GetX(JoystickHand hand) const {
|
||||
double Joystick::GetX(JoystickHand hand) const {
|
||||
return GetRawAxis(m_axes[kXAxis]);
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ float Joystick::GetX(JoystickHand hand) const {
|
||||
* @param hand This parameter is ignored for the Joystick class and is only
|
||||
* here to complete the GenericHID interface.
|
||||
*/
|
||||
float Joystick::GetY(JoystickHand hand) const {
|
||||
double Joystick::GetY(JoystickHand hand) const {
|
||||
return GetRawAxis(m_axes[kYAxis]);
|
||||
}
|
||||
|
||||
@@ -108,7 +108,7 @@ float Joystick::GetY(JoystickHand hand) const {
|
||||
*
|
||||
* This depends on the mapping of the joystick connected to the current port.
|
||||
*/
|
||||
float Joystick::GetZ(JoystickHand hand) const {
|
||||
double Joystick::GetZ(JoystickHand hand) const {
|
||||
return GetRawAxis(m_axes[kZAxis]);
|
||||
}
|
||||
|
||||
@@ -117,14 +117,14 @@ float Joystick::GetZ(JoystickHand hand) const {
|
||||
*
|
||||
* This depends on the mapping of the joystick connected to the current port.
|
||||
*/
|
||||
float Joystick::GetTwist() const { return GetRawAxis(m_axes[kTwistAxis]); }
|
||||
double Joystick::GetTwist() const { return GetRawAxis(m_axes[kTwistAxis]); }
|
||||
|
||||
/**
|
||||
* Get the throttle value of the current joystick.
|
||||
*
|
||||
* This depends on the mapping of the joystick connected to the current port.
|
||||
*/
|
||||
float Joystick::GetThrottle() const {
|
||||
double Joystick::GetThrottle() const {
|
||||
return GetRawAxis(m_axes[kThrottleAxis]);
|
||||
}
|
||||
|
||||
@@ -138,7 +138,7 @@ float Joystick::GetThrottle() const {
|
||||
* @param axis The axis to read.
|
||||
* @return The value of the axis.
|
||||
*/
|
||||
float Joystick::GetAxis(AxisType axis) const {
|
||||
double Joystick::GetAxis(AxisType axis) const {
|
||||
switch (axis) {
|
||||
case kXAxis:
|
||||
return this->GetX();
|
||||
@@ -246,7 +246,7 @@ void Joystick::SetAxisChannel(AxisType axis, int channel) {
|
||||
*
|
||||
* @return The magnitude of the direction vector
|
||||
*/
|
||||
float Joystick::GetMagnitude() const {
|
||||
double Joystick::GetMagnitude() const {
|
||||
return std::sqrt(std::pow(GetX(), 2) + std::pow(GetY(), 2));
|
||||
}
|
||||
|
||||
@@ -256,7 +256,7 @@ float Joystick::GetMagnitude() const {
|
||||
*
|
||||
* @return The direction of the vector in radians
|
||||
*/
|
||||
float Joystick::GetDirectionRadians() const {
|
||||
double Joystick::GetDirectionRadians() const {
|
||||
return std::atan2(GetX(), -GetY());
|
||||
}
|
||||
|
||||
@@ -269,6 +269,6 @@ float Joystick::GetDirectionRadians() const {
|
||||
*
|
||||
* @return The direction of the vector in degrees
|
||||
*/
|
||||
float Joystick::GetDirectionDegrees() const {
|
||||
double Joystick::GetDirectionDegrees() const {
|
||||
return (180 / std::acos(-1)) * GetDirectionRadians();
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ void MotorSafetyHelper::Feed() {
|
||||
*
|
||||
* @param expirationTime The timeout value in seconds.
|
||||
*/
|
||||
void MotorSafetyHelper::SetExpiration(float expirationTime) {
|
||||
void MotorSafetyHelper::SetExpiration(double expirationTime) {
|
||||
std::lock_guard<priority_recursive_mutex> sync(m_syncMutex);
|
||||
m_expiration = expirationTime;
|
||||
}
|
||||
@@ -71,7 +71,7 @@ void MotorSafetyHelper::SetExpiration(float expirationTime) {
|
||||
*
|
||||
* @return the timeout value in seconds.
|
||||
*/
|
||||
float MotorSafetyHelper::GetExpiration() const {
|
||||
double MotorSafetyHelper::GetExpiration() const {
|
||||
std::lock_guard<priority_recursive_mutex> sync(m_syncMutex);
|
||||
return m_expiration;
|
||||
}
|
||||
|
||||
@@ -34,9 +34,9 @@ static const std::string kEnabled = "enabled";
|
||||
* calculations of the integral and differental terms. The
|
||||
* default is 50ms.
|
||||
*/
|
||||
PIDController::PIDController(float Kp, float Ki, float Kd, PIDSource* source,
|
||||
PIDOutput* output, float period)
|
||||
: PIDController(Kp, Ki, Kd, 0.0f, source, output, period) {}
|
||||
PIDController::PIDController(double Kp, double Ki, double Kd, PIDSource* source,
|
||||
PIDOutput* output, double period)
|
||||
: PIDController(Kp, Ki, Kd, 0.0, source, output, period) {}
|
||||
|
||||
/**
|
||||
* Allocate a PID object with the given constants for P, I, D.
|
||||
@@ -50,9 +50,9 @@ PIDController::PIDController(float Kp, float Ki, float Kd, PIDSource* source,
|
||||
* calculations of the integral and differental terms. The
|
||||
* default is 50ms.
|
||||
*/
|
||||
PIDController::PIDController(float Kp, float Ki, float Kd, float Kf,
|
||||
PIDController::PIDController(double Kp, double Ki, double Kd, double Kf,
|
||||
PIDSource* source, PIDOutput* output,
|
||||
float period) {
|
||||
double period) {
|
||||
m_table = nullptr;
|
||||
|
||||
m_P = Kp;
|
||||
@@ -111,8 +111,8 @@ void PIDController::Calculate() {
|
||||
}
|
||||
|
||||
if (enabled) {
|
||||
float input = pidInput->PIDGet();
|
||||
float result;
|
||||
double input = pidInput->PIDGet();
|
||||
double result;
|
||||
PIDOutput* pidOutput;
|
||||
|
||||
{
|
||||
@@ -299,7 +299,7 @@ double PIDController::GetF() const {
|
||||
*
|
||||
* @return the latest calculated output
|
||||
*/
|
||||
float PIDController::Get() const {
|
||||
double PIDController::Get() const {
|
||||
std::lock_guard<priority_recursive_mutex> lock(m_mutex);
|
||||
return m_result;
|
||||
}
|
||||
@@ -324,7 +324,7 @@ void PIDController::SetContinuous(bool continuous) {
|
||||
* @param minimumInput the minimum value expected from the input
|
||||
* @param maximumInput the maximum value expected from the output
|
||||
*/
|
||||
void PIDController::SetInputRange(float minimumInput, float maximumInput) {
|
||||
void PIDController::SetInputRange(double minimumInput, double maximumInput) {
|
||||
{
|
||||
std::lock_guard<priority_recursive_mutex> lock(m_mutex);
|
||||
m_minimumInput = minimumInput;
|
||||
@@ -340,7 +340,7 @@ void PIDController::SetInputRange(float minimumInput, float maximumInput) {
|
||||
* @param minimumOutput the minimum value to write to the output
|
||||
* @param maximumOutput the maximum value to write to the output
|
||||
*/
|
||||
void PIDController::SetOutputRange(float minimumOutput, float maximumOutput) {
|
||||
void PIDController::SetOutputRange(double minimumOutput, double maximumOutput) {
|
||||
std::lock_guard<priority_recursive_mutex> lock(m_mutex);
|
||||
m_minimumOutput = minimumOutput;
|
||||
m_maximumOutput = maximumOutput;
|
||||
@@ -351,7 +351,7 @@ void PIDController::SetOutputRange(float minimumOutput, float maximumOutput) {
|
||||
*
|
||||
* @param setpoint the desired setpoint
|
||||
*/
|
||||
void PIDController::SetSetpoint(float setpoint) {
|
||||
void PIDController::SetSetpoint(double setpoint) {
|
||||
{
|
||||
std::lock_guard<priority_recursive_mutex> lock(m_mutex);
|
||||
|
||||
@@ -397,7 +397,7 @@ double PIDController::GetDeltaSetpoint() const {
|
||||
*
|
||||
* @return the current error
|
||||
*/
|
||||
float PIDController::GetError() const {
|
||||
double PIDController::GetError() const {
|
||||
double setpoint = GetSetpoint();
|
||||
{
|
||||
std::lock_guard<priority_recursive_mutex> sync(m_mutex);
|
||||
@@ -429,8 +429,8 @@ PIDSourceType PIDController::GetPIDSourceType() const {
|
||||
*
|
||||
* @return the average error
|
||||
*/
|
||||
float PIDController::GetAvgError() const {
|
||||
float avgError = 0;
|
||||
double PIDController::GetAvgError() const {
|
||||
double avgError = 0;
|
||||
{
|
||||
std::lock_guard<priority_recursive_mutex> sync(m_mutex);
|
||||
// Don't divide by zero.
|
||||
@@ -445,7 +445,7 @@ float PIDController::GetAvgError() const {
|
||||
*
|
||||
* @param percent percentage error which is tolerable
|
||||
*/
|
||||
void PIDController::SetTolerance(float percent) {
|
||||
void PIDController::SetTolerance(double percent) {
|
||||
std::lock_guard<priority_recursive_mutex> lock(m_mutex);
|
||||
m_toleranceType = kPercentTolerance;
|
||||
m_tolerance = percent;
|
||||
@@ -457,7 +457,7 @@ void PIDController::SetTolerance(float percent) {
|
||||
*
|
||||
* @param absTolerance absolute error which is tolerable
|
||||
*/
|
||||
void PIDController::SetAbsoluteTolerance(float absTolerance) {
|
||||
void PIDController::SetAbsoluteTolerance(double absTolerance) {
|
||||
std::lock_guard<priority_recursive_mutex> lock(m_mutex);
|
||||
m_toleranceType = kAbsoluteTolerance;
|
||||
m_tolerance = absTolerance;
|
||||
@@ -469,7 +469,7 @@ void PIDController::SetAbsoluteTolerance(float absTolerance) {
|
||||
*
|
||||
* @param percent percentage error which is tolerable
|
||||
*/
|
||||
void PIDController::SetPercentTolerance(float percent) {
|
||||
void PIDController::SetPercentTolerance(double percent) {
|
||||
std::lock_guard<priority_recursive_mutex> lock(m_mutex);
|
||||
m_toleranceType = kPercentTolerance;
|
||||
m_tolerance = percent;
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
|
||||
using namespace frc;
|
||||
|
||||
const float PWM::kDefaultPwmPeriod = 5.05;
|
||||
const float PWM::kDefaultPwmCenter = 1.5;
|
||||
const double PWM::kDefaultPwmPeriod = 5.05;
|
||||
const double PWM::kDefaultPwmCenter = 1.5;
|
||||
const int PWM::kDefaultPwmStepsDown = 1000;
|
||||
const int PWM::kPwmDisabled = 0;
|
||||
|
||||
@@ -108,7 +108,7 @@ void PWM::SetBounds(double max, double deadbandMax, double center,
|
||||
*
|
||||
* @param pos The position to set the servo between 0.0 and 1.0.
|
||||
*/
|
||||
void PWM::SetPosition(float pos) {
|
||||
void PWM::SetPosition(double pos) {
|
||||
if (pos < 0.0) {
|
||||
pos = 0.0;
|
||||
} else if (pos > 1.0) {
|
||||
@@ -128,8 +128,8 @@ void PWM::SetPosition(float pos) {
|
||||
*
|
||||
* @return The position the servo is set to between 0.0 and 1.0.
|
||||
*/
|
||||
float PWM::GetPosition() const {
|
||||
float value = impl->Get();
|
||||
double PWM::GetPosition() const {
|
||||
double value = impl->Get();
|
||||
if (value < 0.0) {
|
||||
return 0.0;
|
||||
} else if (value > 1.0) {
|
||||
@@ -152,7 +152,7 @@ float PWM::GetPosition() const {
|
||||
*
|
||||
* @param speed The speed to set the speed controller between -1.0 and 1.0.
|
||||
*/
|
||||
void PWM::SetSpeed(float speed) {
|
||||
void PWM::SetSpeed(double speed) {
|
||||
// clamp speed to be in the range 1.0 >= speed >= -1.0
|
||||
if (speed < -1.0) {
|
||||
speed = -1.0;
|
||||
@@ -175,8 +175,8 @@ void PWM::SetSpeed(float speed) {
|
||||
*
|
||||
* @return The most recently set speed between -1.0 and 1.0.
|
||||
*/
|
||||
float PWM::GetSpeed() const {
|
||||
float value = impl->Get();
|
||||
double PWM::GetSpeed() const {
|
||||
double value = impl->Get();
|
||||
if (value > 1.0) {
|
||||
return 1.0;
|
||||
} else if (value < -1.0) {
|
||||
|
||||
@@ -147,7 +147,7 @@ int Relay::GetChannel() const { return m_channel; }
|
||||
*
|
||||
* @param timeout The timeout (in seconds) for this relay object
|
||||
*/
|
||||
void Relay::SetExpiration(float timeout) {
|
||||
void Relay::SetExpiration(double timeout) {
|
||||
m_safetyHelper->SetExpiration(timeout);
|
||||
}
|
||||
|
||||
@@ -156,7 +156,7 @@ void Relay::SetExpiration(float timeout) {
|
||||
*
|
||||
* @return The expiration time value.
|
||||
*/
|
||||
float Relay::GetExpiration() const { return m_safetyHelper->GetExpiration(); }
|
||||
double Relay::GetExpiration() const { return m_safetyHelper->GetExpiration(); }
|
||||
|
||||
/**
|
||||
* Check if the relay object is currently alive or stopped due to a timeout.
|
||||
|
||||
@@ -208,22 +208,22 @@ RobotDrive::RobotDrive(std::shared_ptr<SpeedController> frontLeftMotor,
|
||||
* radius r = -ln(curve)*w for a given value of curve and
|
||||
* wheelbase w.
|
||||
*/
|
||||
void RobotDrive::Drive(float outputMagnitude, float curve) {
|
||||
float leftOutput, rightOutput;
|
||||
void RobotDrive::Drive(double outputMagnitude, double curve) {
|
||||
double leftOutput, rightOutput;
|
||||
static bool reported = false;
|
||||
if (!reported) {
|
||||
reported = true;
|
||||
}
|
||||
|
||||
if (curve < 0) {
|
||||
float value = std::log(-curve);
|
||||
float ratio = (value - m_sensitivity) / (value + m_sensitivity);
|
||||
double value = std::log(-curve);
|
||||
double ratio = (value - m_sensitivity) / (value + m_sensitivity);
|
||||
if (ratio == 0) ratio = .0000000001;
|
||||
leftOutput = outputMagnitude / ratio;
|
||||
rightOutput = outputMagnitude;
|
||||
} else if (curve > 0) {
|
||||
float value = std::log(curve);
|
||||
float ratio = (value - m_sensitivity) / (value + m_sensitivity);
|
||||
double value = std::log(curve);
|
||||
double ratio = (value - m_sensitivity) / (value + m_sensitivity);
|
||||
if (ratio == 0) ratio = .0000000001;
|
||||
leftOutput = outputMagnitude;
|
||||
rightOutput = outputMagnitude / ratio;
|
||||
@@ -294,7 +294,7 @@ void RobotDrive::TankDrive(GenericHID& leftStick, int leftAxis,
|
||||
* @param leftValue The value of the left stick.
|
||||
* @param rightValue The value of the right stick.
|
||||
*/
|
||||
void RobotDrive::TankDrive(float leftValue, float rightValue,
|
||||
void RobotDrive::TankDrive(double leftValue, double rightValue,
|
||||
bool squaredInputs) {
|
||||
static bool reported = false;
|
||||
if (!reported) {
|
||||
@@ -376,8 +376,8 @@ void RobotDrive::ArcadeDrive(GenericHID& stick, bool squaredInputs) {
|
||||
void RobotDrive::ArcadeDrive(GenericHID* moveStick, int moveAxis,
|
||||
GenericHID* rotateStick, int rotateAxis,
|
||||
bool squaredInputs) {
|
||||
float moveValue = moveStick->GetRawAxis(moveAxis);
|
||||
float rotateValue = rotateStick->GetRawAxis(rotateAxis);
|
||||
double moveValue = moveStick->GetRawAxis(moveAxis);
|
||||
double rotateValue = rotateStick->GetRawAxis(rotateAxis);
|
||||
|
||||
ArcadeDrive(moveValue, rotateValue, squaredInputs);
|
||||
}
|
||||
@@ -401,8 +401,8 @@ void RobotDrive::ArcadeDrive(GenericHID* moveStick, int moveAxis,
|
||||
void RobotDrive::ArcadeDrive(GenericHID& moveStick, int moveAxis,
|
||||
GenericHID& rotateStick, int rotateAxis,
|
||||
bool squaredInputs) {
|
||||
float moveValue = moveStick.GetRawAxis(moveAxis);
|
||||
float rotateValue = rotateStick.GetRawAxis(rotateAxis);
|
||||
double moveValue = moveStick.GetRawAxis(moveAxis);
|
||||
double rotateValue = rotateStick.GetRawAxis(rotateAxis);
|
||||
|
||||
ArcadeDrive(moveValue, rotateValue, squaredInputs);
|
||||
}
|
||||
@@ -416,7 +416,7 @@ void RobotDrive::ArcadeDrive(GenericHID& moveStick, int moveAxis,
|
||||
* @param rotateValue The value to use for the rotate right/left
|
||||
* @param squaredInputs If set, increases the sensitivity at low speeds
|
||||
*/
|
||||
void RobotDrive::ArcadeDrive(float moveValue, float rotateValue,
|
||||
void RobotDrive::ArcadeDrive(double moveValue, double rotateValue,
|
||||
bool squaredInputs) {
|
||||
static bool reported = false;
|
||||
if (!reported) {
|
||||
@@ -424,8 +424,8 @@ void RobotDrive::ArcadeDrive(float moveValue, float rotateValue,
|
||||
}
|
||||
|
||||
// local variables to hold the computed PWM values for the motors
|
||||
float leftMotorOutput;
|
||||
float rightMotorOutput;
|
||||
double leftMotorOutput;
|
||||
double rightMotorOutput;
|
||||
|
||||
moveValue = Limit(moveValue);
|
||||
rotateValue = Limit(rotateValue);
|
||||
@@ -485,8 +485,8 @@ void RobotDrive::ArcadeDrive(float moveValue, float rotateValue,
|
||||
* @param gyroAngle The current angle reading from the gyro. Use this to
|
||||
* implement field-oriented controls.
|
||||
*/
|
||||
void RobotDrive::MecanumDrive_Cartesian(float x, float y, float rotation,
|
||||
float gyroAngle) {
|
||||
void RobotDrive::MecanumDrive_Cartesian(double x, double y, double rotation,
|
||||
double gyroAngle) {
|
||||
static bool reported = false;
|
||||
if (!reported) {
|
||||
reported = true;
|
||||
@@ -535,8 +535,8 @@ void RobotDrive::MecanumDrive_Cartesian(float x, float y, float rotation,
|
||||
* @param rotation The rate of rotation for the robot that is completely
|
||||
* independent of the magnitute or direction. [-1.0..1.0]
|
||||
*/
|
||||
void RobotDrive::MecanumDrive_Polar(float magnitude, float direction,
|
||||
float rotation) {
|
||||
void RobotDrive::MecanumDrive_Polar(double magnitude, double direction,
|
||||
double rotation) {
|
||||
static bool reported = false;
|
||||
if (!reported) {
|
||||
reported = true;
|
||||
@@ -581,8 +581,8 @@ void RobotDrive::MecanumDrive_Polar(float magnitude, float direction,
|
||||
* @param rotation The rate of rotation for the robot that is completely
|
||||
* independent of the magnitude or direction. [-1.0..1.0]
|
||||
*/
|
||||
void RobotDrive::HolonomicDrive(float magnitude, float direction,
|
||||
float rotation) {
|
||||
void RobotDrive::HolonomicDrive(double magnitude, double direction,
|
||||
double rotation) {
|
||||
MecanumDrive_Polar(magnitude, direction, rotation);
|
||||
}
|
||||
|
||||
@@ -596,7 +596,8 @@ void RobotDrive::HolonomicDrive(float magnitude, float direction,
|
||||
* @param leftOutput The speed to send to the left side of the robot.
|
||||
* @param rightOutput The speed to send to the right side of the robot.
|
||||
*/
|
||||
void RobotDrive::SetLeftRightMotorOutputs(float leftOutput, float rightOutput) {
|
||||
void RobotDrive::SetLeftRightMotorOutputs(double leftOutput,
|
||||
double rightOutput) {
|
||||
wpi_assert(m_rearLeftMotor != nullptr && m_rearRightMotor != nullptr);
|
||||
|
||||
if (m_frontLeftMotor != nullptr)
|
||||
@@ -617,7 +618,7 @@ void RobotDrive::SetLeftRightMotorOutputs(float leftOutput, float rightOutput) {
|
||||
/**
|
||||
* Limit motor values to the -1.0 to +1.0 range.
|
||||
*/
|
||||
float RobotDrive::Limit(float num) {
|
||||
double RobotDrive::Limit(double num) {
|
||||
if (num > 1.0) {
|
||||
return 1.0;
|
||||
}
|
||||
@@ -682,7 +683,7 @@ void RobotDrive::SetInvertedMotor(MotorType motor, bool isInverted) {
|
||||
* @param sensitivity Effectively sets the turning sensitivity (or turn radius
|
||||
* for a given value)
|
||||
*/
|
||||
void RobotDrive::SetSensitivity(float sensitivity) {
|
||||
void RobotDrive::SetSensitivity(double sensitivity) {
|
||||
m_sensitivity = sensitivity;
|
||||
}
|
||||
|
||||
@@ -695,11 +696,11 @@ void RobotDrive::SetSensitivity(float sensitivity) {
|
||||
*/
|
||||
void RobotDrive::SetMaxOutput(double maxOutput) { m_maxOutput = maxOutput; }
|
||||
|
||||
void RobotDrive::SetExpiration(float timeout) {
|
||||
void RobotDrive::SetExpiration(double timeout) {
|
||||
// FIXME: m_safetyHelper->SetExpiration(timeout);
|
||||
}
|
||||
|
||||
float RobotDrive::GetExpiration() const {
|
||||
double RobotDrive::GetExpiration() const {
|
||||
return -1; // FIXME: return m_safetyHelper->GetExpiration();
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ SafePWM::SafePWM(int channel) : PWM(channel) {
|
||||
*
|
||||
* @param timeout The timeout (in seconds) for this motor object
|
||||
*/
|
||||
void SafePWM::SetExpiration(float timeout) {
|
||||
void SafePWM::SetExpiration(double timeout) {
|
||||
m_safetyHelper->SetExpiration(timeout);
|
||||
}
|
||||
|
||||
@@ -36,7 +36,9 @@ void SafePWM::SetExpiration(float timeout) {
|
||||
*
|
||||
* @returns The expiration time value.
|
||||
*/
|
||||
float SafePWM::GetExpiration() const { return m_safetyHelper->GetExpiration(); }
|
||||
double SafePWM::GetExpiration() const {
|
||||
return m_safetyHelper->GetExpiration();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the PWM object is currently alive or stopped due to a timeout.
|
||||
@@ -86,7 +88,7 @@ void SafePWM::GetDescription(std::ostringstream& desc) const {
|
||||
*
|
||||
* @param speed Value to pass to the PWM class
|
||||
*/
|
||||
void SafePWM::SetSpeed(float speed) {
|
||||
void SafePWM::SetSpeed(double speed) {
|
||||
PWM::SetSpeed(speed);
|
||||
m_safetyHelper->Feed();
|
||||
}
|
||||
|
||||
@@ -43,14 +43,14 @@ Talon::Talon(int channel) : SafePWM(channel) {
|
||||
*
|
||||
* @param speed The speed value between -1.0 and 1.0 to set.
|
||||
*/
|
||||
void Talon::Set(float speed) { SetSpeed(speed); }
|
||||
void Talon::Set(double speed) { SetSpeed(speed); }
|
||||
|
||||
/**
|
||||
* Get the recently set value of the PWM.
|
||||
*
|
||||
* @return The most recently set value for the PWM between -1.0 and 1.0.
|
||||
*/
|
||||
float Talon::Get() const { return GetSpeed(); }
|
||||
double Talon::Get() const { return GetSpeed(); }
|
||||
|
||||
/**
|
||||
* Common interface for disabling a motor.
|
||||
@@ -62,4 +62,4 @@ void Talon::Disable() { SetRaw(kPwmDisabled); }
|
||||
*
|
||||
* @param output Write out the PWM value as was found in the PIDController
|
||||
*/
|
||||
void Talon::PIDWrite(float output) { Set(output); }
|
||||
void Talon::PIDWrite(double output) { Set(output); }
|
||||
|
||||
@@ -45,14 +45,14 @@ Victor::Victor(int channel) : SafePWM(channel) {
|
||||
*
|
||||
* @param speed The speed value between -1.0 and 1.0 to set.
|
||||
*/
|
||||
void Victor::Set(float speed) { SetSpeed(speed); }
|
||||
void Victor::Set(double speed) { SetSpeed(speed); }
|
||||
|
||||
/**
|
||||
* Get the recently set value of the PWM.
|
||||
*
|
||||
* @return The most recently set value for the PWM between -1.0 and 1.0.
|
||||
*/
|
||||
float Victor::Get() const { return GetSpeed(); }
|
||||
double Victor::Get() const { return GetSpeed(); }
|
||||
|
||||
/**
|
||||
* Common interface for disabling a motor.
|
||||
@@ -64,4 +64,4 @@ void Victor::Disable() { SetRaw(kPwmDisabled); }
|
||||
*
|
||||
* @param output Write out the PWM value as was found in the PIDController
|
||||
*/
|
||||
void Victor::PIDWrite(float output) { Set(output); }
|
||||
void Victor::PIDWrite(double output) { Set(output); }
|
||||
|
||||
@@ -27,7 +27,7 @@ XboxController::XboxController(int port)
|
||||
*
|
||||
* @param hand Side of controller whose value should be returned.
|
||||
*/
|
||||
float XboxController::GetX(JoystickHand hand) const {
|
||||
double XboxController::GetX(JoystickHand hand) const {
|
||||
if (hand == kLeftHand) {
|
||||
return GetRawAxis(0);
|
||||
} else {
|
||||
@@ -40,7 +40,7 @@ float XboxController::GetX(JoystickHand hand) const {
|
||||
*
|
||||
* @param hand Side of controller whose value should be returned.
|
||||
*/
|
||||
float XboxController::GetY(JoystickHand hand) const {
|
||||
double XboxController::GetY(JoystickHand hand) const {
|
||||
if (hand == kLeftHand) {
|
||||
return GetRawAxis(1);
|
||||
} else {
|
||||
@@ -80,7 +80,7 @@ bool XboxController::GetStickButton(JoystickHand hand) const {
|
||||
*
|
||||
* @param hand Side of controller whose value should be returned.
|
||||
*/
|
||||
float XboxController::GetTriggerAxis(JoystickHand hand) const {
|
||||
double XboxController::GetTriggerAxis(JoystickHand hand) const {
|
||||
if (hand == kLeftHand) {
|
||||
return GetRawAxis(2);
|
||||
} else {
|
||||
|
||||
@@ -16,10 +16,10 @@ SimContinuousOutput::SimContinuousOutput(std::string topic) {
|
||||
std::cout << "Initialized ~/simulator/" + topic << std::endl;
|
||||
}
|
||||
|
||||
void SimContinuousOutput::Set(float speed) {
|
||||
void SimContinuousOutput::Set(double speed) {
|
||||
gazebo::msgs::Float64 msg;
|
||||
msg.set_data(speed);
|
||||
pub->Publish(msg);
|
||||
}
|
||||
|
||||
float SimContinuousOutput::Get() { return speed; }
|
||||
double SimContinuousOutput::Get() { return speed; }
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user