Cleaned up integer type usage in wpilibc (#92)

Replaced all unsigned types to signed and int32_t with int in wpilibc
This commit is contained in:
Tyler Veness
2016-09-06 00:01:45 -07:00
committed by Peter Johnson
parent ff93050b31
commit 0cd05d1a42
169 changed files with 914 additions and 943 deletions

View File

@@ -24,10 +24,10 @@
*/
class ADXL345_I2C : public Accelerometer, public LiveWindowSendable {
protected:
static const uint8_t kAddress = 0x1D;
static const uint8_t kPowerCtlRegister = 0x2D;
static const uint8_t kDataFormatRegister = 0x31;
static const uint8_t kDataRegister = 0x32;
static const int kAddress = 0x1D;
static const int kPowerCtlRegister = 0x2D;
static const int kDataFormatRegister = 0x31;
static const int kDataRegister = 0x32;
static constexpr double kGsPerLSB = 0.00390625;
enum PowerCtlFields {
kPowerCtl_Link = 0x20,

View File

@@ -27,9 +27,9 @@ class DigitalOutput;
*/
class ADXL345_SPI : public Accelerometer, public LiveWindowSendable {
protected:
static const uint8_t kPowerCtlRegister = 0x2D;
static const uint8_t kDataFormatRegister = 0x31;
static const uint8_t kDataRegister = 0x32;
static const int kPowerCtlRegister = 0x2D;
static const int kDataFormatRegister = 0x31;
static const int kDataRegister = 0x32;
static constexpr double kGsPerLSB = 0.00390625;
enum SPIAddressFields { kAddress_Read = 0x80, kAddress_MultiByte = 0x40 };
enum PowerCtlFields {

View File

@@ -39,5 +39,5 @@ class ADXRS450_Gyro : public GyroBase {
private:
SPI m_spi;
uint16_t ReadRegister(uint8_t reg);
uint16_t ReadRegister(int reg);
};

View File

@@ -25,7 +25,7 @@ class AnalogAccelerometer : public SensorBase,
public PIDSource,
public LiveWindowSendable {
public:
explicit AnalogAccelerometer(int32_t channel);
explicit AnalogAccelerometer(int channel);
explicit AnalogAccelerometer(AnalogInput* channel);
explicit AnalogAccelerometer(std::shared_ptr<AnalogInput> channel);
virtual ~AnalogAccelerometer() = default;

View File

@@ -29,23 +29,22 @@ class AnalogInput;
*/
class AnalogGyro : public GyroBase {
public:
static const uint32_t kOversampleBits = 10;
static const uint32_t kAverageBits = 0;
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;
explicit AnalogGyro(int32_t channel);
explicit AnalogGyro(int channel);
explicit AnalogGyro(AnalogInput* channel);
explicit AnalogGyro(std::shared_ptr<AnalogInput> channel);
AnalogGyro(int32_t channel, uint32_t center, float offset);
AnalogGyro(std::shared_ptr<AnalogInput> channel, uint32_t center,
float offset);
AnalogGyro(int channel, int center, float offset);
AnalogGyro(std::shared_ptr<AnalogInput> channel, int center, float offset);
virtual ~AnalogGyro();
float GetAngle() const override;
double GetRate() const override;
virtual uint32_t GetCenter() const;
virtual int GetCenter() const;
virtual float GetOffset() const;
void SetSensitivity(float voltsPerDegreePerSecond);
void SetDeadband(float volts);

View File

@@ -34,35 +34,35 @@ class AnalogInput : public SensorBase,
friend class AnalogGyro;
public:
static const uint8_t kAccumulatorModuleNumber = 1;
static const uint32_t kAccumulatorNumChannels = 2;
static const uint32_t kAccumulatorChannels[kAccumulatorNumChannels];
static const int kAccumulatorModuleNumber = 1;
static const int kAccumulatorNumChannels = 2;
static const int kAccumulatorChannels[kAccumulatorNumChannels];
explicit AnalogInput(uint32_t channel);
explicit AnalogInput(int channel);
virtual ~AnalogInput();
int32_t GetValue() const;
int32_t GetAverageValue() const;
int GetValue() const;
int GetAverageValue() const;
float GetVoltage() const;
float GetAverageVoltage() const;
uint32_t GetChannel() const;
int GetChannel() const;
void SetAverageBits(int32_t bits);
int32_t GetAverageBits() const;
void SetOversampleBits(int32_t bits);
int32_t GetOversampleBits() const;
void SetAverageBits(int bits);
int GetAverageBits() const;
void SetOversampleBits(int bits);
int GetOversampleBits() const;
int32_t GetLSBWeight() const;
int32_t GetOffset() const;
int GetLSBWeight() const;
int GetOffset() const;
bool IsAccumulatorChannel() const;
void InitAccumulator();
void SetAccumulatorInitialValue(int64_t value);
void ResetAccumulator();
void SetAccumulatorCenter(int32_t center);
void SetAccumulatorDeadband(int32_t deadband);
void SetAccumulatorCenter(int center);
void SetAccumulatorDeadband(int deadband);
int64_t GetAccumulatorValue() const;
int64_t GetAccumulatorCount() const;
void GetAccumulatorOutput(int64_t& value, int64_t& count) const;
@@ -80,7 +80,7 @@ class AnalogInput : public SensorBase,
std::shared_ptr<ITable> GetTable() const override;
private:
uint32_t m_channel;
int m_channel;
// TODO: Adjust HAL to avoid use of raw pointers.
HAL_AnalogInputHandle m_port;
int64_t m_accumulatorOffset;

View File

@@ -21,7 +21,7 @@
*/
class AnalogOutput : public SensorBase, public LiveWindowSendable {
public:
explicit AnalogOutput(uint32_t channel);
explicit AnalogOutput(int channel);
virtual ~AnalogOutput();
void SetVoltage(float voltage);
@@ -35,7 +35,7 @@ class AnalogOutput : public SensorBase, public LiveWindowSendable {
std::shared_ptr<ITable> GetTable() const override;
protected:
uint32_t m_channel;
int m_channel;
HAL_AnalogOutputHandle m_port;
std::shared_ptr<ITable> m_table;

View File

@@ -19,22 +19,22 @@ class AnalogTrigger : public SensorBase {
friend class AnalogTriggerOutput;
public:
explicit AnalogTrigger(int32_t channel);
explicit AnalogTrigger(int channel);
explicit AnalogTrigger(AnalogInput* channel);
virtual ~AnalogTrigger();
void SetLimitsVoltage(float lower, float upper);
void SetLimitsRaw(int32_t lower, int32_t upper);
void SetLimitsRaw(int lower, int upper);
void SetAveraged(bool useAveragedValue);
void SetFiltered(bool useFilteredValue);
int32_t GetIndex() const;
int GetIndex() const;
bool GetInWindow();
bool GetTriggerState();
std::shared_ptr<AnalogTriggerOutput> CreateOutput(
AnalogTriggerType type) const;
private:
uint8_t m_index;
int m_index;
HAL_AnalogTriggerHandle m_trigger;
AnalogInput* m_analogInput = nullptr;
bool m_ownsAnalog = false;

View File

@@ -54,7 +54,7 @@ class AnalogTriggerOutput : public DigitalSource {
HAL_Handle GetPortHandleForRouting() const override;
AnalogTriggerType GetAnalogTriggerTypeForRouting() const override;
bool IsAnalogTrigger() const override;
uint32_t GetChannel() const override;
int GetChannel() const override;
protected:
AnalogTriggerOutput(const AnalogTrigger& trigger,

View File

@@ -22,7 +22,6 @@
#include "MotorSafety.h"
#include "MotorSafetyHelper.h"
#include "PIDOutput.h"
#include "Resource.h"
#include "tables/ITableListener.h"
/**
@@ -35,7 +34,7 @@ class CANJaguar : public MotorSafety,
public ITableListener {
public:
// The internal PID control loop in the Jaguar runs at 1kHz.
static const int32_t kControllerRate = 1000;
static const int kControllerRate = 1000;
static constexpr double kApproxBusVoltage = 12.0;
// Control mode tags
@@ -52,11 +51,11 @@ class CANJaguar : public MotorSafety,
static const struct PotentiometerStruct {
} Potentiometer;
explicit CANJaguar(uint8_t deviceNumber);
explicit CANJaguar(int deviceNumber);
virtual ~CANJaguar();
uint8_t getDeviceNumber() const;
uint8_t GetHardwareVersion() const;
int getDeviceNumber() const;
int GetHardwareVersion() const;
// PIDOutput interface
void PIDWrite(float output) override;
@@ -91,7 +90,7 @@ class CANJaguar : public MotorSafety,
void SetVoltageMode(QuadEncoderStruct, uint16_t codesPerRev);
void SetVoltageMode(PotentiometerStruct);
void Set(float value, uint8_t syncGroup);
void Set(float value, int syncGroup);
// CANSpeedController interface
float Get() const override;
@@ -115,7 +114,7 @@ class CANJaguar : public MotorSafety,
bool GetReverseLimitOK() const override;
uint16_t GetFaults() const override;
void SetVoltageRampRate(double rampRate) override;
uint32_t GetFirmwareVersion() const override;
int GetFirmwareVersion() const override;
void ConfigNeutralMode(NeutralMode mode) override;
void ConfigEncoderCodesPerRev(uint16_t codesPerRev) override;
void ConfigPotentiometerTurns(uint16_t turns) override;
@@ -139,7 +138,7 @@ class CANJaguar : public MotorSafety,
bool IsSafetyEnabled() const override;
void SetSafetyEnabled(bool enabled) override;
void GetDescription(std::ostringstream& desc) const override;
uint8_t GetDeviceID() const;
int GetDeviceID() const;
// SpeedController overrides
void SetInverted(bool isInverted) override;
@@ -147,28 +146,27 @@ class CANJaguar : public MotorSafety,
protected:
// Control mode helpers
void SetSpeedReference(uint8_t reference);
uint8_t GetSpeedReference() const;
void SetSpeedReference(int reference);
int GetSpeedReference() const;
void SetPositionReference(uint8_t reference);
uint8_t GetPositionReference() const;
void SetPositionReference(int reference);
int GetPositionReference() const;
uint8_t packPercentage(uint8_t* buffer, double value);
uint8_t packFXP8_8(uint8_t* buffer, double value);
uint8_t packFXP16_16(uint8_t* buffer, double value);
uint8_t packint16_t(uint8_t* buffer, int16_t value);
uint8_t packint32_t(uint8_t* buffer, int32_t value);
int packPercentage(uint8_t* buffer, double value);
int packFXP8_8(uint8_t* buffer, double value);
int packFXP16_16(uint8_t* buffer, double value);
int packInt16(uint8_t* buffer, int16_t value);
int packInt32(uint8_t* buffer, int32_t value);
double unpackPercentage(uint8_t* buffer) const;
double unpackFXP8_8(uint8_t* buffer) const;
double unpackFXP16_16(uint8_t* buffer) const;
int16_t unpackint16_t(uint8_t* buffer) const;
int32_t unpackint32_t(uint8_t* buffer) const;
int16_t unpackInt16(uint8_t* buffer) const;
int32_t unpackInt32(uint8_t* buffer) const;
void sendMessage(uint32_t messageID, const uint8_t* data, uint8_t dataSize,
int32_t period = CAN_SEND_PERIOD_NO_REPEAT);
void requestMessage(uint32_t messageID,
int32_t period = CAN_SEND_PERIOD_NO_REPEAT);
bool getMessage(uint32_t messageID, uint32_t mask, uint8_t* data,
void sendMessage(int messageID, const uint8_t* data, uint8_t dataSize,
int period = CAN_SEND_PERIOD_NO_REPEAT);
void requestMessage(int messageID, int period = CAN_SEND_PERIOD_NO_REPEAT);
bool getMessage(int messageID, uint32_t mask, uint8_t* data,
uint8_t* dataSize) const;
void setupPeriodicStatus();
@@ -176,13 +174,13 @@ class CANJaguar : public MotorSafety,
mutable priority_recursive_mutex m_mutex;
uint8_t m_deviceNumber;
int m_deviceNumber;
float m_value = 0.0f;
// Parameters/configuration
ControlMode m_controlMode = kPercentVbus;
uint8_t m_speedReference = LM_REF_NONE;
uint8_t m_positionReference = LM_REF_NONE;
int m_speedReference = LM_REF_NONE;
int m_positionReference = LM_REF_NONE;
double m_p = 0.0;
double m_i = 0.0;
double m_d = 0.0;
@@ -221,10 +219,10 @@ class CANJaguar : public MotorSafety,
mutable float m_temperature = 0.0f;
mutable double m_position = 0.0;
mutable double m_speed = 0.0;
mutable uint8_t m_limits = 0x00;
mutable int m_limits = 0x00;
mutable uint16_t m_faults = 0x0000;
uint32_t m_firmwareVersion = 0;
uint8_t m_hardwareVersion = 0;
int m_firmwareVersion = 0;
int m_hardwareVersion = 0;
// Which periodic status messages have we received at least once?
mutable std::atomic<bool> m_receivedStatusMessage0{false};

View File

@@ -84,7 +84,7 @@ class CANSpeedController : public SpeedController {
virtual bool GetReverseLimitOK() const = 0;
virtual uint16_t GetFaults() const = 0;
virtual void SetVoltageRampRate(double rampRate) = 0;
virtual uint32_t GetFirmwareVersion() const = 0;
virtual int GetFirmwareVersion() const = 0;
virtual void ConfigNeutralMode(NeutralMode mode) = 0;
virtual void ConfigEncoderCodesPerRev(uint16_t codesPerRev) = 0;
virtual void ConfigPotentiometerTurns(uint16_t turns) = 0;

View File

@@ -119,7 +119,7 @@ class CANTalon : public MotorSafety,
* Value should be between 1ms and 255ms. If value is zero
* then Talon will default to 1ms. If value exceeds 255ms API will cap it.
*/
unsigned int timeDurMs;
int timeDurMs;
/**
* Which slot to get PIDF gains.
* PID is used for position servo.
@@ -127,7 +127,7 @@ class CANTalon : public MotorSafety,
* Typically this is hardcoded to the a particular slot, but you are free
* gain schedule if need be.
*/
unsigned int profileSlotSelect;
int profileSlotSelect;
/**
* Set to true to only perform the velocity feed-forward and not perform
* position servo. This is useful when learning how the position servo
@@ -181,15 +181,15 @@ class CANTalon : public MotorSafety,
* them into the Talon's low-level buffer, allowing the Talon to act on
* them.
*/
unsigned int topBufferRem;
int topBufferRem;
/**
* The number of points in the top trajectory buffer.
*/
unsigned int topBufferCnt;
int topBufferCnt;
/**
* The number of points in the low level Talon buffer.
*/
unsigned int btmBufferCnt;
int btmBufferCnt;
/**
* Set if isUnderrun ever gets set.
* Only is cleared by clearMotionProfileHasUnderrun() to ensure
@@ -253,7 +253,7 @@ class CANTalon : public MotorSafety,
void SetI(double i) override;
void SetD(double d) override;
void SetF(double f);
void SetIzone(unsigned iz);
void SetIzone(int iz);
void SetPID(double p, double i, double d) override;
virtual void SetPID(double p, double i, double d, double f);
double GetP() const override;
@@ -269,7 +269,7 @@ class CANTalon : public MotorSafety,
double GetPosition() const override;
double GetSpeed() const override;
virtual int GetClosedLoopError() const;
virtual void SetAllowableClosedLoopErr(uint32_t allowableCloseLoopError);
virtual void SetAllowableClosedLoopErr(int allowableCloseLoopError);
virtual int GetAnalogIn() const;
virtual void SetAnalogPosition(int newPosition);
virtual int GetAnalogInRaw() const;
@@ -298,7 +298,7 @@ class CANTalon : public MotorSafety,
void ClearStickyFaults();
void SetVoltageRampRate(double rampRate) override;
virtual void SetVoltageCompensationRampRate(double rampRate);
uint32_t GetFirmwareVersion() const override;
int GetFirmwareVersion() const override;
void ConfigNeutralMode(NeutralMode mode) override;
void ConfigEncoderCodesPerRev(uint16_t codesPerRev) override;
void ConfigPotentiometerTurns(uint16_t turns) override;
@@ -347,8 +347,8 @@ class CANTalon : public MotorSafety,
* edge, pass false to clear the position on falling edge.
*/
void EnableZeroSensorPositionOnIndex(bool enable, bool risingEdge);
void ConfigSetParameter(uint32_t paramEnum, double value);
bool GetParameter(uint32_t paramEnum, double& dvalue) const;
void ConfigSetParameter(int paramEnum, double value);
bool GetParameter(int paramEnum, double& dvalue) const;
void ConfigFaultTime(float faultTime) override;
virtual void SetControlMode(ControlMode mode);
@@ -469,8 +469,8 @@ class CANTalon : public MotorSafety,
int m_deviceNumber;
std::unique_ptr<CanTalonSRX> m_impl;
std::unique_ptr<MotorSafetyHelper> m_safetyHelper;
int m_profile = 0; // Profile from CANTalon to use. Set to zero until we can
// actually test this.
int m_profile = 0; // Profile from CANTalon to use. Set to zero until we
// can actually test this.
bool m_controlEnabled = true;
bool m_stopped = false;
@@ -485,7 +485,7 @@ class CANTalon : public MotorSafety,
* count (4X). Caller can use ConfigEncoderCodesPerRev to set the quadrature
* encoder CPR.
*/
uint32_t m_codesPerRev = 0;
int m_codesPerRev = 0;
/**
* Number of turns per rotation. For example, a 10-turn pot spins ten full
* rotations from a wiper voltage of zero to 3.3 volts. Therefore knowing
@@ -494,14 +494,14 @@ class CANTalon : public MotorSafety,
* behaves as it did during the 2015 season, there are 1024 position units
* from zero to 3.3V.
*/
uint32_t m_numPotTurns = 0;
int m_numPotTurns = 0;
/**
* Although the Talon handles feedback selection, caching the feedback
* selection is helpful at the API level for scaling into rotations and RPM.
*/
FeedbackDevice m_feedbackDevice = QuadEncoder;
static constexpr unsigned int kDelayForSolicitedSignalsUs = 4000;
static constexpr int kDelayForSolicitedSignalsUs = 4000;
/**
* @param devToLookup FeedbackDevice to lookup the scalar for. Because Talon
* allows multiple sensors to be attached simultaneously,
@@ -531,8 +531,8 @@ class CANTalon : public MotorSafety,
* @return fullRotations in native engineering units of the Talon SRX
* firmware.
*/
int32_t ScaleRotationsToNativeUnits(FeedbackDevice devToLookup,
double fullRotations) const;
int ScaleRotationsToNativeUnits(FeedbackDevice devToLookup,
double fullRotations) const;
/**
* @param rpm double precision value representing number of rotations per
* minute of selected feedback sensor. If user has never called
@@ -544,8 +544,7 @@ class CANTalon : public MotorSafety,
* @return sensor velocity in native engineering units of the Talon SRX
* firmware.
*/
int32_t ScaleVelocityToNativeUnits(FeedbackDevice devToLookup,
double rpm) const;
int ScaleVelocityToNativeUnits(FeedbackDevice devToLookup, double rpm) const;
/**
* @param nativePos integral position of the feedback sensor in native
* Talon SRX units. If user has never called the config
@@ -558,7 +557,7 @@ class CANTalon : public MotorSafety,
* performed.
*/
double ScaleNativeUnitsToRotations(FeedbackDevice devToLookup,
int32_t nativePos) const;
int nativePos) const;
/**
* @param nativeVel integral velocity of the feedback sensor in native
* Talon SRX units. If user has never called the config
@@ -570,8 +569,7 @@ class CANTalon : public MotorSafety,
* @return double precision of sensor velocity in RPM, unless config was never
* performed.
*/
double ScaleNativeUnitsToRpm(FeedbackDevice devToLookup,
int32_t nativeVel) const;
double ScaleNativeUnitsToRpm(FeedbackDevice devToLookup, int nativeVel) const;
// LiveWindow stuff.
std::shared_ptr<ITable> m_table;

View File

@@ -23,11 +23,11 @@ class CameraServer : public ErrorBase {
private:
static constexpr uint16_t kPort = 1180;
static constexpr uint8_t kMagicNumber[] = {0x01, 0x00, 0x00, 0x00};
static constexpr uint32_t kSize640x480 = 0;
static constexpr uint32_t kSize320x240 = 1;
static constexpr uint32_t kSize160x120 = 2;
static constexpr int32_t kHardwareCompression = -1;
static constexpr uint32_t kMaxImageSize = 200000;
static constexpr int kSize640x480 = 0;
static constexpr int kSize320x240 = 1;
static constexpr int kSize160x120 = 2;
static constexpr int kHardwareCompression = -1;
static constexpr int kMaxImageSize = 200000;
protected:
CameraServer();
@@ -38,22 +38,21 @@ class CameraServer : public ErrorBase {
priority_recursive_mutex m_imageMutex;
std::condition_variable_any m_newImageVariable;
std::vector<uint8_t*> m_dataPool;
unsigned int m_quality;
int m_quality;
bool m_autoCaptureStarted;
bool m_hwClient;
std::tuple<uint8_t*, unsigned int, unsigned int, bool> m_imageData;
std::tuple<uint8_t*, int, int, bool> m_imageData;
void Serve();
void AutoCapture();
void SetImageData(uint8_t* data, unsigned int size, unsigned int start = 0,
void SetImageData(uint8_t* data, int size, int start = 0,
bool imaqData = false);
void FreeImageData(
std::tuple<uint8_t*, unsigned int, unsigned int, bool> imageData);
void FreeImageData(std::tuple<uint8_t*, int, int, bool> imageData);
struct Request {
uint32_t fps;
int32_t compression;
uint32_t size;
int fps;
int compression;
int size;
};
public:
@@ -76,8 +75,8 @@ class CameraServer : public ErrorBase {
bool IsAutoCaptureStarted();
void SetQuality(unsigned int quality);
unsigned int GetQuality();
void SetQuality(int quality);
int GetQuality();
void SetSize(unsigned int size);
void SetSize(int size);
};

View File

@@ -23,7 +23,7 @@ class Compressor : public SensorBase,
public ITableListener {
public:
// Default PCM ID is 0
explicit Compressor(uint8_t pcmID = GetDefaultSolenoidModule());
explicit Compressor(int pcmID = GetDefaultSolenoidModule());
virtual ~Compressor() = default;
void Start();
@@ -59,7 +59,7 @@ class Compressor : public SensorBase,
private:
void SetCompressor(bool on);
uint8_t m_module;
int m_module;
std::shared_ptr<ITable> m_table;
};

View File

@@ -39,7 +39,7 @@ class Counter : public SensorBase,
kExternalDirection = 3
};
explicit Counter(Mode mode = kTwoPulse);
explicit Counter(int32_t channel);
explicit Counter(int channel);
explicit Counter(DigitalSource* source);
explicit Counter(std::shared_ptr<DigitalSource> source);
DEPRECATED("Use pass-by-reference instead.")
@@ -51,7 +51,7 @@ class Counter : public SensorBase,
std::shared_ptr<DigitalSource> downSource, bool inverted);
virtual ~Counter();
void SetUpSource(int32_t channel);
void SetUpSource(int channel);
void SetUpSource(AnalogTrigger* analogTrigger, AnalogTriggerType triggerType);
void SetUpSource(std::shared_ptr<AnalogTrigger> analogTrigger,
AnalogTriggerType triggerType);
@@ -61,7 +61,7 @@ class Counter : public SensorBase,
void SetUpSourceEdge(bool risingEdge, bool fallingEdge);
void ClearUpSource();
void SetDownSource(int32_t channel);
void SetDownSource(int channel);
void SetDownSource(AnalogTrigger* analogTrigger,
AnalogTriggerType triggerType);
void SetDownSource(std::shared_ptr<AnalogTrigger> analogTrigger,
@@ -80,7 +80,7 @@ class Counter : public SensorBase,
void SetReverseDirection(bool reverseDirection);
// CounterBase interface
int32_t Get() const override;
int Get() const override;
void Reset() override;
double GetPeriod() const override;
void SetMaxPeriod(double maxPeriod) override;
@@ -90,7 +90,7 @@ class Counter : public SensorBase,
void SetSamplesToAverage(int samplesToAverage);
int GetSamplesToAverage() const;
int32_t GetFPGAIndex() const { return m_index; }
int GetFPGAIndex() const { return m_index; }
void UpdateTable() override;
void StartLiveWindowMode() override;
@@ -108,7 +108,7 @@ class Counter : public SensorBase,
HAL_CounterHandle m_counter = HAL_kInvalidHandle;
private:
int32_t m_index = 0; ///< The index of this counter.
int m_index = 0; ///< The index of this counter.
std::shared_ptr<ITable> m_table;
friend class DigitalGlitchFilter;

View File

@@ -22,7 +22,7 @@ class CounterBase {
enum EncodingType { k1X, k2X, k4X };
virtual ~CounterBase() = default;
virtual int32_t Get() const = 0;
virtual int Get() const = 0;
virtual void Reset() = 0;
virtual double GetPeriod() const = 0;
virtual void SetMaxPeriod(double maxPeriod) = 0;

View File

@@ -34,10 +34,10 @@ class DigitalGlitchFilter : public SensorBase {
void Remove(Encoder* input);
void Remove(Counter* input);
void SetPeriodCycles(uint32_t fpga_cycles);
void SetPeriodCycles(int fpga_cycles);
void SetPeriodNanoSeconds(uint64_t nanoseconds);
uint32_t GetPeriodCycles();
int GetPeriodCycles();
uint64_t GetPeriodNanoSeconds();
private:

View File

@@ -27,10 +27,10 @@ class DigitalGlitchFilter;
*/
class DigitalInput : public DigitalSource, public LiveWindowSendable {
public:
explicit DigitalInput(uint32_t channel);
explicit DigitalInput(int channel);
virtual ~DigitalInput();
bool Get() const;
uint32_t GetChannel() const override;
int GetChannel() const override;
// Digital Source Interface
HAL_Handle GetPortHandleForRouting() const override;
@@ -45,7 +45,7 @@ class DigitalInput : public DigitalSource, public LiveWindowSendable {
std::shared_ptr<ITable> GetTable() const;
private:
uint32_t m_channel;
int m_channel;
HAL_DigitalHandle m_handle;
std::shared_ptr<ITable> m_table;

View File

@@ -25,11 +25,11 @@ class DigitalOutput : public DigitalSource,
public ITableListener,
public LiveWindowSendable {
public:
explicit DigitalOutput(uint32_t channel);
explicit DigitalOutput(int channel);
virtual ~DigitalOutput();
void Set(bool value);
bool Get();
uint32_t GetChannel() const override;
bool Get() const;
int GetChannel() const override;
void Pulse(float length);
bool IsPulsing() const;
void SetPWMRate(float rate);
@@ -52,7 +52,7 @@ class DigitalOutput : public DigitalSource,
std::shared_ptr<ITable> GetTable() const;
private:
uint32_t m_channel;
int m_channel;
HAL_DigitalHandle m_handle;
HAL_DigitalPWMHandle m_pwmGenerator;

View File

@@ -26,5 +26,5 @@ class DigitalSource : public InterruptableSensorBase {
virtual HAL_Handle GetPortHandleForRouting() const = 0;
virtual AnalogTriggerType GetAnalogTriggerTypeForRouting() const = 0;
virtual bool IsAnalogTrigger() const = 0;
virtual uint32_t GetChannel() const = 0;
virtual int GetChannel() const = 0;
};

View File

@@ -28,9 +28,8 @@ class DoubleSolenoid : public SolenoidBase,
public:
enum Value { kOff, kForward, kReverse };
explicit DoubleSolenoid(uint32_t forwardChannel, uint32_t reverseChannel);
DoubleSolenoid(uint8_t moduleNumber, uint32_t forwardChannel,
uint32_t reverseChannel);
explicit DoubleSolenoid(int forwardChannel, int reverseChannel);
DoubleSolenoid(int moduleNumber, int forwardChannel, int reverseChannel);
virtual ~DoubleSolenoid();
virtual void Set(Value value);
virtual Value Get() const;
@@ -47,10 +46,10 @@ class DoubleSolenoid : public SolenoidBase,
std::shared_ptr<ITable> GetTable() const;
private:
uint32_t m_forwardChannel; ///< The forward channel on the module to control.
uint32_t m_reverseChannel; ///< The reverse channel on the module to control.
uint8_t m_forwardMask; ///< The mask for the forward channel.
uint8_t m_reverseMask; ///< The mask for the reverse channel.
int m_forwardChannel; ///< The forward channel on the module to control.
int m_reverseChannel; ///< The reverse channel on the module to control.
int m_forwardMask; ///< The mask for the forward channel.
int m_reverseMask; ///< The mask for the reverse channel.
HAL_SolenoidHandle m_forwardHandle = HAL_kInvalidHandle;
HAL_SolenoidHandle m_reverseHandle = HAL_kInvalidHandle;

View File

@@ -34,25 +34,25 @@ class DriverStation : public SensorBase, public RobotStateInterface {
static DriverStation& GetInstance();
static void ReportError(std::string error);
static void ReportWarning(std::string error);
static void ReportError(bool is_error, int32_t code, const std::string& error,
static void ReportError(bool is_error, int code, const std::string& error,
const std::string& location,
const std::string& stack);
static const uint32_t kJoystickPorts = 6;
static const int kJoystickPorts = 6;
float GetStickAxis(uint32_t stick, uint32_t axis);
int GetStickPOV(uint32_t stick, uint32_t pov);
uint32_t GetStickButtons(uint32_t stick) const;
bool GetStickButton(uint32_t stick, uint8_t button);
float GetStickAxis(int stick, int axis);
int GetStickPOV(int stick, int pov);
int GetStickButtons(int stick) const;
bool GetStickButton(int stick, int button);
int GetStickAxisCount(uint32_t stick) const;
int GetStickPOVCount(uint32_t stick) const;
int GetStickButtonCount(uint32_t stick) const;
int GetStickAxisCount(int stick) const;
int GetStickPOVCount(int stick) const;
int GetStickButtonCount(int stick) const;
bool GetJoystickIsXbox(uint32_t stick) const;
int GetJoystickType(uint32_t stick) const;
std::string GetJoystickName(uint32_t stick) const;
int GetJoystickAxisType(uint32_t stick, uint8_t axis) const;
bool GetJoystickIsXbox(int stick) const;
int GetJoystickType(int stick) const;
std::string GetJoystickName(int stick) const;
int GetJoystickAxisType(int stick, int axis) const;
bool IsEnabled() const override;
bool IsDisabled() const override;
@@ -66,7 +66,7 @@ class DriverStation : public SensorBase, public RobotStateInterface {
bool IsBrownedOut() const;
Alliance GetAlliance() const;
uint32_t GetLocation() const;
int GetLocation() const;
void WaitForData();
double GetMatchTime() const;
float GetBatteryVoltage() const;

View File

@@ -46,7 +46,7 @@ class Encoder : public SensorBase,
kResetOnRisingEdge
};
Encoder(uint32_t aChannel, uint32_t bChannel, bool reverseDirection = false,
Encoder(int aChannel, int bChannel, bool reverseDirection = false,
EncodingType encodingType = k4X);
Encoder(std::shared_ptr<DigitalSource> aSource,
std::shared_ptr<DigitalSource> bSource, bool reverseDirection = false,
@@ -58,9 +58,9 @@ class Encoder : public SensorBase,
virtual ~Encoder();
// CounterBase interface
int32_t Get() const override;
int32_t GetRaw() const;
int32_t GetEncodingScale() const;
int Get() const override;
int GetRaw() const;
int GetEncodingScale() const;
void Reset() override;
double GetPeriod() const override;
void SetMaxPeriod(double maxPeriod) override;
@@ -76,7 +76,7 @@ class Encoder : public SensorBase,
int GetSamplesToAverage() const;
double PIDGet() override;
void SetIndexSource(uint32_t channel, IndexingType type = kResetOnRisingEdge);
void SetIndexSource(int channel, IndexingType type = kResetOnRisingEdge);
DEPRECATED("Use pass-by-reference instead.")
void SetIndexSource(DigitalSource* source,
IndexingType type = kResetOnRisingEdge);
@@ -90,7 +90,7 @@ class Encoder : public SensorBase,
void InitTable(std::shared_ptr<ITable> subTable) override;
std::shared_ptr<ITable> GetTable() const override;
int32_t GetFPGAIndex() const;
int GetFPGAIndex() const;
private:
void InitEncoder(bool reverseDirection, EncodingType encodingType);

View File

@@ -22,7 +22,7 @@ class GearTooth : public Counter {
public:
/// 55 uSec for threshold
static constexpr double kGearToothThreshold = 55e-6;
explicit GearTooth(uint32_t channel, bool directionSensitive = false);
explicit GearTooth(int channel, bool directionSensitive = false);
explicit GearTooth(DigitalSource* source, bool directionSensitive = false);
explicit GearTooth(std::shared_ptr<DigitalSource> source,
bool directionSensitive = false);

View File

@@ -20,24 +20,23 @@ class I2C : SensorBase {
public:
enum Port { kOnboard, kMXP };
I2C(Port port, uint8_t deviceAddress);
I2C(Port port, int deviceAddress);
virtual ~I2C();
I2C(const I2C&) = delete;
I2C& operator=(const I2C&) = delete;
bool Transaction(uint8_t* dataToSend, uint8_t sendSize, uint8_t* dataReceived,
uint8_t receiveSize);
bool Transaction(uint8_t* dataToSend, int sendSize, uint8_t* dataReceived,
int receiveSize);
bool AddressOnly();
bool Write(uint8_t registerAddress, uint8_t data);
bool WriteBulk(uint8_t* data, uint8_t count);
bool Read(uint8_t registerAddress, uint8_t count, uint8_t* data);
bool ReadOnly(uint8_t count, uint8_t* buffer);
void Broadcast(uint8_t registerAddress, uint8_t data);
bool VerifySensor(uint8_t registerAddress, uint8_t count,
const uint8_t* expected);
bool Write(int registerAddress, uint8_t data);
bool WriteBulk(uint8_t* data, int count);
bool Read(int registerAddress, int count, uint8_t* data);
bool ReadOnly(int count, uint8_t* buffer);
void Broadcast(int registerAddress, uint8_t data);
bool VerifySensor(int registerAddress, int count, const uint8_t* expected);
private:
Port m_port;
uint8_t m_deviceAddress;
int m_deviceAddress;
};

View File

@@ -14,6 +14,6 @@
*/
class Jaguar : public PWMSpeedController {
public:
explicit Jaguar(uint32_t channel);
explicit Jaguar(int channel);
virtual ~Jaguar() = default;
};

View File

@@ -27,11 +27,11 @@ class DriverStation;
*/
class Joystick : public GenericHID, public ErrorBase {
public:
static const uint32_t kDefaultXAxis = 0;
static const uint32_t kDefaultYAxis = 1;
static const uint32_t kDefaultZAxis = 2;
static const uint32_t kDefaultTwistAxis = 2;
static const uint32_t kDefaultThrottleAxis = 3;
static const int kDefaultXAxis = 0;
static const int kDefaultYAxis = 1;
static const int kDefaultZAxis = 2;
static const int kDefaultTwistAxis = 2;
static const int kDefaultThrottleAxis = 3;
typedef enum {
kXAxis,
kYAxis,
@@ -40,8 +40,8 @@ class Joystick : public GenericHID, public ErrorBase {
kThrottleAxis,
kNumAxisTypes
} AxisType;
static const uint32_t kDefaultTriggerButton = 1;
static const uint32_t kDefaultTopButton = 2;
static const int kDefaultTriggerButton = 1;
static const int kDefaultTopButton = 2;
typedef enum { kTriggerButton, kTopButton, kNumButtonTypes } ButtonType;
typedef enum { kLeftRumble, kRightRumble } RumbleType;
typedef enum {
@@ -63,15 +63,15 @@ class Joystick : public GenericHID, public ErrorBase {
kHIDFlight = 23,
kHID1stPerson = 24
} HIDType;
explicit Joystick(uint32_t port);
Joystick(uint32_t port, uint32_t numAxisTypes, uint32_t numButtonTypes);
explicit Joystick(int port);
Joystick(int port, int numAxisTypes, int numButtonTypes);
virtual ~Joystick() = default;
Joystick(const Joystick&) = delete;
Joystick& operator=(const Joystick&) = delete;
uint32_t GetAxisChannel(AxisType axis) const;
void SetAxisChannel(AxisType axis, uint32_t channel);
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;
@@ -79,15 +79,15 @@ class Joystick : public GenericHID, public ErrorBase {
float GetTwist() const override;
float GetThrottle() const override;
virtual float GetAxis(AxisType axis) const;
float GetRawAxis(uint32_t axis) const override;
float GetRawAxis(int axis) const override;
bool GetTrigger(JoystickHand hand = kRightHand) const override;
bool GetTop(JoystickHand hand = kRightHand) const override;
bool GetBumper(JoystickHand hand = kRightHand) const override;
bool GetRawButton(uint32_t button) const override;
int GetPOV(uint32_t pov = 0) const override;
bool GetRawButton(int button) const override;
int GetPOV(int pov = 0) const override;
bool GetButton(ButtonType button) const;
static Joystick* GetStickForPort(uint32_t port);
static Joystick* GetStickForPort(int port);
virtual float GetMagnitude() const;
virtual float GetDirectionRadians() const;
@@ -104,15 +104,15 @@ class Joystick : public GenericHID, public ErrorBase {
int GetPOVCount() const;
void SetRumble(RumbleType type, float value);
void SetOutput(uint8_t outputNumber, bool value);
void SetOutputs(uint32_t value);
void SetOutput(int outputNumber, bool value);
void SetOutputs(int value);
private:
DriverStation& m_ds;
uint32_t m_port;
std::vector<uint32_t> m_axes;
std::vector<uint32_t> m_buttons;
uint32_t m_outputs = 0;
int m_port;
std::vector<int> m_axes;
std::vector<int> m_buttons;
int m_outputs = 0;
uint16_t m_leftRumble = 0;
uint16_t m_rightRumble = 0;
};

View File

@@ -42,7 +42,7 @@ class PWM : public SensorBase,
kPeriodMultiplier_4X = 4
};
explicit PWM(uint32_t channel);
explicit PWM(int channel);
virtual ~PWM();
virtual void SetRaw(uint16_t value);
virtual uint16_t GetRaw() const;
@@ -56,11 +56,11 @@ class PWM : public SensorBase,
void EnableDeadbandElimination(bool eliminateDeadband);
void SetBounds(float max, float deadbandMax, float center, float deadbandMin,
float min);
void SetRawBounds(int32_t max, int32_t deadbandMax, int32_t center,
int32_t deadbandMin, int32_t min);
void SetRawBounds(int max, int deadbandMax, int center, int deadbandMin,
int min);
void GetRawBounds(int32_t* max, int32_t* deadbandMax, int32_t* center,
int32_t* deadbandMin, int32_t* min);
uint32_t GetChannel() const { return m_channel; }
int GetChannel() const { return m_channel; }
protected:
void ValueChanged(ITable* source, llvm::StringRef key,
@@ -75,6 +75,6 @@ class PWM : public SensorBase,
std::shared_ptr<ITable> m_table;
private:
uint32_t m_channel;
int m_channel;
HAL_DigitalHandle m_handle;
};

View File

@@ -27,7 +27,7 @@ class PWMSpeedController : public SafePWM, public SpeedController {
bool GetInverted() const override;
protected:
explicit PWMSpeedController(uint32_t channel);
explicit PWMSpeedController(int channel);
private:
bool m_isInverted = false;

View File

@@ -20,11 +20,11 @@
class PowerDistributionPanel : public SensorBase, public LiveWindowSendable {
public:
PowerDistributionPanel();
explicit PowerDistributionPanel(uint8_t module);
explicit PowerDistributionPanel(int module);
float GetVoltage() const;
float GetTemperature() const;
float GetCurrent(uint8_t channel) const;
float GetCurrent(int channel) const;
float GetTotalCurrent() const;
float GetTotalPower() const;
float GetTotalEnergy() const;
@@ -40,5 +40,5 @@ class PowerDistributionPanel : public SensorBase, public LiveWindowSendable {
private:
std::shared_ptr<ITable> m_table;
uint8_t m_module;
int m_module;
};

View File

@@ -66,7 +66,7 @@ class Preferences : public ErrorBase {
std::shared_ptr<nt::Value> value, bool isNew) override;
void ValueChangedEx(ITable* source, llvm::StringRef key,
std::shared_ptr<nt::Value> value,
unsigned int flags) override;
uint32_t flags) override;
};
Listener m_listener;
};

View File

@@ -38,12 +38,12 @@ class Relay : public MotorSafety,
enum Value { kOff, kOn, kForward, kReverse };
enum Direction { kBothDirections, kForwardOnly, kReverseOnly };
explicit Relay(uint32_t channel, Direction direction = kBothDirections);
explicit Relay(int channel, Direction direction = kBothDirections);
virtual ~Relay();
void Set(Value value);
Value Get() const;
uint32_t GetChannel() const;
int GetChannel() const;
void SetExpiration(float timeout) override;
float GetExpiration() const override;
@@ -65,7 +65,7 @@ class Relay : public MotorSafety,
std::shared_ptr<ITable> m_table;
private:
uint32_t m_channel;
int m_channel;
Direction m_direction;
HAL_RelayHandle m_forwardHandle = HAL_kInvalidHandle;

View File

@@ -36,9 +36,9 @@ class RobotDrive : public MotorSafety, public ErrorBase {
kRearRightMotor = 3
};
RobotDrive(uint32_t leftMotorChannel, uint32_t rightMotorChannel);
RobotDrive(uint32_t frontLeftMotorChannel, uint32_t rearLeftMotorChannel,
uint32_t frontRightMotorChannel, uint32_t rearRightMotorChannel);
RobotDrive(int leftMotorChannel, int rightMotorChannel);
RobotDrive(int frontLeftMotorChannel, int rearLeftMotorChannel,
int frontRightMotorChannel, int rearRightMotorChannel);
RobotDrive(SpeedController* leftMotor, SpeedController* rightMotor);
RobotDrive(SpeedController& leftMotor, SpeedController& rightMotor);
RobotDrive(std::shared_ptr<SpeedController> leftMotor,
@@ -61,20 +61,18 @@ class RobotDrive : public MotorSafety, public ErrorBase {
bool squaredInputs = true);
void TankDrive(GenericHID& leftStick, GenericHID& rightStick,
bool squaredInputs = true);
void TankDrive(GenericHID* leftStick, uint32_t leftAxis,
GenericHID* rightStick, uint32_t rightAxis,
bool squaredInputs = true);
void TankDrive(GenericHID& leftStick, uint32_t leftAxis,
GenericHID& rightStick, uint32_t rightAxis,
bool squaredInputs = true);
void TankDrive(GenericHID* leftStick, int leftAxis, GenericHID* rightStick,
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 ArcadeDrive(GenericHID* stick, bool squaredInputs = true);
void ArcadeDrive(GenericHID& stick, bool squaredInputs = true);
void ArcadeDrive(GenericHID* moveStick, uint32_t moveChannel,
GenericHID* rotateStick, uint32_t rotateChannel,
void ArcadeDrive(GenericHID* moveStick, int moveChannel,
GenericHID* rotateStick, int rotateChannel,
bool squaredInputs = true);
void ArcadeDrive(GenericHID& moveStick, uint32_t moveChannel,
GenericHID& rotateStick, uint32_t rotateChannel,
void ArcadeDrive(GenericHID& moveStick, int moveChannel,
GenericHID& rotateStick, int rotateChannel,
bool squaredInputs = true);
void ArcadeDrive(float moveValue, float rotateValue,
bool squaredInputs = true);
@@ -101,7 +99,7 @@ class RobotDrive : public MotorSafety, public ErrorBase {
void Normalize(double* wheelSpeeds);
void RotateVector(double& x, double& y, double angle);
static const int32_t kMaxNumberOfMotors = 4;
static const int kMaxNumberOfMotors = 4;
float m_sensitivity = 0.5;
double m_maxOutput = 1.0;
std::shared_ptr<SpeedController> m_frontLeftMotor;
@@ -111,7 +109,7 @@ class RobotDrive : public MotorSafety, public ErrorBase {
std::unique_ptr<MotorSafetyHelper> m_safetyHelper;
private:
int32_t GetNumMotors() {
int GetNumMotors() {
int motors = 0;
if (m_frontLeftMotor) motors++;
if (m_frontRightMotor) motors++;

View File

@@ -14,6 +14,6 @@
*/
class SD540 : public PWMSpeedController {
public:
explicit SD540(uint32_t channel);
explicit SD540(int channel);
virtual ~SD540() = default;
};

View File

@@ -42,27 +42,25 @@ class SPI : public SensorBase {
void SetChipSelectActiveHigh();
void SetChipSelectActiveLow();
virtual int32_t Write(uint8_t* data, uint8_t size);
virtual int32_t Read(bool initiate, uint8_t* dataReceived, uint8_t size);
virtual int32_t Transaction(uint8_t* dataToSend, uint8_t* dataReceived,
uint8_t size);
virtual int Write(uint8_t* data, int size);
virtual int Read(bool initiate, uint8_t* dataReceived, int size);
virtual int Transaction(uint8_t* dataToSend, uint8_t* dataReceived, int size);
void InitAccumulator(double period, uint32_t cmd, uint8_t xfer_size,
uint32_t valid_mask, uint32_t valid_value,
uint8_t data_shift, uint8_t data_size, bool is_signed,
bool big_endian);
void InitAccumulator(double period, int cmd, int xfer_size, int valid_mask,
int valid_value, int data_shift, int data_size,
bool is_signed, bool big_endian);
void FreeAccumulator();
void ResetAccumulator();
void SetAccumulatorCenter(int32_t center);
void SetAccumulatorDeadband(int32_t deadband);
int32_t GetAccumulatorLastValue() const;
void SetAccumulatorCenter(int center);
void SetAccumulatorDeadband(int deadband);
int GetAccumulatorLastValue() const;
int64_t GetAccumulatorValue() const;
int64_t GetAccumulatorCount() const;
double GetAccumulatorAverage() const;
void GetAccumulatorOutput(int64_t& value, int64_t& count) const;
protected:
uint8_t m_port;
int m_port;
bool m_msbFirst = false; // default little-endian
bool m_sampleOnTrailing = false; // default data updated on falling edge
bool m_clk_idle_high = false; // default clock active high

View File

@@ -23,7 +23,7 @@
*/
class SafePWM : public PWM, public MotorSafety {
public:
explicit SafePWM(uint32_t channel);
explicit SafePWM(int channel);
virtual ~SafePWM() = default;
void SetExpiration(float timeout);

View File

@@ -46,7 +46,7 @@ class SerialPort : public ErrorBase {
enum WriteBufferMode { kFlushOnAccess = 1, kFlushWhenFull = 2 };
enum Port { kOnboard = 0, kMXP = 1, kUSB = 2 };
SerialPort(uint32_t baudRate, Port port = kOnboard, uint8_t dataBits = 8,
SerialPort(int baudRate, Port port = kOnboard, int dataBits = 8,
Parity parity = kParity_None, StopBits stopBits = kStopBits_One);
~SerialPort();
@@ -56,19 +56,19 @@ class SerialPort : public ErrorBase {
void SetFlowControl(FlowControl flowControl);
void EnableTermination(char terminator = '\n');
void DisableTermination();
int32_t GetBytesReceived();
uint32_t Read(char* buffer, int32_t count);
uint32_t Write(const std::string& buffer, int32_t count);
int GetBytesReceived();
int Read(char* buffer, int count);
int Write(const std::string& buffer, int count);
void SetTimeout(float timeout);
void SetReadBufferSize(uint32_t size);
void SetWriteBufferSize(uint32_t size);
void SetReadBufferSize(int size);
void SetWriteBufferSize(int size);
void SetWriteBufferMode(WriteBufferMode mode);
void Flush();
void Reset();
private:
uint32_t m_resourceManagerHandle = 0;
uint32_t m_portHandle = 0;
int m_resourceManagerHandle = 0;
int m_portHandle = 0;
bool m_consoleModeEnabled = false;
uint8_t m_port;
int m_port;
};

View File

@@ -22,7 +22,7 @@
*/
class Servo : public SafePWM {
public:
explicit Servo(uint32_t channel);
explicit Servo(int channel);
virtual ~Servo();
void Set(float value);
void SetOffline();

View File

@@ -25,8 +25,8 @@ class Solenoid : public SolenoidBase,
public LiveWindowSendable,
public ITableListener {
public:
explicit Solenoid(uint32_t channel);
Solenoid(uint8_t moduleNumber, uint32_t channel);
explicit Solenoid(int channel);
Solenoid(int moduleNumber, int channel);
virtual ~Solenoid();
virtual void Set(bool on);
virtual bool Get() const;
@@ -43,6 +43,6 @@ class Solenoid : public SolenoidBase,
private:
HAL_SolenoidHandle m_solenoidHandle = HAL_kInvalidHandle;
uint32_t m_channel; ///< The channel on the module to control.
int m_channel; ///< The channel on the module to control.
std::shared_ptr<ITable> m_table;
};

View File

@@ -18,18 +18,18 @@
class SolenoidBase : public SensorBase {
public:
virtual ~SolenoidBase() = default;
uint8_t GetAll(int module = 0) const;
int GetAll(int module = 0) const;
uint8_t GetPCMSolenoidBlackList(int module) const;
int GetPCMSolenoidBlackList(int module) const;
bool GetPCMSolenoidVoltageStickyFault(int module) const;
bool GetPCMSolenoidVoltageFault(int module) const;
void ClearAllPCMStickyFaults(int module);
protected:
explicit SolenoidBase(uint8_t pcmID);
explicit SolenoidBase(int pcmID);
static const int m_maxModules = 63;
static const int m_maxPorts = 8;
// static void* m_ports[m_maxModules][m_maxPorts];
uint8_t m_moduleNumber; ///< Slot number where the module is plugged into
/// the chassis.
int m_moduleNumber; ///< Slot number where the module is plugged into
/// the chassis.
};

View File

@@ -14,6 +14,6 @@
*/
class Spark : public PWMSpeedController {
public:
explicit Spark(uint32_t channel);
explicit Spark(int channel);
virtual ~Spark() = default;
};

View File

@@ -14,6 +14,6 @@
*/
class Talon : public PWMSpeedController {
public:
explicit Talon(uint32_t channel);
explicit Talon(int channel);
virtual ~Talon() = default;
};

View File

@@ -15,6 +15,6 @@
*/
class TalonSRX : public PWMSpeedController {
public:
explicit TalonSRX(uint32_t channel);
explicit TalonSRX(int channel);
virtual ~TalonSRX() = default;
};

View File

@@ -50,19 +50,19 @@ class USBCamera : public ErrorBase {
priority_recursive_mutex m_mutex;
unsigned int m_width = 320;
unsigned int m_height = 240;
int m_width = 320;
int m_height = 240;
double m_fps = 30;
std::string m_whiteBalance = AUTO;
unsigned int m_whiteBalanceValue = 0;
int m_whiteBalanceValue = 0;
bool m_whiteBalanceValuePresent = false;
std::string m_exposure = MANUAL;
unsigned int m_exposureValue = 50;
int m_exposureValue = 50;
bool m_exposureValuePresent = false;
unsigned int m_brightness = 80;
int m_brightness = 80;
bool m_needSettingsUpdate = true;
unsigned int GetJpegSize(void* buffer, unsigned int buffSize);
int GetJpegSize(void* buffer, int buffSize);
public:
static constexpr char const* kDefaultCameraName = "cam0";
@@ -74,18 +74,18 @@ class USBCamera : public ErrorBase {
void StartCapture();
void StopCapture();
void SetFPS(double fps);
void SetSize(unsigned int width, unsigned int height);
void SetSize(int width, int height);
void UpdateSettings();
/**
* Set the brightness, as a percentage (0-100).
*/
void SetBrightness(unsigned int brightness);
void SetBrightness(int brightness);
/**
* Get the brightness, as a percentage (0-100).
*/
unsigned int GetBrightness();
int GetBrightness();
/**
* Set the white balance to auto
@@ -100,7 +100,7 @@ class USBCamera : public ErrorBase {
/**
* Set the white balance to manual, with specified color temperature
*/
void SetWhiteBalanceManual(unsigned int wbValue);
void SetWhiteBalanceManual(int wbValue);
/**
* Set the exposure to auto exposure
@@ -115,8 +115,8 @@ class USBCamera : public ErrorBase {
/**
* Set the exposure to manual, with a given percentage (0-100)
*/
void SetExposureManual(unsigned int expValue);
void SetExposureManual(int expValue);
void GetImage(Image* image);
unsigned int GetImageData(void* buffer, unsigned int bufferSize);
int GetImageData(void* buffer, int bufferSize);
};

View File

@@ -47,8 +47,7 @@ class Ultrasonic : public SensorBase,
Ultrasonic(std::shared_ptr<DigitalOutput> pingChannel,
std::shared_ptr<DigitalInput> echoChannel,
DistanceUnit units = kInches);
Ultrasonic(uint32_t pingChannel, uint32_t echoChannel,
DistanceUnit units = kInches);
Ultrasonic(int pingChannel, int echoChannel, DistanceUnit units = kInches);
virtual ~Ultrasonic();
void Ping();
@@ -79,7 +78,7 @@ class Ultrasonic : public SensorBase,
// Time (sec) for the ping trigger pulse.
static constexpr double kPingTime = 10 * 1e-6;
// Priority that the ultrasonic round robin task runs.
static const uint32_t kPriority = 64;
static const int kPriority = 64;
// Max time (ms) between readings.
static constexpr double kMaxUltrasonicTime = 0.1;
static constexpr double kSpeedOfSoundInchesPerSec = 1130.0 * 12.0;

View File

@@ -17,6 +17,6 @@
*/
class Victor : public PWMSpeedController {
public:
explicit Victor(uint32_t channel);
explicit Victor(int channel);
virtual ~Victor() = default;
};

View File

@@ -14,6 +14,6 @@
*/
class VictorSP : public PWMSpeedController {
public:
explicit VictorSP(uint32_t channel);
explicit VictorSP(int channel);
virtual ~VictorSP() = default;
};

View File

@@ -61,8 +61,7 @@ class AxisCamera : public ErrorBase {
int GetImage(Image* image);
int GetImage(ColorImage* image);
HSLImage* GetImage();
int CopyJPEG(char** destImage, unsigned int& destImageSize,
unsigned int& destImageBufferSize);
int CopyJPEG(char** destImage, int& destImageSize, int& destImageBufferSize);
void WriteBrightness(int brightness);
int GetBrightness();

View File

@@ -7,6 +7,8 @@
#pragma once
#include <stdint.h>
#include <string>
/* Constants */

View File

@@ -7,6 +7,8 @@
#pragma once
#include <stdint.h>
/* Error Codes */
#define ERR_VISION_GENERAL_ERROR 166000 //
#define ERR_COLOR_NOT_FOUND 166100 // TrackAPI.cpp

View File

@@ -7,6 +7,8 @@
#pragma once
#include <stdint.h>
/**
* Color threshold values.
* This object represnts the threshold values for any type of color object

View File

@@ -7,6 +7,8 @@
#pragma once
#include <stdint.h>
#include "nivision.h"
/* Constants */
@@ -142,14 +144,13 @@ int frcColorEqualize(Image* dest, const Image* source, int colorEqualization);
/* Image Thresholding & Conversion functions */
/* Smart Threshold: calls imaqLocalThreshold */
int frcSmartThreshold(Image* dest, const Image* source,
unsigned int windowWidth, unsigned int windowHeight,
LocalThresholdMethod method, double deviationWeight,
ObjectType type);
int frcSmartThreshold(Image* dest, const Image* source,
unsigned int windowWidth, unsigned int windowHeight,
LocalThresholdMethod method, double deviationWeight,
ObjectType type, float replaceValue);
int frcSmartThreshold(Image* dest, const Image* source, int windowWidth,
int windowHeight, LocalThresholdMethod method,
double deviationWeight, ObjectType type);
int frcSmartThreshold(Image* dest, const Image* source, int windowWidth,
int windowHeight, LocalThresholdMethod method,
double deviationWeight, ObjectType type,
float replaceValue);
/* Simple Threshold: calls imaqThreshold */
int frcSimpleThreshold(Image* dest, const Image* source, float rangeMin,

View File

@@ -65,7 +65,6 @@
#include "PowerDistributionPanel.h"
#include "Preferences.h"
#include "Relay.h"
#include "Resource.h"
#include "RobotBase.h"
#include "RobotDrive.h"
#include "SD540.h"

View File

@@ -10,10 +10,10 @@
#include "I2C.h"
#include "LiveWindow/LiveWindow.h"
const uint8_t ADXL345_I2C::kAddress;
const uint8_t ADXL345_I2C::kPowerCtlRegister;
const uint8_t ADXL345_I2C::kDataFormatRegister;
const uint8_t ADXL345_I2C::kDataRegister;
const int ADXL345_I2C::kAddress;
const int ADXL345_I2C::kPowerCtlRegister;
const int ADXL345_I2C::kDataFormatRegister;
const int ADXL345_I2C::kDataRegister;
constexpr double ADXL345_I2C::kGsPerLSB;
/**
@@ -54,7 +54,7 @@ double ADXL345_I2C::GetZ() { return GetAcceleration(kAxis_Z); }
*/
double ADXL345_I2C::GetAcceleration(ADXL345_I2C::Axes axis) {
int16_t rawAccel = 0;
m_i2c.Read(kDataRegister + static_cast<uint8_t>(axis), sizeof(rawAccel),
m_i2c.Read(kDataRegister + static_cast<int>(axis), sizeof(rawAccel),
reinterpret_cast<uint8_t*>(&rawAccel));
return rawAccel * kGsPerLSB;
}

View File

@@ -11,9 +11,9 @@
#include "HAL/HAL.h"
#include "LiveWindow/LiveWindow.h"
const uint8_t ADXL345_SPI::kPowerCtlRegister;
const uint8_t ADXL345_SPI::kDataFormatRegister;
const uint8_t ADXL345_SPI::kDataRegister;
const int ADXL345_SPI::kPowerCtlRegister;
const int ADXL345_SPI::kDataFormatRegister;
const int ADXL345_SPI::kDataRegister;
constexpr double ADXL345_SPI::kGsPerLSB;
/**
@@ -92,7 +92,7 @@ ADXL345_SPI::AllAxes ADXL345_SPI::GetAccelerations() {
dataBuffer[0] = (kAddress_Read | kAddress_MultiByte | kDataRegister);
m_spi.Transaction(dataBuffer, dataBuffer, 7);
for (int32_t i = 0; i < 3; i++) {
for (int i = 0; i < 3; i++) {
// Sensor is little endian... swap bytes
rawData[i] = dataBuffer[i * 2 + 2] << 8 | dataBuffer[i * 2 + 1];
}

View File

@@ -12,22 +12,22 @@
#include "HAL/HAL.h"
#include "LiveWindow/LiveWindow.h"
static uint8_t kRegWrite = 0x0A;
static uint8_t kRegRead = 0x0B;
static int kRegWrite = 0x0A;
static int kRegRead = 0x0B;
static uint8_t kPartIdRegister = 0x02;
static uint8_t kDataRegister = 0x0E;
static uint8_t kFilterCtlRegister = 0x2C;
static uint8_t kPowerCtlRegister = 0x2D;
static int kPartIdRegister = 0x02;
static int kDataRegister = 0x0E;
static int kFilterCtlRegister = 0x2C;
static int kPowerCtlRegister = 0x2D;
// static uint8_t kFilterCtl_Range2G = 0x00;
// static uint8_t kFilterCtl_Range4G = 0x40;
// static uint8_t kFilterCtl_Range8G = 0x80;
static uint8_t kFilterCtl_ODR_100Hz = 0x03;
// static int kFilterCtl_Range2G = 0x00;
// static int kFilterCtl_Range4G = 0x40;
// static int kFilterCtl_Range8G = 0x80;
static int kFilterCtl_ODR_100Hz = 0x03;
static uint8_t kPowerCtl_UltraLowNoise = 0x20;
// static uint8_t kPowerCtl_AutoSleep = 0x04;
static uint8_t kPowerCtl_Measure = 0x02;
static int kPowerCtl_UltraLowNoise = 0x20;
// static int kPowerCtl_AutoSleep = 0x04;
static int kPowerCtl_Measure = 0x02;
/**
* Constructor. Uses the onboard CS1.
@@ -147,7 +147,7 @@ ADXL362::AllAxes ADXL362::GetAccelerations() {
dataBuffer[1] = kDataRegister;
m_spi.Transaction(dataBuffer, dataBuffer, 8);
for (int32_t i = 0; i < 3; i++) {
for (int i = 0; i < 3; i++) {
// Sensor is little endian... swap bytes
rawData[i] = dataBuffer[i * 2 + 3] << 8 | dataBuffer[i * 2 + 2];
}

View File

@@ -14,15 +14,15 @@ static constexpr double kSamplePeriod = 0.001;
static constexpr double kCalibrationSampleTime = 5.0;
static constexpr double kDegreePerSecondPerLSB = 0.0125;
static constexpr uint8_t kRateRegister = 0x00;
static constexpr uint8_t kTemRegister = 0x02;
static constexpr uint8_t kLoCSTRegister = 0x04;
static constexpr uint8_t kHiCSTRegister = 0x06;
static constexpr uint8_t kQuadRegister = 0x08;
static constexpr uint8_t kFaultRegister = 0x0A;
static constexpr uint8_t kPIDRegister = 0x0C;
static constexpr uint8_t kSNHighRegister = 0x0E;
static constexpr uint8_t kSNLowRegister = 0x10;
static constexpr int kRateRegister = 0x00;
static constexpr int kTemRegister = 0x02;
static constexpr int kLoCSTRegister = 0x04;
static constexpr int kHiCSTRegister = 0x06;
static constexpr int kQuadRegister = 0x08;
static constexpr int kFaultRegister = 0x0A;
static constexpr int kPIDRegister = 0x0C;
static constexpr int kSNHighRegister = 0x0E;
static constexpr int kSNLowRegister = 0x10;
/**
* Initialize the gyro.
@@ -43,8 +43,7 @@ void ADXRS450_Gyro::Calibrate() {
Wait(kCalibrationSampleTime);
m_spi.SetAccumulatorCenter(
static_cast<int32_t>(m_spi.GetAccumulatorAverage()));
m_spi.SetAccumulatorCenter(static_cast<int>(m_spi.GetAccumulatorAverage()));
m_spi.ResetAccumulator();
}
@@ -80,7 +79,7 @@ ADXRS450_Gyro::ADXRS450_Gyro(SPI::Port port) : m_spi(port) {
LiveWindow::GetInstance()->AddSensor("ADXRS450_Gyro", port, this);
}
static bool CalcParity(uint32_t v) {
static bool CalcParity(int v) {
bool parity = false;
while (v != 0) {
parity = !parity;
@@ -89,16 +88,16 @@ static bool CalcParity(uint32_t v) {
return parity;
}
static inline uint32_t BytesToIntBE(uint8_t* buf) {
uint32_t result = static_cast<uint32_t>(buf[0]) << 24;
result |= static_cast<uint32_t>(buf[1]) << 16;
result |= static_cast<uint32_t>(buf[2]) << 8;
result |= static_cast<uint32_t>(buf[3]);
static inline int BytesToIntBE(uint8_t* buf) {
int result = static_cast<int>(buf[0]) << 24;
result |= static_cast<int>(buf[1]) << 16;
result |= static_cast<int>(buf[2]) << 8;
result |= static_cast<int>(buf[3]);
return result;
}
uint16_t ADXRS450_Gyro::ReadRegister(uint8_t reg) {
uint32_t cmd = 0x80000000 | static_cast<uint32_t>(reg) << 17;
uint16_t ADXRS450_Gyro::ReadRegister(int reg) {
int cmd = 0x80000000 | static_cast<int>(reg) << 17;
if (!CalcParity(cmd)) cmd |= 1u;
// big endian

View File

@@ -28,7 +28,7 @@ void AnalogAccelerometer::InitAccelerometer() {
* @param channel The channel number for the analog input the accelerometer is
* connected to
*/
AnalogAccelerometer::AnalogAccelerometer(int32_t channel) {
AnalogAccelerometer::AnalogAccelerometer(int channel) {
m_analogInput = std::make_shared<AnalogInput>(channel);
InitAccelerometer();
}

View File

@@ -15,8 +15,8 @@
#include "Timer.h"
#include "WPIErrors.h"
const uint32_t AnalogGyro::kOversampleBits;
const uint32_t AnalogGyro::kAverageBits;
const int AnalogGyro::kOversampleBits;
const int AnalogGyro::kAverageBits;
constexpr float AnalogGyro::kSamplesPerSecond;
constexpr float AnalogGyro::kCalibrationSampleTime;
constexpr float AnalogGyro::kDefaultVoltsPerDegreePerSecond;
@@ -27,7 +27,7 @@ constexpr float AnalogGyro::kDefaultVoltsPerDegreePerSecond;
* @param channel The analog channel the gyro is connected to. Gyros can only
* be used on on-board Analog Inputs 0-1.
*/
AnalogGyro::AnalogGyro(int32_t channel)
AnalogGyro::AnalogGyro(int channel)
: AnalogGyro(std::make_shared<AnalogInput>(channel)) {}
/**
@@ -76,7 +76,7 @@ AnalogGyro::AnalogGyro(std::shared_ptr<AnalogInput> channel)
* value.
* @param offset Preset uncalibrated value to use as the gyro offset.
*/
AnalogGyro::AnalogGyro(int32_t channel, uint32_t center, float offset) {
AnalogGyro::AnalogGyro(int channel, int center, float offset) {
m_analog = std::make_shared<AnalogInput>(channel);
InitGyro();
int32_t status = 0;
@@ -101,7 +101,7 @@ AnalogGyro::AnalogGyro(int32_t channel, uint32_t center, float offset) {
* @param channel A pointer to the AnalogInput object that the gyro is
* connected to.
*/
AnalogGyro::AnalogGyro(std::shared_ptr<AnalogInput> channel, uint32_t center,
AnalogGyro::AnalogGyro(std::shared_ptr<AnalogInput> channel, int center,
float offset)
: m_analog(channel) {
if (channel == nullptr) {
@@ -239,10 +239,10 @@ float AnalogGyro::GetOffset() const {
*
* @return the current center value
*/
uint32_t AnalogGyro::GetCenter() const {
int AnalogGyro::GetCenter() const {
if (StatusIsFatal()) return 0;
int32_t status = 0;
uint32_t value = HAL_GetAnalogGyroCenter(m_gyroHandle, &status);
int value = HAL_GetAnalogGyroCenter(m_gyroHandle, &status);
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
return value;
}

View File

@@ -14,9 +14,9 @@
#include "Timer.h"
#include "WPIErrors.h"
const uint8_t AnalogInput::kAccumulatorModuleNumber;
const uint32_t AnalogInput::kAccumulatorNumChannels;
const uint32_t AnalogInput::kAccumulatorChannels[] = {0, 1};
const int AnalogInput::kAccumulatorModuleNumber;
const int AnalogInput::kAccumulatorNumChannels;
const int AnalogInput::kAccumulatorChannels[] = {0, 1};
/**
* Construct an analog input.
@@ -24,7 +24,7 @@ const uint32_t AnalogInput::kAccumulatorChannels[] = {0, 1};
* @param channel The channel number on the roboRIO to represent. 0-3 are
* on-board 4-7 are on the MXP port.
*/
AnalogInput::AnalogInput(uint32_t channel) {
AnalogInput::AnalogInput(int channel) {
std::stringstream buf;
buf << "Analog Input " << channel;
@@ -41,7 +41,7 @@ AnalogInput::AnalogInput(uint32_t channel) {
if (status != 0) {
wpi_setErrorWithContextRange(status, 0, HAL_GetNumAnalogInputs(), channel,
HAL_GetErrorMessage(status));
m_channel = std::numeric_limits<uint32_t>::max();
m_channel = std::numeric_limits<int>::max();
m_port = HAL_kInvalidHandle;
return;
}
@@ -67,10 +67,10 @@ AnalogInput::~AnalogInput() {
*
* @return A sample straight from this channel.
*/
int32_t AnalogInput::GetValue() const {
int AnalogInput::GetValue() const {
if (StatusIsFatal()) return 0;
int32_t status = 0;
int32_t value = HAL_GetAnalogValue(m_port, &status);
int value = HAL_GetAnalogValue(m_port, &status);
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
return value;
}
@@ -89,10 +89,10 @@ int32_t AnalogInput::GetValue() const {
*
* @return A sample from the oversample and average engine for this channel.
*/
int32_t AnalogInput::GetAverageValue() const {
int AnalogInput::GetAverageValue() const {
if (StatusIsFatal()) return 0;
int32_t status = 0;
int32_t value = HAL_GetAnalogAverageValue(m_port, &status);
int value = HAL_GetAnalogAverageValue(m_port, &status);
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
return value;
}
@@ -142,10 +142,10 @@ float AnalogInput::GetAverageVoltage() const {
*
* @return Least significant bit weight.
*/
int32_t AnalogInput::GetLSBWeight() const {
int AnalogInput::GetLSBWeight() const {
if (StatusIsFatal()) return 0;
int32_t status = 0;
int32_t lsbWeight = HAL_GetAnalogLSBWeight(m_port, &status);
int lsbWeight = HAL_GetAnalogLSBWeight(m_port, &status);
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
return lsbWeight;
}
@@ -157,10 +157,10 @@ int32_t AnalogInput::GetLSBWeight() const {
*
* @return Offset constant.
*/
int32_t AnalogInput::GetOffset() const {
int AnalogInput::GetOffset() const {
if (StatusIsFatal()) return 0;
int32_t status = 0;
int32_t offset = HAL_GetAnalogOffset(m_port, &status);
int offset = HAL_GetAnalogOffset(m_port, &status);
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
return offset;
}
@@ -170,7 +170,7 @@ int32_t AnalogInput::GetOffset() const {
*
* @return The channel number.
*/
uint32_t AnalogInput::GetChannel() const {
int AnalogInput::GetChannel() const {
if (StatusIsFatal()) return 0;
return m_channel;
}
@@ -186,7 +186,7 @@ uint32_t AnalogInput::GetChannel() const {
*
* @param bits Number of bits of averaging.
*/
void AnalogInput::SetAverageBits(int32_t bits) {
void AnalogInput::SetAverageBits(int bits) {
if (StatusIsFatal()) return;
int32_t status = 0;
HAL_SetAnalogAverageBits(m_port, bits, &status);
@@ -201,9 +201,9 @@ void AnalogInput::SetAverageBits(int32_t bits) {
*
* @return Number of bits of averaging previously configured.
*/
int32_t AnalogInput::GetAverageBits() const {
int AnalogInput::GetAverageBits() const {
int32_t status = 0;
int32_t averageBits = HAL_GetAnalogAverageBits(m_port, &status);
int averageBits = HAL_GetAnalogAverageBits(m_port, &status);
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
return averageBits;
}
@@ -218,7 +218,7 @@ int32_t AnalogInput::GetAverageBits() const {
*
* @param bits Number of bits of oversampling.
*/
void AnalogInput::SetOversampleBits(int32_t bits) {
void AnalogInput::SetOversampleBits(int bits) {
if (StatusIsFatal()) return;
int32_t status = 0;
HAL_SetAnalogOversampleBits(m_port, bits, &status);
@@ -234,10 +234,10 @@ void AnalogInput::SetOversampleBits(int32_t bits) {
*
* @return Number of bits of oversampling previously configured.
*/
int32_t AnalogInput::GetOversampleBits() const {
int AnalogInput::GetOversampleBits() const {
if (StatusIsFatal()) return 0;
int32_t status = 0;
int32_t oversampleBits = HAL_GetAnalogOversampleBits(m_port, &status);
int oversampleBits = HAL_GetAnalogOversampleBits(m_port, &status);
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
return oversampleBits;
}
@@ -309,7 +309,7 @@ void AnalogInput::ResetAccumulator() {
* source from the accumulator channel. Because of this, any non-zero
* oversample bits will affect the size of the value for this field.
*/
void AnalogInput::SetAccumulatorCenter(int32_t center) {
void AnalogInput::SetAccumulatorCenter(int center) {
if (StatusIsFatal()) return;
int32_t status = 0;
HAL_SetAccumulatorCenter(m_port, center, &status);
@@ -319,7 +319,7 @@ void AnalogInput::SetAccumulatorCenter(int32_t center) {
/**
* Set the accumulator's deadband.
*/
void AnalogInput::SetAccumulatorDeadband(int32_t deadband) {
void AnalogInput::SetAccumulatorDeadband(int deadband) {
if (StatusIsFatal()) return;
int32_t status = 0;
HAL_SetAccumulatorDeadband(m_port, deadband, &status);

View File

@@ -21,13 +21,13 @@
*
* @param channel The channel number on the roboRIO to represent.
*/
AnalogOutput::AnalogOutput(uint32_t channel) {
AnalogOutput::AnalogOutput(int channel) {
std::stringstream buf;
buf << "analog input " << channel;
if (!SensorBase::CheckAnalogOutputChannel(channel)) {
wpi_setWPIErrorWithContext(ChannelIndexOutOfRange, buf.str());
m_channel = std::numeric_limits<uint32_t>::max();
m_channel = std::numeric_limits<int>::max();
m_port = HAL_kInvalidHandle;
return;
}
@@ -40,7 +40,7 @@ AnalogOutput::AnalogOutput(uint32_t channel) {
if (status != 0) {
wpi_setErrorWithContextRange(status, 0, HAL_GetNumAnalogOutputs(), channel,
HAL_GetErrorMessage(status));
m_channel = std::numeric_limits<uint32_t>::max();
m_channel = std::numeric_limits<int>::max();
m_port = HAL_kInvalidHandle;
return;
}

View File

@@ -19,7 +19,7 @@
* @param channel The channel number on the roboRIO to represent. 0-3 are
* on-board 4-7 are on the MXP port.
*/
AnalogTrigger::AnalogTrigger(int32_t channel)
AnalogTrigger::AnalogTrigger(int channel)
: AnalogTrigger(new AnalogInput(channel)) {
m_ownsAnalog = true;
}
@@ -35,11 +35,11 @@ AnalogTrigger::AnalogTrigger(int32_t channel)
AnalogTrigger::AnalogTrigger(AnalogInput* input) {
m_analogInput = input;
int32_t status = 0;
int32_t index = 0;
int index = 0;
m_trigger = HAL_InitializeAnalogTrigger(input->m_port, &index, &status);
if (status != 0) {
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
m_index = std::numeric_limits<uint8_t>::max();
m_index = std::numeric_limits<int>::max();
m_trigger = HAL_kInvalidHandle;
return;
}
@@ -66,7 +66,7 @@ AnalogTrigger::~AnalogTrigger() {
* @param lower The lower limit of the trigger in ADC codes (12-bit values).
* @param upper The upper limit of the trigger in ADC codes (12-bit values).
*/
void AnalogTrigger::SetLimitsRaw(int32_t lower, int32_t upper) {
void AnalogTrigger::SetLimitsRaw(int lower, int upper) {
if (StatusIsFatal()) return;
int32_t status = 0;
HAL_SetAnalogTriggerLimitsRaw(m_trigger, lower, upper, &status);
@@ -128,7 +128,7 @@ void AnalogTrigger::SetFiltered(bool useFilteredValue) {
*
* @return The index of the analog trigger.
*/
int32_t AnalogTrigger::GetIndex() const {
int AnalogTrigger::GetIndex() const {
if (StatusIsFatal()) return -1;
return m_index;
}

View File

@@ -73,4 +73,4 @@ AnalogTriggerType AnalogTriggerOutput::GetAnalogTriggerTypeForRouting() const {
/**
* @return The channel of the source.
*/
uint32_t AnalogTriggerOutput::GetChannel() const { return m_trigger.m_index; }
int AnalogTriggerOutput::GetChannel() const { return m_trigger.m_index; }

View File

@@ -12,6 +12,7 @@
#include "FRC_NetworkCommunication/CANSessionMux.h"
#include "HAL/HAL.h"
#include "LiveWindow/LiveWindow.h"
#include "Resource.h"
#include "Timer.h"
#include "WPIErrors.h"
@@ -27,20 +28,20 @@
#define FXP16_EQ(a, b) \
(static_cast<int32_t>((a)*65536.0) == static_cast<int32_t>((b)*65536.0))
const int32_t CANJaguar::kControllerRate;
const int CANJaguar::kControllerRate;
constexpr double CANJaguar::kApproxBusVoltage;
static const int32_t kSendMessagePeriod = 20;
static const uint32_t kFullMessageIDMask =
static const int kSendMessagePeriod = 20;
static const int kFullMessageIDMask =
(CAN_MSGID_API_M | CAN_MSGID_MFR_M | CAN_MSGID_DTYPE_M);
static const int32_t kReceiveStatusAttempts = 50;
static const int kReceiveStatusAttempts = 50;
static std::unique_ptr<Resource> allocated;
static int32_t sendMessageHelper(uint32_t messageID, const uint8_t* data,
uint8_t dataSize, int32_t period) {
static const uint32_t kTrustedMessages[] = {
static int sendMessageHelper(int messageID, const uint8_t* data,
uint8_t dataSize, int period) {
static const int kTrustedMessages[] = {
LM_API_VOLT_T_EN, LM_API_VOLT_T_SET, LM_API_SPD_T_EN, LM_API_SPD_T_SET,
LM_API_VCOMP_T_EN, LM_API_VCOMP_T_SET, LM_API_POS_T_EN, LM_API_POS_T_SET,
LM_API_ICTRL_T_EN, LM_API_ICTRL_T_SET};
@@ -56,7 +57,7 @@ static int32_t sendMessageHelper(uint32_t messageID, const uint8_t* data,
// Make sure the data will still fit after adjusting for the token.
assert(dataSize <= 6);
for (uint8_t j = 0; j < dataSize; j++) {
for (int j = 0; j < dataSize; j++) {
dataBuffer[j + 2] = data[j];
}
@@ -97,7 +98,7 @@ void CANJaguar::InitCANJaguar() {
if (!receivedFirmwareVersion &&
getMessage(CAN_MSGID_API_FIRMVER, CAN_MSGID_FULL_M, dataBuffer,
&dataSize)) {
m_firmwareVersion = unpackint32_t(dataBuffer);
m_firmwareVersion = unpackInt32(dataBuffer);
receivedFirmwareVersion = true;
}
@@ -180,7 +181,7 @@ void CANJaguar::InitCANJaguar() {
* @see CANJaguar#SetVoltageMode(EncoderTag, int)
* @see CANJaguar#SetVoltageMode(QuadEncoderTag, int)
*/
CANJaguar::CANJaguar(uint8_t deviceNumber) : m_deviceNumber(deviceNumber) {
CANJaguar::CANJaguar(int deviceNumber) : m_deviceNumber(deviceNumber) {
std::stringstream buf;
buf << "CANJaguar device number " << m_deviceNumber;
Resource::CreateResourceObject(allocated, 63);
@@ -229,7 +230,7 @@ CANJaguar::~CANJaguar() {
/**
* @return The CAN ID passed in the constructor
*/
uint8_t CANJaguar::getDeviceNumber() const { return m_deviceNumber; }
int CANJaguar::getDeviceNumber() const { return m_deviceNumber; }
/**
* Sets the output set-point value.
@@ -246,8 +247,8 @@ uint8_t CANJaguar::getDeviceNumber() const { return m_deviceNumber; }
* @param syncGroup The update group to add this Set() to, pending
* UpdateSyncGroup(). If 0, update immediately.
*/
void CANJaguar::Set(float outputValue, uint8_t syncGroup) {
uint32_t messageID;
void CANJaguar::Set(float outputValue, int syncGroup) {
int messageID;
uint8_t dataBuffer[8];
uint8_t dataSize;
@@ -344,30 +345,30 @@ void CANJaguar::PIDWrite(float output) {
}
}
uint8_t CANJaguar::packPercentage(uint8_t* buffer, double value) {
int CANJaguar::packPercentage(uint8_t* buffer, double value) {
int16_t intValue = static_cast<int16_t>(value * 32767.0);
*reinterpret_cast<int16_t*>(buffer) = swap16(intValue);
return sizeof(int16_t);
}
uint8_t CANJaguar::packFXP8_8(uint8_t* buffer, double value) {
int CANJaguar::packFXP8_8(uint8_t* buffer, double value) {
int16_t intValue = static_cast<int16_t>(value * 256.0);
*reinterpret_cast<int16_t*>(buffer) = swap16(intValue);
return sizeof(int16_t);
}
uint8_t CANJaguar::packFXP16_16(uint8_t* buffer, double value) {
int32_t intValue = static_cast<int32_t>(value * 65536.0);
int CANJaguar::packFXP16_16(uint8_t* buffer, double value) {
int intValue = static_cast<int>(value * 65536.0);
*reinterpret_cast<int32_t*>(buffer) = swap32(intValue);
return sizeof(int32_t);
}
uint8_t CANJaguar::packint16_t(uint8_t* buffer, int16_t value) {
int CANJaguar::packInt16(uint8_t* buffer, int16_t value) {
*reinterpret_cast<int16_t*>(buffer) = swap16(value);
return sizeof(int16_t);
}
uint8_t CANJaguar::packint32_t(uint8_t* buffer, int32_t value) {
int CANJaguar::packInt32(uint8_t* buffer, int32_t value) {
*reinterpret_cast<int32_t*>(buffer) = swap32(value);
return sizeof(int32_t);
}
@@ -385,17 +386,17 @@ double CANJaguar::unpackFXP8_8(uint8_t* buffer) const {
}
double CANJaguar::unpackFXP16_16(uint8_t* buffer) const {
int32_t value = *reinterpret_cast<int32_t*>(buffer);
int value = *reinterpret_cast<int*>(buffer);
value = swap32(value);
return value / 65536.0;
}
int16_t CANJaguar::unpackint16_t(uint8_t* buffer) const {
int16_t CANJaguar::unpackInt16(uint8_t* buffer) const {
int16_t value = *reinterpret_cast<int16_t*>(buffer);
return swap16(value);
}
int32_t CANJaguar::unpackint32_t(uint8_t* buffer) const {
int32_t CANJaguar::unpackInt32(uint8_t* buffer) const {
int32_t value = *reinterpret_cast<int32_t*>(buffer);
return swap32(value);
}
@@ -410,9 +411,9 @@ int32_t CANJaguar::unpackint32_t(uint8_t* buffer) const {
* @param periodic If positive, tell Network Communications to send the
* message every "period" milliseconds.
*/
void CANJaguar::sendMessage(uint32_t messageID, const uint8_t* data,
uint8_t dataSize, int32_t period) {
int32_t localStatus =
void CANJaguar::sendMessage(int messageID, const uint8_t* data,
uint8_t dataSize, int period) {
int localStatus =
sendMessageHelper(messageID | m_deviceNumber, data, dataSize, period);
if (localStatus < 0) {
@@ -427,7 +428,7 @@ void CANJaguar::sendMessage(uint32_t messageID, const uint8_t* data,
* @param periodic If positive, tell Network Communications to send the
* message every "period" milliseconds.
*/
void CANJaguar::requestMessage(uint32_t messageID, int32_t period) {
void CANJaguar::requestMessage(int messageID, int period) {
sendMessageHelper(messageID | m_deviceNumber, nullptr, 0, period);
}
@@ -444,8 +445,8 @@ void CANJaguar::requestMessage(uint32_t messageID, int32_t period) {
* @return true if the message was found. Otherwise, no new message is
* available.
*/
bool CANJaguar::getMessage(uint32_t messageID, uint32_t messageMask,
uint8_t* data, uint8_t* dataSize) const {
bool CANJaguar::getMessage(int messageID, uint32_t messageMask, uint8_t* data,
uint8_t* dataSize) const {
uint32_t targetedMessageID = messageID | m_deviceNumber;
int32_t status = 0;
uint32_t timeStamp;
@@ -490,7 +491,7 @@ void CANJaguar::setupPeriodicStatus() {
static const uint8_t kMessage2Data[] = {LM_PSTAT_LIMIT_CLR, LM_PSTAT_FAULT,
LM_PSTAT_END};
dataSize = packint16_t(data, kSendMessagePeriod);
dataSize = packInt16(data, kSendMessagePeriod);
sendMessage(LM_API_PSTAT_PER_EN_S0, data, dataSize);
sendMessage(LM_API_PSTAT_PER_EN_S1, data, dataSize);
sendMessage(LM_API_PSTAT_PER_EN_S2, data, dataSize);
@@ -638,7 +639,7 @@ void CANJaguar::verify() {
if (!m_speedRefVerified) {
if (getMessage(LM_API_SPD_REF, CAN_MSGID_FULL_M, dataBuffer, &dataSize)) {
uint8_t speedRef = dataBuffer[0];
int speedRef = dataBuffer[0];
if (m_speedReference == speedRef)
m_speedRefVerified = true;
@@ -653,7 +654,7 @@ void CANJaguar::verify() {
if (!m_posRefVerified) {
if (getMessage(LM_API_POS_REF, CAN_MSGID_FULL_M, dataBuffer, &dataSize)) {
uint8_t posRef = dataBuffer[0];
int posRef = dataBuffer[0];
if (m_positionReference == posRef)
m_posRefVerified = true;
@@ -667,7 +668,7 @@ void CANJaguar::verify() {
}
if (!m_pVerified) {
uint32_t message = 0;
int message = 0;
if (m_controlMode == kSpeed) {
message = LM_API_SPD_PC;
@@ -697,7 +698,7 @@ void CANJaguar::verify() {
}
if (!m_iVerified) {
uint32_t message = 0;
int message = 0;
if (m_controlMode == kSpeed) {
message = LM_API_SPD_IC;
@@ -727,7 +728,7 @@ void CANJaguar::verify() {
}
if (!m_dVerified) {
uint32_t message = 0;
int message = 0;
if (m_controlMode == kSpeed) {
message = LM_API_SPD_DC;
@@ -775,7 +776,7 @@ void CANJaguar::verify() {
if (!m_encoderCodesPerRevVerified) {
if (getMessage(LM_API_CFG_ENC_LINES, CAN_MSGID_FULL_M, dataBuffer,
&dataSize)) {
uint16_t codes = unpackint16_t(dataBuffer);
uint16_t codes = unpackInt16(dataBuffer);
if (codes == m_encoderCodesPerRev)
m_encoderCodesPerRevVerified = true;
@@ -791,7 +792,7 @@ void CANJaguar::verify() {
if (!m_potentiometerTurnsVerified) {
if (getMessage(LM_API_CFG_POT_TURNS, CAN_MSGID_FULL_M, dataBuffer,
&dataSize)) {
uint16_t turns = unpackint16_t(dataBuffer);
uint16_t turns = unpackInt16(dataBuffer);
if (turns == m_potentiometerTurns)
m_potentiometerTurnsVerified = true;
@@ -912,7 +913,7 @@ void CANJaguar::verify() {
if (!m_faultTimeVerified) {
if (getMessage(LM_API_CFG_FAULT_TIME, CAN_MSGID_FULL_M, dataBuffer,
&dataSize)) {
uint16_t faultTime = unpackint16_t(dataBuffer);
uint16_t faultTime = unpackInt16(dataBuffer);
if (static_cast<uint16_t>(m_faultTime * 1000.0) == faultTime) {
m_faultTimeVerified = true;
@@ -945,7 +946,7 @@ void CANJaguar::verify() {
*
* @param reference Specify a speed reference.
*/
void CANJaguar::SetSpeedReference(uint8_t reference) {
void CANJaguar::SetSpeedReference(int reference) {
uint8_t dataBuffer[8];
// Send the speed reference parameter
@@ -962,7 +963,7 @@ void CANJaguar::SetSpeedReference(uint8_t reference) {
* @return A speed reference indicating the currently selected reference device
* for speed controller mode.
*/
uint8_t CANJaguar::GetSpeedReference() const { return m_speedReference; }
int CANJaguar::GetSpeedReference() const { return m_speedReference; }
/**
* Set the reference source device for position controller mode.
@@ -972,7 +973,7 @@ uint8_t CANJaguar::GetSpeedReference() const { return m_speedReference; }
*
* @param reference Specify a PositionReference.
*/
void CANJaguar::SetPositionReference(uint8_t reference) {
void CANJaguar::SetPositionReference(int reference) {
uint8_t dataBuffer[8];
// Send the position reference parameter
@@ -989,7 +990,7 @@ void CANJaguar::SetPositionReference(uint8_t reference) {
* @return A PositionReference indicating the currently selected reference
* device for position controller mode.
*/
uint8_t CANJaguar::GetPositionReference() const { return m_positionReference; }
int CANJaguar::GetPositionReference() const { return m_positionReference; }
/**
* Set the P, I, and D constants for the closed loop modes.
@@ -1711,7 +1712,7 @@ uint16_t CANJaguar::GetFaults() const {
void CANJaguar::SetVoltageRampRate(double rampRate) {
uint8_t dataBuffer[8];
uint8_t dataSize;
uint32_t message;
int message;
switch (m_controlMode) {
case kPercentVbus:
@@ -1741,14 +1742,14 @@ void CANJaguar::SetVoltageRampRate(double rampRate) {
*
* @return The firmware version. 0 if the device did not respond.
*/
uint32_t CANJaguar::GetFirmwareVersion() const { return m_firmwareVersion; }
int CANJaguar::GetFirmwareVersion() const { return m_firmwareVersion; }
/**
* Get the version of the Jaguar hardware.
*
* @return The hardware version. 1: Jaguar, 2: Black Jaguar
*/
uint8_t CANJaguar::GetHardwareVersion() const { return m_hardwareVersion; }
int CANJaguar::GetHardwareVersion() const { return m_hardwareVersion; }
/**
* Configure what the controller does to the H-Bridge when neutral (not driving
@@ -1778,7 +1779,7 @@ void CANJaguar::ConfigEncoderCodesPerRev(uint16_t codesPerRev) {
uint8_t dataBuffer[8];
// Set the codes per revolution mode
packint16_t(dataBuffer, codesPerRev);
packInt16(dataBuffer, codesPerRev);
sendMessage(LM_API_CFG_ENC_LINES, dataBuffer, sizeof(uint16_t));
m_encoderCodesPerRev = codesPerRev;
@@ -1798,7 +1799,7 @@ void CANJaguar::ConfigPotentiometerTurns(uint16_t turns) {
uint8_t dataSize;
// Set the pot turns
dataSize = packint16_t(dataBuffer, turns);
dataSize = packInt16(dataBuffer, turns);
sendMessage(LM_API_CFG_POT_TURNS, dataBuffer, dataSize);
m_potentiometerTurns = turns;
@@ -1921,7 +1922,7 @@ void CANJaguar::ConfigFaultTime(float faultTime) {
faultTime = 3.0;
// Message takes ms
dataSize = packint16_t(dataBuffer, static_cast<int16_t>(faultTime * 1000.0));
dataSize = packInt16(dataBuffer, static_cast<int16_t>(faultTime * 1000.0));
sendMessage(LM_API_CFG_FAULT_TIME, dataBuffer, dataSize);
m_faultTime = faultTime;
@@ -1965,7 +1966,7 @@ void CANJaguar::GetDescription(std::ostringstream& desc) const {
desc << "CANJaguar ID " << m_deviceNumber;
}
uint8_t CANJaguar::GetDeviceID() const { return m_deviceNumber; }
int CANJaguar::GetDeviceID() const { return m_deviceNumber; }
/**
* Common interface for stopping the motor until the next Set() command

View File

@@ -31,7 +31,7 @@ const double kNativePwdUnitsPerRotation = 4096.0;
*/
const double kMinutesPer100msUnit = 1.0 / 600.0;
constexpr unsigned int CANTalon::kDelayForSolicitedSignalsUs;
constexpr int CANTalon::kDelayForSolicitedSignalsUs;
/**
* Constructor for the CANTalon device.
@@ -299,7 +299,7 @@ void CANTalon::SetF(double f) {
*
* @see SelectProfileSlot to choose between the two sets of gains.
*/
void CANTalon::SetIzone(unsigned iz) {
void CANTalon::SetIzone(int iz) {
CTR_Code status = m_impl->SetIzone(m_profile, iz);
if (status != CTR_OKAY) {
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
@@ -562,7 +562,7 @@ float CANTalon::GetTemperature() const {
* portion of the postion based on overflows).
*/
void CANTalon::SetPosition(double pos) {
int32_t nativePos = ScaleRotationsToNativeUnits(m_feedbackDevice, pos);
int nativePos = ScaleRotationsToNativeUnits(m_feedbackDevice, pos);
CTR_Code status = m_impl->SetSensorPosition(nativePos);
if (status != CTR_OKAY) {
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
@@ -580,7 +580,7 @@ void CANTalon::SetPosition(double pos) {
* When using quadrature, each unit is a quadrature edge (4X) mode.
*/
double CANTalon::GetPosition() const {
int32_t position;
int position;
CTR_Code status = m_impl->GetSensorPosition(position);
if (status != CTR_OKAY) {
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
@@ -642,7 +642,7 @@ int CANTalon::GetClosedLoopError() const {
* Units: mA for Curent closed loop.
* Talon Native Units for position and velocity.
*/
void CANTalon::SetAllowableClosedLoopErr(uint32_t allowableCloseLoopError) {
void CANTalon::SetAllowableClosedLoopErr(int allowableCloseLoopError) {
/* grab param enum */
CanTalonSRX::param_t param;
if (m_profile == 1) {
@@ -669,7 +669,7 @@ void CANTalon::SetAllowableClosedLoopErr(uint32_t allowableCloseLoopError) {
* would then equate to 20% of a rotation per 100ms, or 10 rotations per second.
*/
double CANTalon::GetSpeed() const {
int32_t speed;
int speed;
CTR_Code status = m_impl->GetSensorVelocity(speed);
if (status != CTR_OKAY) {
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
@@ -1124,7 +1124,7 @@ void CANTalon::SetCloseLoopRampRate(double rampRate) {
/**
* @return The version of the firmware running on the Talon
*/
uint32_t CANTalon::GetFirmwareVersion() const {
int CANTalon::GetFirmwareVersion() const {
int firmwareVersion;
CTR_Code status = m_impl->RequestParam(CanTalonSRX::eFirmVers);
if (status != CTR_OKAY) {
@@ -1378,7 +1378,7 @@ void CANTalon::ConfigLimitMode(LimitMode mode) {
*/
void CANTalon::ConfigForwardLimit(double forwardLimitPosition) {
CTR_Code status = CTR_OKAY;
int32_t nativeLimitPos =
int nativeLimitPos =
ScaleRotationsToNativeUnits(m_feedbackDevice, forwardLimitPosition);
status = m_impl->SetForwardSoftLimit(nativeLimitPos);
if (status != CTR_OKAY) {
@@ -1459,7 +1459,7 @@ void CANTalon::ConfigRevLimitSwitchNormallyOpen(bool normallyOpen) {
*/
void CANTalon::ConfigReverseLimit(double reverseLimitPosition) {
CTR_Code status = CTR_OKAY;
int32_t nativeLimitPos =
int nativeLimitPos =
ScaleRotationsToNativeUnits(m_feedbackDevice, reverseLimitPosition);
status = m_impl->SetReverseSoftLimit(nativeLimitPos);
if (status != CTR_OKAY) {
@@ -1514,7 +1514,7 @@ void CANTalon::ConfigNominalOutputVoltage(double forwardVoltage,
* General set frame. Since the parameter is a general integral type, this can
* be used for testing future features.
*/
void CANTalon::ConfigSetParameter(uint32_t paramEnum, double value) {
void CANTalon::ConfigSetParameter(int paramEnum, double value) {
CTR_Code status;
/* config peak throttle when in closed-loop mode in the positive direction. */
status = m_impl->SetParam((CanTalonSRX::param_t)paramEnum, value);
@@ -1527,7 +1527,7 @@ void CANTalon::ConfigSetParameter(uint32_t paramEnum, double value) {
* General get frame. Since the parameter is a general integral type, this can
* be used for testing future features.
*/
bool CANTalon::GetParameter(uint32_t paramEnum, double& dvalue) const {
bool CANTalon::GetParameter(int paramEnum, double& dvalue) const {
bool retval = true;
/* send the request frame */
CTR_Code status = m_impl->RequestParam((CanTalonSRX::param_t)paramEnum);
@@ -1658,7 +1658,7 @@ double CANTalon::GetNativeUnitsPerRotationScalar(
* that the calling app does not require knowing the CPR at all. So do
* both checks here.
*/
int32_t qeiPulsePerCount = 4; /* default to 4x */
int qeiPulsePerCount = 4; /* default to 4x */
switch (m_feedbackDevice) {
case CtreMagEncoder_Relative:
case CtreMagEncoder_Absolute:
@@ -1747,14 +1747,14 @@ double CANTalon::GetNativeUnitsPerRotationScalar(
* @see ConfigEncoderCodesPerRev
* @return fullRotations in native engineering units of the Talon SRX firmware.
*/
int32_t CANTalon::ScaleRotationsToNativeUnits(FeedbackDevice devToLookup,
double fullRotations) const {
int CANTalon::ScaleRotationsToNativeUnits(FeedbackDevice devToLookup,
double fullRotations) const {
/* first assume we don't have config info, prep the default return */
int32_t retval = static_cast<int32_t>(fullRotations);
int retval = static_cast<int>(fullRotations);
/* retrieve scaling info */
double scalar = GetNativeUnitsPerRotationScalar(devToLookup);
/* apply scalar if its available */
if (scalar > 0) retval = static_cast<int32_t>(fullRotations * scalar);
if (scalar > 0) retval = static_cast<int>(fullRotations * scalar);
return retval;
}
@@ -1769,15 +1769,15 @@ int32_t CANTalon::ScaleRotationsToNativeUnits(FeedbackDevice devToLookup,
* @return sensor velocity in native engineering units of the Talon SRX
* firmware.
*/
int32_t CANTalon::ScaleVelocityToNativeUnits(FeedbackDevice devToLookup,
double rpm) const {
int CANTalon::ScaleVelocityToNativeUnits(FeedbackDevice devToLookup,
double rpm) const {
/* first assume we don't have config info, prep the default return */
int32_t retval = static_cast<int32_t>(rpm);
int retval = static_cast<int>(rpm);
/* retrieve scaling info */
double scalar = GetNativeUnitsPerRotationScalar(devToLookup);
/* apply scalar if its available */
if (scalar > 0) {
retval = static_cast<int32_t>(rpm * kMinutesPer100msUnit * scalar);
retval = static_cast<int>(rpm * kMinutesPer100msUnit * scalar);
}
return retval;
}
@@ -1793,7 +1793,7 @@ int32_t CANTalon::ScaleVelocityToNativeUnits(FeedbackDevice devToLookup,
* performed.
*/
double CANTalon::ScaleNativeUnitsToRotations(FeedbackDevice devToLookup,
int32_t nativePos) const {
int nativePos) const {
/* first assume we don't have config info, prep the default return */
double retval = static_cast<double>(nativePos);
/* retrieve scaling info */
@@ -1814,7 +1814,7 @@ double CANTalon::ScaleNativeUnitsToRotations(FeedbackDevice devToLookup,
* performed.
*/
double CANTalon::ScaleNativeUnitsToRpm(FeedbackDevice devToLookup,
int32_t nativeVel) const {
int nativeVel) const {
/* first assume we don't have config info, prep the default return */
double retval = static_cast<double>(nativeVel);
/* retrieve scaling info */
@@ -1891,15 +1891,13 @@ int CANTalon::GetMotionProfileTopLevelBufferCount() {
*/
bool CANTalon::PushMotionProfileTrajectory(const TrajectoryPoint& trajPt) {
/* convert positiona and velocity to native units */
int32_t targPos =
ScaleRotationsToNativeUnits(m_feedbackDevice, trajPt.position);
int32_t targVel =
ScaleVelocityToNativeUnits(m_feedbackDevice, trajPt.velocity);
int targPos = ScaleRotationsToNativeUnits(m_feedbackDevice, trajPt.position);
int targVel = ScaleVelocityToNativeUnits(m_feedbackDevice, trajPt.velocity);
/* bounds check signals that require it */
uint32_t profileSlotSelect = (trajPt.profileSlotSelect) ? 1 : 0;
uint8_t timeDurMs = (trajPt.timeDurMs >= 255)
? 255
: trajPt.timeDurMs; /* cap time to 255ms */
int profileSlotSelect = (trajPt.profileSlotSelect) ? 1 : 0;
int timeDurMs = (trajPt.timeDurMs >= 255)
? 255
: trajPt.timeDurMs; /* cap time to 255ms */
/* send it to the top level buffer */
CTR_Code status = m_impl->PushMotionProfileTrajectory(
targPos, targVel, profileSlotSelect, timeDurMs, trajPt.velocityOnly,
@@ -1939,7 +1937,7 @@ void CANTalon::GetMotionProfileStatus(
MotionProfileStatus& motionProfileStatus) {
uint32_t flags;
uint32_t profileSlotSelect;
int32_t targPos, targVel;
int targPos, targVel;
uint32_t topBufferRem, topBufferCnt, btmBufferCnt;
uint32_t outputEnable;
/* retrieve all motion profile signals from status frame */

View File

@@ -40,7 +40,7 @@ CameraServer::CameraServer()
}
void CameraServer::FreeImageData(
std::tuple<uint8_t*, unsigned int, unsigned int, bool> imageData) {
std::tuple<uint8_t*, int, int, bool> imageData) {
if (std::get<3>(imageData)) {
imaqDispose(std::get<0>(imageData));
} else if (std::get<0>(imageData) != nullptr) {
@@ -49,8 +49,8 @@ void CameraServer::FreeImageData(
}
}
void CameraServer::SetImageData(uint8_t* data, unsigned int size,
unsigned int start, bool imaqData) {
void CameraServer::SetImageData(uint8_t* data, int size, int start,
bool imaqData) {
std::lock_guard<priority_recursive_mutex> lock(m_imageMutex);
FreeImageData(m_imageData);
m_imageData = std::make_tuple(data, size, start, imaqData);
@@ -58,7 +58,7 @@ void CameraServer::SetImageData(uint8_t* data, unsigned int size,
}
void CameraServer::SetImage(Image const* image) {
unsigned int dataSize = 0;
uint32_t dataSize = 0;
uint8_t* data = reinterpret_cast<uint8_t*>(
imaqFlatten(image, IMAQ_FLATTEN_IMAGE, IMAQ_COMPRESSION_JPEG,
10 * m_quality, &dataSize));
@@ -70,7 +70,7 @@ void CameraServer::SetImage(Image const* image) {
std::lock_guard<priority_recursive_mutex> lock(m_imageMutex);
hwClient = m_hwClient;
}
unsigned int start = 0;
uint32_t start = 0;
if (hwClient) {
while (start < dataSize - 1) {
if (data[start] == 0xFF && data[start + 1] == 0xD8)
@@ -101,7 +101,7 @@ void CameraServer::AutoCapture() {
}
if (hwClient) {
unsigned int size = m_camera->GetImageData(data, kMaxImageSize);
int size = m_camera->GetImageData(data, kMaxImageSize);
SetImageData(data, size);
} else {
m_camera->GetImage(frame);
@@ -134,7 +134,7 @@ bool CameraServer::IsAutoCaptureStarted() {
return m_autoCaptureStarted;
}
void CameraServer::SetSize(unsigned int size) {
void CameraServer::SetSize(int size) {
std::lock_guard<priority_recursive_mutex> lock(m_imageMutex);
if (!m_camera) return;
if (size == kSize160x120)
@@ -145,12 +145,12 @@ void CameraServer::SetSize(unsigned int size) {
m_camera->SetSize(640, 480);
}
void CameraServer::SetQuality(unsigned int quality) {
void CameraServer::SetQuality(int quality) {
std::lock_guard<priority_recursive_mutex> lock(m_imageMutex);
m_quality = quality > 100 ? 100 : quality;
}
unsigned int CameraServer::GetQuality() {
int CameraServer::GetQuality() {
std::lock_guard<priority_recursive_mutex> lock(m_imageMutex);
return m_quality;
}
@@ -238,7 +238,7 @@ void CameraServer::Serve() {
auto period = std::chrono::microseconds(1000000) / req.fps;
while (true) {
auto startTime = std::chrono::steady_clock::now();
std::tuple<uint8_t*, unsigned int, unsigned int, bool> imageData;
std::tuple<uint8_t*, int, int, bool> imageData;
{
std::unique_lock<priority_recursive_mutex> lock(m_imageMutex);
m_newImageVariable.wait(lock);
@@ -246,9 +246,9 @@ void CameraServer::Serve() {
m_imageData = std::make_tuple<uint8_t*>(nullptr, 0, 0, false);
}
unsigned int size = std::get<1>(imageData);
unsigned int netSize = htonl(size);
unsigned int start = std::get<2>(imageData);
int size = std::get<1>(imageData);
int netSize = htonl(size);
int start = std::get<2>(imageData);
uint8_t* data = std::get<0>(imageData);
if (data == nullptr) continue;

View File

@@ -15,7 +15,7 @@
*
* @param module The PCM ID to use (0-62)
*/
Compressor::Compressor(uint8_t pcmID) : m_module(pcmID) {
Compressor::Compressor(int pcmID) : m_module(pcmID) {
int32_t status = 0;
m_compressorHandle = HAL_InitializeCompressor(m_module, &status);
if (status != 0) {

View File

@@ -80,7 +80,7 @@ Counter::Counter(std::shared_ptr<DigitalSource> source) : Counter(kTwoPulse) {
* @param channel The DIO channel to use as the up source. 0-9 are on-board,
* 10-25 are on the MXP
*/
Counter::Counter(int32_t channel) : Counter(kTwoPulse) {
Counter::Counter(int channel) : Counter(kTwoPulse) {
SetUpSource(channel);
ClearDownSource();
}
@@ -190,7 +190,7 @@ Counter::~Counter() {
* @param channel The DIO channel to use as the up source. 0-9 are on-board,
* 10-25 are on the MXP
*/
void Counter::SetUpSource(int32_t channel) {
void Counter::SetUpSource(int channel) {
if (StatusIsFatal()) return;
SetUpSource(std::make_shared<DigitalInput>(channel));
}
@@ -296,7 +296,7 @@ void Counter::ClearUpSource() {
* @param channel The DIO channel to use as the up source. 0-9 are on-board,
* 10-25 are on the MXP
*/
void Counter::SetDownSource(int32_t channel) {
void Counter::SetDownSource(int channel) {
if (StatusIsFatal()) return;
SetDownSource(std::make_shared<DigitalInput>(channel));
}
@@ -462,7 +462,7 @@ void Counter::SetPulseLengthMode(float threshold) {
*/
int Counter::GetSamplesToAverage() const {
int32_t status = 0;
int32_t samples = HAL_GetCounterSamplesToAverage(m_counter, &status);
int samples = HAL_GetCounterSamplesToAverage(m_counter, &status);
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
return samples;
}
@@ -491,10 +491,10 @@ void Counter::SetSamplesToAverage(int samplesToAverage) {
* Read the value at this instant. It may still be running, so it reflects the
* current value. Next time it is read, it might have a different value.
*/
int32_t Counter::Get() const {
int Counter::Get() const {
if (StatusIsFatal()) return 0;
int32_t status = 0;
int32_t value = HAL_GetCounter(m_counter, &status);
int value = HAL_GetCounter(m_counter, &status);
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
return value;
}

View File

@@ -146,7 +146,7 @@ void DigitalGlitchFilter::Remove(Counter* input) {
*
* @param fpga_cycles The number of FPGA cycles.
*/
void DigitalGlitchFilter::SetPeriodCycles(uint32_t fpga_cycles) {
void DigitalGlitchFilter::SetPeriodCycles(int fpga_cycles) {
int32_t status = 0;
HAL_SetFilterPeriod(m_channelIndex, fpga_cycles, &status);
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
@@ -159,7 +159,7 @@ void DigitalGlitchFilter::SetPeriodCycles(uint32_t fpga_cycles) {
*/
void DigitalGlitchFilter::SetPeriodNanoSeconds(uint64_t nanoseconds) {
int32_t status = 0;
uint32_t fpga_cycles =
int fpga_cycles =
nanoseconds * HAL_GetSystemClockTicksPerMicrosecond() / 4 / 1000;
HAL_SetFilterPeriod(m_channelIndex, fpga_cycles, &status);
@@ -171,9 +171,9 @@ void DigitalGlitchFilter::SetPeriodNanoSeconds(uint64_t nanoseconds) {
*
* @return The number of cycles.
*/
uint32_t DigitalGlitchFilter::GetPeriodCycles() {
int DigitalGlitchFilter::GetPeriodCycles() {
int32_t status = 0;
uint32_t fpga_cycles = HAL_GetFilterPeriod(m_channelIndex, &status);
int fpga_cycles = HAL_GetFilterPeriod(m_channelIndex, &status);
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
@@ -187,7 +187,7 @@ uint32_t DigitalGlitchFilter::GetPeriodCycles() {
*/
uint64_t DigitalGlitchFilter::GetPeriodNanoSeconds() {
int32_t status = 0;
uint32_t fpga_cycles = HAL_GetFilterPeriod(m_channelIndex, &status);
int fpga_cycles = HAL_GetFilterPeriod(m_channelIndex, &status);
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));

View File

@@ -21,13 +21,13 @@
*
* @param channel The DIO channel 0-9 are on-board, 10-25 are on the MXP port
*/
DigitalInput::DigitalInput(uint32_t channel) {
DigitalInput::DigitalInput(int channel) {
std::stringstream buf;
if (!CheckDigitalChannel(channel)) {
buf << "Digital Channel " << channel;
wpi_setWPIErrorWithContext(ChannelIndexOutOfRange, buf.str());
m_channel = std::numeric_limits<uint32_t>::max();
m_channel = std::numeric_limits<int>::max();
return;
}
m_channel = channel;
@@ -38,7 +38,7 @@ DigitalInput::DigitalInput(uint32_t channel) {
wpi_setErrorWithContextRange(status, 0, HAL_GetNumDigitalChannels(),
channel, HAL_GetErrorMessage(status));
m_handle = HAL_kInvalidHandle;
m_channel = std::numeric_limits<uint32_t>::max();
m_channel = std::numeric_limits<int>::max();
return;
}
@@ -77,7 +77,7 @@ bool DigitalInput::Get() const {
/**
* @return The GPIO channel number that this object represents.
*/
uint32_t DigitalInput::GetChannel() const { return m_channel; }
int DigitalInput::GetChannel() const { return m_channel; }
/**
* @return The HAL Handle to the specified source.

View File

@@ -21,14 +21,14 @@
* @param channel The digital channel 0-9 are on-board, 10-25 are on the MXP
* port
*/
DigitalOutput::DigitalOutput(uint32_t channel) {
DigitalOutput::DigitalOutput(int channel) {
std::stringstream buf;
m_pwmGenerator = HAL_kInvalidHandle;
if (!CheckDigitalChannel(channel)) {
buf << "Digital Channel " << channel;
wpi_setWPIErrorWithContext(ChannelIndexOutOfRange, buf.str());
m_channel = std::numeric_limits<uint32_t>::max();
m_channel = std::numeric_limits<int>::max();
return;
}
m_channel = channel;
@@ -38,7 +38,7 @@ DigitalOutput::DigitalOutput(uint32_t channel) {
if (status != 0) {
wpi_setErrorWithContextRange(status, 0, HAL_GetNumDigitalChannels(),
channel, HAL_GetErrorMessage(status));
m_channel = std::numeric_limits<uint32_t>::max();
m_channel = std::numeric_limits<int>::max();
m_handle = HAL_kInvalidHandle;
return;
}
@@ -78,7 +78,7 @@ void DigitalOutput::Set(bool value) {
*
* @return the state of the digital output.
*/
bool DigitalOutput::Get() {
bool DigitalOutput::Get() const {
if (StatusIsFatal()) return false;
int32_t status = 0;
@@ -90,7 +90,7 @@ bool DigitalOutput::Get() {
/**
* @return The GPIO channel number that this object represents.
*/
uint32_t DigitalOutput::GetChannel() const { return m_channel; }
int DigitalOutput::GetChannel() const { return m_channel; }
/**
* Output a single pulse on the digital output line.

View File

@@ -21,7 +21,7 @@
* @param forwardChannel The forward channel number on the PCM (0..7).
* @param reverseChannel The reverse channel number on the PCM (0..7).
*/
DoubleSolenoid::DoubleSolenoid(uint32_t forwardChannel, uint32_t reverseChannel)
DoubleSolenoid::DoubleSolenoid(int forwardChannel, int reverseChannel)
: DoubleSolenoid(GetDefaultSolenoidModule(), forwardChannel,
reverseChannel) {}
@@ -32,8 +32,8 @@ DoubleSolenoid::DoubleSolenoid(uint32_t forwardChannel, uint32_t reverseChannel)
* @param forwardChannel The forward channel on the PCM to control (0..7).
* @param reverseChannel The reverse channel on the PCM to control (0..7).
*/
DoubleSolenoid::DoubleSolenoid(uint8_t moduleNumber, uint32_t forwardChannel,
uint32_t reverseChannel)
DoubleSolenoid::DoubleSolenoid(int moduleNumber, int forwardChannel,
int reverseChannel)
: SolenoidBase(moduleNumber),
m_forwardChannel(forwardChannel),
m_reverseChannel(reverseChannel) {
@@ -120,9 +120,9 @@ void DoubleSolenoid::Set(Value value) {
reverse = true;
break;
}
int32_t fstatus = 0;
int fstatus = 0;
HAL_SetSolenoid(m_forwardHandle, forward, &fstatus);
int32_t rstatus = 0;
int rstatus = 0;
HAL_SetSolenoid(m_reverseHandle, reverse, &rstatus);
wpi_setErrorWithContext(fstatus, HAL_GetErrorMessage(fstatus));
@@ -136,8 +136,8 @@ void DoubleSolenoid::Set(Value value) {
*/
DoubleSolenoid::Value DoubleSolenoid::Get() const {
if (StatusIsFatal()) return kOff;
int32_t fstatus = 0;
int32_t rstatus = 0;
int fstatus = 0;
int rstatus = 0;
bool valueForward = HAL_GetSolenoid(m_forwardHandle, &fstatus);
bool valueReverse = HAL_GetSolenoid(m_reverseHandle, &rstatus);

View File

@@ -17,7 +17,7 @@
const double JOYSTICK_UNPLUGGED_MESSAGE_INTERVAL = 1.0;
const uint32_t DriverStation::kJoystickPorts;
const int DriverStation::kJoystickPorts;
DriverStation::~DriverStation() {
m_isRunning = false;
@@ -74,7 +74,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(uint32_t stick, uint32_t axis) {
float DriverStation::GetStickAxis(int stick, int axis) {
if (stick >= kJoystickPorts) {
wpi_setWPIError(BadJoystickIndex);
return 0;
@@ -100,7 +100,7 @@ float DriverStation::GetStickAxis(uint32_t stick, uint32_t axis) {
*
* @return the angle of the POV in degrees, or -1 if the POV is not pressed.
*/
int DriverStation::GetStickPOV(uint32_t stick, uint32_t pov) {
int DriverStation::GetStickPOV(int stick, int pov) {
if (stick >= kJoystickPorts) {
wpi_setWPIError(BadJoystickIndex);
return -1;
@@ -126,7 +126,7 @@ int DriverStation::GetStickPOV(uint32_t stick, uint32_t pov) {
* @param stick The joystick to read.
* @return The state of the buttons on the joystick.
*/
uint32_t DriverStation::GetStickButtons(uint32_t stick) const {
int DriverStation::GetStickButtons(int stick) const {
if (stick >= kJoystickPorts) {
wpi_setWPIError(BadJoystickIndex);
return 0;
@@ -142,7 +142,7 @@ uint32_t DriverStation::GetStickButtons(uint32_t stick) const {
* @param button The button index, beginning at 1.
* @return The state of the joystick button.
*/
bool DriverStation::GetStickButton(uint32_t stick, uint8_t button) {
bool DriverStation::GetStickButton(int stick, int button) {
if (stick >= kJoystickPorts) {
wpi_setWPIError(BadJoystickIndex);
return false;
@@ -171,7 +171,7 @@ bool DriverStation::GetStickButton(uint32_t stick, uint8_t button) {
* @param stick The joystick port number
* @return The number of axes on the indicated joystick
*/
int DriverStation::GetStickAxisCount(uint32_t stick) const {
int DriverStation::GetStickAxisCount(int stick) const {
if (stick >= kJoystickPorts) {
wpi_setWPIError(BadJoystickIndex);
return 0;
@@ -186,7 +186,7 @@ int DriverStation::GetStickAxisCount(uint32_t stick) const {
* @param stick The joystick port number
* @return The number of POVs on the indicated joystick
*/
int DriverStation::GetStickPOVCount(uint32_t stick) const {
int DriverStation::GetStickPOVCount(int stick) const {
if (stick >= kJoystickPorts) {
wpi_setWPIError(BadJoystickIndex);
return 0;
@@ -201,7 +201,7 @@ int DriverStation::GetStickPOVCount(uint32_t stick) const {
* @param stick The joystick port number
* @return The number of buttons on the indicated joystick
*/
int DriverStation::GetStickButtonCount(uint32_t stick) const {
int DriverStation::GetStickButtonCount(int stick) const {
if (stick >= kJoystickPorts) {
wpi_setWPIError(BadJoystickIndex);
return 0;
@@ -216,7 +216,7 @@ int DriverStation::GetStickButtonCount(uint32_t stick) const {
* @param stick The joystick port number
* @return A boolean that is true if the controller is an xbox controller.
*/
bool DriverStation::GetJoystickIsXbox(uint32_t stick) const {
bool DriverStation::GetJoystickIsXbox(int stick) const {
if (stick >= kJoystickPorts) {
wpi_setWPIError(BadJoystickIndex);
return false;
@@ -231,7 +231,7 @@ bool DriverStation::GetJoystickIsXbox(uint32_t stick) const {
* @param stick The joystick port number
* @return The HID type of joystick at the given port
*/
int DriverStation::GetJoystickType(uint32_t stick) const {
int DriverStation::GetJoystickType(int stick) const {
if (stick >= kJoystickPorts) {
wpi_setWPIError(BadJoystickIndex);
return -1;
@@ -246,7 +246,7 @@ int DriverStation::GetJoystickType(uint32_t stick) const {
* @param stick The joystick port number
* @return The name of the joystick at the given port
*/
std::string DriverStation::GetJoystickName(uint32_t stick) const {
std::string DriverStation::GetJoystickName(int stick) const {
if (stick >= kJoystickPorts) {
wpi_setWPIError(BadJoystickIndex);
}
@@ -261,7 +261,7 @@ std::string DriverStation::GetJoystickName(uint32_t stick) const {
* @param stick The joystick port number and the target axis
* @return What type of axis the axis is reporting to be
*/
int DriverStation::GetJoystickAxisType(uint32_t stick, uint8_t axis) const {
int DriverStation::GetJoystickAxisType(int stick, int axis) const {
if (stick >= kJoystickPorts) {
wpi_setWPIError(BadJoystickIndex);
return -1;
@@ -419,7 +419,7 @@ DriverStation::Alliance DriverStation::GetAlliance() const {
*
* @return The location of the driver station (1-3, 0 for invalid)
*/
uint32_t DriverStation::GetLocation() const {
int DriverStation::GetLocation() const {
int32_t status = 0;
auto allianceStationID = HAL_GetAllianceStation(&status);
switch (allianceStationID) {

View File

@@ -68,7 +68,7 @@ void Encoder::InitEncoder(bool reverseDirection, EncodingType encodingType) {
* value will either exactly match the spec'd count or
* be double (2x) the spec'd count.
*/
Encoder::Encoder(uint32_t aChannel, uint32_t bChannel, bool reverseDirection,
Encoder::Encoder(int aChannel, int bChannel, bool reverseDirection,
EncodingType encodingType) {
m_aSource = std::make_shared<DigitalInput>(aChannel);
m_bSource = std::make_shared<DigitalInput>(bChannel);
@@ -164,9 +164,9 @@ Encoder::~Encoder() {
*
* Used to divide raw edge counts down to spec'd counts.
*/
int32_t Encoder::GetEncodingScale() const {
int Encoder::GetEncodingScale() const {
int32_t status = 0;
int32_t val = HAL_GetEncoderEncodingScale(m_encoder, &status);
int val = HAL_GetEncoderEncodingScale(m_encoder, &status);
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
return val;
}
@@ -179,10 +179,10 @@ int32_t Encoder::GetEncodingScale() const {
*
* @return Current raw count from the encoder
*/
int32_t Encoder::GetRaw() const {
int Encoder::GetRaw() const {
if (StatusIsFatal()) return 0;
int32_t status = 0;
int32_t value = HAL_GetEncoderRaw(m_encoder, &status);
int value = HAL_GetEncoderRaw(m_encoder, &status);
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
return value;
}
@@ -196,10 +196,10 @@ int32_t Encoder::GetRaw() const {
* @return Current count from the Encoder adjusted for the 1x, 2x, or 4x scale
* factor.
*/
int32_t Encoder::Get() const {
int Encoder::Get() const {
if (StatusIsFatal()) return 0;
int32_t status = 0;
int32_t value = HAL_GetEncoder(m_encoder, &status);
int value = HAL_GetEncoder(m_encoder, &status);
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
return value;
}
@@ -445,7 +445,7 @@ double Encoder::PIDGet() {
* @param channel A DIO channel to set as the encoder index
* @param type The state that will cause the encoder to reset
*/
void Encoder::SetIndexSource(uint32_t channel, Encoder::IndexingType type) {
void Encoder::SetIndexSource(int channel, Encoder::IndexingType type) {
// Force digital input if just given an index
m_indexSource = std::make_unique<DigitalInput>(channel);
SetIndexSource(m_indexSource.get(), type);
@@ -483,9 +483,9 @@ void Encoder::SetIndexSource(const DigitalSource& source,
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
}
int32_t Encoder::GetFPGAIndex() const {
int Encoder::GetFPGAIndex() const {
int32_t status = 0;
int32_t val = HAL_GetEncoderFPGAIndex(m_encoder, &status);
int val = HAL_GetEncoderFPGAIndex(m_encoder, &status);
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
return val;
}

View File

@@ -27,8 +27,7 @@ void GearTooth::EnableDirectionSensing(bool directionSensitive) {
* @param directionSensitive True to enable the pulse length decoding in
* hardware to specify count direction.
*/
GearTooth::GearTooth(uint32_t channel, bool directionSensitive)
: Counter(channel) {
GearTooth::GearTooth(int channel, bool directionSensitive) : Counter(channel) {
EnableDirectionSensing(directionSensitive);
LiveWindow::GetInstance()->AddSensor("GearTooth", channel, this);
}

View File

@@ -15,7 +15,7 @@
* @param port The I2C port to which the device is connected.
* @param deviceAddress The address of the device on the I2C bus.
*/
I2C::I2C(Port port, uint8_t deviceAddress)
I2C::I2C(Port port, int deviceAddress)
: m_port(port), m_deviceAddress(deviceAddress) {
int32_t status = 0;
HAL_InitializeI2C(m_port, &status);
@@ -41,8 +41,8 @@ I2C::~I2C() { HAL_CloseI2C(m_port); }
* @param receiveSize Number of bytes to read from the device.
* @return Transfer Aborted... false for success, true for aborted.
*/
bool I2C::Transaction(uint8_t* dataToSend, uint8_t sendSize,
uint8_t* dataReceived, uint8_t receiveSize) {
bool I2C::Transaction(uint8_t* dataToSend, int sendSize, uint8_t* dataReceived,
int receiveSize) {
int32_t status = 0;
status = HAL_TransactionI2C(m_port, m_deviceAddress, dataToSend, sendSize,
dataReceived, receiveSize);
@@ -71,13 +71,13 @@ bool I2C::AddressOnly() { return Transaction(nullptr, 0, nullptr, 0); }
* @param data The byte to write to the register on the device.
* @return Transfer Aborted... false for success, true for aborted.
*/
bool I2C::Write(uint8_t registerAddress, uint8_t data) {
bool I2C::Write(int registerAddress, uint8_t data) {
uint8_t buffer[2];
buffer[0] = registerAddress;
buffer[1] = data;
int32_t status = 0;
status = HAL_WriteI2C(m_port, m_deviceAddress, buffer, sizeof(buffer));
return status < static_cast<int32_t>(sizeof(buffer));
return status < static_cast<int>(sizeof(buffer));
}
/**
@@ -90,7 +90,7 @@ bool I2C::Write(uint8_t registerAddress, uint8_t data) {
* @param count The number of bytes to be written.
* @return Transfer Aborted... false for success, true for aborted.
*/
bool I2C::WriteBulk(uint8_t* data, uint8_t count) {
bool I2C::WriteBulk(uint8_t* data, int count) {
int32_t status = 0;
status = HAL_WriteI2C(m_port, m_deviceAddress, data, count);
return status < count;
@@ -109,7 +109,7 @@ bool I2C::WriteBulk(uint8_t* data, uint8_t count) {
* read from the device.
* @return Transfer Aborted... false for success, true for aborted.
*/
bool I2C::Read(uint8_t registerAddress, uint8_t count, uint8_t* buffer) {
bool I2C::Read(int registerAddress, int count, uint8_t* buffer) {
if (count < 1) {
wpi_setWPIErrorWithContext(ParameterOutOfRange, "count");
return true;
@@ -118,7 +118,8 @@ bool I2C::Read(uint8_t registerAddress, uint8_t count, uint8_t* buffer) {
wpi_setWPIErrorWithContext(NullParameter, "buffer");
return true;
}
return Transaction(&registerAddress, sizeof(registerAddress), buffer, count);
return Transaction(reinterpret_cast<uint8_t*>(&registerAddress),
sizeof(registerAddress), buffer, count);
}
/**
@@ -132,7 +133,7 @@ bool I2C::Read(uint8_t registerAddress, uint8_t count, uint8_t* buffer) {
* @param count The number of bytes to read in the transaction.
* @return Transfer Aborted... false for success, true for aborted.
*/
bool I2C::ReadOnly(uint8_t count, uint8_t* buffer) {
bool I2C::ReadOnly(int count, uint8_t* buffer) {
if (count < 1) {
wpi_setWPIErrorWithContext(ParameterOutOfRange, "count");
return true;
@@ -155,7 +156,7 @@ bool I2C::ReadOnly(uint8_t count, uint8_t* buffer) {
* @param data The value to write to the devices.
*/
[[gnu::warning("I2C::Broadcast() is not implemented.")]] void I2C::Broadcast(
uint8_t registerAddress, uint8_t data) {}
int registerAddress, uint8_t data) {}
/**
* Verify that a device's registers contain expected values.
@@ -172,17 +173,17 @@ bool I2C::ReadOnly(uint8_t count, uint8_t* buffer) {
* @param expected A buffer containing the values expected from the
* device.
*/
bool I2C::VerifySensor(uint8_t registerAddress, uint8_t count,
bool I2C::VerifySensor(int registerAddress, int count,
const uint8_t* expected) {
// TODO: Make use of all 7 read bytes
uint8_t deviceData[4];
for (uint8_t i = 0, curRegisterAddress = registerAddress; i < count;
for (int i = 0, curRegisterAddress = registerAddress; i < count;
i += 4, curRegisterAddress += 4) {
uint8_t toRead = count - i < 4 ? count - i : 4;
int toRead = count - i < 4 ? count - i : 4;
// Read the chunk of data. Return false if the sensor does not respond.
if (Read(curRegisterAddress, toRead, deviceData)) return false;
for (uint8_t j = 0; j < toRead; j++) {
for (int j = 0; j < toRead; j++) {
if (deviceData[j] != expected[i + j]) return false;
}
}

View File

@@ -101,7 +101,7 @@ InterruptableSensorBase::WaitResult InterruptableSensorBase::WaitForInterrupt(
if (StatusIsFatal()) return InterruptableSensorBase::kTimeout;
wpi_assert(m_interrupt != HAL_kInvalidHandle);
int32_t status = 0;
uint32_t result;
int result;
result = HAL_WaitForInterrupt(m_interrupt, timeout, ignorePrevious, &status);
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));

View File

@@ -15,7 +15,7 @@
* @param channel The PWM channel that the Jaguar is attached to. 0-9 are
* on-board, 10-19 are on the MXP port
*/
Jaguar::Jaguar(uint32_t channel) : PWMSpeedController(channel) {
Jaguar::Jaguar(int channel) : PWMSpeedController(channel) {
/**
* Input profile defined by Luminary Micro.
*

View File

@@ -11,13 +11,13 @@
#include "DriverStation.h"
#include "WPIErrors.h"
const uint32_t Joystick::kDefaultXAxis;
const uint32_t Joystick::kDefaultYAxis;
const uint32_t Joystick::kDefaultZAxis;
const uint32_t Joystick::kDefaultTwistAxis;
const uint32_t Joystick::kDefaultThrottleAxis;
const uint32_t Joystick::kDefaultTriggerButton;
const uint32_t Joystick::kDefaultTopButton;
const int Joystick::kDefaultXAxis;
const int Joystick::kDefaultYAxis;
const int Joystick::kDefaultZAxis;
const int Joystick::kDefaultTwistAxis;
const int Joystick::kDefaultThrottleAxis;
const int Joystick::kDefaultTriggerButton;
const int Joystick::kDefaultTopButton;
static Joystick* joysticks[DriverStation::kJoystickPorts];
static bool joySticksInitialized = false;
@@ -29,8 +29,7 @@ static bool joySticksInitialized = false;
* @param port The port on the driver station that the joystick is plugged into
* (0-5).
*/
Joystick::Joystick(uint32_t port)
: Joystick(port, kNumAxisTypes, kNumButtonTypes) {
Joystick::Joystick(int port) : Joystick(port, kNumAxisTypes, kNumButtonTypes) {
m_axes[kXAxis] = kDefaultXAxis;
m_axes[kYAxis] = kDefaultYAxis;
m_axes[kZAxis] = kDefaultZAxis;
@@ -54,8 +53,7 @@ Joystick::Joystick(uint32_t port)
* @param numAxisTypes The number of axis types in the enum.
* @param numButtonTypes The number of button types in the enum.
*/
Joystick::Joystick(uint32_t port, uint32_t numAxisTypes,
uint32_t numButtonTypes)
Joystick::Joystick(int port, int numAxisTypes, int numButtonTypes)
: m_ds(DriverStation::GetInstance()),
m_port(port),
m_axes(numAxisTypes),
@@ -71,7 +69,7 @@ Joystick::Joystick(uint32_t port, uint32_t numAxisTypes,
}
}
Joystick* Joystick::GetStickForPort(uint32_t port) {
Joystick* Joystick::GetStickForPort(int port) {
Joystick* stick = joysticks[port];
if (stick == nullptr) {
stick = new Joystick(port);
@@ -133,7 +131,7 @@ float Joystick::GetThrottle() const {
* @param axis The axis to read, starting at 0.
* @return The value of the axis.
*/
float Joystick::GetRawAxis(uint32_t axis) const {
float Joystick::GetRawAxis(int axis) const {
return m_ds.GetStickAxis(m_port, axis);
}
@@ -211,7 +209,7 @@ bool Joystick::GetBumper(JoystickHand hand) const {
* @param button The button number to be read (starting at 1)
* @return The state of the button.
**/
bool Joystick::GetRawButton(uint32_t button) const {
bool Joystick::GetRawButton(int button) const {
return m_ds.GetStickButton(m_port, button);
}
@@ -224,9 +222,7 @@ bool Joystick::GetRawButton(uint32_t button) const {
* @param pov The index of the POV to read (starting at 0)
* @return the angle of the POV in degrees, or -1 if the POV is not pressed.
*/
int Joystick::GetPOV(uint32_t pov) const {
return m_ds.GetStickPOV(m_port, pov);
}
int Joystick::GetPOV(int pov) const { return m_ds.GetStickPOV(m_port, pov); }
/**
* Get buttons based on an enumerated type.
@@ -315,7 +311,7 @@ int Joystick::GetPOVCount() const { return m_ds.GetStickPOVCount(m_port); }
* @param axis The axis to look up the channel for.
* @return The channel fr the axis.
*/
uint32_t Joystick::GetAxisChannel(AxisType axis) const { return m_axes[axis]; }
int Joystick::GetAxisChannel(AxisType axis) const { return m_axes[axis]; }
/**
* Set the channel associated with a specified axis.
@@ -323,7 +319,7 @@ uint32_t Joystick::GetAxisChannel(AxisType axis) const { return m_axes[axis]; }
* @param axis The axis to set the channel for.
* @param channel The channel to set the axis to.
*/
void Joystick::SetAxisChannel(AxisType axis, uint32_t channel) {
void Joystick::SetAxisChannel(AxisType axis, int channel) {
m_axes[axis] = channel;
}
@@ -385,7 +381,7 @@ void Joystick::SetRumble(RumbleType type, float value) {
* @param value The value to set the output to
*/
void Joystick::SetOutput(uint8_t outputNumber, bool value) {
void Joystick::SetOutput(int outputNumber, bool value) {
m_outputs =
(m_outputs & ~(1 << (outputNumber - 1))) | (value << (outputNumber - 1));
@@ -397,7 +393,7 @@ void Joystick::SetOutput(uint8_t outputNumber, bool value) {
*
* @param value The 32 bit output value (1 bit for each output)
*/
void Joystick::SetOutputs(uint32_t value) {
void Joystick::SetOutputs(int value) {
m_outputs = value;
HAL_SetJoystickOutputs(m_port, m_outputs, m_leftRumble, m_rightRumble);
}

View File

@@ -67,7 +67,7 @@ PIDController::PIDController(float Kp, float Ki, float Kd, float Kf,
m_controlLoop->StartPeriodic(m_period);
m_setpointTimer.Start();
static int32_t instances = 0;
static int instances = 0;
instances++;
HAL_Report(HALUsageReporting::kResourceType_PIDController, instances);
}
@@ -473,12 +473,12 @@ void PIDController::SetPercentTolerance(float percent) {
*
* @param bufLength Number of previous cycles to average. Defaults to 1.
*/
void PIDController::SetToleranceBuffer(unsigned bufLength) {
void PIDController::SetToleranceBuffer(int bufLength) {
std::lock_guard<priority_recursive_mutex> sync(m_mutex);
m_bufLength = bufLength;
// Cut the buffer down to size if needed.
while (m_buf.size() > bufLength) {
while (m_buf.size() > static_cast<uint32_t>(bufLength)) {
m_bufTotal -= m_buf.front();
m_buf.pop();
}

View File

@@ -23,7 +23,7 @@
* @param channel The PWM channel number. 0-9 are on-board, 10-19 are on the
* MXP port
*/
PWM::PWM(uint32_t channel) {
PWM::PWM(int channel) {
std::stringstream buf;
if (!CheckPWMChannel(channel)) {
@@ -37,7 +37,7 @@ PWM::PWM(uint32_t channel) {
if (status != 0) {
wpi_setErrorWithContextRange(status, 0, HAL_GetNumPWMChannels(), channel,
HAL_GetErrorMessage(status));
m_channel = std::numeric_limits<uint32_t>::max();
m_channel = std::numeric_limits<int>::max();
m_handle = HAL_kInvalidHandle;
return;
}
@@ -120,8 +120,8 @@ void PWM::SetBounds(float max, float deadbandMax, float center,
* @param deadbandMin The low end of the deadband range
* @param min The minimum pwm value
*/
void PWM::SetRawBounds(int32_t max, int32_t deadbandMax, int32_t center,
int32_t deadbandMin, int32_t min) {
void PWM::SetRawBounds(int max, int deadbandMax, int center, int deadbandMin,
int min) {
if (StatusIsFatal()) return;
int32_t status = 0;
HAL_SetPWMConfigRaw(m_handle, max, deadbandMax, center, deadbandMin, min,
@@ -142,8 +142,8 @@ void PWM::SetRawBounds(int32_t max, int32_t deadbandMax, int32_t center,
* @param deadbandMin The low end of the deadband range
* @param min The minimum pwm value
*/
void PWM::GetRawBounds(int32_t* max, int32_t* deadbandMax, int32_t* center,
int32_t* deadbandMin, int32_t* min) {
void PWM::GetRawBounds(int* max, int* deadbandMax, int* center,
int* deadbandMin, int* min) {
int32_t status = 0;
HAL_GetPWMConfigRaw(m_handle, max, deadbandMax, center, deadbandMin, min,
&status);

View File

@@ -13,7 +13,7 @@
* @param channel The PWM channel that the controller is attached to. 0-9 are
* on-board, 10-19 are on the MXP port
*/
PWMSpeedController::PWMSpeedController(uint32_t channel) : SafePWM(channel) {}
PWMSpeedController::PWMSpeedController(int channel) : SafePWM(channel) {}
/**
* Set the PWM value.

View File

@@ -18,8 +18,7 @@ PowerDistributionPanel::PowerDistributionPanel() : PowerDistributionPanel(0) {}
/**
* Initialize the PDP.
*/
PowerDistributionPanel::PowerDistributionPanel(uint8_t module)
: m_module(module) {
PowerDistributionPanel::PowerDistributionPanel(int module) : m_module(module) {
int32_t status = 0;
HAL_InitializePDP(m_module, &status);
if (status != 0) {
@@ -71,7 +70,7 @@ float PowerDistributionPanel::GetTemperature() const {
*
* @return The current of one of the PDP channels (channels 0-15) in Amperes
*/
float PowerDistributionPanel::GetCurrent(uint8_t channel) const {
float PowerDistributionPanel::GetCurrent(int channel) const {
if (StatusIsFatal()) return 0;
int32_t status = 0;

View File

@@ -20,7 +20,7 @@ void Preferences::Listener::ValueChanged(ITable* source, llvm::StringRef key,
bool isNew) {}
void Preferences::Listener::ValueChangedEx(ITable* source, llvm::StringRef key,
std::shared_ptr<nt::Value> value,
unsigned int flags) {
uint32_t flags) {
source->SetPersistent(key);
}

View File

@@ -23,7 +23,7 @@
* @param channel The channel number (0-3).
* @param direction The direction that the Relay object will control.
*/
Relay::Relay(uint32_t channel, Relay::Direction direction)
Relay::Relay(int channel, Relay::Direction direction)
: m_channel(channel), m_direction(direction) {
std::stringstream buf;
if (!SensorBase::CheckRelayChannel(m_channel)) {
@@ -206,7 +206,7 @@ Relay::Value Relay::Get() const {
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
}
uint32_t Relay::GetChannel() const { return m_channel; }
int Relay::GetChannel() const { return m_channel; }
/**
* Set the expiration time for the Relay object

View File

@@ -17,7 +17,7 @@
#include "Utility.h"
#include "WPIErrors.h"
const int32_t RobotDrive::kMaxNumberOfMotors;
const int RobotDrive::kMaxNumberOfMotors;
static auto make_shared_nodelete(SpeedController* ptr) {
return std::shared_ptr<SpeedController>(ptr, NullDeleter<SpeedController>());
@@ -55,7 +55,7 @@ void RobotDrive::InitRobotDrive() {
* @param rightMotorChannel The PWM channel number that drives the right motor.
* 0-9 are on-board, 10-19 are on the MXP port
*/
RobotDrive::RobotDrive(uint32_t leftMotorChannel, uint32_t rightMotorChannel) {
RobotDrive::RobotDrive(int leftMotorChannel, int rightMotorChannel) {
InitRobotDrive();
m_rearLeftMotor = std::make_shared<Talon>(leftMotorChannel);
m_rearRightMotor = std::make_shared<Talon>(rightMotorChannel);
@@ -78,8 +78,8 @@ RobotDrive::RobotDrive(uint32_t leftMotorChannel, uint32_t rightMotorChannel) {
* @param rearRightMotor Rear Right motor channel number. 0-9 are on-board,
* 10-19 are on the MXP port
*/
RobotDrive::RobotDrive(uint32_t frontLeftMotor, uint32_t rearLeftMotor,
uint32_t frontRightMotor, uint32_t rearRightMotor) {
RobotDrive::RobotDrive(int frontLeftMotor, int rearLeftMotor,
int frontRightMotor, int rearRightMotor) {
InitRobotDrive();
m_rearLeftMotor = std::make_shared<Talon>(rearLeftMotor);
m_rearRightMotor = std::make_shared<Talon>(rearRightMotor);
@@ -275,8 +275,8 @@ void RobotDrive::TankDrive(GenericHID& leftStick, GenericHID& rightStick,
* robot.
* @param rightAxis The axis to select on the right side Joystick object.
*/
void RobotDrive::TankDrive(GenericHID* leftStick, uint32_t leftAxis,
GenericHID* rightStick, uint32_t rightAxis,
void RobotDrive::TankDrive(GenericHID* leftStick, int leftAxis,
GenericHID* rightStick, int rightAxis,
bool squaredInputs) {
if (leftStick == nullptr || rightStick == nullptr) {
wpi_setWPIError(NullParameter);
@@ -286,8 +286,8 @@ void RobotDrive::TankDrive(GenericHID* leftStick, uint32_t leftAxis,
squaredInputs);
}
void RobotDrive::TankDrive(GenericHID& leftStick, uint32_t leftAxis,
GenericHID& rightStick, uint32_t rightAxis,
void RobotDrive::TankDrive(GenericHID& leftStick, int leftAxis,
GenericHID& rightStick, int rightAxis,
bool squaredInputs) {
TankDrive(leftStick.GetRawAxis(leftAxis), rightStick.GetRawAxis(rightAxis),
squaredInputs);
@@ -382,8 +382,8 @@ void RobotDrive::ArcadeDrive(GenericHID& stick, bool squaredInputs) {
* @param squaredInputs Setting this parameter to true increases the
* sensitivity at lower speeds
*/
void RobotDrive::ArcadeDrive(GenericHID* moveStick, uint32_t moveAxis,
GenericHID* rotateStick, uint32_t rotateAxis,
void RobotDrive::ArcadeDrive(GenericHID* moveStick, int moveAxis,
GenericHID* rotateStick, int rotateAxis,
bool squaredInputs) {
float moveValue = moveStick->GetRawAxis(moveAxis);
float rotateValue = rotateStick->GetRawAxis(rotateAxis);
@@ -407,8 +407,8 @@ void RobotDrive::ArcadeDrive(GenericHID* moveStick, uint32_t moveAxis,
* @param squaredInputs Setting this parameter to true increases the
* sensitivity at lower speeds
*/
void RobotDrive::ArcadeDrive(GenericHID& moveStick, uint32_t moveAxis,
GenericHID& rotateStick, uint32_t rotateAxis,
void RobotDrive::ArcadeDrive(GenericHID& moveStick, int moveAxis,
GenericHID& rotateStick, int rotateAxis,
bool squaredInputs) {
float moveValue = moveStick.GetRawAxis(moveAxis);
float rotateValue = rotateStick.GetRawAxis(rotateAxis);
@@ -637,7 +637,7 @@ float RobotDrive::Limit(float num) {
*/
void RobotDrive::Normalize(double* wheelSpeeds) {
double maxMagnitude = std::fabs(wheelSpeeds[0]);
int32_t i;
int i;
for (i = 1; i < kMaxNumberOfMotors; i++) {
double temp = std::fabs(wheelSpeeds[i]);
if (maxMagnitude < temp) maxMagnitude = temp;

View File

@@ -31,7 +31,7 @@
* @param channel The PWM channel that the SD540 is attached to. 0-9 are
* on-board, 10-19 are on the MXP port
*/
SD540::SD540(uint32_t channel) : PWMSpeedController(channel) {
SD540::SD540(int channel) : PWMSpeedController(channel) {
SetBounds(2.05, 1.55, 1.50, 1.44, .94);
SetPeriodMultiplier(kPeriodMultiplier_1X);
SetSpeed(0.0);

View File

@@ -23,7 +23,7 @@ SPI::SPI(Port SPIport) {
HAL_InitializeSPI(m_port, &status);
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
static int32_t instances = 0;
static int instances = 0;
instances++;
HAL_Report(HALUsageReporting::kResourceType_SPI, instances);
}
@@ -122,8 +122,8 @@ void SPI::SetChipSelectActiveLow() {
* If not running in output only mode, also saves the data received
* on the MISO input during the transfer into the receive FIFO.
*/
int32_t SPI::Write(uint8_t* data, uint8_t size) {
int32_t retVal = 0;
int SPI::Write(uint8_t* data, int size) {
int retVal = 0;
retVal = HAL_WriteSPI(m_port, data, size);
return retVal;
}
@@ -141,8 +141,8 @@ int32_t SPI::Write(uint8_t* data, uint8_t size) {
* that data is already in the receive FIFO from a previous
* write.
*/
int32_t SPI::Read(bool initiate, uint8_t* dataReceived, uint8_t size) {
int32_t retVal = 0;
int SPI::Read(bool initiate, uint8_t* dataReceived, int size) {
int retVal = 0;
if (initiate) {
auto dataToSend = new uint8_t[size];
std::memset(dataToSend, 0, size);
@@ -160,9 +160,8 @@ int32_t SPI::Read(bool initiate, uint8_t* dataReceived, uint8_t size) {
* @param dataReceived Buffer to receive data from the device
* @param size The length of the transaction, in bytes
*/
int32_t SPI::Transaction(uint8_t* dataToSend, uint8_t* dataReceived,
uint8_t size) {
int32_t retVal = 0;
int SPI::Transaction(uint8_t* dataToSend, uint8_t* dataReceived, int size) {
int retVal = 0;
retVal = HAL_TransactionSPI(m_port, dataToSend, dataReceived, size);
return retVal;
}
@@ -182,12 +181,11 @@ int32_t SPI::Transaction(uint8_t* dataToSend, uint8_t* dataReceived,
* @param is_signed Is data field signed?
* @param big_endian Is device big endian?
*/
void SPI::InitAccumulator(double period, uint32_t cmd, uint8_t xfer_size,
uint32_t valid_mask, uint32_t valid_value,
uint8_t data_shift, uint8_t data_size, bool is_signed,
bool big_endian) {
void SPI::InitAccumulator(double period, int cmd, int xfer_size, int valid_mask,
int valid_value, int data_shift, int data_size,
bool is_signed, bool big_endian) {
int32_t status = 0;
HAL_InitSPIAccumulator(m_port, static_cast<uint32_t>(period * 1e6), cmd,
HAL_InitSPIAccumulator(m_port, static_cast<int32_t>(period * 1e6), cmd,
xfer_size, valid_mask, valid_value, data_shift,
data_size, is_signed, big_endian, &status);
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
@@ -219,7 +217,7 @@ void SPI::ResetAccumulator() {
* accelerometers to make integration work and to take the device offset into
* account when integrating.
*/
void SPI::SetAccumulatorCenter(int32_t center) {
void SPI::SetAccumulatorCenter(int center) {
int32_t status = 0;
HAL_SetSPIAccumulatorCenter(m_port, center, &status);
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
@@ -228,7 +226,7 @@ void SPI::SetAccumulatorCenter(int32_t center) {
/**
* Set the accumulator's deadband.
*/
void SPI::SetAccumulatorDeadband(int32_t deadband) {
void SPI::SetAccumulatorDeadband(int deadband) {
int32_t status = 0;
HAL_SetSPIAccumulatorDeadband(m_port, deadband, &status);
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
@@ -237,9 +235,9 @@ void SPI::SetAccumulatorDeadband(int32_t deadband) {
/**
* Read the last value read by the accumulator engine.
*/
int32_t SPI::GetAccumulatorLastValue() const {
int SPI::GetAccumulatorLastValue() const {
int32_t status = 0;
int32_t retVal = HAL_GetSPIAccumulatorLastValue(m_port, &status);
int retVal = HAL_GetSPIAccumulatorLastValue(m_port, &status);
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
return retVal;
}

View File

@@ -13,7 +13,7 @@
* @param channel The PWM channel number 0-9 are on-board, 10-19 are on the MXP
* port
*/
SafePWM::SafePWM(uint32_t channel) : PWM(channel) {
SafePWM::SafePWM(int channel) : PWM(channel) {
m_safetyHelper = std::make_unique<MotorSafetyHelper>(this);
m_safetyHelper->SetSafetyEnabled(false);
}

View File

@@ -23,7 +23,7 @@
* @param stopBits The number of stop bits to use as defined by the enum
* StopBits.
*/
SerialPort::SerialPort(uint32_t baudRate, Port port, uint8_t dataBits,
SerialPort::SerialPort(int baudRate, Port port, int dataBits,
SerialPort::Parity parity,
SerialPort::StopBits stopBits) {
int32_t status = 0;
@@ -105,9 +105,9 @@ void SerialPort::DisableTermination() {
*
* @return The number of bytes available to read
*/
int32_t SerialPort::GetBytesReceived() {
int SerialPort::GetBytesReceived() {
int32_t status = 0;
int32_t retVal = HAL_GetSerialBytesReceived(m_port, &status);
int retVal = HAL_GetSerialBytesReceived(m_port, &status);
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
return retVal;
}
@@ -119,9 +119,9 @@ int32_t SerialPort::GetBytesReceived() {
* @param count The maximum number of bytes to read.
* @return The number of bytes actually read into the buffer.
*/
uint32_t SerialPort::Read(char* buffer, int32_t count) {
int SerialPort::Read(char* buffer, int count) {
int32_t status = 0;
int32_t retVal = HAL_ReadSerial(m_port, buffer, count, &status);
int retVal = HAL_ReadSerial(m_port, buffer, count, &status);
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
return retVal;
}
@@ -133,9 +133,9 @@ uint32_t SerialPort::Read(char* buffer, int32_t count) {
* @param count The maximum number of bytes to write.
* @return The number of bytes actually written into the port.
*/
uint32_t SerialPort::Write(const std::string& buffer, int32_t count) {
int SerialPort::Write(const std::string& buffer, int count) {
int32_t status = 0;
int32_t retVal = HAL_WriteSerial(m_port, buffer.c_str(), count, &status);
int retVal = HAL_WriteSerial(m_port, buffer.c_str(), count, &status);
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
return retVal;
}
@@ -166,7 +166,7 @@ void SerialPort::SetTimeout(float timeout) {
*
* @param size The read buffer size.
*/
void SerialPort::SetReadBufferSize(uint32_t size) {
void SerialPort::SetReadBufferSize(int size) {
int32_t status = 0;
HAL_SetSerialReadBufferSize(m_port, size, &status);
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
@@ -180,7 +180,7 @@ void SerialPort::SetReadBufferSize(uint32_t size) {
*
* @param size The write buffer size.
*/
void SerialPort::SetWriteBufferSize(uint32_t size) {
void SerialPort::SetWriteBufferSize(int size) {
int32_t status = 0;
HAL_SetSerialWriteBufferSize(m_port, size, &status);
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));

View File

@@ -19,7 +19,7 @@ constexpr float Servo::kDefaultMinServoPWM;
* @param channel The PWM channel to which the servo is attached. 0-9 are
* on-board, 10-19 are on the MXP port
*/
Servo::Servo(uint32_t channel) : SafePWM(channel) {
Servo::Servo(int channel) : SafePWM(channel) {
// Set minimum and maximum PWM values supported by the servo
SetBounds(kDefaultMaxServoPWM, 0.0, 0.0, 0.0, kDefaultMinServoPWM);

View File

@@ -18,7 +18,7 @@
*
* @param channel The channel on the PCM to control (0..7).
*/
Solenoid::Solenoid(uint32_t channel)
Solenoid::Solenoid(int channel)
: Solenoid(GetDefaultSolenoidModule(), channel) {}
/**
@@ -27,7 +27,7 @@ Solenoid::Solenoid(uint32_t channel)
* @param moduleNumber The CAN ID of the PCM the solenoid is attached to
* @param channel The channel on the PCM to control (0..7).
*/
Solenoid::Solenoid(uint8_t moduleNumber, uint32_t channel)
Solenoid::Solenoid(int moduleNumber, int channel)
: SolenoidBase(moduleNumber), m_channel(channel) {
std::stringstream buf;
if (!CheckSolenoidModule(m_moduleNumber)) {

View File

@@ -14,18 +14,17 @@
*
* @param moduleNumber The CAN PCM ID.
*/
SolenoidBase::SolenoidBase(uint8_t moduleNumber)
: m_moduleNumber(moduleNumber) {}
SolenoidBase::SolenoidBase(int moduleNumber) : m_moduleNumber(moduleNumber) {}
/**
* Read all 8 solenoids as a single byte
*
* @return The current value of all 8 solenoids on the module.
*/
uint8_t SolenoidBase::GetAll(int module) const {
uint8_t value = 0;
int SolenoidBase::GetAll(int module) const {
int value = 0;
int32_t status = 0;
value = HAL_GetAllSolenoids(static_cast<uint8_t>(module), &status);
value = HAL_GetAllSolenoids(static_cast<int>(module), &status);
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
return value;
}
@@ -39,9 +38,9 @@ uint8_t SolenoidBase::GetAll(int module) const {
*
* @return The solenoid blacklist of all 8 solenoids on the module.
*/
uint8_t SolenoidBase::GetPCMSolenoidBlackList(int module) const {
int SolenoidBase::GetPCMSolenoidBlackList(int module) const {
int32_t status = 0;
return HAL_GetPCMSolenoidBlackList(static_cast<uint8_t>(module), &status);
return HAL_GetPCMSolenoidBlackList(static_cast<int>(module), &status);
}
/**
@@ -50,7 +49,7 @@ uint8_t SolenoidBase::GetPCMSolenoidBlackList(int module) const {
*/
bool SolenoidBase::GetPCMSolenoidVoltageStickyFault(int module) const {
int32_t status = 0;
return HAL_GetPCMSolenoidVoltageStickyFault(static_cast<uint8_t>(module),
return HAL_GetPCMSolenoidVoltageStickyFault(static_cast<int>(module),
&status);
}
@@ -60,7 +59,7 @@ bool SolenoidBase::GetPCMSolenoidVoltageStickyFault(int module) const {
*/
bool SolenoidBase::GetPCMSolenoidVoltageFault(int module) const {
int32_t status = 0;
return HAL_GetPCMSolenoidVoltageFault(static_cast<uint8_t>(module), &status);
return HAL_GetPCMSolenoidVoltageFault(static_cast<int>(module), &status);
}
/**
@@ -75,5 +74,5 @@ bool SolenoidBase::GetPCMSolenoidVoltageFault(int module) const {
*/
void SolenoidBase::ClearAllPCMStickyFaults(int module) {
int32_t status = 0;
return HAL_ClearAllPCMStickyFaults(static_cast<uint8_t>(module), &status);
return HAL_ClearAllPCMStickyFaults(static_cast<int>(module), &status);
}

View File

@@ -31,7 +31,7 @@
* @param channel The PWM channel that the Spark is attached to. 0-9 are
* on-board, 10-19 are on the MXP port
*/
Spark::Spark(uint32_t channel) : PWMSpeedController(channel) {
Spark::Spark(int channel) : PWMSpeedController(channel) {
SetBounds(2.003, 1.55, 1.50, 1.46, .999);
SetPeriodMultiplier(kPeriodMultiplier_1X);
SetSpeed(0.0);

View File

@@ -16,7 +16,7 @@
* @param channel The PWM channel number that the Talon is attached to. 0-9 are
* on-board, 10-19 are on the MXP port
*/
Talon::Talon(uint32_t channel) : PWMSpeedController(channel) {
Talon::Talon(int channel) : PWMSpeedController(channel) {
/* Note that the Talon uses the following bounds for PWM values. These values
* should work reasonably well for most controllers, but if users experience
* issues such as asymmetric behavior around the deadband or inability to

View File

@@ -16,7 +16,7 @@
* @param channel The PWM channel that the TalonSRX is attached to. 0-9 are
* on-board, 10-19 are on the MXP port
*/
TalonSRX::TalonSRX(uint32_t channel) : PWMSpeedController(channel) {
TalonSRX::TalonSRX(int channel) : PWMSpeedController(channel) {
/* Note that the TalonSRX uses the following bounds for PWM values. These
* values should work reasonably well for most controllers, but if users
* experience issues such as asymmetric behavior around the deadband or

View File

@@ -18,7 +18,7 @@
#define ERROR (-1)
#endif /* ERROR */
const uint32_t Task::kDefaultPriority;
const int Task::kDefaultPriority;
Task& Task::operator=(Task&& task) {
m_thread.swap(task.m_thread);
@@ -60,7 +60,7 @@ bool Task::Verify() {
*
* @return task priority or 0 if an error occured
*/
int32_t Task::GetPriority() {
int Task::GetPriority() {
int priority;
auto id = m_thread.native_handle();
if (HandleError(HAL_GetTaskPriority(&id, &priority)))
@@ -77,7 +77,7 @@ int32_t Task::GetPriority() {
* @param priority The priority at which the internal thread should run.
* @return true on success.
*/
bool Task::SetPriority(int32_t priority) {
bool Task::SetPriority(int priority) {
auto id = m_thread.native_handle();
return HandleError(HAL_SetTaskPriority(&id, priority));
}

View File

@@ -22,7 +22,7 @@
// To call it, just give the name of the function and the arguments
#define SAFE_IMAQ_CALL(funName, ...) \
{ \
unsigned int error = funName(__VA_ARGS__); \
int error = funName(__VA_ARGS__); \
if (error != IMAQdxErrorSuccess) \
wpi_setImaqErrorWithContext(error, #funName); \
}
@@ -33,15 +33,15 @@
* http://stackoverflow.com/a/1602428. Be sure to also read the comments for
* the SOS flag explanation.
*/
unsigned int USBCamera::GetJpegSize(void* buffer, unsigned int buffSize) {
int USBCamera::GetJpegSize(void* buffer, int buffSize) {
uint8_t* data = static_cast<uint8_t*>(buffer);
if (!wpi_assert(data[0] == 0xff && data[1] == 0xd8)) return 0;
unsigned int pos = 2;
int pos = 2;
while (pos < buffSize) {
// All control markers start with 0xff, so if this isn't present,
// the JPEG is not valid
if (!wpi_assert(data[pos] == 0xff)) return 0;
unsigned char t = data[pos + 1];
int t = data[pos + 1];
// These are RST markers. We just skip them and move onto the next marker
if (t == 0x01 || (t >= 0xd0 && t <= 0xd7)) {
pos += 2;
@@ -54,7 +54,8 @@ unsigned int USBCamera::GetJpegSize(void* buffer, unsigned int buffSize) {
} else if (t == 0xda) {
// SOS marker. The next two bytes are a 16-bit big-endian int that is
// the length of the SOS header, skip that
unsigned int len = (data[pos + 2] & 0xffu) << 8 | (data[pos + 3] & 0xffu);
int len = (static_cast<int>(data[pos + 2]) & 0xff) << 8 |
(static_cast<int>(data[pos + 3]) & 0xff);
pos += len + 2;
// The next marker is the first marker that is 0xff followed by a non-RST
// element. 0xff followed by 0x00 is an escaped 0xff. 0xd0-0xd7 are RST
@@ -69,7 +70,8 @@ unsigned int USBCamera::GetJpegSize(void* buffer, unsigned int buffSize) {
// 16-bit
// big-endian int with the length of the marker header, skip that then
// continue searching
unsigned int len = (data[pos + 2] & 0xffu) << 8 | (data[pos + 3] & 0xffu);
int len = (static_cast<int>(data[pos + 2]) & 0xff) << 8 |
(static_cast<int>(data[pos + 3]) & 0xff);
pos += len + 2;
}
}
@@ -82,7 +84,7 @@ USBCamera::USBCamera(std::string name, bool useJpeg)
void USBCamera::OpenCamera() {
std::lock_guard<priority_recursive_mutex> lock(m_mutex);
for (unsigned int i = 0; i < 3; i++) {
for (int i = 0; i < 3; i++) {
uInt32 id = 0;
// Can't use SAFE_IMAQ_CALL here because we only error on the third time
IMAQdxError error = IMAQdxOpenCamera(
@@ -151,11 +153,11 @@ void USBCamera::UpdateSettings() {
double foundFps = 1000.0;
// Loop through the modes, and find the match with the lowest fps
for (unsigned int i = 0; i < count; i++) {
for (uint32_t i = 0; i < count; i++) {
std::cmatch m;
if (!std::regex_match(modes[i].Name, m, reMode)) continue;
unsigned int width = static_cast<unsigned int>(std::stoul(m[1].str()));
unsigned int height = static_cast<unsigned int>(std::stoul(m[2].str()));
int width = static_cast<int>(std::stoul(m[1].str()));
int height = static_cast<int>(std::stoul(m[2].str()));
if (width != m_width) continue;
if (height != m_height) continue;
double fps = atof(m[4].str().c_str());
@@ -230,7 +232,7 @@ void USBCamera::SetFPS(double fps) {
}
}
void USBCamera::SetSize(unsigned int width, unsigned int height) {
void USBCamera::SetSize(int width, int height) {
std::lock_guard<priority_recursive_mutex> lock(m_mutex);
if (m_width != width || m_height != height) {
m_needSettingsUpdate = true;
@@ -239,7 +241,7 @@ void USBCamera::SetSize(unsigned int width, unsigned int height) {
}
}
void USBCamera::SetBrightness(unsigned int brightness) {
void USBCamera::SetBrightness(int brightness) {
std::lock_guard<priority_recursive_mutex> lock(m_mutex);
if (m_brightness != brightness) {
m_needSettingsUpdate = true;
@@ -247,7 +249,7 @@ void USBCamera::SetBrightness(unsigned int brightness) {
}
}
unsigned int USBCamera::GetBrightness() {
int USBCamera::GetBrightness() {
std::lock_guard<priority_recursive_mutex> lock(m_mutex);
return m_brightness;
}
@@ -268,7 +270,7 @@ void USBCamera::SetWhiteBalanceHoldCurrent() {
m_needSettingsUpdate = true;
}
void USBCamera::SetWhiteBalanceManual(unsigned int whiteBalance) {
void USBCamera::SetWhiteBalanceManual(int whiteBalance) {
std::lock_guard<priority_recursive_mutex> lock(m_mutex);
m_whiteBalance = MANUAL;
m_whiteBalanceValue = whiteBalance;
@@ -292,7 +294,7 @@ void USBCamera::SetExposureHoldCurrent() {
m_needSettingsUpdate = true;
}
void USBCamera::SetExposureManual(unsigned int level) {
void USBCamera::SetExposureManual(int level) {
std::lock_guard<priority_recursive_mutex> lock(m_mutex);
m_exposure = MANUAL;
if (level > 100)
@@ -316,7 +318,7 @@ void USBCamera::GetImage(Image* image) {
SAFE_IMAQ_CALL(IMAQdxGrab, m_id, image, 1, &bufNum);
}
unsigned int USBCamera::GetImageData(void* buffer, unsigned int bufferSize) {
int USBCamera::GetImageData(void* buffer, int bufferSize) {
std::lock_guard<priority_recursive_mutex> lock(m_mutex);
if (m_needSettingsUpdate || !m_useJpeg) {
m_needSettingsUpdate = false;

View File

@@ -18,7 +18,7 @@
// Time (sec) for the ping trigger pulse.
constexpr double Ultrasonic::kPingTime;
// Priority that the ultrasonic round robin task runs.
const uint32_t Ultrasonic::kPriority;
const int Ultrasonic::kPriority;
// Max time (ms) between readings.
constexpr double Ultrasonic::kMaxUltrasonicTime;
constexpr double Ultrasonic::kSpeedOfSoundInchesPerSec;
@@ -91,8 +91,7 @@ void Ultrasonic::Initialize() {
* round trip time of the ping, and the distance.
* @param units The units returned in either kInches or kMilliMeters
*/
Ultrasonic::Ultrasonic(uint32_t pingChannel, uint32_t echoChannel,
DistanceUnit units)
Ultrasonic::Ultrasonic(int pingChannel, int echoChannel, DistanceUnit units)
: m_pingChannel(std::make_shared<DigitalOutput>(pingChannel)),
m_echoChannel(std::make_shared<DigitalInput>(echoChannel)),
m_counter(m_echoChannel) {

View File

@@ -23,8 +23,8 @@
* Utility.h.
*/
bool wpi_assert_impl(bool conditionValue, const char* conditionText,
const char* message, const char* fileName,
uint32_t lineNumber, const char* funcName) {
const char* message, const char* fileName, int lineNumber,
const char* funcName) {
if (!conditionValue) {
std::stringstream locStream;
locStream << funcName << " [";
@@ -58,7 +58,7 @@ bool wpi_assert_impl(bool conditionValue, const char* conditionText,
*/
void wpi_assertEqual_common_impl(const char* valueA, const char* valueB,
const char* equalityType, const char* message,
const char* fileName, uint32_t lineNumber,
const char* fileName, int lineNumber,
const char* funcName) {
std::stringstream locStream;
locStream << funcName << " [";
@@ -92,7 +92,7 @@ void wpi_assertEqual_common_impl(const char* valueA, const char* valueB,
*/
bool wpi_assertEqual_impl(int valueA, int valueB, const char* valueAString,
const char* valueBString, const char* message,
const char* fileName, uint32_t lineNumber,
const char* fileName, int lineNumber,
const char* funcName) {
if (!(valueA == valueB)) {
wpi_assertEqual_common_impl(valueAString, valueBString, "==", message,
@@ -110,7 +110,7 @@ bool wpi_assertEqual_impl(int valueA, int valueB, const char* valueAString,
*/
bool wpi_assertNotEqual_impl(int valueA, int valueB, const char* valueAString,
const char* valueBString, const char* message,
const char* fileName, uint32_t lineNumber,
const char* fileName, int lineNumber,
const char* funcName) {
if (!(valueA != valueB)) {
wpi_assertEqual_common_impl(valueAString, valueBString, "!=", message,
@@ -125,9 +125,9 @@ bool wpi_assertNotEqual_impl(int valueA, int valueB, const char* valueAString,
* For now, expect this to be competition year.
* @return FPGA Version number.
*/
int32_t GetFPGAVersion() {
int GetFPGAVersion() {
int32_t status = 0;
int32_t version = HAL_GetFPGAVersion(&status);
int version = HAL_GetFPGAVersion(&status);
wpi_setGlobalErrorWithContext(status, HAL_GetErrorMessage(status));
return version;
}
@@ -180,7 +180,7 @@ bool GetUserButton() {
static std::string demangle(char const* mangledSymbol) {
char buffer[256];
size_t length;
int status;
int32_t status;
if (sscanf(mangledSymbol, "%*[^(]%*[(]%255[^)+]", buffer)) {
char* symbol = abi::__cxa_demangle(buffer, nullptr, &length, &status);
@@ -201,7 +201,7 @@ static std::string demangle(char const* mangledSymbol) {
* Get a stack trace, ignoring the first "offset" symbols.
* @param offset The number of symbols at the top of the stack to ignore
*/
std::string GetStackTrace(uint32_t offset) {
std::string GetStackTrace(int offset) {
void* stackTrace[128];
int stackSize = backtrace(stackTrace, 128);
char** mangledSymbols = backtrace_symbols(stackTrace, stackSize);

Some files were not shown because too many files have changed in this diff Show More