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

@@ -29,13 +29,13 @@ class AnalogModule;
*/
class AnalogGyro : public GyroBase {
public:
static const uint32_t kOversampleBits;
static const uint32_t kAverageBits;
static const int kOversampleBits;
static const int kAverageBits;
static const float kSamplesPerSecond;
static const float kCalibrationSampleTime;
static const float kDefaultVoltsPerDegreePerSecond;
explicit AnalogGyro(uint32_t channel);
explicit AnalogGyro(int channel);
virtual ~AnalogGyro() = default;
float GetAngle() const;
void Calibrate() override;

View File

@@ -31,17 +31,17 @@ class AnalogInput : public SensorBase,
public PIDSource,
public LiveWindowSendable {
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() = default;
float GetVoltage() const;
float GetAverageVoltage() const;
uint32_t GetChannel() const;
int GetChannel() const;
double PIDGet() override;
@@ -53,7 +53,7 @@ class AnalogInput : public SensorBase,
std::shared_ptr<ITable> GetTable() const override;
private:
uint32_t m_channel;
int m_channel;
SimFloatInput* m_impl;
int64_t m_accumulatorOffset;

View File

@@ -29,7 +29,7 @@ class Counter : public SensorBase,
public LiveWindowSendable {
public:
explicit Counter(Mode mode = kTwoPulse);
explicit Counter(uint32_t channel);
explicit Counter(int channel);
// TODO: [Not Supported] explicit Counter(DigitalSource *source);
// TODO: [Not Supported] explicit Counter(DigitalSource &source);
// TODO: [Not Supported] explicit Counter(AnalogTrigger *source);
@@ -38,7 +38,7 @@ class Counter : public SensorBase,
// *upSource, DigitalSource *downSource, bool inverted);
virtual ~Counter();
void SetUpSource(uint32_t channel);
void SetUpSource(int channel);
// TODO: [Not Supported] void SetUpSource(AnalogTrigger *analogTrigger,
// AnalogTriggerType triggerType);
// TODO: [Not Supported] void SetUpSource(AnalogTrigger &analogTrigger,
@@ -48,7 +48,7 @@ class Counter : public SensorBase,
void SetUpSourceEdge(bool risingEdge, bool fallingEdge);
void ClearUpSource();
void SetDownSource(uint32_t channel);
void SetDownSource(int channel);
// TODO: [Not Supported] void SetDownSource(AnalogTrigger *analogTrigger,
// AnalogTriggerType triggerType);
// TODO: [Not Supported] void SetDownSource(AnalogTrigger &analogTrigger,
@@ -66,7 +66,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;
@@ -76,7 +76,7 @@ class Counter : public SensorBase,
void SetSamplesToAverage(int samplesToAverage);
int GetSamplesToAverage() const;
uint32_t GetFPGAIndex() const { return m_index; }
int GetFPGAIndex() const { return m_index; }
void UpdateTable() override;
void StartLiveWindowMode() override;
@@ -94,7 +94,7 @@ class Counter : public SensorBase,
private:
bool m_allocatedUpSource; ///< Was the upSource allocated locally?
bool m_allocatedDownSource; ///< Was the downSource allocated locally?
uint32_t m_index; ///< The index of this counter.
int m_index; ///< The index of this counter.
std::shared_ptr<ITable> m_table;
};

View File

@@ -21,7 +21,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

@@ -24,10 +24,10 @@
*/
class DigitalInput : public LiveWindowSendable {
public:
explicit DigitalInput(uint32_t channel);
explicit DigitalInput(int channel);
virtual ~DigitalInput() = default;
uint32_t Get() const;
uint32_t GetChannel() const;
int Get() const;
int GetChannel() const;
void UpdateTable() override;
void StartLiveWindowMode() override;
@@ -37,7 +37,7 @@ class DigitalInput : public LiveWindowSendable {
std::shared_ptr<ITable> GetTable() const override;
private:
uint32_t m_channel;
int m_channel;
bool m_lastValue;
SimDigitalInput* m_impl;

View File

@@ -25,9 +25,8 @@ class DoubleSolenoid : public LiveWindowSendable, public ITableListener {
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;

View File

@@ -40,22 +40,22 @@ 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 kBatteryChannel = 7;
static const uint32_t kJoystickPorts = 4;
static const uint32_t kJoystickAxes = 6;
static const int kBatteryChannel = 7;
static const int kJoystickPorts = 4;
static const int kJoystickAxes = 6;
float GetStickAxis(uint32_t stick, uint32_t axis);
bool GetStickButton(uint32_t stick, uint32_t button);
int16_t GetStickButtons(uint32_t stick);
float GetStickAxis(int stick, int axis);
bool GetStickButton(int stick, int button);
int16_t GetStickButtons(int stick);
float GetAnalogIn(uint32_t channel);
bool GetDigitalIn(uint32_t channel);
void SetDigitalOut(uint32_t channel, bool value);
bool GetDigitalOut(uint32_t channel);
float GetAnalogIn(int channel);
bool GetDigitalIn(int channel);
void SetDigitalOut(int channel, bool value);
bool GetDigitalOut(int channel);
bool IsEnabled() const;
bool IsDisabled() const;
@@ -64,9 +64,9 @@ class DriverStation : public SensorBase, public RobotStateInterface {
bool IsTest() const;
bool IsFMSAttached() const;
uint32_t GetPacketNumber() const;
int GetPacketNumber() const;
Alliance GetAlliance() const;
uint32_t GetLocation() const;
int GetLocation() const;
void WaitForData();
double GetMatchTime() const;
float GetBatteryVoltage() const;
@@ -112,7 +112,7 @@ class DriverStation : public SensorBase, public RobotStateInterface {
private:
static void InitTask(DriverStation* ds);
static DriverStation* m_instance;
static uint8_t m_updateNumber;
static int m_updateNumber;
///< TODO: Get rid of this and use the semaphore signaling
static const float kUpdatePeriod;
@@ -125,7 +125,7 @@ class DriverStation : public SensorBase, public RobotStateInterface {
void joystickCallback4(const msgs::ConstFRCJoystickPtr& msg);
void joystickCallback5(const msgs::ConstFRCJoystickPtr& msg);
uint8_t m_digitalOut = 0;
int m_digitalOut = 0;
std::condition_variable m_waitForDataCond;
std::mutex m_waitForDataMutex;
mutable std::recursive_mutex m_stateMutex;

View File

@@ -38,7 +38,7 @@ class Encoder : public SensorBase,
public PIDSource,
public LiveWindowSendable {
public:
Encoder(uint32_t aChannel, uint32_t bChannel, bool reverseDirection = false,
Encoder(int aChannel, int bChannel, bool reverseDirection = false,
EncodingType encodingType = k4X);
// TODO: [Not Supported] Encoder(DigitalSource *aSource, DigitalSource
// *bSource, bool reverseDirection=false, EncodingType encodingType = k4X);
@@ -47,9 +47,9 @@ class Encoder : public SensorBase,
virtual ~Encoder() = default;
// 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;
@@ -73,7 +73,7 @@ class Encoder : public SensorBase,
void InitTable(std::shared_ptr<ITable> subTable) override;
std::shared_ptr<ITable> GetTable() const override;
int32_t FPGAEncoderIndex() const { return 0; }
int FPGAEncoderIndex() const { return 0; }
private:
void InitEncoder(int channelA, int channelB, bool _reverseDirection,
@@ -91,7 +91,7 @@ class Encoder : public SensorBase,
int channelA, channelB;
double m_distancePerPulse; // distance of travel for each encoder tick
EncodingType m_encodingType; // Encoding type
int32_t m_encodingScale; // 1x, 2x, or 4x, per the encodingType
int m_encodingScale; // 1x, 2x, or 4x, per the encodingType
bool m_reverseDirection;
SimEncoder* impl;

View File

@@ -16,7 +16,7 @@
*/
class Jaguar : public SafePWM, public SpeedController {
public:
explicit Jaguar(uint32_t channel);
explicit Jaguar(int channel);
virtual ~Jaguar() = default;
virtual void Set(float value);
virtual float Get() const;

View File

@@ -23,11 +23,11 @@ class DriverStation;
*/
class Joystick : public GenericHID, public ErrorBase {
public:
static const uint32_t kDefaultXAxis = 1;
static const uint32_t kDefaultYAxis = 2;
static const uint32_t kDefaultZAxis = 3;
static const uint32_t kDefaultTwistAxis = 4;
static const uint32_t kDefaultThrottleAxis = 3;
static const int kDefaultXAxis = 1;
static const int kDefaultYAxis = 2;
static const int kDefaultZAxis = 3;
static const int kDefaultTwistAxis = 4;
static const int kDefaultThrottleAxis = 3;
typedef enum {
kXAxis,
kYAxis,
@@ -36,19 +36,19 @@ 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;
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);
void SetAxisChannel(AxisType axis, uint32_t channel);
int GetAxisChannel(AxisType axis);
void SetAxisChannel(AxisType axis, int channel);
float GetX(JoystickHand hand = kRightHand) const override;
float GetY(JoystickHand hand = kRightHand) const override;
@@ -56,15 +56,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 = 1) const override;
bool GetRawButton(int button) const override;
int GetPOV(int pov = 1) 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;
@@ -72,7 +72,7 @@ class Joystick : public GenericHID, public ErrorBase {
private:
DriverStation& m_ds;
uint32_t m_port;
std::unique_ptr<uint32_t[]> m_axes;
std::unique_ptr<uint32_t[]> m_buttons;
int m_port;
std::unique_ptr<int[]> m_axes;
std::unique_ptr<int[]> m_buttons;
};

View File

@@ -43,7 +43,7 @@ class Notifier : public ErrorBase {
static std::atomic<int> refcount;
// Process the timer queue on a timer event
static void ProcessQueue(uint32_t mask, void* params);
static void ProcessQueue(int mask, void* params);
// Update the FPGA alarm since the queue has changed
static void UpdateAlarm();

View File

@@ -42,16 +42,16 @@ class PWM : public SensorBase,
kPeriodMultiplier_4X = 4
};
explicit PWM(uint32_t channel);
explicit PWM(int channel);
virtual ~PWM();
virtual void SetRaw(uint16_t value);
void SetPeriodMultiplier(PeriodMultiplier mult);
void EnableDeadbandElimination(bool eliminateDeadband);
void SetBounds(int32_t max, int32_t deadbandMax, int32_t center,
int32_t deadbandMin, int32_t min);
void SetBounds(int max, int deadbandMax, int center, int deadbandMin,
int min);
void SetBounds(double max, double deadbandMax, double center,
double deadbandMin, double min);
uint32_t GetChannel() const { return m_channel; }
int GetChannel() const { return m_channel; }
protected:
/**
@@ -80,8 +80,8 @@ class PWM : public SensorBase,
/**
* kDefaultPWMStepsDown is the number of PWM steps below the centerpoint
*/
static const int32_t kDefaultPwmStepsDown;
static const int32_t kPwmDisabled;
static const int kDefaultPwmStepsDown;
static const int kPwmDisabled;
virtual void SetPosition(float pos);
virtual float GetPosition() const;
@@ -89,7 +89,7 @@ class PWM : public SensorBase,
virtual float GetSpeed() const;
bool m_eliminateDeadband;
int32_t m_centerPwm;
int m_centerPwm;
void ValueChanged(ITable* source, llvm::StringRef key,
std::shared_ptr<nt::Value> value, bool isNew) override;
@@ -103,6 +103,6 @@ class PWM : public SensorBase,
std::shared_ptr<ITable> m_table;
private:
uint32_t m_channel;
int m_channel;
SimContinuousOutput* impl;
};

View File

@@ -40,12 +40,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;
@@ -67,7 +67,7 @@ class Relay : public MotorSafety,
std::shared_ptr<ITable> m_table;
private:
uint32_t m_channel;
int m_channel;
Direction m_direction;
std::unique_ptr<MotorSafetyHelper> m_safetyHelper;
SimContinuousOutput* impl;

View File

@@ -38,9 +38,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,
@@ -63,20 +63,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);
@@ -103,9 +101,9 @@ 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;
int32_t m_invertedMotors[kMaxNumberOfMotors] = {1, 1, 1, 1};
int m_invertedMotors[kMaxNumberOfMotors] = {1, 1, 1, 1};
float m_sensitivity = 0.5;
double m_maxOutput = 1.0;
bool m_deleteSpeedControllers;
@@ -116,7 +114,7 @@ class RobotDrive : public MotorSafety, public ErrorBase {
// FIXME: MotorSafetyHelper *m_safetyHelper;
private:
int32_t GetNumMotors() {
int GetNumMotors() {
int motors = 0;
if (m_frontLeftMotor) motors++;
if (m_frontRightMotor) motors++;

View File

@@ -22,7 +22,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

@@ -22,8 +22,8 @@
*/
class Solenoid : 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;

View File

@@ -16,7 +16,7 @@
*/
class Talon : public SafePWM, public SpeedController {
public:
explicit Talon(uint32_t channel);
explicit Talon(int channel);
virtual ~Talon() = default;
virtual void Set(float value);
virtual float Get() const;

View File

@@ -16,7 +16,7 @@
*/
class Victor : public SafePWM, public SpeedController {
public:
explicit Victor(uint32_t channel);
explicit Victor(int channel);
virtual ~Victor() = default;
virtual void Set(float value);
virtual float Get() const;

View File

@@ -25,7 +25,7 @@ class MainNode {
template <typename M>
static transport::PublisherPtr Advertise(const std::string& topic,
unsigned int _queueLimit = 10,
int _queueLimit = 10,
bool _latch = false) {
return GetInstance()->main->Advertise<M>(topic, _queueLimit, _latch);
}

View File

@@ -13,8 +13,8 @@
#include "Timer.h"
#include "WPIErrors.h"
const uint32_t AnalogGyro::kOversampleBits = 10;
const uint32_t AnalogGyro::kAverageBits = 0;
const int AnalogGyro::kOversampleBits = 10;
const int AnalogGyro::kAverageBits = 0;
const float AnalogGyro::kSamplesPerSecond = 50.0;
const float AnalogGyro::kCalibrationSampleTime = 5.0;
const float AnalogGyro::kDefaultVoltsPerDegreePerSecond = 0.007;
@@ -44,7 +44,7 @@ void AnalogGyro::InitAnalogGyro(int channel) {
*
* @param channel The analog channel the gyro is connected to.
*/
AnalogGyro::AnalogGyro(uint32_t channel) { InitAnalogGyro(channel); }
AnalogGyro::AnalogGyro(int channel) { InitAnalogGyro(channel); }
/**
* Reset the gyro.

View File

@@ -17,7 +17,7 @@
*
* @param channel The channel number to represent.
*/
AnalogInput::AnalogInput(uint32_t channel) : m_channel(channel) {
AnalogInput::AnalogInput(int channel) : m_channel(channel) {
std::stringstream ss;
ss << "analog/" << channel;
m_impl = new SimFloatInput(ss.str());
@@ -54,7 +54,7 @@ float AnalogInput::GetAverageVoltage() const { return m_impl->Get(); }
*
* @return The channel number.
*/
uint32_t AnalogInput::GetChannel() const { return m_channel; }
int AnalogInput::GetChannel() const { return m_channel; }
/**
* Get the Average value for the PID Source base object.

View File

@@ -17,7 +17,7 @@
*
* @param channel The digital channel (1..14).
*/
DigitalInput::DigitalInput(uint32_t channel) : m_channel(channel) {
DigitalInput::DigitalInput(int channel) : m_channel(channel) {
std::stringstream ss;
ss << "dio/" << channel;
m_impl = new SimDigitalInput(ss.str());
@@ -27,12 +27,12 @@ DigitalInput::DigitalInput(uint32_t channel) : m_channel(channel) {
* Get the value from a digital input channel.
* Retrieve the value of a single digital input channel from the FPGA.
*/
uint32_t DigitalInput::Get() const { return m_impl->Get(); }
int DigitalInput::Get() const { return m_impl->Get(); }
/**
* @return The GPIO channel number that this object represents.
*/
uint32_t DigitalInput::GetChannel() const { return m_channel; }
int DigitalInput::GetChannel() const { return m_channel; }
void DigitalInput::UpdateTable() {
if (m_table != nullptr) {

View File

@@ -16,7 +16,7 @@
* @param forwardChannel The forward channel on the module to control.
* @param reverseChannel The reverse channel on the module to control.
*/
DoubleSolenoid::DoubleSolenoid(uint32_t forwardChannel, uint32_t reverseChannel)
DoubleSolenoid::DoubleSolenoid(int forwardChannel, int reverseChannel)
: DoubleSolenoid(1, forwardChannel, reverseChannel) {}
/**
@@ -26,8 +26,8 @@ DoubleSolenoid::DoubleSolenoid(uint32_t forwardChannel, uint32_t reverseChannel)
* @param forwardChannel The forward channel on the module to control.
* @param reverseChannel The reverse channel on the module to control.
*/
DoubleSolenoid::DoubleSolenoid(uint8_t moduleNumber, uint32_t forwardChannel,
uint32_t reverseChannel) {
DoubleSolenoid::DoubleSolenoid(int moduleNumber, int forwardChannel,
int reverseChannel) {
m_reversed = false;
if (reverseChannel < forwardChannel) { // Swap ports to get the right address
int channel = reverseChannel;

View File

@@ -17,11 +17,11 @@
#include "WPIErrors.h"
#include "simulation/MainNode.h"
const uint32_t DriverStation::kBatteryChannel;
const uint32_t DriverStation::kJoystickPorts;
const uint32_t DriverStation::kJoystickAxes;
const int DriverStation::kBatteryChannel;
const int DriverStation::kJoystickPorts;
const int DriverStation::kJoystickAxes;
const float DriverStation::kUpdatePeriod = 0.02;
uint8_t DriverStation::m_updateNumber = 0;
int DriverStation::m_updateNumber = 0;
/**
* DriverStation contructor.
@@ -78,7 +78,7 @@ float DriverStation::GetBatteryVoltage() const {
* @param axis The analog axis value to read from the joystick.
* @return The value of the axis on the joystick.
*/
float DriverStation::GetStickAxis(uint32_t stick, uint32_t axis) {
float DriverStation::GetStickAxis(int stick, int axis) {
if (axis < 0 || axis > (kJoystickAxes - 1)) {
wpi_setWPIError(BadJoystickAxis);
return 0.0;
@@ -105,7 +105,7 @@ float DriverStation::GetStickAxis(uint32_t stick, uint32_t axis) {
* @param button The button number to check.
* @return If the button is pressed.
*/
bool DriverStation::GetStickButton(uint32_t stick, uint32_t button) {
bool DriverStation::GetStickButton(int stick, int button) {
if (stick < 0 || stick >= 6) {
wpi_setWPIErrorWithContext(ParameterOutOfRange,
"stick must be between 0 and 5");
@@ -128,7 +128,7 @@ bool DriverStation::GetStickButton(uint32_t stick, uint32_t button) {
* @param stick The joystick to read.
* @return The state of the buttons on the joystick.
*/
int16_t DriverStation::GetStickButtons(uint32_t stick) {
int16_t DriverStation::GetStickButtons(int stick) {
if (stick < 0 || stick >= 6) {
wpi_setWPIErrorWithContext(ParameterOutOfRange,
"stick must be between 0 and 5");
@@ -161,7 +161,7 @@ int16_t DriverStation::GetStickButtons(uint32_t stick) {
* Valid range is 1 - 4.
* @return The analog voltage on the input.
*/
float DriverStation::GetAnalogIn(uint32_t channel) {
float DriverStation::GetAnalogIn(int channel) {
wpi_setWPIErrorWithContext(UnsupportedInSimulation, "GetAnalogIn");
return 0.0;
}
@@ -174,7 +174,7 @@ float DriverStation::GetAnalogIn(uint32_t channel) {
*
* @param channel The digital input to get. Valid range is 1 - 8.
*/
bool DriverStation::GetDigitalIn(uint32_t channel) {
bool DriverStation::GetDigitalIn(int channel) {
wpi_setWPIErrorWithContext(UnsupportedInSimulation, "GetDigitalIn");
return false;
}
@@ -188,7 +188,7 @@ bool DriverStation::GetDigitalIn(uint32_t channel) {
* @param channel The digital output to set. Valid range is 1 - 8.
* @param value The state to set the digital output.
*/
void DriverStation::SetDigitalOut(uint32_t channel, bool value) {
void DriverStation::SetDigitalOut(int channel, bool value) {
wpi_setWPIErrorWithContext(UnsupportedInSimulation, "SetDigitalOut");
}
@@ -198,7 +198,7 @@ void DriverStation::SetDigitalOut(uint32_t channel, bool value) {
* @param channel The digital ouput to monitor. Valid range is 1 through 8.
* @return A digital value being output on the Drivers Station.
*/
bool DriverStation::GetDigitalOut(uint32_t channel) {
bool DriverStation::GetDigitalOut(int channel) {
wpi_setWPIErrorWithContext(UnsupportedInSimulation, "GetDigitalOut");
return false;
}
@@ -253,7 +253,7 @@ DriverStation::Alliance DriverStation::GetAlliance() const {
* This could return 1, 2, or 3.
* @return The location of the driver station
*/
uint32_t DriverStation::GetLocation() const {
int DriverStation::GetLocation() const {
return -1; // TODO: Support locations
}
@@ -304,7 +304,7 @@ void DriverStation::ReportWarning(std::string error) {
* Report an error to the DriverStation messages window.
* The error is also printed to the program console.
*/
void DriverStation::ReportError(bool is_error, int32_t code,
void DriverStation::ReportError(bool is_error, int code,
const std::string& error,
const std::string& location,
const std::string& stack) {

View File

@@ -10,7 +10,6 @@
#include <sstream>
#include "LiveWindow/LiveWindow.h"
#include "Resource.h"
#include "WPIErrors.h"
/**
@@ -30,15 +29,15 @@
* value will either exactly match the spec'd count or
* be double (2x) the spec'd count.
*/
void Encoder::InitEncoder(int32_t channelA, int32_t channelB,
bool reverseDirection, EncodingType encodingType) {
void Encoder::InitEncoder(int channelA, int channelB, bool reverseDirection,
EncodingType encodingType) {
m_table = nullptr;
this->channelA = channelA;
this->channelB = channelB;
m_encodingType = encodingType;
m_encodingScale = encodingType == k4X ? 4 : encodingType == k2X ? 2 : 1;
int32_t index = 0;
int index = 0;
m_distancePerPulse = 1.0;
LiveWindow::GetInstance()->AddSensor("Encoder", channelA, this);
@@ -77,7 +76,7 @@ void Encoder::InitEncoder(int32_t channelA, int32_t channelB,
* 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) {
InitEncoder(aChannel, bChannel, reverseDirection, encodingType);
}
@@ -204,7 +203,7 @@ double Encoder::DecodingScaleFactor() const {
*
* Used to divide raw edge counts down to spec'd counts.
*/
int32_t Encoder::GetEncodingScale() const { return m_encodingScale; }
int Encoder::GetEncodingScale() const { return m_encodingScale; }
/**
* Gets the raw value from the encoder.
@@ -214,7 +213,7 @@ int32_t Encoder::GetEncodingScale() const { return m_encodingScale; }
*
* @return Current raw count from the encoder
*/
int32_t Encoder::GetRaw() const {
int Encoder::GetRaw() const {
throw "Simulation doesn't currently support this method.";
}
@@ -227,7 +226,7 @@ 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 {
throw "Simulation doesn't currently support this method.";
}

View File

@@ -11,7 +11,7 @@
/**
* @param channel The PWM channel that the Jaguar is attached to.
*/
Jaguar::Jaguar(uint32_t channel) : SafePWM(channel) {
Jaguar::Jaguar(int channel) : SafePWM(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;
@@ -28,8 +28,7 @@ static bool joySticksInitialized = false;
*
* @param port The port on the driver station that the joystick is plugged into.
*/
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;
@@ -51,21 +50,20 @@ 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_port(port), m_ds(DriverStation::GetInstance()) {
if (!joySticksInitialized) {
for (unsigned i = 0; i < DriverStation::kJoystickPorts; i++)
for (int i = 0; i < DriverStation::kJoystickPorts; i++)
joysticks[i] = nullptr;
joySticksInitialized = true;
}
joysticks[m_port] = this;
m_axes = std::make_unique<uint32_t[]>(numAxisTypes);
m_buttons = std::make_unique<uint32_t[]>(numButtonTypes);
m_axes = std::make_unique<int[]>(numAxisTypes);
m_buttons = std::make_unique<int[]>(numButtonTypes);
}
Joystick* Joystick::GetStickForPort(uint32_t port) {
Joystick* Joystick::GetStickForPort(int port) {
Joystick* stick = joysticks[port];
if (stick == nullptr) {
stick = new Joystick(port);
@@ -121,7 +119,7 @@ float Joystick::GetThrottle() const {
* @param axis The axis to read [1-6].
* @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);
}
@@ -199,7 +197,7 @@ bool Joystick::GetBumper(JoystickHand hand) const {
* @param button The button number to be read.
* @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);
}
@@ -208,7 +206,7 @@ bool Joystick::GetRawButton(uint32_t button) const {
*
* @return the angle of the POV in degrees, or -1 if the POV is not pressed.
*/
int Joystick::GetPOV(uint32_t pov) const {
int Joystick::GetPOV(int pov) const {
return 0; // TODO
}
@@ -237,7 +235,7 @@ bool Joystick::GetButton(ButtonType button) const {
* @param axis The axis to look up the channel for.
* @return The channel fr the axis.
*/
uint32_t Joystick::GetAxisChannel(AxisType axis) { return m_axes[axis]; }
int Joystick::GetAxisChannel(AxisType axis) { return m_axes[axis]; }
/**
* Set the channel associated with a specified axis.
@@ -245,7 +243,7 @@ uint32_t Joystick::GetAxisChannel(AxisType axis) { 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;
}

View File

@@ -80,7 +80,7 @@ void Notifier::UpdateAlarm() {}
* long as its scheduled time is after the current time. Then the item is
* removed or rescheduled (repetitive events) in the queue.
*/
void Notifier::ProcessQueue(uint32_t mask, void* params) {
void Notifier::ProcessQueue(int mask, void* params) {
Notifier* current;
// keep processing events until no more

View File

@@ -81,7 +81,7 @@ PIDController::PIDController(float Kp, float Ki, float Kd, float Kf,
m_controlLoop = std::make_unique<Notifier>(&PIDController::Calculate, this);
m_controlLoop->StartPeriodic(m_period);
static int32_t instances = 0;
static int instances = 0;
instances++;
m_toleranceType = kNoTolerance;
@@ -483,7 +483,7 @@ void PIDController::SetPercentTolerance(float percent) {
* not register as on target for at least the specified bufLength cycles.
* @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> lock(m_mutex);
m_bufLength = bufLength;

View File

@@ -14,8 +14,8 @@
const float PWM::kDefaultPwmPeriod = 5.05;
const float PWM::kDefaultPwmCenter = 1.5;
const int32_t PWM::kDefaultPwmStepsDown = 1000;
const int32_t PWM::kPwmDisabled = 0;
const int PWM::kDefaultPwmStepsDown = 1000;
const int PWM::kPwmDisabled = 0;
/**
* Allocate a PWM given a channel number.
@@ -27,7 +27,7 @@ const int32_t PWM::kPwmDisabled = 0;
* @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 ss;
if (!CheckPWMChannel(channel)) {
@@ -73,8 +73,8 @@ void PWM::EnableDeadbandElimination(bool eliminateDeadband) {
* @param deadbandMin The low end of the deadband range
* @param min The minimum pwm value
*/
void PWM::SetBounds(int32_t max, int32_t deadbandMax, int32_t center,
int32_t deadbandMin, int32_t min) {
void PWM::SetBounds(int max, int deadbandMax, int center, int deadbandMin,
int min) {
// Nothing to do in simulation.
}

View File

@@ -22,7 +22,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 ss;
if (!SensorBase::CheckRelayChannel(m_channel)) {
@@ -138,7 +138,7 @@ Relay::Value Relay::Get() const {
}
}
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

@@ -16,7 +16,7 @@
#undef max
#include <algorithm>
const int32_t RobotDrive::kMaxNumberOfMotors;
const int RobotDrive::kMaxNumberOfMotors;
static auto make_shared_nodelete(SpeedController* ptr) {
return std::shared_ptr<SpeedController>(ptr, NullDeleter<SpeedController>());
@@ -52,7 +52,7 @@ void RobotDrive::InitRobotDrive() {
* @param leftMotorChannel The PWM channel number that drives the left motor.
* @param rightMotorChannel The PWM channel number that drives the right motor.
*/
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);
@@ -72,8 +72,8 @@ RobotDrive::RobotDrive(uint32_t leftMotorChannel, uint32_t rightMotorChannel) {
* @param frontRightMotor Front right motor channel number
* @param rearRightMotor Rear Right motor channel number
*/
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);
@@ -266,8 +266,8 @@ void RobotDrive::TankDrive(GenericHID& leftStick, GenericHID& rightStick,
* @param rightStick The Joystick object to use for the right side of the 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);
@@ -277,8 +277,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);
@@ -371,8 +371,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);
@@ -396,8 +396,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);
@@ -630,7 +630,7 @@ float RobotDrive::Limit(float num) {
*/
void RobotDrive::Normalize(double* wheelSpeeds) {
double maxMagnitude = fabs(wheelSpeeds[0]);
int32_t i;
int i;
for (i = 1; i < kMaxNumberOfMotors; i++) {
double temp = fabs(wheelSpeeds[i]);
if (maxMagnitude < temp) maxMagnitude = temp;

View File

@@ -14,7 +14,7 @@
*
* @param channel The PWM channel number (0..19).
*/
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

@@ -18,7 +18,7 @@
#include <unistd.h>
#elif defined(_WIN32)
#include <windows.h>
void sleep(unsigned milliseconds) { Sleep(milliseconds); }
void sleep(unsigned int milliseconds) { Sleep(milliseconds); }
#endif
SampleRobot::SampleRobot() : m_robotMainOverridden(true) {}

View File

@@ -18,7 +18,7 @@
*
* @param channel The channel on the solenoid module to control (1..8).
*/
Solenoid::Solenoid(uint32_t channel) : Solenoid(1, channel) {}
Solenoid::Solenoid(int channel) : Solenoid(1, channel) {}
/**
* Constructor.
@@ -26,7 +26,7 @@ Solenoid::Solenoid(uint32_t channel) : Solenoid(1, channel) {}
* @param moduleNumber The solenoid module (1 or 2).
* @param channel The channel on the solenoid module to control (1..8).
*/
Solenoid::Solenoid(uint8_t moduleNumber, uint32_t channel) {
Solenoid::Solenoid(int moduleNumber, int channel) {
std::stringstream ss;
ss << "pneumatic/" << moduleNumber << "/" << channel;
m_impl = new SimContinuousOutput(ss.str());

View File

@@ -12,7 +12,7 @@
/**
* @param channel The PWM channel that the Talon is attached to.
*/
Talon::Talon(uint32_t channel) : SafePWM(channel) {
Talon::Talon(int channel) : SafePWM(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

@@ -53,8 +53,8 @@ static void wpi_handleTracing() {
* 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 errorStream;
@@ -84,8 +84,7 @@ bool wpi_assert_impl(bool conditionValue, const char* conditionText,
void wpi_assertEqual_common_impl(int valueA, int valueB,
const std::string& equalityType,
const std::string& message,
const std::string& fileName,
uint32_t lineNumber,
const std::string& fileName, int lineNumber,
const std::string& funcName) {
// Error string buffer
std::stringstream error;
@@ -116,7 +115,7 @@ void wpi_assertEqual_common_impl(int valueA, int valueB,
* Utility.h.
*/
bool wpi_assertEqual_impl(int valueA, int valueB, const std::string& message,
const std::string& fileName, uint32_t lineNumber,
const std::string& fileName, int lineNumber,
const std::string& funcName) {
if (!(valueA == valueB)) {
wpi_assertEqual_common_impl(valueA, valueB, "!=", message, fileName,
@@ -133,7 +132,7 @@ bool wpi_assertEqual_impl(int valueA, int valueB, const std::string& message,
* Utility.h.
*/
bool wpi_assertNotEqual_impl(int valueA, int valueB, const std::string& message,
const std::string& fileName, uint32_t lineNumber,
const std::string& fileName, int lineNumber,
const std::string& funcName) {
if (!(valueA != valueB)) {
wpi_assertEqual_common_impl(valueA, valueB, "==", message, fileName,
@@ -159,7 +158,7 @@ uint64_t GetFPGATime() { return wpilib::internal::simTime * 1e6; }
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);
@@ -180,7 +179,7 @@ static std::string demangle(char const* mangledSymbol) {
/**
* Get a stack trace, ignoring the first "offset" symbols.
*/
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);
@@ -202,7 +201,5 @@ std::string GetStackTrace(uint32_t offset) {
static std::string demangle(char const* mangledSymbol) {
return "no demangling on windows";
}
std::string GetStackTrace(uint32_t offset) {
return "no stack trace on windows";
}
std::string GetStackTrace(int offset) { return "no stack trace on windows"; }
#endif

View File

@@ -12,7 +12,7 @@
/**
* @param channel The PWM channel that the Victor is attached to.
*/
Victor::Victor(uint32_t channel) : SafePWM(channel) {
Victor::Victor(int channel) : SafePWM(channel) {
/* Note that the Victor uses the following bounds for PWM values. These values
* were determined empirically and optimized for the Victor 888. These values
* should work reasonably well for Victor 884 controllers as well but if users