diff --git a/networktables/cpp/include/networktables2/connection/BadMessageException.h b/networktables/cpp/include/networktables2/connection/BadMessageException.h
index bea48bfcbc..c1fad836c3 100644
--- a/networktables/cpp/include/networktables2/connection/BadMessageException.h
+++ b/networktables/cpp/include/networktables2/connection/BadMessageException.h
@@ -15,7 +15,7 @@ class BadMessageException : public std::exception
{
public:
BadMessageException(const char* message);
- ~BadMessageException() throw ();
+ ~BadMessageException() noexcept;
const char* what() const noexcept;
private:
std::string message;
diff --git a/networktables/cpp/lib/share/networktables2/connection/BadMessageException.cpp b/networktables/cpp/lib/share/networktables2/connection/BadMessageException.cpp
index 9859d812ad..403ed9b0a3 100644
--- a/networktables/cpp/lib/share/networktables2/connection/BadMessageException.cpp
+++ b/networktables/cpp/lib/share/networktables2/connection/BadMessageException.cpp
@@ -13,7 +13,7 @@ BadMessageException::BadMessageException(const char* msg)
}
-BadMessageException::~BadMessageException() throw ()
+BadMessageException::~BadMessageException() noexcept
{
}
diff --git a/wpilibc/wpilibC++/include/Buttons/ButtonScheduler.h b/wpilibc/wpilibC++/include/Buttons/ButtonScheduler.h
index 7accbc9e36..6222da710c 100644
--- a/wpilibc/wpilibC++/include/Buttons/ButtonScheduler.h
+++ b/wpilibc/wpilibC++/include/Buttons/ButtonScheduler.h
@@ -14,7 +14,7 @@ class Command;
class ButtonScheduler {
public:
ButtonScheduler(bool last, Trigger *button, Command *orders);
- virtual ~ButtonScheduler() {}
+ virtual ~ButtonScheduler() = default;
virtual void Execute() = 0;
void Start();
diff --git a/wpilibc/wpilibC++/include/Buttons/CancelButtonScheduler.h b/wpilibc/wpilibC++/include/Buttons/CancelButtonScheduler.h
index ea5f8ff2d0..ba3ba2475a 100644
--- a/wpilibc/wpilibC++/include/Buttons/CancelButtonScheduler.h
+++ b/wpilibc/wpilibC++/include/Buttons/CancelButtonScheduler.h
@@ -16,7 +16,7 @@ class Command;
class CancelButtonScheduler : public ButtonScheduler {
public:
CancelButtonScheduler(bool last, Trigger *button, Command *orders);
- virtual ~CancelButtonScheduler() {}
+ virtual ~CancelButtonScheduler() = default;
virtual void Execute();
private:
diff --git a/wpilibc/wpilibC++/include/Buttons/HeldButtonScheduler.h b/wpilibc/wpilibC++/include/Buttons/HeldButtonScheduler.h
index f68bcd70e7..6dcd7a36f3 100644
--- a/wpilibc/wpilibC++/include/Buttons/HeldButtonScheduler.h
+++ b/wpilibc/wpilibC++/include/Buttons/HeldButtonScheduler.h
@@ -16,7 +16,7 @@ class Command;
class HeldButtonScheduler : public ButtonScheduler {
public:
HeldButtonScheduler(bool last, Trigger *button, Command *orders);
- virtual ~HeldButtonScheduler() {}
+ virtual ~HeldButtonScheduler() = default;
virtual void Execute();
};
diff --git a/wpilibc/wpilibC++/include/Buttons/InternalButton.h b/wpilibc/wpilibC++/include/Buttons/InternalButton.h
index 5f54d34818..fdad6f991a 100644
--- a/wpilibc/wpilibC++/include/Buttons/InternalButton.h
+++ b/wpilibc/wpilibC++/include/Buttons/InternalButton.h
@@ -12,9 +12,9 @@
class InternalButton : public Button {
public:
- InternalButton();
+ InternalButton() = default;
InternalButton(bool inverted);
- virtual ~InternalButton() {}
+ virtual ~InternalButton() = default;
void SetInverted(bool inverted);
void SetPressed(bool pressed);
@@ -22,8 +22,8 @@ class InternalButton : public Button {
virtual bool Get();
private:
- bool m_pressed;
- bool m_inverted;
+ bool m_pressed = false;
+ bool m_inverted = false;
};
#endif
diff --git a/wpilibc/wpilibC++/include/Buttons/JoystickButton.h b/wpilibc/wpilibC++/include/Buttons/JoystickButton.h
index f34f36561a..028efeaf7d 100644
--- a/wpilibc/wpilibC++/include/Buttons/JoystickButton.h
+++ b/wpilibc/wpilibC++/include/Buttons/JoystickButton.h
@@ -14,7 +14,7 @@
class JoystickButton : public Button {
public:
JoystickButton(GenericHID *joystick, int buttonNumber);
- virtual ~JoystickButton() {}
+ virtual ~JoystickButton() = default;
virtual bool Get();
diff --git a/wpilibc/wpilibC++/include/Buttons/NetworkButton.h b/wpilibc/wpilibC++/include/Buttons/NetworkButton.h
index 6ec0c1ea79..19d2249213 100644
--- a/wpilibc/wpilibC++/include/Buttons/NetworkButton.h
+++ b/wpilibc/wpilibC++/include/Buttons/NetworkButton.h
@@ -15,7 +15,7 @@ class NetworkButton : public Button {
public:
NetworkButton(const char *tableName, const char *field);
NetworkButton(ITable *table, const char *field);
- virtual ~NetworkButton() {}
+ virtual ~NetworkButton() = default;
virtual bool Get();
diff --git a/wpilibc/wpilibC++/include/Buttons/PressedButtonScheduler.h b/wpilibc/wpilibC++/include/Buttons/PressedButtonScheduler.h
index 4acb1a1498..62ff7a8496 100644
--- a/wpilibc/wpilibC++/include/Buttons/PressedButtonScheduler.h
+++ b/wpilibc/wpilibC++/include/Buttons/PressedButtonScheduler.h
@@ -16,7 +16,7 @@ class Command;
class PressedButtonScheduler : public ButtonScheduler {
public:
PressedButtonScheduler(bool last, Trigger *button, Command *orders);
- virtual ~PressedButtonScheduler() {}
+ virtual ~PressedButtonScheduler() = default;
virtual void Execute();
};
diff --git a/wpilibc/wpilibC++/include/Buttons/ReleasedButtonScheduler.h b/wpilibc/wpilibC++/include/Buttons/ReleasedButtonScheduler.h
index e0fceeaf6c..2a29981ed9 100644
--- a/wpilibc/wpilibC++/include/Buttons/ReleasedButtonScheduler.h
+++ b/wpilibc/wpilibC++/include/Buttons/ReleasedButtonScheduler.h
@@ -16,7 +16,7 @@ class Command;
class ReleasedButtonScheduler : public ButtonScheduler {
public:
ReleasedButtonScheduler(bool last, Trigger *button, Command *orders);
- virtual ~ReleasedButtonScheduler() {}
+ virtual ~ReleasedButtonScheduler() = default;
virtual void Execute();
};
diff --git a/wpilibc/wpilibC++/include/Buttons/ToggleButtonScheduler.h b/wpilibc/wpilibC++/include/Buttons/ToggleButtonScheduler.h
index 42d52bd15a..d79b4561f8 100644
--- a/wpilibc/wpilibC++/include/Buttons/ToggleButtonScheduler.h
+++ b/wpilibc/wpilibC++/include/Buttons/ToggleButtonScheduler.h
@@ -16,7 +16,7 @@ class Command;
class ToggleButtonScheduler : public ButtonScheduler {
public:
ToggleButtonScheduler(bool last, Trigger *button, Command *orders);
- virtual ~ToggleButtonScheduler() {}
+ virtual ~ToggleButtonScheduler() = default;
virtual void Execute();
private:
diff --git a/wpilibc/wpilibC++/include/Buttons/Trigger.h b/wpilibc/wpilibC++/include/Buttons/Trigger.h
index 056042f16d..c5e38a42c5 100644
--- a/wpilibc/wpilibC++/include/Buttons/Trigger.h
+++ b/wpilibc/wpilibC++/include/Buttons/Trigger.h
@@ -31,8 +31,8 @@ class Command;
*/
class Trigger : public Sendable {
public:
- Trigger();
- virtual ~Trigger() {}
+ Trigger() = default;
+ virtual ~Trigger() = default;
bool Grab();
virtual bool Get() = 0;
void WhenActive(Command *command);
@@ -46,7 +46,7 @@ class Trigger : public Sendable {
virtual std::string GetSmartDashboardType() const;
protected:
- ITable *m_table;
+ ITable *m_table = nullptr;
};
#endif
diff --git a/wpilibc/wpilibC++/include/Commands/Command.h b/wpilibc/wpilibC++/include/Commands/Command.h
index 0eccd3c40d..99d4feb7f7 100644
--- a/wpilibc/wpilibC++/include/Commands/Command.h
+++ b/wpilibc/wpilibC++/include/Commands/Command.h
@@ -131,7 +131,6 @@ class Command : public ErrorBase, public NamedSendable, public ITableListener {
virtual void _Cancel();
private:
- void InitCommand(const char *name, double timeout);
void LockChanges();
/*synchronized*/ void Removed();
void StartRunning();
@@ -139,28 +138,39 @@ class Command : public ErrorBase, public NamedSendable, public ITableListener {
/** The name of this command */
std::string m_name;
+
/** The time since this command was initialized */
- double m_startTime;
+ double m_startTime = -1;
+
/** The time (in seconds) before this command "times out" (or -1 if no
* timeout) */
double m_timeout;
+
/** Whether or not this command has been initialized */
- bool m_initialized;
+ bool m_initialized = false;
+
/** The requirements (or null if no requirements) */
SubsystemSet m_requirements;
+
/** Whether or not it is running */
- bool m_running;
+ bool m_running = false;
+
/** Whether or not it is interruptible*/
- bool m_interruptible;
+ bool m_interruptible = true;
+
/** Whether or not it has been canceled */
- bool m_canceled;
+ bool m_canceled = false;
+
/** Whether or not it has been locked */
- bool m_locked;
+ bool m_locked = false;
+
/** Whether this command should run when the robot is disabled */
- bool m_runWhenDisabled;
+ bool m_runWhenDisabled = false;
+
/** The {@link CommandGroup} this is in */
- CommandGroup *m_parent;
- int m_commandID;
+ CommandGroup *m_parent = nullptr;
+
+ int m_commandID = m_commandCounter++;
static int m_commandCounter;
public:
@@ -172,7 +182,7 @@ class Command : public ErrorBase, public NamedSendable, public ITableListener {
EntryValue value, bool isNew);
protected:
- ITable *m_table;
+ ITable *m_table = nullptr;
};
#endif
diff --git a/wpilibc/wpilibC++/include/Commands/CommandGroup.h b/wpilibc/wpilibC++/include/Commands/CommandGroup.h
index 302d9c6c1a..c7a87a060a 100644
--- a/wpilibc/wpilibC++/include/Commands/CommandGroup.h
+++ b/wpilibc/wpilibC++/include/Commands/CommandGroup.h
@@ -36,9 +36,9 @@
*/
class CommandGroup : public Command {
public:
- CommandGroup();
+ CommandGroup() = default;
CommandGroup(const char *name);
- virtual ~CommandGroup();
+ virtual ~CommandGroup() = default;
void AddSequential(Command *command);
void AddSequential(Command *command, double timeout);
@@ -61,14 +61,14 @@ class CommandGroup : public Command {
private:
void CancelConflicts(Command *command);
- typedef std::vector CommandVector;
/** The commands in this group (stored in entries) */
- CommandVector m_commands;
- typedef std::list CommandList;
+ std::vector m_commands;
+
/** The active children in this group (stored in entries) */
- CommandList m_children;
+ std::list m_children;
+
/** The current command, -1 signifies that none have been run */
- int m_currentCommandIndex;
+ int m_currentCommandIndex = -1;
};
#endif
diff --git a/wpilibc/wpilibC++/include/Commands/CommandGroupEntry.h b/wpilibc/wpilibC++/include/Commands/CommandGroupEntry.h
index 4a0d96058c..41d1cbe201 100644
--- a/wpilibc/wpilibC++/include/Commands/CommandGroupEntry.h
+++ b/wpilibc/wpilibC++/include/Commands/CommandGroupEntry.h
@@ -18,14 +18,13 @@ class CommandGroupEntry {
kSequence_BranchChild
} Sequence;
- CommandGroupEntry();
- CommandGroupEntry(Command *command, Sequence state);
- CommandGroupEntry(Command *command, Sequence state, double timeout);
+ CommandGroupEntry() = default;
+ CommandGroupEntry(Command *command, Sequence state, double timeout = -1.0);
bool IsTimedOut() const;
double m_timeout;
- Command *m_command;
- Sequence m_state;
+ Command *m_command = nullptr;
+ Sequence m_state = kSequence_InSequence;
};
#endif
diff --git a/wpilibc/wpilibC++/include/Commands/PrintCommand.h b/wpilibc/wpilibC++/include/Commands/PrintCommand.h
index f36d16d942..14ab971386 100644
--- a/wpilibc/wpilibC++/include/Commands/PrintCommand.h
+++ b/wpilibc/wpilibC++/include/Commands/PrintCommand.h
@@ -14,7 +14,7 @@
class PrintCommand : public Command {
public:
PrintCommand(const char *message);
- virtual ~PrintCommand() {}
+ virtual ~PrintCommand() = default;
protected:
virtual void Initialize();
diff --git a/wpilibc/wpilibC++/include/Commands/Scheduler.h b/wpilibc/wpilibC++/include/Commands/Scheduler.h
index c9e81a4f1c..c794f4871b 100644
--- a/wpilibc/wpilibC++/include/Commands/Scheduler.h
+++ b/wpilibc/wpilibC++/include/Commands/Scheduler.h
@@ -50,22 +50,21 @@ class Scheduler : public ErrorBase, public NamedSendable {
void ProcessCommandAddition(Command *command);
- static Scheduler *_instance;
Command::SubsystemSet m_subsystems;
- MUTEX_ID m_buttonsLock;
+ MUTEX_ID m_buttonsLock = nullptr;
typedef std::vector ButtonVector;
ButtonVector m_buttons;
typedef std::vector CommandVector;
- MUTEX_ID m_additionsLock;
+ MUTEX_ID m_additionsLock = nullptr;
CommandVector m_additions;
typedef std::set CommandSet;
CommandSet m_commands;
- bool m_adding;
- bool m_enabled;
- StringArray *commands;
- NumberArray *ids;
- NumberArray *toCancel;
- ITable *m_table;
- bool m_runningCommandsChanged;
+ bool m_adding = false;
+ bool m_enabled = true;
+ StringArray *commands = nullptr;
+ NumberArray *ids = nullptr;
+ NumberArray *toCancel = nullptr;
+ ITable *m_table = nullptr;
+ bool m_runningCommandsChanged = false;
};
#endif
diff --git a/wpilibc/wpilibC++/include/Commands/StartCommand.h b/wpilibc/wpilibC++/include/Commands/StartCommand.h
index 3e612d2b21..8f53d14837 100644
--- a/wpilibc/wpilibC++/include/Commands/StartCommand.h
+++ b/wpilibc/wpilibC++/include/Commands/StartCommand.h
@@ -13,7 +13,7 @@
class StartCommand : public Command {
public:
StartCommand(Command *commandToStart);
- virtual ~StartCommand() {}
+ virtual ~StartCommand() = default;
protected:
virtual void Initialize();
diff --git a/wpilibc/wpilibC++/include/Commands/Subsystem.h b/wpilibc/wpilibC++/include/Commands/Subsystem.h
index a6973d230c..df6d5d86eb 100644
--- a/wpilibc/wpilibC++/include/Commands/Subsystem.h
+++ b/wpilibc/wpilibC++/include/Commands/Subsystem.h
@@ -19,7 +19,7 @@ class Subsystem : public ErrorBase, public NamedSendable {
public:
Subsystem(const char *name);
- virtual ~Subsystem() {}
+ virtual ~Subsystem() = default;
void SetDefaultCommand(Command *command);
Command *GetDefaultCommand();
@@ -30,11 +30,11 @@ class Subsystem : public ErrorBase, public NamedSendable {
private:
void ConfirmCommand();
- Command *m_currentCommand;
- bool m_currentCommandChanged;
- Command *m_defaultCommand;
+ Command *m_currentCommand = nullptr;
+ bool m_currentCommandChanged = true;
+ Command *m_defaultCommand = nullptr;
std::string m_name;
- bool m_initializedDefaultCommand;
+ bool m_initializedDefaultCommand = false;
public:
virtual std::string GetName();
@@ -43,7 +43,7 @@ class Subsystem : public ErrorBase, public NamedSendable {
virtual std::string GetSmartDashboardType() const;
protected:
- ITable *m_table;
+ ITable *m_table = nullptr;
};
#endif
diff --git a/wpilibc/wpilibC++/include/Commands/WaitCommand.h b/wpilibc/wpilibC++/include/Commands/WaitCommand.h
index 7a61968bd2..33e45e9183 100644
--- a/wpilibc/wpilibC++/include/Commands/WaitCommand.h
+++ b/wpilibc/wpilibC++/include/Commands/WaitCommand.h
@@ -14,7 +14,7 @@ class WaitCommand : public Command {
public:
WaitCommand(double timeout);
WaitCommand(const char *name, double timeout);
- virtual ~WaitCommand() {}
+ virtual ~WaitCommand() = default;
protected:
virtual void Initialize();
diff --git a/wpilibc/wpilibC++/include/Commands/WaitForChildren.h b/wpilibc/wpilibC++/include/Commands/WaitForChildren.h
index 17435ce36c..60db4aff06 100644
--- a/wpilibc/wpilibC++/include/Commands/WaitForChildren.h
+++ b/wpilibc/wpilibC++/include/Commands/WaitForChildren.h
@@ -14,7 +14,7 @@ class WaitForChildren : public Command {
public:
WaitForChildren(double timeout);
WaitForChildren(const char *name, double timeout);
- virtual ~WaitForChildren() {}
+ virtual ~WaitForChildren() = default;
protected:
virtual void Initialize();
diff --git a/wpilibc/wpilibC++/include/Commands/WaitUntilCommand.h b/wpilibc/wpilibC++/include/Commands/WaitUntilCommand.h
index dbd08a0873..d445bfae1b 100644
--- a/wpilibc/wpilibC++/include/Commands/WaitUntilCommand.h
+++ b/wpilibc/wpilibC++/include/Commands/WaitUntilCommand.h
@@ -14,7 +14,7 @@ class WaitUntilCommand : public Command {
public:
WaitUntilCommand(double time);
WaitUntilCommand(const char *name, double time);
- virtual ~WaitUntilCommand() {}
+ virtual ~WaitUntilCommand() = default;
protected:
virtual void Initialize();
diff --git a/wpilibc/wpilibC++/include/Controller.h b/wpilibc/wpilibC++/include/Controller.h
index 1b25c2516a..7ececd1151 100644
--- a/wpilibc/wpilibC++/include/Controller.h
+++ b/wpilibc/wpilibC++/include/Controller.h
@@ -20,7 +20,7 @@
*/
class Controller {
public:
- virtual ~Controller(){};
+ virtual ~Controller() = default;
/**
* Allows the control loop to run
diff --git a/wpilibc/wpilibC++/include/Error.h b/wpilibc/wpilibC++/include/Error.h
index 9fde78ec28..9b804ff174 100644
--- a/wpilibc/wpilibC++/include/Error.h
+++ b/wpilibc/wpilibC++/include/Error.h
@@ -21,7 +21,6 @@ class Error {
typedef int32_t Code;
Error();
- ~Error();
void Clone(Error& error);
Code GetCode() const;
const char* GetMessage() const;
@@ -41,13 +40,13 @@ class Error {
private:
void Report();
- Code m_code;
+ Code m_code = 0;
std::string m_message;
std::string m_filename;
std::string m_function;
- uint32_t m_lineNumber;
- const ErrorBase* m_originatingObject;
- double m_timestamp;
+ uint32_t m_lineNumber = 0;
+ const ErrorBase* m_originatingObject = nullptr;
+ double m_timestamp = 0.0;
static bool m_suspendOnErrorEnabled;
DISALLOW_COPY_AND_ASSIGN(Error);
diff --git a/wpilibc/wpilibC++/include/ErrorBase.h b/wpilibc/wpilibC++/include/ErrorBase.h
index 5b0dbce081..d56251e98f 100644
--- a/wpilibc/wpilibC++/include/ErrorBase.h
+++ b/wpilibc/wpilibC++/include/ErrorBase.h
@@ -51,7 +51,8 @@
class ErrorBase {
// TODO: Consider initializing instance variables and cleanup in destructor
public:
- virtual ~ErrorBase();
+ ErrorBase();
+ virtual ~ErrorBase() = default;
virtual Error& GetError();
virtual const Error& GetError() const;
virtual void SetErrnoError(const char* contextMessage, const char* filename,
@@ -82,7 +83,6 @@ class ErrorBase {
// TODO: Replace globalError with a global list of all errors.
static MUTEX_ID _globalErrorMutex;
static Error _globalError;
- ErrorBase();
private:
DISALLOW_COPY_AND_ASSIGN(ErrorBase);
diff --git a/wpilibc/wpilibC++/include/GenericHID.h b/wpilibc/wpilibC++/include/GenericHID.h
index 84f0f76f74..bf1fe8eb9a 100644
--- a/wpilibc/wpilibC++/include/GenericHID.h
+++ b/wpilibc/wpilibC++/include/GenericHID.h
@@ -14,7 +14,7 @@ class GenericHID {
public:
enum JoystickHand { kLeftHand = 0, kRightHand = 1 };
- virtual ~GenericHID() {}
+ virtual ~GenericHID() = default;
virtual float GetX(JoystickHand hand = kRightHand) const = 0;
virtual float GetY(JoystickHand hand = kRightHand) const = 0;
diff --git a/wpilibc/wpilibC++/include/HLUsageReporting.h b/wpilibc/wpilibC++/include/HLUsageReporting.h
index 991125b3a2..5d8d34ffda 100644
--- a/wpilibc/wpilibC++/include/HLUsageReporting.h
+++ b/wpilibc/wpilibC++/include/HLUsageReporting.h
@@ -7,7 +7,7 @@
class HLUsageReportingInterface {
public:
- virtual ~HLUsageReportingInterface(){};
+ virtual ~HLUsageReportingInterface() = default;
virtual void ReportScheduler() = 0;
virtual void ReportSmartDashboard() = 0;
};
diff --git a/wpilibc/wpilibC++/include/LiveWindow/LiveWindow.h b/wpilibc/wpilibC++/include/LiveWindow/LiveWindow.h
index a50c9f99f3..3b4b8f2260 100644
--- a/wpilibc/wpilibC++/include/LiveWindow/LiveWindow.h
+++ b/wpilibc/wpilibC++/include/LiveWindow/LiveWindow.h
@@ -12,7 +12,7 @@ struct LiveWindowComponent {
std::string name;
bool isSensor;
- LiveWindowComponent() {}
+ LiveWindowComponent() = default;
LiveWindowComponent(std::string subsystem, std::string name, bool isSensor) {
this->subsystem = subsystem;
this->name = name;
@@ -46,7 +46,7 @@ class LiveWindow {
protected:
LiveWindow();
- virtual ~LiveWindow();
+ virtual ~LiveWindow() = default;
private:
void UpdateValues();
@@ -61,8 +61,8 @@ class LiveWindow {
Scheduler *m_scheduler;
- bool m_enabled;
- bool m_firstTime;
+ bool m_enabled = false;
+ bool m_firstTime = true;
};
#endif
diff --git a/wpilibc/wpilibC++/include/Notifier.h b/wpilibc/wpilibC++/include/Notifier.h
index 06e3c87c97..b034b12a84 100644
--- a/wpilibc/wpilibC++/include/Notifier.h
+++ b/wpilibc/wpilibC++/include/Notifier.h
@@ -14,7 +14,7 @@ typedef void (*TimerEventHandler)(void *param);
class Notifier : public ErrorBase {
public:
- Notifier(TimerEventHandler handler, void *param = NULL);
+ Notifier(TimerEventHandler handler, void *param = nullptr);
virtual ~Notifier();
void StartSingle(double delay);
void StartPeriodic(double period);
@@ -35,11 +35,11 @@ class Notifier : public ErrorBase {
void DeleteFromQueue(); // delete this Notifier from the timer queue
TimerEventHandler m_handler; // address of the handler
void *m_param; // a parameter to pass to the handler
- double m_period; // the relative time (either periodic or single)
- double m_expirationTime; // absolute expiration time for the current event
- Notifier *m_nextEvent; // next Nofifier event
- bool m_periodic; // true if this is a periodic event
- bool m_queued; // indicates if this entry is queued
+ double m_period = 0; // the relative time (either periodic or single)
+ double m_expirationTime = 0; // absolute expiration time for the current event
+ Notifier *m_nextEvent = nullptr; // next Nofifier event
+ bool m_periodic = false; // true if this is a periodic event
+ bool m_queued = false; // indicates if this entry is queued
SEMAPHORE_ID m_handlerSemaphore; // held by interrupt manager task while
// handler call is in progress
diff --git a/wpilibc/wpilibC++/include/PIDController.h b/wpilibc/wpilibC++/include/PIDController.h
index 19da382cbe..135055ac9f 100644
--- a/wpilibc/wpilibC++/include/PIDController.h
+++ b/wpilibc/wpilibC++/include/PIDController.h
@@ -59,31 +59,35 @@ class PIDController : public LiveWindowSendable,
virtual void Reset() override;
- virtual void InitTable(ITable *table);
+ virtual void InitTable(ITable *table) override;
private:
float m_P; // factor for "proportional" control
float m_I; // factor for "integral" control
float m_D; // factor for "derivative" control
float m_F; // factor for "feed forward" control
- float m_maximumOutput; // |maximum output|
- float m_minimumOutput; // |minimum output|
- float m_maximumInput; // maximum input - limit setpoint to this
- float m_minimumInput; // minimum input - limit setpoint to this
- bool m_continuous; // do the endpoints wrap around? eg. Absolute encoder
- bool m_enabled; // is the pid controller enabled
+ float m_maximumOutput = 1.0; // |maximum output|
+ float m_minimumOutput = -1.0; // |minimum output|
+ float m_maximumInput = 0; // maximum input - limit setpoint to this
+ float m_minimumInput = 0; // minimum input - limit setpoint to this
+ bool m_continuous = false; // do the endpoints wrap around? eg. Absolute encoder
+ bool m_enabled = false; // is the pid controller enabled
bool m_destruct; // should the calculate thread stop running
- float m_prevError; // the prior sensor input (used to compute velocity)
- double m_totalError; // the sum of the errors for use in the integral calc
- enum { kAbsoluteTolerance, kPercentTolerance, kNoTolerance } m_toleranceType;
- float m_tolerance; // the percetage or absolute error that is considered on
+ float m_prevError = 0; // the prior sensor input (used to compute velocity)
+ double m_totalError = 0; // the sum of the errors for use in the integral calc
+ enum {
+ kAbsoluteTolerance,
+ kPercentTolerance,
+ kNoTolerance
+ } m_toleranceType = kNoTolerance;
+ float m_tolerance = 0.05; // the percetage or absolute error that is considered on
// target
- float m_setpoint;
+ float m_setpoint = 0;
float m_error;
- float m_result;
+ float m_result = 0;
float m_period;
- MUTEX_ID m_semaphore;
+ MUTEX_ID m_semaphore = 0;
PIDSource *m_pidInput;
PIDOutput *m_pidOutput;
@@ -94,16 +98,16 @@ class PIDController : public LiveWindowSendable,
PIDOutput *output, float period = 0.05);
static void CallCalculate(void *controller);
- virtual ITable *GetTable() const;
- virtual std::string GetSmartDashboardType() const;
+ virtual ITable *GetTable() const override;
+ virtual std::string GetSmartDashboardType() const override;
virtual void ValueChanged(ITable *source, const std::string &key,
- EntryValue value, bool isNew);
- virtual void UpdateTable();
- virtual void StartLiveWindowMode();
- virtual void StopLiveWindowMode();
+ EntryValue value, bool isNew) override;
+ virtual void UpdateTable() override;
+ virtual void StartLiveWindowMode() override;
+ virtual void StopLiveWindowMode() override;
protected:
- ITable *m_table;
+ ITable *m_table = nullptr;
virtual void Calculate();
DISALLOW_COPY_AND_ASSIGN(PIDController);
diff --git a/wpilibc/wpilibC++/include/RobotState.h b/wpilibc/wpilibC++/include/RobotState.h
index 82dcd3242b..941afc38e3 100644
--- a/wpilibc/wpilibC++/include/RobotState.h
+++ b/wpilibc/wpilibC++/include/RobotState.h
@@ -7,7 +7,7 @@
class RobotStateInterface {
public:
- virtual ~RobotStateInterface(){};
+ virtual ~RobotStateInterface() = default;
virtual bool IsDisabled() const = 0;
virtual bool IsEnabled() const = 0;
virtual bool IsOperatorControl() const = 0;
diff --git a/wpilibc/wpilibC++/include/SensorBase.h b/wpilibc/wpilibC++/include/SensorBase.h
index 3f6f95873f..afff0baf88 100644
--- a/wpilibc/wpilibC++/include/SensorBase.h
+++ b/wpilibc/wpilibC++/include/SensorBase.h
@@ -19,7 +19,7 @@
class SensorBase : public ErrorBase {
public:
SensorBase();
- virtual ~SensorBase();
+ virtual ~SensorBase() = default;
static void DeleteSingletons();
static uint32_t GetDefaultSolenoidModule() { return 0; }
diff --git a/wpilibc/wpilibC++/include/SmartDashboard/SendableChooser.h b/wpilibc/wpilibC++/include/SmartDashboard/SendableChooser.h
index 46d6ccbe08..c3512506a4 100644
--- a/wpilibc/wpilibC++/include/SmartDashboard/SendableChooser.h
+++ b/wpilibc/wpilibC++/include/SmartDashboard/SendableChooser.h
@@ -32,8 +32,7 @@
*/
class SendableChooser : public Sendable {
public:
- SendableChooser();
- virtual ~SendableChooser(){};
+ virtual ~SendableChooser() = default;
void AddObject(const char *name, void *object);
void AddDefault(const char *name, void *object);
diff --git a/wpilibc/wpilibC++/include/SmartDashboard/SmartDashboard.h b/wpilibc/wpilibC++/include/SmartDashboard/SmartDashboard.h
index ce490a6388..ce32caae27 100644
--- a/wpilibc/wpilibC++/include/SmartDashboard/SmartDashboard.h
+++ b/wpilibc/wpilibC++/include/SmartDashboard/SmartDashboard.h
@@ -40,9 +40,7 @@ class SmartDashboard : public SensorBase {
static void RetrieveValue(std::string keyName, ComplexData &value);
private:
- SmartDashboard();
- virtual ~SmartDashboard();
- DISALLOW_COPY_AND_ASSIGN(SmartDashboard);
+ virtual ~SmartDashboard() = default;
/** The {@link NetworkTable} used by {@link SmartDashboard} */
static ITable *m_table;
diff --git a/wpilibc/wpilibC++/include/Task.h b/wpilibc/wpilibC++/include/Task.h
index 123e3224cb..a394d46d1d 100644
--- a/wpilibc/wpilibC++/include/Task.h
+++ b/wpilibc/wpilibC++/include/Task.h
@@ -44,7 +44,7 @@ class Task : public ErrorBase {
private:
FUNCPTR m_function;
char* m_taskName;
- TASK m_taskID;
+ TASK m_taskID = NULL_TASK;
uint32_t m_stackSize;
int m_priority;
bool HandleError(STATUS results);
diff --git a/wpilibc/wpilibC++/include/Timer.h b/wpilibc/wpilibC++/include/Timer.h
index 0a8b69c68d..bd914806b5 100644
--- a/wpilibc/wpilibC++/include/Timer.h
+++ b/wpilibc/wpilibC++/include/Timer.h
@@ -43,9 +43,9 @@ class Timer {
static constexpr double kRolloverTime = (1ll << 32) / 1e6;
private:
- double m_startTime;
- double m_accumulatedTime;
- bool m_running;
- MUTEX_ID m_semaphore;
+ double m_startTime = 0.0;
+ double m_accumulatedTime = 0.0;
+ bool m_running = false;
+ MUTEX_ID m_semaphore = nullptr;
DISALLOW_COPY_AND_ASSIGN(Timer);
};
diff --git a/wpilibc/wpilibC++/include/Utility.h b/wpilibc/wpilibC++/include/Utility.h
index 9b2f1d4f84..345b694c66 100644
--- a/wpilibc/wpilibC++/include/Utility.h
+++ b/wpilibc/wpilibC++/include/Utility.h
@@ -14,18 +14,18 @@
#include
#define wpi_assert(condition) \
- wpi_assert_impl(condition, #condition, NULL, __FILE__, __LINE__, __FUNCTION__)
+ wpi_assert_impl(condition, #condition, nullptr, __FILE__, __LINE__, __FUNCTION__)
#define wpi_assertWithMessage(condition, message) \
wpi_assert_impl(condition, #condition, message, __FILE__, __LINE__, \
__FUNCTION__)
#define wpi_assertEqual(a, b) \
- wpi_assertEqual_impl(a, b, #a, #b, NULL, __FILE__, __LINE__, __FUNCTION__)
+ wpi_assertEqual_impl(a, b, #a, #b, nullptr, __FILE__, __LINE__, __FUNCTION__)
#define wpi_assertEqualWithMessage(a, b, message) \
wpi_assertEqual_impl(a, b, #a, #b, message, __FILE__, __LINE__, __FUNCTION__)
#define wpi_assertNotEqual(a, b) \
- wpi_assertNotEqual_impl(a, b, #a, #b, NULL, __FILE__, __LINE__, __FUNCTION__)
+ wpi_assertNotEqual_impl(a, b, #a, #b, nullptr, __FILE__, __LINE__, __FUNCTION__)
#define wpi_assertNotEqualWithMessage(a, b, message) \
wpi_assertNotEqual_impl(a, b, #a, #b, message, __FILE__, __LINE__, \
__FUNCTION__)
diff --git a/wpilibc/wpilibC++/include/WPIErrors.h b/wpilibc/wpilibC++/include/WPIErrors.h
index 1a751b631f..25cb5fe7be 100644
--- a/wpilibc/wpilibC++/include/WPIErrors.h
+++ b/wpilibc/wpilibC++/include/WPIErrors.h
@@ -27,7 +27,7 @@ S(ChannelIndexOutOfRange, -1, "Allocating channel that is out of range");
S(NotAllocated, -2, "Attempting to free unallocated resource");
S(ResourceAlreadyAllocated, -3, "Attempted to reuse an allocated resource");
S(NoAvailableResources, -4, "No available resources to allocate");
-S(NullParameter, -5, "A pointer parameter to a method is NULL");
+S(NullParameter, -5, "A pointer parameter to a method is nullptr");
S(Timeout, -6, "A timeout has been exceeded");
S(CompassManufacturerError, -7, "Compass manufacturer doesn't match HiTechnic");
S(CompassTypeError, -8,
diff --git a/wpilibc/wpilibC++/include/interfaces/Accelerometer.h b/wpilibc/wpilibC++/include/interfaces/Accelerometer.h
index 9c024f1dc6..528d1200a7 100644
--- a/wpilibc/wpilibC++/include/interfaces/Accelerometer.h
+++ b/wpilibc/wpilibC++/include/interfaces/Accelerometer.h
@@ -10,7 +10,7 @@
*/
class Accelerometer {
public:
- virtual ~Accelerometer(){};
+ virtual ~Accelerometer() = default;
enum Range { kRange_2G = 0, kRange_4G = 1, kRange_8G = 2, kRange_16G = 3 };
diff --git a/wpilibc/wpilibC++/include/interfaces/Potentiometer.h b/wpilibc/wpilibC++/include/interfaces/Potentiometer.h
index f89da062af..66c2eb887f 100644
--- a/wpilibc/wpilibC++/include/interfaces/Potentiometer.h
+++ b/wpilibc/wpilibC++/include/interfaces/Potentiometer.h
@@ -15,7 +15,7 @@
*/
class Potentiometer : public PIDSource {
public:
- virtual ~Potentiometer(){};
+ virtual ~Potentiometer() = default;
/**
* Common interface for getting the current value of a potentiometer.
*
diff --git a/wpilibc/wpilibC++/src/Buttons/InternalButton.cpp b/wpilibc/wpilibC++/src/Buttons/InternalButton.cpp
index 932c943ce1..8c9b22afec 100644
--- a/wpilibc/wpilibC++/src/Buttons/InternalButton.cpp
+++ b/wpilibc/wpilibC++/src/Buttons/InternalButton.cpp
@@ -7,8 +7,6 @@
#include "Buttons/InternalButton.h"
-InternalButton::InternalButton() : m_pressed(false), m_inverted(false) {}
-
InternalButton::InternalButton(bool inverted)
: m_pressed(inverted), m_inverted(inverted) {}
diff --git a/wpilibc/wpilibC++/src/Buttons/Trigger.cpp b/wpilibc/wpilibC++/src/Buttons/Trigger.cpp
index d605cc2a8a..0715868e8d 100644
--- a/wpilibc/wpilibC++/src/Buttons/Trigger.cpp
+++ b/wpilibc/wpilibC++/src/Buttons/Trigger.cpp
@@ -13,12 +13,10 @@
#include "Buttons/ToggleButtonScheduler.h"
#include "Buttons/CancelButtonScheduler.h"
-Trigger::Trigger() { m_table = NULL; }
-
bool Trigger::Grab() {
if (Get())
return true;
- else if (m_table != NULL) {
+ else if (m_table != nullptr) {
// if (m_table->isConnected())//TODO is connected on button?
return m_table->GetBoolean("pressed");
/*else
@@ -28,29 +26,27 @@ bool Trigger::Grab() {
}
void Trigger::WhenActive(Command *command) {
- PressedButtonScheduler *pbs =
- new PressedButtonScheduler(Grab(), this, command);
+ auto pbs = new PressedButtonScheduler(Grab(), this, command);
pbs->Start();
}
void Trigger::WhileActive(Command *command) {
- HeldButtonScheduler *hbs = new HeldButtonScheduler(Grab(), this, command);
+ auto hbs = new HeldButtonScheduler(Grab(), this, command);
hbs->Start();
}
void Trigger::WhenInactive(Command *command) {
- ReleasedButtonScheduler *rbs =
- new ReleasedButtonScheduler(Grab(), this, command);
+ auto rbs = new ReleasedButtonScheduler(Grab(), this, command);
rbs->Start();
}
void Trigger::CancelWhenActive(Command *command) {
- CancelButtonScheduler *cbs = new CancelButtonScheduler(Grab(), this, command);
+ auto cbs = new CancelButtonScheduler(Grab(), this, command);
cbs->Start();
}
void Trigger::ToggleWhenActive(Command *command) {
- ToggleButtonScheduler *tbs = new ToggleButtonScheduler(Grab(), this, command);
+ auto tbs = new ToggleButtonScheduler(Grab(), this, command);
tbs->Start();
}
@@ -58,7 +54,7 @@ std::string Trigger::GetSmartDashboardType() const { return "Button"; }
void Trigger::InitTable(ITable *table) {
m_table = table;
- if (m_table != NULL) {
+ if (m_table != nullptr) {
m_table->PutBoolean("pressed", Get());
}
}
diff --git a/wpilibc/wpilibC++/src/Commands/Command.cpp b/wpilibc/wpilibC++/src/Commands/Command.cpp
index d465681d07..5c6af1b472 100644
--- a/wpilibc/wpilibC++/src/Commands/Command.cpp
+++ b/wpilibc/wpilibC++/src/Commands/Command.cpp
@@ -19,46 +19,24 @@ static const char *kIsParented = "isParented";
int Command::m_commandCounter = 0;
-void Command::InitCommand(const char *name, double timeout) {
- m_commandID = m_commandCounter++;
- m_timeout = timeout;
- m_locked = false;
- m_startTime = -1;
- m_initialized = false;
- m_running = false;
- m_interruptible = true;
- m_canceled = false;
- m_runWhenDisabled = false;
- m_parent = NULL;
- m_name = name == NULL ? std::string() : name;
- m_table = NULL;
-}
-
/**
* Creates a new command.
* The name of this command will be default.
*/
-Command::Command() { InitCommand(NULL, -1.0); }
+Command::Command() : Command(nullptr, -1.0) {}
/**
* Creates a new command with the given name and no timeout.
* @param name the name for this command
*/
-Command::Command(const char *name) {
- if (name == NULL) wpi_setWPIErrorWithContext(NullParameter, "name");
- InitCommand(name, -1.0);
-}
+Command::Command(const char *name) : Command(name, -1.0) {}
/**
* Creates a new command with the given timeout and a default name.
* @param timeout the time (in seconds) before this command "times out"
* @see Command#isTimedOut() isTimedOut()
*/
-Command::Command(double timeout) {
- if (timeout < 0.0)
- wpi_setWPIErrorWithContext(ParameterOutOfRange, "timeout < 0.0");
- InitCommand(NULL, timeout);
-}
+Command::Command(double timeout) : Command(nullptr, timeout) {}
/**
* Creates a new command with the given name and timeout.
@@ -67,14 +45,16 @@ Command::Command(double timeout) {
* @see Command#isTimedOut() isTimedOut()
*/
Command::Command(const char *name, double timeout) {
- if (name == NULL) wpi_setWPIErrorWithContext(NullParameter, "name");
+ if (name == nullptr) wpi_setWPIErrorWithContext(NullParameter, "name");
if (timeout < 0.0)
wpi_setWPIErrorWithContext(ParameterOutOfRange, "timeout < 0.0");
- InitCommand(name, timeout);
+
+ m_timeout = timeout;
+ m_name = name == nullptr ? std::string() : name;
}
Command::~Command() { // TODO deal with cleaning up all listeners
- /*if (m_table != NULL){
+ /*if (m_table != nullptr){
m_table->RemoveChangeListener(kRunning, this);
}*/
}
@@ -124,7 +104,7 @@ double Command::TimeSinceInitialized() const {
void Command::Requires(Subsystem *subsystem) {
if (!AssertUnlocked("Can not add new requirement to command")) return;
- if (subsystem != NULL)
+ if (subsystem != nullptr)
m_requirements.insert(subsystem);
else
wpi_setWPIErrorWithContext(NullParameter, "subsystem");
@@ -148,7 +128,7 @@ void Command::Removed() {
m_initialized = false;
m_canceled = false;
m_running = false;
- if (m_table != NULL) m_table->PutBoolean(kRunning, false);
+ if (m_table != nullptr) m_table->PutBoolean(kRunning, false);
}
/**
@@ -160,7 +140,7 @@ void Command::Removed() {
*/
void Command::Start() {
LockChanges();
- if (m_parent != NULL)
+ if (m_parent != nullptr)
wpi_setWPIErrorWithContext(
CommandIllegalUse,
"Can not start a command that is part of a command group");
@@ -173,7 +153,7 @@ void Command::Start() {
* @return whether or not the command should stay within the {@link Scheduler}.
*/
bool Command::Run() {
- if (!m_runWhenDisabled && m_parent == NULL && RobotState::IsDisabled())
+ if (!m_runWhenDisabled && m_parent == nullptr && RobotState::IsDisabled())
Cancel();
if (IsCanceled()) return false;
@@ -255,16 +235,16 @@ bool Command::AssertUnlocked(const char *message) {
* @param parent the parent
*/
void Command::SetParent(CommandGroup *parent) {
- if (parent == NULL) {
+ if (parent == nullptr) {
wpi_setWPIErrorWithContext(NullParameter, "parent");
- } else if (m_parent != NULL) {
+ } else if (m_parent != nullptr) {
wpi_setWPIErrorWithContext(CommandIllegalUse,
"Can not give command to a command group after "
"already being put in a command group");
} else {
LockChanges();
m_parent = parent;
- if (m_table != NULL) {
+ if (m_table != nullptr) {
m_table->PutBoolean(kIsParented, true);
}
}
@@ -285,7 +265,7 @@ void Command::SetParent(CommandGroup *parent) {
void Command::StartRunning() {
m_running = true;
m_startTime = -1;
- if (m_table != NULL) m_table->PutBoolean(kRunning, true);
+ if (m_table != nullptr) m_table->PutBoolean(kRunning, true);
}
/**
@@ -308,7 +288,7 @@ bool Command::IsRunning() const { return m_running; }
* instead.
*/
void Command::Cancel() {
- if (m_parent != NULL)
+ if (m_parent != nullptr)
wpi_setWPIErrorWithContext(
CommandIllegalUse,
"Can not cancel a command that is part of a command group");
@@ -348,7 +328,7 @@ void Command::SetInterruptible(bool interruptible) {
/**
* Checks if the command requires the given {@link Subsystem}.
* @param system the system
- * @return whether or not the subsystem is required (false if given NULL)
+ * @return whether or not the subsystem is required (false if given nullptr)
*/
bool Command::DoesRequire(Subsystem *system) const {
return m_requirements.count(system) > 0;
@@ -390,12 +370,12 @@ std::string Command::GetName() {
std::string Command::GetSmartDashboardType() const { return "Command"; }
void Command::InitTable(ITable *table) {
- if (m_table != NULL) m_table->RemoveTableListener(this);
+ if (m_table != nullptr) m_table->RemoveTableListener(this);
m_table = table;
- if (m_table != NULL) {
+ if (m_table != nullptr) {
m_table->PutString(kName, GetName());
m_table->PutBoolean(kRunning, IsRunning());
- m_table->PutBoolean(kIsParented, m_parent != NULL);
+ m_table->PutBoolean(kIsParented, m_parent != nullptr);
m_table->AddTableListener(kRunning, this, false);
}
}
diff --git a/wpilibc/wpilibC++/src/Commands/CommandGroup.cpp b/wpilibc/wpilibC++/src/Commands/CommandGroup.cpp
index d1058feb63..43be3b87ca 100644
--- a/wpilibc/wpilibC++/src/Commands/CommandGroup.cpp
+++ b/wpilibc/wpilibC++/src/Commands/CommandGroup.cpp
@@ -8,20 +8,11 @@
#include "Commands/CommandGroup.h"
#include "WPIErrors.h"
-/**
- * Creates a new {@link CommandGroup CommandGroup}.
- */
-CommandGroup::CommandGroup() { m_currentCommandIndex = -1; }
-
/**
* Creates a new {@link CommandGroup CommandGroup} with the given name.
* @param name the name for this command group
*/
-CommandGroup::CommandGroup(const char *name) : Command(name) {
- m_currentCommandIndex = -1;
-}
-
-CommandGroup::~CommandGroup() {}
+CommandGroup::CommandGroup(const char *name) : Command(name) {}
/**
* Adds a new {@link Command Command} to the group. The {@link Command Command}
@@ -39,7 +30,7 @@ CommandGroup::~CommandGroup() {}
* @param command The {@link Command Command} to be added
*/
void CommandGroup::AddSequential(Command *command) {
- if (command == NULL) {
+ if (command == nullptr) {
wpi_setWPIErrorWithContext(NullParameter, "command");
return;
}
@@ -52,7 +43,7 @@ void CommandGroup::AddSequential(Command *command) {
// Iterate through command->GetRequirements() and call Requires() on each
// required subsystem
Command::SubsystemSet requirements = command->GetRequirements();
- Command::SubsystemSet::iterator iter = requirements.begin();
+ auto iter = requirements.begin();
for (; iter != requirements.end(); iter++) Requires(*iter);
}
@@ -79,7 +70,7 @@ void CommandGroup::AddSequential(Command *command) {
* @param timeout The timeout (in seconds)
*/
void CommandGroup::AddSequential(Command *command, double timeout) {
- if (command == NULL) {
+ if (command == nullptr) {
wpi_setWPIErrorWithContext(NullParameter, "command");
return;
}
@@ -96,7 +87,7 @@ void CommandGroup::AddSequential(Command *command, double timeout) {
// Iterate through command->GetRequirements() and call Requires() on each
// required subsystem
Command::SubsystemSet requirements = command->GetRequirements();
- Command::SubsystemSet::iterator iter = requirements.begin();
+ auto iter = requirements.begin();
for (; iter != requirements.end(); iter++) Requires(*iter);
}
@@ -126,7 +117,7 @@ void CommandGroup::AddSequential(Command *command, double timeout) {
* @param command The command to be added
*/
void CommandGroup::AddParallel(Command *command) {
- if (command == NULL) {
+ if (command == nullptr) {
wpi_setWPIErrorWithContext(NullParameter, "command");
return;
}
@@ -139,7 +130,7 @@ void CommandGroup::AddParallel(Command *command) {
// Iterate through command->GetRequirements() and call Requires() on each
// required subsystem
Command::SubsystemSet requirements = command->GetRequirements();
- Command::SubsystemSet::iterator iter = requirements.begin();
+ auto iter = requirements.begin();
for (; iter != requirements.end(); iter++) Requires(*iter);
}
@@ -177,7 +168,7 @@ void CommandGroup::AddParallel(Command *command) {
* @param timeout The timeout (in seconds)
*/
void CommandGroup::AddParallel(Command *command, double timeout) {
- if (command == NULL) {
+ if (command == nullptr) {
wpi_setWPIErrorWithContext(NullParameter, "command");
return;
}
@@ -194,7 +185,7 @@ void CommandGroup::AddParallel(Command *command, double timeout) {
// Iterate through command->GetRequirements() and call Requires() on each
// required subsystem
Command::SubsystemSet requirements = command->GetRequirements();
- Command::SubsystemSet::iterator iter = requirements.begin();
+ auto iter = requirements.begin();
for (; iter != requirements.end(); iter++) Requires(*iter);
}
@@ -202,7 +193,7 @@ void CommandGroup::_Initialize() { m_currentCommandIndex = -1; }
void CommandGroup::_Execute() {
CommandGroupEntry entry;
- Command *cmd = NULL;
+ Command *cmd = nullptr;
bool firstRun = false;
if (m_currentCommandIndex == -1) {
@@ -211,7 +202,7 @@ void CommandGroup::_Execute() {
}
while ((unsigned)m_currentCommandIndex < m_commands.size()) {
- if (cmd != NULL) {
+ if (cmd != nullptr) {
if (entry.IsTimedOut()) cmd->_Cancel();
if (cmd->Run()) {
@@ -220,13 +211,13 @@ void CommandGroup::_Execute() {
cmd->Removed();
m_currentCommandIndex++;
firstRun = true;
- cmd = NULL;
+ cmd = nullptr;
continue;
}
}
entry = m_commands[m_currentCommandIndex];
- cmd = NULL;
+ cmd = nullptr;
switch (entry.m_state) {
case CommandGroupEntry::kSequence_InSequence:
@@ -253,7 +244,7 @@ void CommandGroup::_Execute() {
}
// Run Children
- CommandList::iterator iter = m_children.begin();
+ auto iter = m_children.begin();
for (; iter != m_children.end();) {
entry = *iter;
Command *child = entry.m_command;
@@ -278,7 +269,7 @@ void CommandGroup::_End() {
cmd->Removed();
}
- CommandList::iterator iter = m_children.begin();
+ auto iter = m_children.begin();
for (; iter != m_children.end(); iter++) {
Command *cmd = iter->m_command;
cmd->_Cancel();
@@ -315,7 +306,7 @@ bool CommandGroup::IsInterruptible() const {
if (!cmd->IsInterruptible()) return false;
}
- CommandList::const_iterator iter = m_children.cbegin();
+ auto iter = m_children.cbegin();
for (; iter != m_children.cend(); iter++) {
if (!iter->m_command->IsInterruptible()) return false;
}
@@ -324,13 +315,13 @@ bool CommandGroup::IsInterruptible() const {
}
void CommandGroup::CancelConflicts(Command *command) {
- CommandList::iterator childIter = m_children.begin();
+ auto childIter = m_children.begin();
for (; childIter != m_children.end();) {
Command *child = childIter->m_command;
bool erased = false;
Command::SubsystemSet requirements = command->GetRequirements();
- Command::SubsystemSet::iterator requirementIter = requirements.begin();
+ auto requirementIter = requirements.begin();
for (; requirementIter != requirements.end(); requirementIter++) {
if (child->DoesRequire(*requirementIter)) {
child->_Cancel();
diff --git a/wpilibc/wpilibC++/src/Commands/CommandGroupEntry.cpp b/wpilibc/wpilibC++/src/Commands/CommandGroupEntry.cpp
index 10a36dbc3a..c9f3fa4a45 100644
--- a/wpilibc/wpilibC++/src/Commands/CommandGroupEntry.cpp
+++ b/wpilibc/wpilibC++/src/Commands/CommandGroupEntry.cpp
@@ -9,12 +9,6 @@
#include "Commands/Command.h"
-CommandGroupEntry::CommandGroupEntry()
- : m_timeout(-1.0), m_command(NULL), m_state(kSequence_InSequence) {}
-
-CommandGroupEntry::CommandGroupEntry(Command *command, Sequence state)
- : m_timeout(-1.0), m_command(command), m_state(state) {}
-
CommandGroupEntry::CommandGroupEntry(Command *command, Sequence state,
double timeout)
: m_timeout(timeout), m_command(command), m_state(state) {}
diff --git a/wpilibc/wpilibC++/src/Commands/Scheduler.cpp b/wpilibc/wpilibC++/src/Commands/Scheduler.cpp
index eb030eaae7..c23785d2b6 100644
--- a/wpilibc/wpilibC++/src/Commands/Scheduler.cpp
+++ b/wpilibc/wpilibC++/src/Commands/Scheduler.cpp
@@ -16,21 +16,11 @@
#include
#include
-Scheduler *Scheduler::_instance = NULL;
-
-Scheduler::Scheduler()
- : m_buttonsLock(NULL), m_additionsLock(NULL), m_adding(false) {
+Scheduler::Scheduler() {
m_buttonsLock = initializeMutexNormal();
m_additionsLock = initializeMutexNormal();
HLUsageReporting::ReportScheduler();
-
- m_table = NULL;
- m_enabled = true;
- m_runningCommandsChanged = false;
- toCancel = NULL;
- commands = NULL;
- ids = NULL;
}
Scheduler::~Scheduler() {
@@ -46,8 +36,8 @@ Scheduler::~Scheduler() {
* @return the {@link Scheduler}
*/
Scheduler *Scheduler::GetInstance() {
- if (_instance == NULL) _instance = new Scheduler();
- return _instance;
+ static Scheduler instance;
+ return &instance;
}
void Scheduler::SetEnabled(bool enabled) { m_enabled = enabled; }
@@ -73,7 +63,7 @@ void Scheduler::AddButton(ButtonScheduler *button) {
}
void Scheduler::ProcessCommandAddition(Command *command) {
- if (command == NULL) return;
+ if (command == nullptr) return;
// Check to make sure no adding during adding
if (m_adding) {
@@ -83,14 +73,14 @@ void Scheduler::ProcessCommandAddition(Command *command) {
}
// Only add if not already in
- CommandSet::iterator found = m_commands.find(command);
+ auto found = m_commands.find(command);
if (found == m_commands.end()) {
// Check that the requirements can be had
Command::SubsystemSet requirements = command->GetRequirements();
Command::SubsystemSet::iterator iter;
for (iter = requirements.begin(); iter != requirements.end(); iter++) {
Subsystem *lock = *iter;
- if (lock->GetCurrentCommand() != NULL &&
+ if (lock->GetCurrentCommand() != nullptr &&
!lock->GetCurrentCommand()->IsInterruptible())
return;
}
@@ -99,7 +89,7 @@ void Scheduler::ProcessCommandAddition(Command *command) {
m_adding = true;
for (iter = requirements.begin(); iter != requirements.end(); iter++) {
Subsystem *lock = *iter;
- if (lock->GetCurrentCommand() != NULL) {
+ if (lock->GetCurrentCommand() != nullptr) {
lock->GetCurrentCommand()->Cancel();
Remove(lock->GetCurrentCommand());
}
@@ -133,7 +123,7 @@ void Scheduler::Run() {
if (!m_enabled) return;
Synchronized sync(m_buttonsLock);
- ButtonVector::reverse_iterator rButtonIter = m_buttons.rbegin();
+ auto rButtonIter = m_buttons.rbegin();
for (; rButtonIter != m_buttons.rend(); rButtonIter++) {
(*rButtonIter)->Execute();
}
@@ -142,7 +132,7 @@ void Scheduler::Run() {
m_runningCommandsChanged = false;
// Loop through the commands
- CommandSet::iterator commandIter = m_commands.begin();
+ auto commandIter = m_commands.begin();
for (; commandIter != m_commands.end();) {
Command *command = *commandIter;
// Increment before potentially removing to keep the iterator valid
@@ -156,7 +146,7 @@ void Scheduler::Run() {
// Add the new things
{
Synchronized sync(m_additionsLock);
- CommandVector::iterator additionsIter = m_additions.begin();
+ auto additionsIter = m_additions.begin();
for (; additionsIter != m_additions.end(); additionsIter++) {
ProcessCommandAddition(*additionsIter);
}
@@ -164,10 +154,10 @@ void Scheduler::Run() {
}
// Add in the defaults
- Command::SubsystemSet::iterator subsystemIter = m_subsystems.begin();
+ auto subsystemIter = m_subsystems.begin();
for (; subsystemIter != m_subsystems.end(); subsystemIter++) {
Subsystem *lock = *subsystemIter;
- if (lock->GetCurrentCommand() == NULL) {
+ if (lock->GetCurrentCommand() == nullptr) {
ProcessCommandAddition(lock->GetDefaultCommand());
}
lock->ConfirmCommand();
@@ -184,7 +174,7 @@ void Scheduler::Run() {
* @param system the system
*/
void Scheduler::RegisterSubsystem(Subsystem *subsystem) {
- if (subsystem == NULL) {
+ if (subsystem == nullptr) {
wpi_setWPIErrorWithContext(NullParameter, "subsystem");
return;
}
@@ -196,7 +186,7 @@ void Scheduler::RegisterSubsystem(Subsystem *subsystem) {
* @param command the command to remove
*/
void Scheduler::Remove(Command *command) {
- if (command == NULL) {
+ if (command == nullptr) {
wpi_setWPIErrorWithContext(NullParameter, "command");
return;
}
@@ -204,10 +194,10 @@ void Scheduler::Remove(Command *command) {
if (!m_commands.erase(command)) return;
Command::SubsystemSet requirements = command->GetRequirements();
- Command::SubsystemSet::iterator iter = requirements.begin();
+ auto iter = requirements.begin();
for (; iter != requirements.end(); iter++) {
Subsystem *lock = *iter;
- lock->SetCurrentCommand(NULL);
+ lock->SetCurrentCommand(nullptr);
}
command->Removed();
@@ -228,7 +218,7 @@ void Scheduler::ResetAll() {
m_buttons.clear();
m_additions.clear();
m_commands.clear();
- m_table = NULL;
+ m_table = nullptr;
}
/**
@@ -237,7 +227,7 @@ void Scheduler::ResetAll() {
*/
void Scheduler::UpdateTable() {
CommandSet::iterator commandIter;
- if (m_table != NULL) {
+ if (m_table != nullptr) {
// Get the list of possible commands to cancel
m_table->RetrieveValue("Cancel", *toCancel);
// m_table->RetrieveValue("Ids", *ids);
diff --git a/wpilibc/wpilibC++/src/Commands/Subsystem.cpp b/wpilibc/wpilibC++/src/Commands/Subsystem.cpp
index 45ced0bdf6..53dbfcf74c 100644
--- a/wpilibc/wpilibC++/src/Commands/Subsystem.cpp
+++ b/wpilibc/wpilibC++/src/Commands/Subsystem.cpp
@@ -15,14 +15,9 @@
* Creates a subsystem with the given name
* @param name the name of the subsystem
*/
-Subsystem::Subsystem(const char *name)
- : m_currentCommand(NULL),
- m_defaultCommand(NULL),
- m_initializedDefaultCommand(false) {
+Subsystem::Subsystem(const char *name) {
m_name = name;
Scheduler::GetInstance()->RegisterSubsystem(this);
- m_table = NULL;
- m_currentCommandChanged = true;
}
/**
* Initialize the default command for this subsystem
@@ -47,12 +42,12 @@ void Subsystem::InitDefaultCommand() {}
* @param command the default command (or null if there should be none)
*/
void Subsystem::SetDefaultCommand(Command *command) {
- if (command == NULL) {
- m_defaultCommand = NULL;
+ if (command == nullptr) {
+ m_defaultCommand = nullptr;
} else {
bool found = false;
Command::SubsystemSet requirements = command->GetRequirements();
- Command::SubsystemSet::iterator iter = requirements.begin();
+ auto iter = requirements.begin();
for (; iter != requirements.end(); iter++) {
if (*iter == this) {
found = true;
@@ -68,8 +63,8 @@ void Subsystem::SetDefaultCommand(Command *command) {
m_defaultCommand = command;
}
- if (m_table != NULL) {
- if (m_defaultCommand != NULL) {
+ if (m_table != nullptr) {
+ if (m_defaultCommand != nullptr) {
m_table->PutBoolean("hasDefault", true);
m_table->PutString("default", m_defaultCommand->GetName());
} else {
@@ -115,8 +110,8 @@ Command *Subsystem::GetCurrentCommand() const { return m_currentCommand; }
*/
void Subsystem::ConfirmCommand() {
if (m_currentCommandChanged) {
- if (m_table != NULL) {
- if (m_currentCommand != NULL) {
+ if (m_table != nullptr) {
+ if (m_currentCommand != nullptr) {
m_table->PutBoolean("hasCommand", true);
m_table->PutString("command", m_currentCommand->GetName());
} else {
@@ -133,14 +128,14 @@ std::string Subsystem::GetSmartDashboardType() const { return "Subsystem"; }
void Subsystem::InitTable(ITable *table) {
m_table = table;
- if (m_table != NULL) {
- if (m_defaultCommand != NULL) {
+ if (m_table != nullptr) {
+ if (m_defaultCommand != nullptr) {
m_table->PutBoolean("hasDefault", true);
m_table->PutString("default", m_defaultCommand->GetName());
} else {
m_table->PutBoolean("hasDefault", false);
}
- if (m_currentCommand != NULL) {
+ if (m_currentCommand != nullptr) {
m_table->PutBoolean("hasCommand", true);
m_table->PutString("command", m_currentCommand->GetName());
} else {
diff --git a/wpilibc/wpilibC++/src/Commands/WaitForChildren.cpp b/wpilibc/wpilibC++/src/Commands/WaitForChildren.cpp
index 527f11ed2d..2ec602fa01 100644
--- a/wpilibc/wpilibC++/src/Commands/WaitForChildren.cpp
+++ b/wpilibc/wpilibC++/src/Commands/WaitForChildren.cpp
@@ -23,5 +23,5 @@ void WaitForChildren::End() {}
void WaitForChildren::Interrupted() {}
bool WaitForChildren::IsFinished() {
- return GetGroup() == NULL || GetGroup()->GetSize() == 0;
+ return GetGroup() == nullptr || GetGroup()->GetSize() == 0;
}
diff --git a/wpilibc/wpilibC++/src/Error.cpp b/wpilibc/wpilibC++/src/Error.cpp
index fd11ba5ae4..7f6e700f20 100644
--- a/wpilibc/wpilibC++/src/Error.cpp
+++ b/wpilibc/wpilibC++/src/Error.cpp
@@ -19,10 +19,7 @@
#include "Utility.h"
bool Error::m_suspendOnErrorEnabled = false;
-Error::Error()
- : m_code(0), m_lineNumber(0), m_originatingObject(NULL), m_timestamp(0.0) {}
-
-Error::~Error() {}
+Error::Error() {}
void Error::Clone(Error& error) {
m_code = error.m_code;
@@ -71,7 +68,7 @@ void Error::Set(Code code, const char* contextMessage, const char* filename,
Report();
}
- if (m_suspendOnErrorEnabled) suspendTask(0);
+ if (m_suspendOnErrorEnabled) suspendTask(nullptr);
}
void Error::Report() {
@@ -93,6 +90,6 @@ void Error::Clear() {
m_filename = "";
m_function = "";
m_lineNumber = 0;
- m_originatingObject = NULL;
+ m_originatingObject = nullptr;
m_timestamp = 0.0;
}
diff --git a/wpilibc/wpilibC++/src/ErrorBase.cpp b/wpilibc/wpilibC++/src/ErrorBase.cpp
index 363ae9d94c..b7eae3d48b 100644
--- a/wpilibc/wpilibC++/src/ErrorBase.cpp
+++ b/wpilibc/wpilibC++/src/ErrorBase.cpp
@@ -21,8 +21,6 @@ Error ErrorBase::_globalError;
*/
ErrorBase::ErrorBase() {}
-ErrorBase::~ErrorBase() {}
-
/**
* @brief Retrieve the current error.
* Get the current error information associated with this sensor.
@@ -165,7 +163,7 @@ void ErrorBase::SetGlobalError(Error::Code code, const char* contextMessage,
// Set the current error information for this object.
_globalError.Set(code, contextMessage, filename, function, lineNumber,
- NULL);
+ nullptr);
}
}
@@ -180,7 +178,7 @@ void ErrorBase::SetGlobalWPIError(const char* errorMessage,
if (_globalError.GetCode() != 0) {
_globalError.Clear();
}
- _globalError.Set(-1, err, filename, function, lineNumber, NULL);
+ _globalError.Set(-1, err, filename, function, lineNumber, nullptr);
}
/**
diff --git a/wpilibc/wpilibC++/src/HLUsageReporting.cpp b/wpilibc/wpilibC++/src/HLUsageReporting.cpp
index 94cd7088f2..bcbc6b6a34 100644
--- a/wpilibc/wpilibC++/src/HLUsageReporting.cpp
+++ b/wpilibc/wpilibC++/src/HLUsageReporting.cpp
@@ -1,20 +1,20 @@
#include "HLUsageReporting.h"
-HLUsageReportingInterface* HLUsageReporting::impl = 0;
+HLUsageReportingInterface* HLUsageReporting::impl = nullptr;
void HLUsageReporting::SetImplementation(HLUsageReportingInterface* i) {
impl = i;
}
void HLUsageReporting::ReportScheduler() {
- if (impl != 0) {
+ if (impl != nullptr) {
impl->ReportScheduler();
}
}
void HLUsageReporting::ReportSmartDashboard() {
- if (impl != 0) {
+ if (impl != nullptr) {
impl->ReportSmartDashboard();
}
}
diff --git a/wpilibc/wpilibC++/src/LiveWindow/LiveWindow.cpp b/wpilibc/wpilibC++/src/LiveWindow/LiveWindow.cpp
index 7243c182a4..a211115ea6 100644
--- a/wpilibc/wpilibC++/src/LiveWindow/LiveWindow.cpp
+++ b/wpilibc/wpilibC++/src/LiveWindow/LiveWindow.cpp
@@ -10,9 +10,8 @@
* how many times GetInstance is called.
*/
LiveWindow *LiveWindow::GetInstance() {
- static LiveWindow *instance = new LiveWindow();
-
- return instance;
+ static LiveWindow instance;
+ return &instance;
}
/**
@@ -20,7 +19,6 @@ LiveWindow *LiveWindow::GetInstance() {
* Allocate the necessary tables.
*/
LiveWindow::LiveWindow() {
- m_enabled = false;
m_liveWindowTable = NetworkTable::GetTable("LiveWindow");
m_statusTable = m_liveWindowTable->GetSubTable("~STATUS~");
m_scheduler = Scheduler::GetInstance();
@@ -39,16 +37,12 @@ void LiveWindow::SetEnabled(bool enabled) {
}
m_scheduler->SetEnabled(false);
m_scheduler->RemoveAll();
- for (std::map::iterator it =
- m_components.begin();
- it != m_components.end(); ++it) {
- it->first->StartLiveWindowMode();
+ for (auto& elem : m_components) {
+ elem.first->StartLiveWindowMode();
}
} else {
- for (std::map::iterator it =
- m_components.begin();
- it != m_components.end(); ++it) {
- it->first->StopLiveWindowMode();
+ for (auto& elem : m_components) {
+ elem.first->StopLiveWindowMode();
}
m_scheduler->SetEnabled(true);
}
@@ -56,8 +50,6 @@ void LiveWindow::SetEnabled(bool enabled) {
m_statusTable->PutBoolean("LW Enabled", m_enabled);
}
-LiveWindow::~LiveWindow() {}
-
/**
* Add a Sensor associated with the subsystem and with call it by the given
* name.
@@ -94,7 +86,7 @@ void LiveWindow::AddSensor(std::string type, int channel,
std::ostringstream oss;
oss << type << "[" << channel << "]";
std::string types(oss.str());
- char *cc = new char[types.size() + 1];
+ auto cc = new char[types.size() + 1];
types.copy(cc, types.size());
cc[types.size()] = '\0';
AddSensor("Ungrouped", cc, component);
@@ -111,7 +103,7 @@ void LiveWindow::AddActuator(std::string type, int channel,
std::ostringstream oss;
oss << type << "[" << channel << "]";
std::string types(oss.str());
- char *cc = new char[types.size() + 1];
+ auto cc = new char[types.size() + 1];
types.copy(cc, types.size());
cc[types.size()] = '\0';
AddActuator("Ungrouped", cc, component);
@@ -125,7 +117,7 @@ void LiveWindow::AddActuator(std::string type, int module, int channel,
std::ostringstream oss;
oss << type << "[" << module << "," << channel << "]";
std::string types(oss.str());
- char *cc = new char[types.size() + 1];
+ auto cc = new char[types.size() + 1];
types.copy(cc, types.size());
cc[types.size()] = '\0';
AddActuator("Ungrouped", cc, component);
@@ -137,8 +129,8 @@ void LiveWindow::AddActuator(std::string type, int module, int channel,
* SmartDashboard widgets.
*/
void LiveWindow::UpdateValues() {
- for (unsigned int i = 0; i < m_sensors.size(); i++) {
- m_sensors[i]->UpdateTable();
+ for (auto& elem : m_sensors) {
+ elem->UpdateTable();
}
}
@@ -164,11 +156,9 @@ void LiveWindow::Run() {
* addActuator and addSensor.
*/
void LiveWindow::InitializeLiveWindowComponents() {
- for (std::map::iterator it =
- m_components.begin();
- it != m_components.end(); ++it) {
- LiveWindowSendable *component = it->first;
- LiveWindowComponent c = it->second;
+ for (auto& elem : m_components) {
+ LiveWindowSendable *component = elem.first;
+ LiveWindowComponent c = elem.second;
std::string subsystem = c.subsystem;
std::string name = c.name;
m_liveWindowTable->GetSubTable(subsystem)
diff --git a/wpilibc/wpilibC++/src/Resource.cpp b/wpilibc/wpilibC++/src/Resource.cpp
index 6246f08ad6..492e809a31 100644
--- a/wpilibc/wpilibC++/src/Resource.cpp
+++ b/wpilibc/wpilibC++/src/Resource.cpp
@@ -30,8 +30,8 @@ Resource::Resource(uint32_t elements) {
/**
* Factory method to create a Resource allocation-tracker *if* needed.
*
- * @param r -- address of the caller's Resource pointer. If *r == NULL, this
- * will construct a Resource and make *r point to it. If *r != NULL, i.e.
+ * @param r -- address of the caller's Resource pointer. If *r == nullptr, this
+ * will construct a Resource and make *r point to it. If *r != nullptr, i.e.
* the caller already has a Resource instance, this won't do anything.
* @param elements -- the number of elements for this Resource allocator to
* track, that is, it will allocate resource numbers in the range
@@ -40,7 +40,7 @@ Resource::Resource(uint32_t elements) {
/*static*/ void Resource::CreateResourceObject(Resource **r,
uint32_t elements) {
Synchronized sync(m_createLock);
- if (*r == NULL) {
+ if (*r == nullptr) {
*r = new Resource(elements);
}
}
diff --git a/wpilibc/wpilibC++/src/RobotState.cpp b/wpilibc/wpilibC++/src/RobotState.cpp
index 0e368dfa7d..076c9c8e21 100644
--- a/wpilibc/wpilibC++/src/RobotState.cpp
+++ b/wpilibc/wpilibC++/src/RobotState.cpp
@@ -1,6 +1,6 @@
#include "RobotState.h"
-RobotStateInterface* RobotState::impl = 0;
+RobotStateInterface* RobotState::impl = nullptr;
void RobotState::SetImplementation(RobotStateInterface* i) { impl = i; }
diff --git a/wpilibc/wpilibC++/src/SmartDashboard/SendableChooser.cpp b/wpilibc/wpilibC++/src/SmartDashboard/SendableChooser.cpp
index bad9d14fd2..9e9434ef02 100644
--- a/wpilibc/wpilibC++/src/SmartDashboard/SendableChooser.cpp
+++ b/wpilibc/wpilibC++/src/SmartDashboard/SendableChooser.cpp
@@ -14,8 +14,6 @@ static const char *kDefault = "default";
static const char *kOptions = "options";
static const char *kSelected = "selected";
-SendableChooser::SendableChooser() { m_defaultChoice = ""; }
-
/**
* Adds the given object to the list of options. On the {@link SmartDashboard}
* on the desktop,
@@ -44,13 +42,13 @@ void SendableChooser::AddDefault(const char *name, void *object) {
/**
* Returns the selected option. If there is none selected, it will return the
* default. If there is none selected
- * and no default, then it will return {@code NULL}.
+ * and no default, then it will return {@code nullptr}.
* @return the option selected
*/
void *SendableChooser::GetSelected() {
std::string selected = m_table->GetString(kSelected, m_defaultChoice);
if (selected == "")
- return NULL;
+ return nullptr;
else
return m_choices[selected];
}
@@ -58,7 +56,7 @@ void *SendableChooser::GetSelected() {
void SendableChooser::InitTable(ITable *subtable) {
StringArray keys;
m_table = subtable;
- if (m_table != NULL) {
+ if (m_table != nullptr) {
std::map::iterator iter;
for (iter = m_choices.begin(); iter != m_choices.end(); iter++) {
keys.add(iter->first);
diff --git a/wpilibc/wpilibC++/src/SmartDashboard/SmartDashboard.cpp b/wpilibc/wpilibC++/src/SmartDashboard/SmartDashboard.cpp
index 15321352b4..5724a97578 100644
--- a/wpilibc/wpilibC++/src/SmartDashboard/SmartDashboard.cpp
+++ b/wpilibc/wpilibC++/src/SmartDashboard/SmartDashboard.cpp
@@ -13,7 +13,7 @@
#include "networktables/NetworkTable.h"
#include "HLUsageReporting.h"
-ITable *SmartDashboard::m_table = NULL;
+ITable *SmartDashboard::m_table = nullptr;
std::map SmartDashboard::m_tablesToData;
void SmartDashboard::init() {
@@ -24,14 +24,14 @@ void SmartDashboard::init() {
/**
* Maps the specified key to the specified value in this table.
- * The key can not be NULL.
+ * The key can not be nullptr.
* The value can be retrieved by calling the get method with a key that is equal
* to the original key.
* @param keyName the key
* @param value the value
*/
void SmartDashboard::PutData(std::string key, Sendable *data) {
- if (data == NULL) {
+ if (data == nullptr) {
wpi_setGlobalWPIErrorWithContext(NullParameter, "value");
return;
}
@@ -50,7 +50,7 @@ void SmartDashboard::PutData(std::string key, Sendable *data) {
* @param value the value
*/
void SmartDashboard::PutData(NamedSendable *value) {
- if (value == NULL) {
+ if (value == nullptr) {
wpi_setGlobalWPIErrorWithContext(NullParameter, "value");
return;
}
@@ -65,9 +65,9 @@ void SmartDashboard::PutData(NamedSendable *value) {
Sendable *SmartDashboard::GetData(std::string key) {
ITable *subtable = m_table->GetSubTable(key);
Sendable *data = m_tablesToData[subtable];
- if (data == NULL) {
+ if (data == nullptr) {
wpi_setGlobalWPIErrorWithContext(SmartDashboardMissingKey, key.c_str());
- return NULL;
+ return nullptr;
}
return data;
}
@@ -75,7 +75,7 @@ Sendable *SmartDashboard::GetData(std::string key) {
/**
* Maps the specified key to the specified complex value (such as an array) in
* this table.
- * The key can not be NULL.
+ * The key can not be nullptr.
* The value can be retrieved by calling the RetrieveValue method with a key
* that is equal to the original key.
* @param keyName the key
@@ -88,7 +88,7 @@ void SmartDashboard::PutValue(std::string keyName, ComplexData &value) {
/**
* Retrieves the complex value (such as an array) in this table into the complex
* data object
- * The key can not be NULL.
+ * The key can not be nullptr.
* @param keyName the key
* @param value the object to retrieve the value into
*/
@@ -98,7 +98,7 @@ void SmartDashboard::RetrieveValue(std::string keyName, ComplexData &value) {
/**
* Maps the specified key to the specified value in this table.
- * The key can not be NULL.
+ * The key can not be nullptr.
* The value can be retrieved by calling the get method with a key that is equal
* to the original key.
* @param keyName the key
@@ -130,7 +130,7 @@ bool SmartDashboard::GetBoolean(std::string keyName, bool defaultValue) {
/**
* Maps the specified key to the specified value in this table.
- * The key can not be NULL.
+ * The key can not be nullptr.
* The value can be retrieved by calling the get method with a key that is equal
* to the original key.
* @param keyName the key
@@ -162,7 +162,7 @@ double SmartDashboard::GetNumber(std::string keyName, double defaultValue) {
/**
* Maps the specified key to the specified value in this table.
- * Neither the key nor the value can be NULL.
+ * Neither the key nor the value can be nullptr.
* The value can be retrieved by calling the get method with a key that is equal
* to the original key.
* @param keyName the key
diff --git a/wpilibc/wpilibC++Devices/include/ADXL345_I2C.h b/wpilibc/wpilibC++Devices/include/ADXL345_I2C.h
index f3f537a4a7..8e07ccfbd9 100644
--- a/wpilibc/wpilibC++Devices/include/ADXL345_I2C.h
+++ b/wpilibc/wpilibC++Devices/include/ADXL345_I2C.h
@@ -51,7 +51,7 @@ class ADXL345_I2C : public Accelerometer,
public:
explicit ADXL345_I2C(Port port, Range range = kRange_2G);
- virtual ~ADXL345_I2C();
+ virtual ~ADXL345_I2C() = default;
// Accelerometer interface
virtual void SetRange(Range range) override;
@@ -69,8 +69,6 @@ class ADXL345_I2C : public Accelerometer,
virtual void StartLiveWindowMode() override {}
virtual void StopLiveWindowMode() override {}
- protected:
- // I2C* m_i2c;
private:
ITable *m_table;
};
diff --git a/wpilibc/wpilibC++Devices/include/AnalogAccelerometer.h b/wpilibc/wpilibC++Devices/include/AnalogAccelerometer.h
index 56de0b165c..cd14381dd1 100644
--- a/wpilibc/wpilibC++Devices/include/AnalogAccelerometer.h
+++ b/wpilibc/wpilibC++Devices/include/AnalogAccelerometer.h
@@ -43,9 +43,9 @@ class AnalogAccelerometer : public SensorBase,
void InitAccelerometer();
AnalogInput *m_AnalogInput;
- float m_voltsPerG;
- float m_zeroGVoltage;
+ float m_voltsPerG = 1.0;
+ float m_zeroGVoltage = 2.5;
bool m_allocatedChannel;
- ITable *m_table;
+ ITable *m_table = nullptr;
};
diff --git a/wpilibc/wpilibC++Devices/include/AnalogInput.h b/wpilibc/wpilibC++Devices/include/AnalogInput.h
index a1c8cae810..f91c512731 100644
--- a/wpilibc/wpilibC++Devices/include/AnalogInput.h
+++ b/wpilibc/wpilibC++Devices/include/AnalogInput.h
@@ -75,10 +75,9 @@ class AnalogInput : public SensorBase,
ITable *GetTable() const override;
private:
- void InitAnalogInput(uint32_t channel);
uint32_t m_channel;
void *m_port;
int64_t m_accumulatorOffset;
- ITable *m_table;
+ ITable *m_table = nullptr;
};
diff --git a/wpilibc/wpilibC++Devices/include/AnalogOutput.h b/wpilibc/wpilibC++Devices/include/AnalogOutput.h
index bccf8598bb..e0e091ef4f 100644
--- a/wpilibc/wpilibC++Devices/include/AnalogOutput.h
+++ b/wpilibc/wpilibC++Devices/include/AnalogOutput.h
@@ -30,9 +30,8 @@ class AnalogOutput : public SensorBase, public LiveWindowSendable {
ITable *GetTable() const override;
protected:
- void InitAnalogOutput(uint32_t channel);
uint32_t m_channel;
void *m_port;
- ITable *m_table;
+ ITable *m_table = nullptr;
};
diff --git a/wpilibc/wpilibC++Devices/include/AnalogTrigger.h b/wpilibc/wpilibC++Devices/include/AnalogTrigger.h
index 1f6c7aeba5..6b1df97967 100644
--- a/wpilibc/wpilibC++Devices/include/AnalogTrigger.h
+++ b/wpilibc/wpilibC++Devices/include/AnalogTrigger.h
@@ -30,8 +30,6 @@ class AnalogTrigger : public SensorBase {
AnalogTriggerOutput *CreateOutput(AnalogTriggerType type);
private:
- void InitTrigger(uint32_t channel);
-
uint8_t m_index;
void *m_trigger;
};
diff --git a/wpilibc/wpilibC++Devices/include/BuiltInAccelerometer.h b/wpilibc/wpilibC++Devices/include/BuiltInAccelerometer.h
index 5dc997af39..2fe26c6c26 100644
--- a/wpilibc/wpilibC++Devices/include/BuiltInAccelerometer.h
+++ b/wpilibc/wpilibC++Devices/include/BuiltInAccelerometer.h
@@ -19,7 +19,7 @@ class BuiltInAccelerometer : public Accelerometer,
public LiveWindowSendable {
public:
BuiltInAccelerometer(Range range = kRange_8G);
- virtual ~BuiltInAccelerometer();
+ virtual ~BuiltInAccelerometer() = default;
// Accelerometer interface
virtual void SetRange(Range range) override;
@@ -35,5 +35,5 @@ class BuiltInAccelerometer : public Accelerometer,
virtual void StopLiveWindowMode() override {}
private:
- ITable *m_table;
+ ITable *m_table = nullptr;
};
diff --git a/wpilibc/wpilibC++Devices/include/CANJaguar.h b/wpilibc/wpilibC++Devices/include/CANJaguar.h
index 0ddae45d27..02c5208c66 100644
--- a/wpilibc/wpilibC++Devices/include/CANJaguar.h
+++ b/wpilibc/wpilibC++Devices/include/CANJaguar.h
@@ -16,6 +16,7 @@
#include "LiveWindow/LiveWindowSendable.h"
#include "tables/ITable.h"
#include "NetworkCommunication/CANSessionMux.h"
+#include "CAN/can_proto.h"
#include
#include
@@ -170,64 +171,64 @@ class CANJaguar : public MotorSafety,
mutable std::recursive_mutex m_mutex;
uint8_t m_deviceNumber;
- float m_value;
+ float m_value = 0.0f;
// Parameters/configuration
ControlMode m_controlMode;
- uint8_t m_speedReference;
- uint8_t m_positionReference;
- double m_p;
- double m_i;
- double m_d;
- NeutralMode m_neutralMode;
- uint16_t m_encoderCodesPerRev;
- uint16_t m_potentiometerTurns;
- LimitMode m_limitMode;
- double m_forwardLimit;
- double m_reverseLimit;
- double m_maxOutputVoltage;
- double m_voltageRampRate;
- float m_faultTime;
+ uint8_t m_speedReference = LM_REF_NONE;
+ uint8_t m_positionReference = LM_REF_NONE;
+ double m_p = 0.0;
+ double m_i = 0.0;
+ double m_d = 0.0;
+ NeutralMode m_neutralMode = kNeutralMode_Jumper;
+ uint16_t m_encoderCodesPerRev = 0;
+ uint16_t m_potentiometerTurns = 0;
+ LimitMode m_limitMode = kLimitMode_SwitchInputsOnly;
+ double m_forwardLimit = 0.0;
+ double m_reverseLimit = 0.0;
+ double m_maxOutputVoltage = 30.0;
+ double m_voltageRampRate = 0.0;
+ float m_faultTime = 0.0f;
// Which parameters have been verified since they were last set?
- bool m_controlModeVerified;
- bool m_speedRefVerified;
- bool m_posRefVerified;
- bool m_pVerified;
- bool m_iVerified;
- bool m_dVerified;
- bool m_neutralModeVerified;
- bool m_encoderCodesPerRevVerified;
- bool m_potentiometerTurnsVerified;
- bool m_forwardLimitVerified;
- bool m_reverseLimitVerified;
- bool m_limitModeVerified;
- bool m_maxOutputVoltageVerified;
- bool m_voltageRampRateVerified;
- bool m_faultTimeVerified;
+ bool m_controlModeVerified = false; // Needs to be verified because it's set in the constructor
+ bool m_speedRefVerified = true;
+ bool m_posRefVerified = true;
+ bool m_pVerified = true;
+ bool m_iVerified = true;
+ bool m_dVerified = true;
+ bool m_neutralModeVerified = true;
+ bool m_encoderCodesPerRevVerified = true;
+ bool m_potentiometerTurnsVerified = true;
+ bool m_forwardLimitVerified = true;
+ bool m_reverseLimitVerified = true;
+ bool m_limitModeVerified = true;
+ bool m_maxOutputVoltageVerified = true;
+ bool m_voltageRampRateVerified = true;
+ bool m_faultTimeVerified = true;
// Status data
- mutable float m_busVoltage;
- mutable float m_outputVoltage;
- mutable float m_outputCurrent;
- mutable float m_temperature;
- mutable double m_position;
- mutable double m_speed;
- mutable uint8_t m_limits;
- mutable uint16_t m_faults;
- uint32_t m_firmwareVersion;
- uint8_t m_hardwareVersion;
+ mutable float m_busVoltage = 0.0f;
+ mutable float m_outputVoltage = 0.0f;
+ mutable float m_outputCurrent = 0.0f;
+ 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 uint16_t m_faults = 0x0000;
+ uint32_t m_firmwareVersion = 0;
+ uint8_t m_hardwareVersion = 0;
// Which periodic status messages have we received at least once?
- mutable std::atomic m_receivedStatusMessage0;
- mutable std::atomic m_receivedStatusMessage1;
- mutable std::atomic m_receivedStatusMessage2;
+ mutable std::atomic m_receivedStatusMessage0{false};
+ mutable std::atomic m_receivedStatusMessage1{false};
+ mutable std::atomic m_receivedStatusMessage2{false};
bool m_controlEnabled;
void verify();
- MotorSafetyHelper *m_safetyHelper;
+ MotorSafetyHelper *m_safetyHelper = nullptr;
void ValueChanged(ITable *source, const std::string &key, EntryValue value,
bool isNew) override;
@@ -238,9 +239,9 @@ class CANJaguar : public MotorSafety,
void InitTable(ITable *subTable) override;
ITable *GetTable() const override;
- ITable *m_table;
+ ITable *m_table = nullptr;
private:
void InitCANJaguar();
- bool m_isInverted;
+ bool m_isInverted = false;
};
diff --git a/wpilibc/wpilibC++Devices/include/CANTalon.h b/wpilibc/wpilibC++Devices/include/CANTalon.h
index b8f08af1cf..f6dfdec0a3 100644
--- a/wpilibc/wpilibC++Devices/include/CANTalon.h
+++ b/wpilibc/wpilibC++Devices/include/CANTalon.h
@@ -66,7 +66,7 @@ class CANTalon : public MotorSafety,
virtual void SetSetpoint(float value) override;
virtual void Disable() override;
virtual void EnableControl();
- virtual void Enable();
+ virtual void Enable() override;
virtual void SetP(double p) override;
virtual void SetI(double i) override;
virtual void SetD(double d) override;
@@ -183,14 +183,14 @@ class CANTalon : public MotorSafety,
int m_deviceNumber;
CanTalonSRX *m_impl;
MotorSafetyHelper *m_safetyHelper;
- int m_profile; // 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;
- ControlMode m_controlMode;
+ bool m_controlEnabled = true;
+ ControlMode m_controlMode = kPercentVbus;
TalonControlMode m_sendMode;
- double m_setPoint;
+ double m_setPoint = 0;
static const unsigned int kDelayForSolicitedSignalsUs = 4000;
/**
* Fixup the sendMode so Set() serializes the correct demand value.
diff --git a/wpilibc/wpilibC++Devices/include/CameraServer.h b/wpilibc/wpilibC++Devices/include/CameraServer.h
index 046224a7db..3466ab4663 100644
--- a/wpilibc/wpilibC++Devices/include/CameraServer.h
+++ b/wpilibc/wpilibC++Devices/include/CameraServer.h
@@ -55,8 +55,6 @@ class CameraServer : public ErrorBase {
uint32_t size;
};
- static CameraServer* s_instance;
-
public:
static CameraServer* GetInstance();
void SetImage(Image const* image);
diff --git a/wpilibc/wpilibC++Devices/include/Compressor.h b/wpilibc/wpilibC++Devices/include/Compressor.h
index e13bd962c9..df82a05c0b 100644
--- a/wpilibc/wpilibC++Devices/include/Compressor.h
+++ b/wpilibc/wpilibC++Devices/include/Compressor.h
@@ -19,9 +19,9 @@ class Compressor : public SensorBase,
public LiveWindowSendable,
public ITableListener {
public:
- explicit Compressor(uint8_t pcmID);
- Compressor();
- virtual ~Compressor();
+ // Default PCM ID is 0
+ explicit Compressor(uint8_t pcmID = GetDefaultSolenoidModule());
+ virtual ~Compressor() = default;
void Start();
void Stop();
@@ -49,16 +49,15 @@ class Compressor : public SensorBase,
void InitTable(ITable *subTable) override;
ITable *GetTable() const override;
void ValueChanged(ITable *source, const std::string &key, EntryValue value,
- bool isNew);
+ bool isNew) override;
protected:
void *m_pcm_pointer;
private:
- void InitCompressor(uint8_t module);
void SetCompressor(bool on);
- ITable *m_table;
+ ITable *m_table = nullptr;
};
#endif /* Compressor_H_ */
diff --git a/wpilibc/wpilibC++Devices/include/Counter.h b/wpilibc/wpilibC++Devices/include/Counter.h
index ce8bcaec28..d04c1e1371 100644
--- a/wpilibc/wpilibC++Devices/include/Counter.h
+++ b/wpilibc/wpilibC++Devices/include/Counter.h
@@ -27,7 +27,7 @@ class Counter : public SensorBase,
public CounterBase,
public LiveWindowSendable {
public:
- Counter();
+ explicit Counter(Mode mode = kTwoPulse);
explicit Counter(int32_t channel);
explicit Counter(DigitalSource *source);
explicit Counter(DigitalSource &source);
@@ -83,15 +83,13 @@ class Counter : public SensorBase,
ITable *GetTable() const override;
protected:
- DigitalSource *m_upSource; ///< What makes the counter count up.
- DigitalSource *m_downSource; ///< What makes the counter count down.
- void *m_counter; ///< The FPGA counter object.
+ DigitalSource *m_upSource = nullptr; ///< What makes the counter count up.
+ DigitalSource *m_downSource = nullptr; ///< What makes the counter count down.
+ void *m_counter = nullptr; ///< The FPGA counter object.
private:
- void InitCounter(Mode mode = kTwoPulse);
+ bool m_allocatedUpSource = false; ///< Was the upSource allocated locally?
+ bool m_allocatedDownSource = false; ///< Was the downSource allocated locally?
+ uint32_t m_index = 0; ///< The index of this counter.
- 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.
-
- ITable *m_table;
+ ITable *m_table = nullptr;
};
diff --git a/wpilibc/wpilibC++Devices/include/CounterBase.h b/wpilibc/wpilibC++Devices/include/CounterBase.h
index 921ea0c997..68896a8f33 100644
--- a/wpilibc/wpilibC++Devices/include/CounterBase.h
+++ b/wpilibc/wpilibC++Devices/include/CounterBase.h
@@ -20,7 +20,7 @@ class CounterBase {
public:
enum EncodingType { k1X, k2X, k4X };
- virtual ~CounterBase() {}
+ virtual ~CounterBase() = default;
virtual int32_t Get() const = 0;
virtual void Reset() = 0;
virtual double GetPeriod() const = 0;
diff --git a/wpilibc/wpilibC++Devices/include/DigitalInput.h b/wpilibc/wpilibC++Devices/include/DigitalInput.h
index b43ad071f2..a6c69a954a 100644
--- a/wpilibc/wpilibC++Devices/include/DigitalInput.h
+++ b/wpilibc/wpilibC++Devices/include/DigitalInput.h
@@ -39,9 +39,8 @@ class DigitalInput : public DigitalSource, public LiveWindowSendable {
ITable *GetTable() const;
private:
- void InitDigitalInput(uint32_t channel);
uint32_t m_channel;
bool m_lastValue;
- ITable *m_table;
+ ITable *m_table = nullptr;
};
diff --git a/wpilibc/wpilibC++Devices/include/DigitalOutput.h b/wpilibc/wpilibC++Devices/include/DigitalOutput.h
index b1cf76d16d..b73b141a6f 100644
--- a/wpilibc/wpilibC++Devices/include/DigitalOutput.h
+++ b/wpilibc/wpilibC++Devices/include/DigitalOutput.h
@@ -46,10 +46,8 @@ class DigitalOutput : public DigitalSource,
ITable *GetTable() const;
private:
- void InitDigitalOutput(uint32_t channel);
-
uint32_t m_channel;
void *m_pwmGenerator;
- ITable *m_table;
+ ITable *m_table = nullptr;
};
diff --git a/wpilibc/wpilibC++Devices/include/DigitalSource.h b/wpilibc/wpilibC++Devices/include/DigitalSource.h
index 9e0985ab7f..c716715131 100644
--- a/wpilibc/wpilibC++Devices/include/DigitalSource.h
+++ b/wpilibc/wpilibC++Devices/include/DigitalSource.h
@@ -20,7 +20,7 @@
*/
class DigitalSource : public InterruptableSensorBase {
public:
- virtual ~DigitalSource();
+ virtual ~DigitalSource() = default;
virtual uint32_t GetChannelForRouting() const = 0;
virtual uint32_t GetModuleForRouting() const = 0;
virtual bool GetAnalogTriggerForRouting() const = 0;
diff --git a/wpilibc/wpilibC++Devices/include/DoubleSolenoid.h b/wpilibc/wpilibC++Devices/include/DoubleSolenoid.h
index 4c310c11e9..48ab49c107 100644
--- a/wpilibc/wpilibC++Devices/include/DoubleSolenoid.h
+++ b/wpilibc/wpilibC++Devices/include/DoubleSolenoid.h
@@ -42,12 +42,10 @@ class DoubleSolenoid : public SolenoidBase,
ITable* GetTable() const;
private:
- virtual void InitSolenoid();
-
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.
- ITable* m_table;
+ ITable* m_table = nullptr;
};
diff --git a/wpilibc/wpilibC++Devices/include/DriverStation.h b/wpilibc/wpilibC++Devices/include/DriverStation.h
index 8d8c912d77..be3c368081 100644
--- a/wpilibc/wpilibC++Devices/include/DriverStation.h
+++ b/wpilibc/wpilibC++Devices/include/DriverStation.h
@@ -97,15 +97,15 @@ class DriverStation : public SensorBase, public RobotStateInterface {
HALJoystickPOVs m_joystickPOVs[kJoystickPorts];
HALJoystickButtons m_joystickButtons[kJoystickPorts];
HALJoystickDescriptor m_joystickDescriptor[kJoystickPorts];
- Task m_task;
- SEMAPHORE_ID m_newControlData;
- MULTIWAIT_ID m_packetDataAvailableMultiWait;
+ Task m_task{"DriverStation", (FUNCPTR)DriverStation::InitTask};
+ SEMAPHORE_ID m_newControlData = 0;
+ MULTIWAIT_ID m_packetDataAvailableMultiWait = 0;
MUTEX_ID m_packetDataAvailableMutex;
- MULTIWAIT_ID m_waitForDataSem;
+ MULTIWAIT_ID m_waitForDataSem = 0;
MUTEX_ID m_waitForDataMutex;
- bool m_userInDisabled;
- bool m_userInAutonomous;
- bool m_userInTeleop;
- bool m_userInTest;
- double m_nextMessageTime;
+ bool m_userInDisabled = false;
+ bool m_userInAutonomous = false;
+ bool m_userInTeleop = false;
+ bool m_userInTest = false;
+ double m_nextMessageTime = 0;
};
diff --git a/wpilibc/wpilibC++Devices/include/Encoder.h b/wpilibc/wpilibC++Devices/include/Encoder.h
index ce4b0e04c2..9b0f859bc6 100644
--- a/wpilibc/wpilibC++Devices/include/Encoder.h
+++ b/wpilibc/wpilibC++Devices/include/Encoder.h
@@ -96,14 +96,14 @@ class Encoder : public SensorBase,
DigitalSource *m_bSource; // the B phase of the quad encoder
bool m_allocatedASource; // was the A source allocated locally?
bool m_allocatedBSource; // was the B source allocated locally?
- void *m_encoder;
- int32_t m_index; // The encoder's FPGA index.
- double m_distancePerPulse; // distance of travel for each encoder tick
- Counter *m_counter; // Counter object for 1x and 2x encoding
- EncodingType m_encodingType; // Encoding type
- int32_t m_encodingScale; // 1x, 2x, or 4x, per the encodingType
+ void *m_encoder = nullptr;
+ int32_t m_index = 0; // The encoder's FPGA index.
+ double m_distancePerPulse = 1.0; // distance of travel for each encoder tick
+ Counter *m_counter = nullptr; // Counter object for 1x and 2x encoding
+ EncodingType m_encodingType; // Encoding type
+ int32_t m_encodingScale; // 1x, 2x, or 4x, per the encodingType
PIDSourceParameter
- m_pidSource; // Encoder parameter that sources a PID controller
+ m_pidSource = kDistance; // Encoder parameter that sources a PID controller
- ITable *m_table;
+ ITable *m_table = nullptr;
};
diff --git a/wpilibc/wpilibC++Devices/include/GearTooth.h b/wpilibc/wpilibC++Devices/include/GearTooth.h
index 7d531060f9..fd6a4bac32 100644
--- a/wpilibc/wpilibC++Devices/include/GearTooth.h
+++ b/wpilibc/wpilibC++Devices/include/GearTooth.h
@@ -23,7 +23,7 @@ class GearTooth : public Counter {
GearTooth(uint32_t channel, bool directionSensitive = false);
GearTooth(DigitalSource *source, bool directionSensitive = false);
GearTooth(DigitalSource &source, bool directionSensitive = false);
- virtual ~GearTooth();
+ virtual ~GearTooth() = default;
void EnableDirectionSensing(bool directionSensitive);
virtual std::string GetSmartDashboardType() const override;
diff --git a/wpilibc/wpilibC++Devices/include/Gyro.h b/wpilibc/wpilibC++Devices/include/Gyro.h
index 6845a8f62b..598f9d95f1 100644
--- a/wpilibc/wpilibC++Devices/include/Gyro.h
+++ b/wpilibc/wpilibC++Devices/include/Gyro.h
@@ -68,5 +68,5 @@ class Gyro : public SensorBase, public PIDSource, public LiveWindowSendable {
uint32_t m_center;
PIDSourceParameter m_pidSource;
- ITable *m_table;
+ ITable *m_table = nullptr;
};
diff --git a/wpilibc/wpilibC++Devices/include/InterruptableSensorBase.h b/wpilibc/wpilibC++Devices/include/InterruptableSensorBase.h
index b2225fb8de..07e961cb04 100644
--- a/wpilibc/wpilibC++Devices/include/InterruptableSensorBase.h
+++ b/wpilibc/wpilibC++Devices/include/InterruptableSensorBase.h
@@ -20,7 +20,7 @@ class InterruptableSensorBase : public SensorBase {
};
InterruptableSensorBase();
- virtual ~InterruptableSensorBase();
+ virtual ~InterruptableSensorBase() = default;
virtual uint32_t GetChannelForRouting() const = 0;
virtual uint32_t GetModuleForRouting() const = 0;
virtual bool GetAnalogTriggerForRouting() const = 0;
@@ -42,7 +42,7 @@ class InterruptableSensorBase : public SensorBase {
virtual void SetUpSourceEdge(bool risingEdge, bool fallingEdge);
protected:
- void *m_interrupt;
+ void *m_interrupt = nullptr;
uint32_t m_interruptIndex;
void AllocateInterrupts(bool watcher);
diff --git a/wpilibc/wpilibC++Devices/include/IterativeRobot.h b/wpilibc/wpilibC++Devices/include/IterativeRobot.h
index 79f4c8e544..51387e50fb 100644
--- a/wpilibc/wpilibC++Devices/include/IterativeRobot.h
+++ b/wpilibc/wpilibC++Devices/include/IterativeRobot.h
@@ -72,12 +72,12 @@ class IterativeRobot : public RobotBase {
protected:
virtual void Prestart();
- virtual ~IterativeRobot();
+ virtual ~IterativeRobot() = default;
IterativeRobot();
private:
- bool m_disabledInitialized;
- bool m_autonomousInitialized;
- bool m_teleopInitialized;
- bool m_testInitialized;
+ bool m_disabledInitialized = false;
+ bool m_autonomousInitialized = false;
+ bool m_teleopInitialized = false;
+ bool m_testInitialized = false;
};
diff --git a/wpilibc/wpilibC++Devices/include/Jaguar.h b/wpilibc/wpilibC++Devices/include/Jaguar.h
index cf47e69034..feb00c7699 100644
--- a/wpilibc/wpilibC++Devices/include/Jaguar.h
+++ b/wpilibc/wpilibC++Devices/include/Jaguar.h
@@ -16,16 +16,15 @@
class Jaguar : public SafePWM, public SpeedController {
public:
explicit Jaguar(uint32_t channel);
- virtual ~Jaguar();
- virtual void Set(float value, uint8_t syncGroup = 0);
- virtual float Get() const;
- virtual void Disable();
+ virtual ~Jaguar() = default;
+ virtual void Set(float value, uint8_t syncGroup = 0) override;
+ virtual float Get() const override;
+ virtual void Disable() override;
virtual void PIDWrite(float output) override;
virtual void SetInverted(bool isInverted) override;
virtual bool GetInverted() const override;
private:
- void InitJaguar();
- bool m_isInverted;
+ bool m_isInverted = false;
};
diff --git a/wpilibc/wpilibC++Devices/include/Joystick.h b/wpilibc/wpilibC++Devices/include/Joystick.h
index 66d8af142e..94ad3714d4 100644
--- a/wpilibc/wpilibC++Devices/include/Joystick.h
+++ b/wpilibc/wpilibC++Devices/include/Joystick.h
@@ -102,15 +102,14 @@ class Joystick : public GenericHID, public ErrorBase {
private:
DISALLOW_COPY_AND_ASSIGN(Joystick);
- void InitJoystick(uint32_t numAxisTypes, uint32_t numButtonTypes);
- DriverStation *m_ds;
+ DriverStation *m_ds = nullptr;
uint32_t m_port;
- uint32_t *m_axes;
- uint32_t *m_buttons;
- uint32_t m_outputs;
- uint16_t m_leftRumble;
- uint16_t m_rightRumble;
+ uint32_t *m_axes = nullptr;
+ uint32_t *m_buttons = nullptr;
+ uint32_t m_outputs = 0;
+ uint16_t m_leftRumble = 0;
+ uint16_t m_rightRumble = 0;
};
#endif
diff --git a/wpilibc/wpilibC++Devices/include/NetworkCommunication/CANInterfacePlugin.h b/wpilibc/wpilibC++Devices/include/NetworkCommunication/CANInterfacePlugin.h
index 1dd6404456..8659dac3f7 100644
--- a/wpilibc/wpilibC++Devices/include/NetworkCommunication/CANInterfacePlugin.h
+++ b/wpilibc/wpilibC++Devices/include/NetworkCommunication/CANInterfacePlugin.h
@@ -31,7 +31,7 @@ class CANInterfacePlugin {
* @param messageID The 29-bit CAN message ID in the lsbs. The msb can
* indicate a remote frame.
* @param data A pointer to a buffer containing between 0 and 8 bytes to send
- * with the message. May be NULL if dataSize is 0.
+ * with the message. May be nullptr if dataSize is 0.
* @param dataSize The number of bytes to send with the message.
* @return Return any error code. On success return 0.
*/
@@ -101,7 +101,7 @@ class CANInterfacePlugin {
*
* @param interface A pointer to an object that inherits from CANInterfacePlugin
* and implements
- * the pure virtual interface. If NULL, unregister the current plugin.
+ * the pure virtual interface. If nullptr, unregister the current plugin.
*/
void FRC_NetworkCommunication_CANSessionMux_registerInterface(
CANInterfacePlugin *interface);
diff --git a/wpilibc/wpilibC++Devices/include/NetworkCommunication/UsageReporting.h b/wpilibc/wpilibC++Devices/include/NetworkCommunication/UsageReporting.h
index ca73a2fbf2..693d0dc9c1 100644
--- a/wpilibc/wpilibC++Devices/include/NetworkCommunication/UsageReporting.h
+++ b/wpilibc/wpilibC++Devices/include/NetworkCommunication/UsageReporting.h
@@ -128,7 +128,7 @@ typedef enum {
* change the feature string.
*/
uint32_t EXPORT_FUNC report(tResourceType resource, uint8_t instanceNumber,
- uint8_t context = 0, const char *feature = NULL);
+ uint8_t context = 0, const char *feature = nullptr);
}
#ifdef __cplusplus
diff --git a/wpilibc/wpilibC++Devices/include/PWM.h b/wpilibc/wpilibC++Devices/include/PWM.h
index 565f515e64..ca874c4098 100644
--- a/wpilibc/wpilibC++Devices/include/PWM.h
+++ b/wpilibc/wpilibC++Devices/include/PWM.h
@@ -106,10 +106,9 @@ class PWM : public SensorBase,
void InitTable(ITable* subTable) override;
ITable* GetTable() const override;
- ITable* m_table;
+ ITable* m_table = nullptr;
private:
- void InitPWM(uint32_t channel);
uint32_t m_channel;
int32_t GetMaxPositivePwm() const { return m_maxPwm; }
int32_t GetMinPositivePwm() const {
diff --git a/wpilibc/wpilibC++Devices/include/PowerDistributionPanel.h b/wpilibc/wpilibC++Devices/include/PowerDistributionPanel.h
index bfa9eae1f4..44a873d813 100644
--- a/wpilibc/wpilibC++Devices/include/PowerDistributionPanel.h
+++ b/wpilibc/wpilibC++Devices/include/PowerDistributionPanel.h
@@ -40,7 +40,7 @@ class PowerDistributionPanel : public SensorBase, public LiveWindowSendable {
ITable *GetTable() const override;
private:
- ITable *m_table;
+ ITable *m_table = nullptr;
uint8_t m_module;
};
diff --git a/wpilibc/wpilibC++Devices/include/Preferences.h b/wpilibc/wpilibC++Devices/include/Preferences.h
index b3fd11d30d..9464b2b389 100644
--- a/wpilibc/wpilibC++Devices/include/Preferences.h
+++ b/wpilibc/wpilibC++Devices/include/Preferences.h
@@ -82,14 +82,12 @@ class Preferences : public ErrorBase, public ITableListener {
return 0;
}
- static Preferences *_instance;
-
/** The semaphore for accessing the file */
- MUTEX_ID m_fileLock;
+ MUTEX_ID m_fileLock = nullptr;
/** The semaphore for beginning reads and writes to the file */
- SEMAPHORE_ID m_fileOpStarted;
+ SEMAPHORE_ID m_fileOpStarted = nullptr;
/** The semaphore for reading from the table */
- MUTEX_ID m_tableLock;
+ MUTEX_ID m_tableLock = nullptr;
typedef std::map StringMap;
/** The actual values (String->String) */
StringMap m_values;
diff --git a/wpilibc/wpilibC++Devices/include/Relay.h b/wpilibc/wpilibC++Devices/include/Relay.h
index 0b2aa88f48..9279a1ec5b 100644
--- a/wpilibc/wpilibC++Devices/include/Relay.h
+++ b/wpilibc/wpilibC++Devices/include/Relay.h
@@ -47,11 +47,9 @@ class Relay : public SensorBase,
void InitTable(ITable* subTable) override;
ITable* GetTable() const override;
- ITable* m_table;
+ ITable* m_table = nullptr;
private:
- void InitRelay();
-
uint32_t m_channel;
Direction m_direction;
};
diff --git a/wpilibc/wpilibC++Devices/include/RobotBase.h b/wpilibc/wpilibC++Devices/include/RobotBase.h
index 79a5eecff0..25bb6d4181 100644
--- a/wpilibc/wpilibC++Devices/include/RobotBase.h
+++ b/wpilibc/wpilibC++Devices/include/RobotBase.h
@@ -61,8 +61,8 @@ class RobotBase {
virtual void Prestart();
- Task *m_task;
- DriverStation *m_ds;
+ Task *m_task = nullptr;
+ DriverStation *m_ds = nullptr;
private:
static RobotBase *m_instance;
diff --git a/wpilibc/wpilibC++Devices/include/RobotDrive.h b/wpilibc/wpilibC++Devices/include/RobotDrive.h
index a8cd866d69..04d46bf403 100644
--- a/wpilibc/wpilibC++Devices/include/RobotDrive.h
+++ b/wpilibc/wpilibC++Devices/include/RobotDrive.h
@@ -97,15 +97,15 @@ class RobotDrive : public MotorSafety, public ErrorBase {
void RotateVector(double &x, double &y, double angle);
static const int32_t kMaxNumberOfMotors = 4;
- float m_sensitivity;
- double m_maxOutput;
+ float m_sensitivity = 0.5;
+ double m_maxOutput = 1.0;
bool m_deleteSpeedControllers;
- SpeedController *m_frontLeftMotor;
- SpeedController *m_frontRightMotor;
- SpeedController *m_rearLeftMotor;
- SpeedController *m_rearRightMotor;
- MotorSafetyHelper *m_safetyHelper;
- uint8_t m_syncGroup;
+ SpeedController *m_frontLeftMotor = nullptr;
+ SpeedController *m_frontRightMotor = nullptr;
+ SpeedController *m_rearLeftMotor = nullptr;
+ SpeedController *m_rearRightMotor = nullptr;
+ MotorSafetyHelper *m_safetyHelper = nullptr;
+ uint8_t m_syncGroup = 0;
private:
int32_t GetNumMotors() {
diff --git a/wpilibc/wpilibC++Devices/include/SafePWM.h b/wpilibc/wpilibC++Devices/include/SafePWM.h
index 1896884718..f672dc6210 100644
--- a/wpilibc/wpilibC++Devices/include/SafePWM.h
+++ b/wpilibc/wpilibC++Devices/include/SafePWM.h
@@ -36,6 +36,5 @@ class SafePWM : public PWM, public MotorSafety {
virtual void SetSpeed(float speed);
private:
- void InitSafePWM();
MotorSafetyHelper *m_safetyHelper;
};
diff --git a/wpilibc/wpilibC++Devices/include/SampleRobot.h b/wpilibc/wpilibC++Devices/include/SampleRobot.h
index 924db71620..64ca32c717 100644
--- a/wpilibc/wpilibC++Devices/include/SampleRobot.h
+++ b/wpilibc/wpilibC++Devices/include/SampleRobot.h
@@ -11,7 +11,7 @@
class SampleRobot : public RobotBase {
public:
SampleRobot();
- virtual ~SampleRobot() {}
+ virtual ~SampleRobot() = default;
virtual void RobotInit();
virtual void Disabled();
virtual void Autonomous();
diff --git a/wpilibc/wpilibC++Devices/include/SerialPort.h b/wpilibc/wpilibC++Devices/include/SerialPort.h
index 22f8e3896c..04a61cc55d 100644
--- a/wpilibc/wpilibC++Devices/include/SerialPort.h
+++ b/wpilibc/wpilibC++Devices/include/SerialPort.h
@@ -62,9 +62,9 @@ class SerialPort : public ErrorBase {
void Reset();
private:
- uint32_t m_resourceManagerHandle;
- uint32_t m_portHandle;
- bool m_consoleModeEnabled;
+ uint32_t m_resourceManagerHandle = 0;
+ uint32_t m_portHandle = 0;
+ bool m_consoleModeEnabled = false;
uint8_t m_port;
DISALLOW_COPY_AND_ASSIGN(SerialPort);
diff --git a/wpilibc/wpilibC++Devices/include/Servo.h b/wpilibc/wpilibC++Devices/include/Servo.h
index aa183de963..8386023fff 100644
--- a/wpilibc/wpilibC++Devices/include/Servo.h
+++ b/wpilibc/wpilibC++Devices/include/Servo.h
@@ -37,10 +37,9 @@ class Servo : public SafePWM {
void InitTable(ITable* subTable) override;
ITable* GetTable() const override;
- ITable* m_table;
+ ITable* m_table = nullptr;
private:
- void InitServo();
float GetServoAngleRange() const { return kMaxServoAngle - kMinServoAngle; }
static constexpr float kMaxServoAngle = 180.0;
diff --git a/wpilibc/wpilibC++Devices/include/Solenoid.h b/wpilibc/wpilibC++Devices/include/Solenoid.h
index 2642fc81b0..a760413805 100644
--- a/wpilibc/wpilibC++Devices/include/Solenoid.h
+++ b/wpilibc/wpilibC++Devices/include/Solenoid.h
@@ -38,8 +38,6 @@ class Solenoid : public SolenoidBase,
ITable* GetTable() const;
private:
- void InitSolenoid();
-
uint32_t m_channel; ///< The channel on the module to control.
- ITable* m_table;
+ ITable* m_table = nullptr;
};
diff --git a/wpilibc/wpilibC++Devices/include/SolenoidBase.h b/wpilibc/wpilibC++Devices/include/SolenoidBase.h
index decf8589bb..0a51be6352 100644
--- a/wpilibc/wpilibC++Devices/include/SolenoidBase.h
+++ b/wpilibc/wpilibC++Devices/include/SolenoidBase.h
@@ -18,7 +18,7 @@
*/
class SolenoidBase : public SensorBase {
public:
- virtual ~SolenoidBase();
+ virtual ~SolenoidBase() = default;
uint8_t GetAll(int module = 0) const;
uint8_t GetPCMSolenoidBlackList(int module) const;
@@ -29,7 +29,6 @@ class SolenoidBase : public SensorBase {
protected:
explicit SolenoidBase(uint8_t pcmID);
void Set(uint8_t value, uint8_t mask, int module);
- virtual void InitSolenoid() = 0;
const static int m_maxModules = 63;
const static int m_maxPorts = 8;
static void* m_ports[m_maxModules][m_maxPorts];
diff --git a/wpilibc/wpilibC++Devices/include/SpeedController.h b/wpilibc/wpilibC++Devices/include/SpeedController.h
index 6d8e72c924..a87ed2bc7f 100644
--- a/wpilibc/wpilibC++Devices/include/SpeedController.h
+++ b/wpilibc/wpilibC++Devices/include/SpeedController.h
@@ -14,7 +14,7 @@
*/
class SpeedController : public PIDOutput {
public:
- virtual ~SpeedController() {}
+ virtual ~SpeedController() = default;
/**
* Common interface for setting the speed of a speed controller.
*
diff --git a/wpilibc/wpilibC++Devices/include/Talon.h b/wpilibc/wpilibC++Devices/include/Talon.h
index 6ff5c6ecdc..38764b850d 100644
--- a/wpilibc/wpilibC++Devices/include/Talon.h
+++ b/wpilibc/wpilibC++Devices/include/Talon.h
@@ -16,16 +16,15 @@
class Talon : public SafePWM, public SpeedController {
public:
explicit Talon(uint32_t channel);
- virtual ~Talon();
- virtual void Set(float value, uint8_t syncGroup = 0);
- virtual float Get() const;
- virtual void Disable();
+ virtual ~Talon() = default;
+ virtual void Set(float value, uint8_t syncGroup = 0) override;
+ virtual float Get() const override;
+ virtual void Disable() override;
virtual void PIDWrite(float output) override;
virtual void SetInverted(bool isInverted) override;
virtual bool GetInverted() const override;
private:
- void InitTalon();
- bool m_isInverted;
+ bool m_isInverted = false;
};
diff --git a/wpilibc/wpilibC++Devices/include/TalonSRX.h b/wpilibc/wpilibC++Devices/include/TalonSRX.h
index 76de9b1b23..8819723f7c 100644
--- a/wpilibc/wpilibC++Devices/include/TalonSRX.h
+++ b/wpilibc/wpilibC++Devices/include/TalonSRX.h
@@ -17,7 +17,7 @@
class TalonSRX : public SafePWM, public SpeedController {
public:
explicit TalonSRX(uint32_t channel);
- virtual ~TalonSRX();
+ virtual ~TalonSRX() = default;
virtual void Set(float value, uint8_t syncGroup = 0) override;
virtual float Get() const override;
virtual void Disable() override;
@@ -27,6 +27,5 @@ class TalonSRX : public SafePWM, public SpeedController {
virtual bool GetInverted() const override;
private:
- void InitTalonSRX();
- bool m_isInverted;
+ bool m_isInverted = false;
};
diff --git a/wpilibc/wpilibC++Devices/include/USBCamera.h b/wpilibc/wpilibC++Devices/include/USBCamera.h
index 62fa2a942d..991c38bc90 100644
--- a/wpilibc/wpilibC++Devices/include/USBCamera.h
+++ b/wpilibc/wpilibC++Devices/include/USBCamera.h
@@ -36,26 +36,30 @@ class USBCamera : public ErrorBase {
static constexpr char const *ATTR_BR_VALUE =
"CameraAttributes::Brightness::Value";
+ // Constants for the manual and auto types
+ static constexpr char const* AUTO = "Auto";
+ static constexpr char const* MANUAL = "Manual";
+
protected:
- IMAQdxSession m_id;
+ IMAQdxSession m_id = 0;
std::string m_name;
bool m_useJpeg;
- bool m_active;
- bool m_open;
+ bool m_active = false;
+ bool m_open = false;
std::recursive_mutex m_mutex;
- unsigned int m_width;
- unsigned int m_height;
- double m_fps;
- std::string m_whiteBalance;
- unsigned int m_whiteBalanceValue;
- bool m_whiteBalanceValuePresent;
- std::string m_exposure;
- unsigned int m_exposureValue;
- bool m_exposureValuePresent;
- unsigned int m_brightness;
- bool m_needSettingsUpdate;
+ unsigned int m_width = 320;
+ unsigned int m_height = 240;
+ double m_fps = 30;
+ std::string m_whiteBalance = AUTO;
+ unsigned int m_whiteBalanceValue = 0;
+ bool m_whiteBalanceValuePresent = false;
+ std::string m_exposure = MANUAL;
+ unsigned int m_exposureValue = 50;
+ bool m_exposureValuePresent = false;
+ unsigned int m_brightness = 80;
+ bool m_needSettingsUpdate = true;
unsigned int GetJpegSize(void *buffer, unsigned int buffSize);
diff --git a/wpilibc/wpilibC++Devices/include/Ultrasonic.h b/wpilibc/wpilibC++Devices/include/Ultrasonic.h
index 3a917b36ba..f956fb1edc 100644
--- a/wpilibc/wpilibC++Devices/include/Ultrasonic.h
+++ b/wpilibc/wpilibC++Devices/include/Ultrasonic.h
@@ -90,5 +90,5 @@ class Ultrasonic : public SensorBase,
Ultrasonic *m_nextSensor;
DistanceUnit m_units;
- ITable *m_table;
+ ITable *m_table = nullptr;
};
diff --git a/wpilibc/wpilibC++Devices/include/Victor.h b/wpilibc/wpilibC++Devices/include/Victor.h
index 1c59377624..755955f306 100644
--- a/wpilibc/wpilibC++Devices/include/Victor.h
+++ b/wpilibc/wpilibC++Devices/include/Victor.h
@@ -19,10 +19,10 @@
class Victor : public SafePWM, public SpeedController {
public:
explicit Victor(uint32_t channel);
- virtual ~Victor();
- virtual void Set(float value, uint8_t syncGroup = 0);
- virtual float Get() const;
- virtual void Disable();
+ virtual ~Victor() = default;
+ virtual void Set(float value, uint8_t syncGroup = 0) override;
+ virtual float Get() const override;
+ virtual void Disable() override;
virtual void PIDWrite(float output) override;
@@ -30,6 +30,5 @@ class Victor : public SafePWM, public SpeedController {
virtual bool GetInverted() const override;
private:
- void InitVictor();
- bool m_isInverted;
+ bool m_isInverted = false;
};
diff --git a/wpilibc/wpilibC++Devices/include/VictorSP.h b/wpilibc/wpilibC++Devices/include/VictorSP.h
index 3d5f52f08b..978cd0ac0c 100644
--- a/wpilibc/wpilibC++Devices/include/VictorSP.h
+++ b/wpilibc/wpilibC++Devices/include/VictorSP.h
@@ -16,10 +16,10 @@
class VictorSP : public SafePWM, public SpeedController {
public:
explicit VictorSP(uint32_t channel);
- virtual ~VictorSP();
- virtual void Set(float value, uint8_t syncGroup = 0);
- virtual float Get() const;
- virtual void Disable();
+ virtual ~VictorSP() = default;
+ virtual void Set(float value, uint8_t syncGroup = 0) override;
+ virtual float Get() const override;
+ virtual void Disable() override;
virtual void PIDWrite(float output) override;
@@ -27,6 +27,5 @@ class VictorSP : public SafePWM, public SpeedController {
virtual bool GetInverted() const override;
private:
- void InitVictorSP();
- bool m_isInverted;
+ bool m_isInverted = false;
};
diff --git a/wpilibc/wpilibC++Devices/include/Vision/AxisCamera.h b/wpilibc/wpilibC++Devices/include/Vision/AxisCamera.h
index 23e14e9d2a..99e1baec5e 100644
--- a/wpilibc/wpilibC++Devices/include/Vision/AxisCamera.h
+++ b/wpilibc/wpilibC++Devices/include/Vision/AxisCamera.h
@@ -89,27 +89,27 @@ class AxisCamera : public ErrorBase {
private:
std::thread m_captureThread;
std::string m_cameraHost;
- int m_cameraSocket;
+ int m_cameraSocket = -1;
std::mutex m_captureMutex;
std::mutex m_imageDataMutex;
std::vector m_imageData;
- bool m_freshImage;
+ bool m_freshImage = false;
- int m_brightness;
- WhiteBalance m_whiteBalance;
- int m_colorLevel;
- ExposureControl m_exposureControl;
- int m_exposurePriority;
- int m_maxFPS;
- Resolution m_resolution;
- int m_compression;
- Rotation m_rotation;
- bool m_parametersDirty;
- bool m_streamDirty;
+ int m_brightness = 50;
+ WhiteBalance m_whiteBalance = kWhiteBalance_Automatic;
+ int m_colorLevel = 50;
+ ExposureControl m_exposureControl = kExposureControl_Automatic;
+ int m_exposurePriority = 50;
+ int m_maxFPS = 0;
+ Resolution m_resolution = kResolution_640x480;
+ int m_compression = 50;
+ Rotation m_rotation = kRotation_0;
+ bool m_parametersDirty = true;
+ bool m_streamDirty = true;
std::mutex m_parametersMutex;
- bool m_done;
+ bool m_done = false;
void Capture();
void ReadImagesFromCamera();
diff --git a/wpilibc/wpilibC++Devices/include/Vision/BinaryImage.h b/wpilibc/wpilibC++Devices/include/Vision/BinaryImage.h
index 2eab08fb1f..eda072c84a 100644
--- a/wpilibc/wpilibC++Devices/include/Vision/BinaryImage.h
+++ b/wpilibc/wpilibC++Devices/include/Vision/BinaryImage.h
@@ -19,7 +19,7 @@
class BinaryImage : public MonoImage {
public:
BinaryImage();
- virtual ~BinaryImage();
+ virtual ~BinaryImage() = default;
int GetNumberParticles();
ParticleAnalysisReport GetParticleAnalysisReport(int particleNumber);
void GetParticleAnalysisReport(int particleNumber,
diff --git a/wpilibc/wpilibC++Devices/include/Vision/ColorImage.h b/wpilibc/wpilibC++Devices/include/Vision/ColorImage.h
index cabf08058e..0304ad89bf 100644
--- a/wpilibc/wpilibC++Devices/include/Vision/ColorImage.h
+++ b/wpilibc/wpilibC++Devices/include/Vision/ColorImage.h
@@ -13,7 +13,7 @@
class ColorImage : public ImageBase {
public:
ColorImage(ImageType type);
- virtual ~ColorImage();
+ virtual ~ColorImage() = default;
BinaryImage *ThresholdRGB(int redLow, int redHigh, int greenLow,
int greenHigh, int blueLow, int blueHigh);
BinaryImage *ThresholdHSL(int hueLow, int hueHigh, int saturationLow,
diff --git a/wpilibc/wpilibC++Devices/include/Vision/HSLImage.h b/wpilibc/wpilibC++Devices/include/Vision/HSLImage.h
index 54ee5f1b7b..0407748c62 100644
--- a/wpilibc/wpilibC++Devices/include/Vision/HSLImage.h
+++ b/wpilibc/wpilibC++Devices/include/Vision/HSLImage.h
@@ -15,5 +15,5 @@ class HSLImage : public ColorImage {
public:
HSLImage();
HSLImage(const char *fileName);
- virtual ~HSLImage();
+ virtual ~HSLImage() = default;
};
diff --git a/wpilibc/wpilibC++Devices/include/Vision/MonoImage.h b/wpilibc/wpilibC++Devices/include/Vision/MonoImage.h
index c45e53b0e2..189be052aa 100644
--- a/wpilibc/wpilibC++Devices/include/Vision/MonoImage.h
+++ b/wpilibc/wpilibC++Devices/include/Vision/MonoImage.h
@@ -13,7 +13,7 @@
class MonoImage : public ImageBase {
public:
MonoImage();
- virtual ~MonoImage();
+ virtual ~MonoImage() = default;
std::vector *DetectEllipses(
EllipseDescriptor *ellipseDescriptor, CurveOptions *curveOptions,
diff --git a/wpilibc/wpilibC++Devices/include/Vision/RGBImage.h b/wpilibc/wpilibC++Devices/include/Vision/RGBImage.h
index efe3fda2ee..cb3b3e5dde 100644
--- a/wpilibc/wpilibC++Devices/include/Vision/RGBImage.h
+++ b/wpilibc/wpilibC++Devices/include/Vision/RGBImage.h
@@ -15,5 +15,5 @@ class RGBImage : public ColorImage {
public:
RGBImage();
RGBImage(const char *fileName);
- virtual ~RGBImage();
+ virtual ~RGBImage() = default;
};
diff --git a/wpilibc/wpilibC++Devices/include/nivision.h b/wpilibc/wpilibC++Devices/include/nivision.h
index 4289922e40..5c569622b2 100644
--- a/wpilibc/wpilibC++Devices/include/nivision.h
+++ b/wpilibc/wpilibC++Devices/include/nivision.h
@@ -54,9 +54,9 @@
//============================================================================
#ifndef NULL
#ifdef __cplusplus
-#define NULL 0
-#else
#define NULL ((void*)0)
+#else
+#define NULL 0
#endif
#endif
diff --git a/wpilibc/wpilibC++Devices/src/ADXL345_I2C.cpp b/wpilibc/wpilibC++Devices/src/ADXL345_I2C.cpp
index 4943c93fad..5ebdb08c02 100644
--- a/wpilibc/wpilibC++Devices/src/ADXL345_I2C.cpp
+++ b/wpilibc/wpilibC++Devices/src/ADXL345_I2C.cpp
@@ -35,14 +35,6 @@ ADXL345_I2C::ADXL345_I2C(Port port, Range range) : I2C(port, kAddress) {
LiveWindow::GetInstance()->AddSensor("ADXL345_I2C", port, this);
}
-/**
- * Destructor.
- */
-ADXL345_I2C::~ADXL345_I2C() {
- // delete m_i2c;
- // m_i2c = NULL;
-}
-
/** {@inheritdoc} */
void ADXL345_I2C::SetRange(Range range) {
Write(kDataFormatRegister, kDataFormat_FullRes | (uint8_t)range);
@@ -102,7 +94,7 @@ void ADXL345_I2C::InitTable(ITable *subtable) {
}
void ADXL345_I2C::UpdateTable() {
- if (m_table != NULL) {
+ if (m_table != nullptr) {
m_table->PutNumber("X", GetX());
m_table->PutNumber("Y", GetY());
m_table->PutNumber("Z", GetZ());
diff --git a/wpilibc/wpilibC++Devices/src/ADXL345_SPI.cpp b/wpilibc/wpilibC++Devices/src/ADXL345_SPI.cpp
index 1f000b8d1b..7e430ced6b 100644
--- a/wpilibc/wpilibC++Devices/src/ADXL345_SPI.cpp
+++ b/wpilibc/wpilibC++Devices/src/ADXL345_SPI.cpp
@@ -56,7 +56,7 @@ void ADXL345_SPI::Init(Range range) {
*/
ADXL345_SPI::~ADXL345_SPI() {
delete m_spi;
- m_spi = NULL;
+ m_spi = nullptr;
}
/** {@inheritdoc} */
@@ -136,7 +136,7 @@ void ADXL345_SPI::InitTable(ITable* subtable) {
}
void ADXL345_SPI::UpdateTable() {
- if (m_table != NULL) {
+ if (m_table != nullptr) {
m_table->PutNumber("X", GetX());
m_table->PutNumber("Y", GetY());
m_table->PutNumber("Z", GetZ());
diff --git a/wpilibc/wpilibC++Devices/src/AnalogAccelerometer.cpp b/wpilibc/wpilibC++Devices/src/AnalogAccelerometer.cpp
index 9e685b1045..45b5743b84 100644
--- a/wpilibc/wpilibC++Devices/src/AnalogAccelerometer.cpp
+++ b/wpilibc/wpilibC++Devices/src/AnalogAccelerometer.cpp
@@ -14,9 +14,6 @@
* Common function for initializing the accelerometer.
*/
void AnalogAccelerometer::InitAccelerometer() {
- m_table = NULL;
- m_voltsPerG = 1.0;
- m_zeroGVoltage = 2.5;
HALReport(HALUsageReporting::kResourceType_Accelerometer,
m_AnalogInput->GetChannel());
LiveWindow::GetInstance()->AddSensor("Accelerometer",
@@ -46,7 +43,7 @@ AnalogAccelerometer::AnalogAccelerometer(int32_t channel) {
* accelerometer is connected to
*/
AnalogAccelerometer::AnalogAccelerometer(AnalogInput *channel) {
- if (channel == NULL) {
+ if (channel == nullptr) {
wpi_setWPIError(NullParameter);
} else {
m_AnalogInput = channel;
@@ -107,7 +104,7 @@ void AnalogAccelerometer::SetZero(float zero) { m_zeroGVoltage = zero; }
double AnalogAccelerometer::PIDGet() const { return GetAcceleration(); }
void AnalogAccelerometer::UpdateTable() {
- if (m_table != NULL) {
+ if (m_table != nullptr) {
m_table->PutNumber("Value", GetAcceleration());
}
}
diff --git a/wpilibc/wpilibC++Devices/src/AnalogInput.cpp b/wpilibc/wpilibC++Devices/src/AnalogInput.cpp
index 0ccb60d91b..ef3ab5915d 100644
--- a/wpilibc/wpilibC++Devices/src/AnalogInput.cpp
+++ b/wpilibc/wpilibC++Devices/src/AnalogInput.cpp
@@ -11,17 +11,19 @@
#include "WPIErrors.h"
#include "LiveWindow/LiveWindow.h"
-static Resource *inputs = NULL;
+static Resource *inputs = nullptr;
const uint8_t AnalogInput::kAccumulatorModuleNumber;
const uint32_t AnalogInput::kAccumulatorNumChannels;
const uint32_t AnalogInput::kAccumulatorChannels[] = {0, 1};
/**
- * Common initialization.
+ * Construct an analog input.
+ *
+ * @param channel The channel number on the roboRIO to represent. 0-3 are
+ * on-board 4-7 are on the MXP port.
*/
-void AnalogInput::InitAnalogInput(uint32_t channel) {
- m_table = NULL;
+AnalogInput::AnalogInput(uint32_t channel) {
char buf[64];
Resource::CreateResourceObject(&inputs, kAnalogInputs);
@@ -48,14 +50,6 @@ void AnalogInput::InitAnalogInput(uint32_t channel) {
HALReport(HALUsageReporting::kResourceType_AnalogChannel, channel);
}
-/**
- * Construct an analog input.
- *
- * @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) { InitAnalogInput(channel); }
-
/**
* Channel destructor.
*/
@@ -405,7 +399,7 @@ double AnalogInput::PIDGet() const {
}
void AnalogInput::UpdateTable() {
- if (m_table != NULL) {
+ if (m_table != nullptr) {
m_table->PutNumber("Value", GetAverageVoltage());
}
}
diff --git a/wpilibc/wpilibC++Devices/src/AnalogOutput.cpp b/wpilibc/wpilibC++Devices/src/AnalogOutput.cpp
index a468b1cb3c..c6f2def0c2 100644
--- a/wpilibc/wpilibC++Devices/src/AnalogOutput.cpp
+++ b/wpilibc/wpilibC++Devices/src/AnalogOutput.cpp
@@ -10,11 +10,14 @@
#include "WPIErrors.h"
#include "LiveWindow/LiveWindow.h"
-static Resource *outputs = NULL;
-
-void AnalogOutput::InitAnalogOutput(uint32_t channel) {
- m_table = NULL;
+static Resource *outputs = nullptr;
+/**
+ * Construct an analog output on the given channel.
+ * All analog outputs are located on the MXP port.
+ * @param The channel number on the roboRIO to represent.
+ */
+AnalogOutput::AnalogOutput(uint32_t channel) {
Resource::CreateResourceObject(&outputs, kAnalogOutputs);
char buf[64];
@@ -41,13 +44,6 @@ void AnalogOutput::InitAnalogOutput(uint32_t channel) {
HALReport(HALUsageReporting::kResourceType_AnalogOutput, m_channel);
}
-/**
- * Construct an analog output on the given channel.
- * All analog outputs are located on the MXP port.
- * @param The channel number on the roboRIO to represent.
- */
-AnalogOutput::AnalogOutput(uint32_t channel) { InitAnalogOutput(channel); }
-
/**
* Destructor. Frees analog output resource
*/
@@ -80,7 +76,7 @@ float AnalogOutput::GetVoltage() const {
}
void AnalogOutput::UpdateTable() {
- if (m_table != NULL) {
+ if (m_table != nullptr) {
m_table->PutNumber("Value", GetVoltage());
}
}
diff --git a/wpilibc/wpilibC++Devices/src/AnalogPotentiometer.cpp b/wpilibc/wpilibC++Devices/src/AnalogPotentiometer.cpp
index 05c9ce07d9..c529fa39a9 100644
--- a/wpilibc/wpilibC++Devices/src/AnalogPotentiometer.cpp
+++ b/wpilibc/wpilibC++Devices/src/AnalogPotentiometer.cpp
@@ -103,7 +103,7 @@ void AnalogPotentiometer::InitTable(ITable *subtable) {
}
void AnalogPotentiometer::UpdateTable() {
- if (m_table != NULL) {
+ if (m_table != nullptr) {
m_table->PutNumber("Value", Get());
}
}
diff --git a/wpilibc/wpilibC++Devices/src/AnalogTrigger.cpp b/wpilibc/wpilibC++Devices/src/AnalogTrigger.cpp
index f5ffe64651..9289a2ca58 100644
--- a/wpilibc/wpilibC++Devices/src/AnalogTrigger.cpp
+++ b/wpilibc/wpilibC++Devices/src/AnalogTrigger.cpp
@@ -13,9 +13,12 @@
#include "WPIErrors.h"
/**
- * Initialize an analog trigger from a channel.
+ * Constructor for an analog trigger given a channel number.
+ *
+ * @param channel The channel number on the roboRIO to represent. 0-3 are
+ * on-board 4-7 are on the MXP port.
*/
-void AnalogTrigger::InitTrigger(uint32_t channel) {
+AnalogTrigger::AnalogTrigger(int32_t channel) {
void *port = getPort(channel);
int32_t status = 0;
uint32_t index = 0;
@@ -26,22 +29,14 @@ void AnalogTrigger::InitTrigger(uint32_t channel) {
HALReport(HALUsageReporting::kResourceType_AnalogTrigger, channel);
}
-/**
- * Constructor for an analog trigger given a channel number.
- *
- * @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) { InitTrigger(channel); }
-
/**
* Construct an analog trigger given an analog input.
* This should be used in the case of sharing an analog channel between the
* trigger and an analog input object.
* @param channel The pointer to the existing AnalogInput object
*/
-AnalogTrigger::AnalogTrigger(AnalogInput *input) {
- InitTrigger(input->GetChannel());
+AnalogTrigger::AnalogTrigger(AnalogInput *input) :
+ AnalogTrigger(input->GetChannel()) {
}
AnalogTrigger::~AnalogTrigger() {
@@ -156,6 +151,6 @@ bool AnalogTrigger::GetTriggerState() {
* @return A pointer to a new AnalogTriggerOutput object.
*/
AnalogTriggerOutput *AnalogTrigger::CreateOutput(AnalogTriggerType type) {
- if (StatusIsFatal()) return NULL;
+ if (StatusIsFatal()) return nullptr;
return new AnalogTriggerOutput(this, type);
}
diff --git a/wpilibc/wpilibC++Devices/src/AnalogTriggerOutput.cpp b/wpilibc/wpilibC++Devices/src/AnalogTriggerOutput.cpp
index 87f75c20bc..68348e54fc 100644
--- a/wpilibc/wpilibC++Devices/src/AnalogTriggerOutput.cpp
+++ b/wpilibc/wpilibC++Devices/src/AnalogTriggerOutput.cpp
@@ -30,11 +30,11 @@ AnalogTriggerOutput::AnalogTriggerOutput(AnalogTrigger *trigger,
}
AnalogTriggerOutput::~AnalogTriggerOutput() {
- if (m_interrupt != NULL) {
+ if (m_interrupt != nullptr) {
int32_t status = 0;
cleanInterrupts(m_interrupt, &status);
wpi_setErrorWithContext(status, getHALErrorMessage(status));
- m_interrupt = NULL;
+ m_interrupt = nullptr;
m_interrupts->Free(m_interruptIndex);
}
}
diff --git a/wpilibc/wpilibC++Devices/src/BuiltInAccelerometer.cpp b/wpilibc/wpilibC++Devices/src/BuiltInAccelerometer.cpp
index 4b2a7f5745..0de2820249 100644
--- a/wpilibc/wpilibC++Devices/src/BuiltInAccelerometer.cpp
+++ b/wpilibc/wpilibC++Devices/src/BuiltInAccelerometer.cpp
@@ -13,7 +13,7 @@
* Constructor.
* @param range The range the accelerometer will measure
*/
-BuiltInAccelerometer::BuiltInAccelerometer(Range range) : m_table(0) {
+BuiltInAccelerometer::BuiltInAccelerometer(Range range) {
SetRange(range);
HALReport(HALUsageReporting::kResourceType_Accelerometer, 0, 0,
@@ -21,8 +21,6 @@ BuiltInAccelerometer::BuiltInAccelerometer(Range range) : m_table(0) {
LiveWindow::GetInstance()->AddSensor((std::string) "BuiltInAccel", 0, this);
}
-BuiltInAccelerometer::~BuiltInAccelerometer() {}
-
/** {@inheritdoc} */
void BuiltInAccelerometer::SetRange(Range range) {
if (range == kRange_16G) {
@@ -60,7 +58,7 @@ void BuiltInAccelerometer::InitTable(ITable* subtable) {
}
void BuiltInAccelerometer::UpdateTable() {
- if (m_table != NULL) {
+ if (m_table != nullptr) {
m_table->PutNumber("X", GetX());
m_table->PutNumber("Y", GetY());
m_table->PutNumber("Z", GetZ());
diff --git a/wpilibc/wpilibC++Devices/src/CANJaguar.cpp b/wpilibc/wpilibC++Devices/src/CANJaguar.cpp
index 25782df8c8..2bad4a0daf 100644
--- a/wpilibc/wpilibC++Devices/src/CANJaguar.cpp
+++ b/wpilibc/wpilibC++Devices/src/CANJaguar.cpp
@@ -8,7 +8,6 @@
#include "Timer.h"
#define tNIRIO_i32 int
#include "NetworkCommunication/CANSessionMux.h"
-#include "CAN/can_proto.h"
//#include "NetworkCommunication/UsageReporting.h"
#include "WPIErrors.h"
#include
@@ -32,7 +31,7 @@ static const uint32_t kFullMessageIDMask =
static const int32_t kReceiveStatusAttempts = 50;
-static Resource *allocated = NULL;
+static Resource *allocated = nullptr;
static int32_t sendMessageHelper(uint32_t messageID, const uint8_t *data,
uint8_t dataSize, int32_t period) {
@@ -43,9 +42,8 @@ static int32_t sendMessageHelper(uint32_t messageID, const uint8_t *data,
int32_t status = 0;
- for (uint8_t i = 0;
- i < (sizeof(kTrustedMessages) / sizeof(kTrustedMessages[0])); i++) {
- if ((kFullMessageIDMask & messageID) == kTrustedMessages[i]) {
+ for (auto& kTrustedMessage : kTrustedMessages) {
+ if ((kFullMessageIDMask & messageID) == kTrustedMessage) {
uint8_t dataBuffer[8];
dataBuffer[0] = 0;
dataBuffer[1] = 0;
@@ -74,57 +72,8 @@ static int32_t sendMessageHelper(uint32_t messageID, const uint8_t *data,
* Common initialization code called by all constructors.
*/
void CANJaguar::InitCANJaguar() {
- m_table = NULL;
m_safetyHelper = new MotorSafetyHelper(this);
- m_value = 0.0f;
- m_speedReference = LM_REF_NONE;
- m_positionReference = LM_REF_NONE;
- m_p = 0.0;
- m_i = 0.0;
- m_d = 0.0;
- m_busVoltage = 0.0f;
- m_outputVoltage = 0.0f;
- m_outputCurrent = 0.0f;
- m_temperature = 0.0f;
- m_position = 0.0;
- m_speed = 0.0;
- m_limits = 0x00;
- m_faults = 0x0000;
- m_firmwareVersion = 0;
- m_hardwareVersion = 0;
- m_neutralMode = kNeutralMode_Jumper;
- m_encoderCodesPerRev = 0;
- m_potentiometerTurns = 0;
- m_limitMode = kLimitMode_SwitchInputsOnly;
- m_forwardLimit = 0.0;
- m_reverseLimit = 0.0;
- m_maxOutputVoltage = 30.0;
- m_voltageRampRate = 0.0;
- m_faultTime = 0.0f;
-
- // Parameters only need to be verified if they are set
- m_controlModeVerified =
- false; // Needs to be verified because it's set in the constructor
- m_speedRefVerified = true;
- m_posRefVerified = true;
- m_pVerified = true;
- m_iVerified = true;
- m_dVerified = true;
- m_neutralModeVerified = true;
- m_encoderCodesPerRevVerified = true;
- m_potentiometerTurnsVerified = true;
- m_limitModeVerified = true;
- m_forwardLimitVerified = true;
- m_reverseLimitVerified = true;
- m_maxOutputVoltageVerified = true;
- m_voltageRampRateVerified = true;
- m_faultTimeVerified = true;
-
- m_receivedStatusMessage0 = false;
- m_receivedStatusMessage1 = false;
- m_receivedStatusMessage2 = false;
-
bool receivedFirmwareVersion = false;
uint8_t dataBuffer[8];
uint8_t dataSize;
@@ -198,7 +147,6 @@ void CANJaguar::InitCANJaguar() {
default:
break;
}
- m_isInverted = false;
HALReport(HALUsageReporting::kResourceType_CANJaguar, m_deviceNumber,
m_controlMode);
LiveWindow::GetInstance()->AddActuator("CANJaguar", m_deviceNumber, this);
@@ -229,9 +177,7 @@ void CANJaguar::InitCANJaguar() {
* @see CANJaguar#SetVoltageMode(QuadEncoderTag, int)
*/
CANJaguar::CANJaguar(uint8_t deviceNumber)
- : m_deviceNumber(deviceNumber),
- m_maxOutputVoltage(kApproxBusVoltage),
- m_safetyHelper(NULL) {
+ : m_deviceNumber(deviceNumber) {
char buf[64];
snprintf(buf, 64, "CANJaguar device number %d", m_deviceNumber);
Resource::CreateResourceObject(&allocated, 63);
@@ -254,27 +200,27 @@ CANJaguar::~CANJaguar() {
// Disable periodic setpoints
if (m_controlMode == kPercentVbus)
FRC_NetworkCommunication_CANSessionMux_sendMessage(
- m_deviceNumber | LM_API_VOLT_T_SET, NULL, 0,
+ m_deviceNumber | LM_API_VOLT_T_SET, nullptr, 0,
CAN_SEND_PERIOD_STOP_REPEATING, &status);
else if (m_controlMode == kSpeed)
FRC_NetworkCommunication_CANSessionMux_sendMessage(
- m_deviceNumber | LM_API_SPD_T_SET, NULL, 0,
+ m_deviceNumber | LM_API_SPD_T_SET, nullptr, 0,
CAN_SEND_PERIOD_STOP_REPEATING, &status);
else if (m_controlMode == kPosition)
FRC_NetworkCommunication_CANSessionMux_sendMessage(
- m_deviceNumber | LM_API_POS_T_SET, NULL, 0,
+ m_deviceNumber | LM_API_POS_T_SET, nullptr, 0,
CAN_SEND_PERIOD_STOP_REPEATING, &status);
else if (m_controlMode == kCurrent)
FRC_NetworkCommunication_CANSessionMux_sendMessage(
- m_deviceNumber | LM_API_ICTRL_T_SET, NULL, 0,
+ m_deviceNumber | LM_API_ICTRL_T_SET, nullptr, 0,
CAN_SEND_PERIOD_STOP_REPEATING, &status);
else if (m_controlMode == kVoltage)
FRC_NetworkCommunication_CANSessionMux_sendMessage(
- m_deviceNumber | LM_API_VCOMP_T_SET, NULL, 0,
+ m_deviceNumber | LM_API_VCOMP_T_SET, nullptr, 0,
CAN_SEND_PERIOD_STOP_REPEATING, &status);
delete m_safetyHelper;
- m_safetyHelper = NULL;
+ m_safetyHelper = nullptr;
}
/**
@@ -478,7 +424,7 @@ void CANJaguar::sendMessage(uint32_t messageID, const uint8_t *data,
* every "period" milliseconds.
*/
void CANJaguar::requestMessage(uint32_t messageID, int32_t period) {
- sendMessageHelper(messageID | m_deviceNumber, NULL, 0, period);
+ sendMessageHelper(messageID | m_deviceNumber, nullptr, 0, period);
}
/**
@@ -2000,19 +1946,19 @@ void CANJaguar::ValueChanged(ITable *source, const std::string &key,
}
void CANJaguar::UpdateTable() {
- if (m_table != NULL) {
+ if (m_table != nullptr) {
m_table->PutNumber("Value", Get());
}
}
void CANJaguar::StartLiveWindowMode() {
- if (m_table != NULL) {
+ if (m_table != nullptr) {
m_table->AddTableListener("Value", this, true);
}
}
void CANJaguar::StopLiveWindowMode() {
- if (m_table != NULL) {
+ if (m_table != nullptr) {
m_table->RemoveTableListener(this);
}
}
diff --git a/wpilibc/wpilibC++Devices/src/CANTalon.cpp b/wpilibc/wpilibC++Devices/src/CANTalon.cpp
index 5e4860d754..0d8f5407bb 100644
--- a/wpilibc/wpilibC++Devices/src/CANTalon.cpp
+++ b/wpilibc/wpilibC++Devices/src/CANTalon.cpp
@@ -15,11 +15,7 @@
CANTalon::CANTalon(int deviceNumber)
: m_deviceNumber(deviceNumber),
m_impl(new CanTalonSRX(deviceNumber)),
- m_safetyHelper(new MotorSafetyHelper(this)),
- m_profile(0),
- m_controlEnabled(true),
- m_controlMode(kPercentVbus),
- m_setPoint(0) {
+ m_safetyHelper(new MotorSafetyHelper(this)) {
ApplyControlMode(m_controlMode);
m_impl->SetProfileSlotSelect(m_profile);
m_isInverted = false;
@@ -1283,19 +1279,19 @@ void CANTalon::ValueChanged(ITable* source, const std::string& key,
}
void CANTalon::UpdateTable() {
- if (m_table != NULL) {
+ if (m_table != nullptr) {
m_table->PutNumber("Value", Get());
}
}
void CANTalon::StartLiveWindowMode() {
- if (m_table != NULL) {
+ if (m_table != nullptr) {
m_table->AddTableListener("Value", this, true);
}
}
void CANTalon::StopLiveWindowMode() {
- if (m_table != NULL) {
+ if (m_table != nullptr) {
m_table->RemoveTableListener(this);
}
}
diff --git a/wpilibc/wpilibC++Devices/src/CameraServer.cpp b/wpilibc/wpilibC++Devices/src/CameraServer.cpp
index c639a2c004..847fd2bab2 100644
--- a/wpilibc/wpilibC++Devices/src/CameraServer.cpp
+++ b/wpilibc/wpilibC++Devices/src/CameraServer.cpp
@@ -10,13 +10,10 @@
#include
constexpr uint8_t CameraServer::kMagicNumber[];
-CameraServer* CameraServer::s_instance = nullptr;
CameraServer* CameraServer::GetInstance() {
- if (s_instance == NULL) {
- s_instance = new CameraServer;
- }
- return s_instance;
+ static CameraServer instance;
+ return &instance;
}
CameraServer::CameraServer()
@@ -225,7 +222,7 @@ void CameraServer::Serve() {
std::unique_lock lock(m_imageMutex);
m_newImageVariable.wait(lock);
imageData = m_imageData;
- m_imageData = std::make_tuple(nullptr, 0, 0, false);
+ m_imageData = std::make_tuple(nullptr, 0, 0, false);
}
unsigned int size = std::get<1>(imageData);
diff --git a/wpilibc/wpilibC++Devices/src/Compressor.cpp b/wpilibc/wpilibC++Devices/src/Compressor.cpp
index 79c6131f4c..1d31eb3f54 100644
--- a/wpilibc/wpilibC++Devices/src/Compressor.cpp
+++ b/wpilibc/wpilibC++Devices/src/Compressor.cpp
@@ -5,28 +5,15 @@
#include "Compressor.h"
#include "WPIErrors.h"
-void Compressor::InitCompressor(uint8_t pcmID) {
- m_table = 0;
- m_pcm_pointer = initializeCompressor(pcmID);
-
- SetClosedLoopControl(true);
-}
-
-/**
- * Constructor
- *
- * Uses the default PCM ID (0)
- */
-Compressor::Compressor() { InitCompressor(GetDefaultSolenoidModule()); }
-
/**
* Constructor
*
* @param module The PCM ID to use (0-62)
*/
-Compressor::Compressor(uint8_t pcmID) { InitCompressor(pcmID); }
-
-Compressor::~Compressor() {}
+Compressor::Compressor(uint8_t pcmID) {
+ m_pcm_pointer = initializeCompressor(pcmID);
+ SetClosedLoopControl(true);
+}
/**
* Starts closed-loop control. Note that closed loop control is enabled by
diff --git a/wpilibc/wpilibC++Devices/src/Counter.cpp b/wpilibc/wpilibC++Devices/src/Counter.cpp
index b36b2154f5..c4e333ce83 100644
--- a/wpilibc/wpilibC++Devices/src/Counter.cpp
+++ b/wpilibc/wpilibC++Devices/src/Counter.cpp
@@ -12,42 +12,26 @@
#include "Resource.h"
#include "WPIErrors.h"
-/**
- * Create an instance of a counter object.
- * This creates a ChipObject counter and initializes status variables
- * appropriately
- *
- * The counter will start counting immediately.
- * @param mode The counter mode
- */
-void Counter::InitCounter(Mode mode) {
- m_table = NULL;
-
- int32_t status = 0;
- m_index = 0;
- m_counter = initializeCounter(mode, &m_index, &status);
- wpi_setErrorWithContext(status, getHALErrorMessage(status));
-
- m_upSource = NULL;
- m_downSource = NULL;
- m_allocatedUpSource = false;
- m_allocatedDownSource = false;
-
- SetMaxPeriod(.5);
-
- HALReport(HALUsageReporting::kResourceType_Counter, m_index, mode);
-}
-
/**
* Create an instance of a counter where no sources are selected.
* They all must be selected by calling functions to specify the upsource and
* the downsource
* independently.
*
+ * This creates a ChipObject counter and initializes status variables
+ * appropriately.
+ *
* The counter will start counting immediately.
+ * @param mode The counter mode
*/
-Counter::Counter() : m_upSource(NULL), m_downSource(NULL), m_counter(NULL) {
- InitCounter();
+Counter::Counter(Mode mode) {
+ int32_t status = 0;
+ m_counter = initializeCounter(mode, &m_index, &status);
+ wpi_setErrorWithContext(status, getHALErrorMessage(status));
+
+ SetMaxPeriod(.5);
+
+ HALReport(HALUsageReporting::kResourceType_Counter, m_index, mode);
}
/**
@@ -62,9 +46,7 @@ Counter::Counter() : m_upSource(NULL), m_downSource(NULL), m_counter(NULL) {
* @param source A pointer to the existing DigitalSource object. It will be set
* as the Up Source.
*/
-Counter::Counter(DigitalSource *source)
- : m_upSource(NULL), m_downSource(NULL), m_counter(NULL) {
- InitCounter();
+Counter::Counter(DigitalSource *source) : Counter() {
SetUpSource(source);
ClearDownSource();
}
@@ -81,9 +63,7 @@ Counter::Counter(DigitalSource *source)
* @param source A reference to the existing DigitalSource object. It will be
* set as the Up Source.
*/
-Counter::Counter(DigitalSource &source)
- : m_upSource(NULL), m_downSource(NULL), m_counter(NULL) {
- InitCounter();
+Counter::Counter(DigitalSource &source) : Counter() {
SetUpSource(&source);
ClearDownSource();
}
@@ -96,9 +76,7 @@ Counter::Counter(DigitalSource &source)
* @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)
- : m_upSource(NULL), m_downSource(NULL), m_counter(NULL) {
- InitCounter();
+Counter::Counter(int32_t channel) : Counter() {
SetUpSource(channel);
ClearDownSource();
}
@@ -111,9 +89,7 @@ Counter::Counter(int32_t channel)
* The counter will start counting immediately.
* @param trigger The pointer to the existing AnalogTrigger object.
*/
-Counter::Counter(AnalogTrigger *trigger)
- : m_upSource(NULL), m_downSource(NULL), m_counter(NULL) {
- InitCounter();
+Counter::Counter(AnalogTrigger *trigger) : Counter() {
SetUpSource(trigger->CreateOutput(kState));
ClearDownSource();
m_allocatedUpSource = true;
@@ -127,9 +103,7 @@ Counter::Counter(AnalogTrigger *trigger)
* The counter will start counting immediately.
* @param trigger The reference to the existing AnalogTrigger object.
*/
-Counter::Counter(AnalogTrigger &trigger)
- : m_upSource(NULL), m_downSource(NULL), m_counter(NULL) {
- InitCounter();
+Counter::Counter(AnalogTrigger &trigger) : Counter() {
SetUpSource(trigger.CreateOutput(kState));
ClearDownSource();
m_allocatedUpSource = true;
@@ -146,14 +120,13 @@ Counter::Counter(AnalogTrigger &trigger)
Counter::Counter(EncodingType encodingType, DigitalSource *upSource,
DigitalSource *downSource, bool inverted)
- : m_upSource(NULL), m_downSource(NULL), m_counter(NULL) {
+ : Counter(kExternalDirection) {
if (encodingType != k1X && encodingType != k2X) {
wpi_setWPIErrorWithContext(
ParameterOutOfRange,
"Counter only supports 1X and 2X quadrature decoding.");
return;
}
- InitCounter(kExternalDirection);
SetUpSource(upSource);
SetDownSource(downSource);
int32_t status = 0;
@@ -177,17 +150,17 @@ Counter::~Counter() {
SetUpdateWhenEmpty(true);
if (m_allocatedUpSource) {
delete m_upSource;
- m_upSource = NULL;
+ m_upSource = nullptr;
}
if (m_allocatedDownSource) {
delete m_downSource;
- m_downSource = NULL;
+ m_downSource = nullptr;
}
int32_t status = 0;
freeCounter(m_counter, &status);
wpi_setErrorWithContext(status, getHALErrorMessage(status));
- m_counter = NULL;
+ m_counter = nullptr;
}
/**
@@ -232,7 +205,7 @@ void Counter::SetUpSource(DigitalSource *source) {
if (StatusIsFatal()) return;
if (m_allocatedUpSource) {
delete m_upSource;
- m_upSource = NULL;
+ m_upSource = nullptr;
m_allocatedUpSource = false;
}
m_upSource = source;
@@ -261,10 +234,10 @@ void Counter::SetUpSource(DigitalSource &source) { SetUpSource(&source); }
*/
void Counter::SetUpSourceEdge(bool risingEdge, bool fallingEdge) {
if (StatusIsFatal()) return;
- if (m_upSource == NULL) {
+ if (m_upSource == nullptr) {
wpi_setWPIErrorWithContext(
NullParameter,
- "Must set non-NULL UpSource before setting UpSourceEdge");
+ "Must set non-nullptr UpSource before setting UpSourceEdge");
}
int32_t status = 0;
setCounterUpSourceEdge(m_counter, risingEdge, fallingEdge, &status);
@@ -278,7 +251,7 @@ void Counter::ClearUpSource() {
if (StatusIsFatal()) return;
if (m_allocatedUpSource) {
delete m_upSource;
- m_upSource = NULL;
+ m_upSource = nullptr;
m_allocatedUpSource = false;
}
int32_t status = 0;
@@ -330,7 +303,7 @@ void Counter::SetDownSource(DigitalSource *source) {
if (StatusIsFatal()) return;
if (m_allocatedDownSource) {
delete m_downSource;
- m_downSource = NULL;
+ m_downSource = nullptr;
m_allocatedDownSource = false;
}
m_downSource = source;
@@ -359,10 +332,10 @@ void Counter::SetDownSource(DigitalSource &source) { SetDownSource(&source); }
*/
void Counter::SetDownSourceEdge(bool risingEdge, bool fallingEdge) {
if (StatusIsFatal()) return;
- if (m_downSource == NULL) {
+ if (m_downSource == nullptr) {
wpi_setWPIErrorWithContext(
NullParameter,
- "Must set non-NULL DownSource before setting DownSourceEdge");
+ "Must set non-nullptr DownSource before setting DownSourceEdge");
}
int32_t status = 0;
setCounterDownSourceEdge(m_counter, risingEdge, fallingEdge, &status);
@@ -376,7 +349,7 @@ void Counter::ClearDownSource() {
if (StatusIsFatal()) return;
if (m_allocatedDownSource) {
delete m_downSource;
- m_downSource = NULL;
+ m_downSource = nullptr;
m_allocatedDownSource = false;
}
int32_t status = 0;
@@ -597,7 +570,7 @@ void Counter::SetReverseDirection(bool reverseDirection) {
}
void Counter::UpdateTable() {
- if (m_table != NULL) {
+ if (m_table != nullptr) {
m_table->PutNumber("Value", Get());
}
}
diff --git a/wpilibc/wpilibC++Devices/src/DigitalInput.cpp b/wpilibc/wpilibC++Devices/src/DigitalInput.cpp
index afa39cac80..b80bebd4d7 100644
--- a/wpilibc/wpilibC++Devices/src/DigitalInput.cpp
+++ b/wpilibc/wpilibC++Devices/src/DigitalInput.cpp
@@ -12,12 +12,12 @@
#include "LiveWindow/LiveWindow.h"
/**
- * Create an instance of a DigitalInput.
- * Creates a digital input given a channel. Common creation routine for all
- * constructors.
+ * Create an instance of a Digital Input class.
+ * Creates a digital input given a channel.
+ *
+ * @param channel The DIO channel 0-9 are on-board, 10-25 are on the MXP port
*/
-void DigitalInput::InitDigitalInput(uint32_t channel) {
- m_table = NULL;
+DigitalInput::DigitalInput(uint32_t channel) {
char buf[64];
if (!CheckDigitalChannel(channel)) {
@@ -35,24 +35,16 @@ void DigitalInput::InitDigitalInput(uint32_t channel) {
HALReport(HALUsageReporting::kResourceType_DigitalInput, channel);
}
-/**
- * Create an instance of a Digital Input class.
- * Creates a digital input given a channel.
- *
- * @param channel The DIO channel 0-9 are on-board, 10-25 are on the MXP port
- */
-DigitalInput::DigitalInput(uint32_t channel) { InitDigitalInput(channel); }
-
/**
* Free resources associated with the Digital Input class.
*/
DigitalInput::~DigitalInput() {
if (StatusIsFatal()) return;
- if (m_interrupt != NULL) {
+ if (m_interrupt != nullptr) {
int32_t status = 0;
cleanInterrupts(m_interrupt, &status);
wpi_setErrorWithContext(status, getHALErrorMessage(status));
- m_interrupt = NULL;
+ m_interrupt = nullptr;
m_interrupts->Free(m_interruptIndex);
}
@@ -93,7 +85,7 @@ uint32_t DigitalInput::GetModuleForRouting() const { return 0; }
bool DigitalInput::GetAnalogTriggerForRouting() const { return false; }
void DigitalInput::UpdateTable() {
- if (m_table != NULL) {
+ if (m_table != nullptr) {
m_table->PutBoolean("Value", Get());
}
}
diff --git a/wpilibc/wpilibC++Devices/src/DigitalOutput.cpp b/wpilibc/wpilibC++Devices/src/DigitalOutput.cpp
index 1e597442e6..56157661c1 100644
--- a/wpilibc/wpilibC++Devices/src/DigitalOutput.cpp
+++ b/wpilibc/wpilibC++Devices/src/DigitalOutput.cpp
@@ -10,12 +10,13 @@
#include "WPIErrors.h"
/**
- * Create an instance of a DigitalOutput.
- * Creates a digital output given a channel. Common creation routine for all
- * constructors.
+ * Create an instance of a digital output.
+ * Create a digital output given a channel.
+ *
+ * @param channel The digital channel 0-9 are on-board, 10-25 are on the MXP
+ * port
*/
-void DigitalOutput::InitDigitalOutput(uint32_t channel) {
- m_table = NULL;
+DigitalOutput::DigitalOutput(uint32_t channel) {
char buf[64];
if (!CheckDigitalChannel(channel)) {
@@ -33,15 +34,6 @@ void DigitalOutput::InitDigitalOutput(uint32_t channel) {
HALReport(HALUsageReporting::kResourceType_DigitalOutput, channel);
}
-/**
- * Create an instance of a digital output.
- * Create a digital output given a channel.
- *
- * @param channel The digital channel 0-9 are on-board, 10-25 are on the MXP
- * port
- */
-DigitalOutput::DigitalOutput(uint32_t channel) { InitDigitalOutput(channel); }
-
/**
* Free the resources associated with a digital output.
*/
@@ -210,13 +202,13 @@ void DigitalOutput::ValueChanged(ITable *source, const std::string &key,
void DigitalOutput::UpdateTable() {}
void DigitalOutput::StartLiveWindowMode() {
- if (m_table != NULL) {
+ if (m_table != nullptr) {
m_table->AddTableListener("Value", this, true);
}
}
void DigitalOutput::StopLiveWindowMode() {
- if (m_table != NULL) {
+ if (m_table != nullptr) {
m_table->RemoveTableListener(this);
}
}
diff --git a/wpilibc/wpilibC++Devices/src/DigitalSource.cpp b/wpilibc/wpilibC++Devices/src/DigitalSource.cpp
deleted file mode 100644
index cc7f0b94cd..0000000000
--- a/wpilibc/wpilibC++Devices/src/DigitalSource.cpp
+++ /dev/null
@@ -1,13 +0,0 @@
-/*----------------------------------------------------------------------------*/
-/* Copyright (c) FIRST 2008. All Rights Reserved.
- */
-/* Open Source Software - may be modified and shared by FRC teams. The code */
-/* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */
-/*----------------------------------------------------------------------------*/
-
-#include "DigitalSource.h"
-
-/**
- * DigitalSource destructor.
- */
-DigitalSource::~DigitalSource() {}
diff --git a/wpilibc/wpilibC++Devices/src/DoubleSolenoid.cpp b/wpilibc/wpilibC++Devices/src/DoubleSolenoid.cpp
index 2973bbaf4e..ede689f573 100644
--- a/wpilibc/wpilibC++Devices/src/DoubleSolenoid.cpp
+++ b/wpilibc/wpilibC++Devices/src/DoubleSolenoid.cpp
@@ -10,10 +10,26 @@
#include "LiveWindow/LiveWindow.h"
/**
- * Common function to implement constructor behaviour.
+ * Constructor.
+ * Uses the default PCM ID of 0
+ * @param forwardChannel The forward channel number on the PCM (0..7).
+ * @param reverseChannel The reverse channel number on the PCM (0..7).
*/
-void DoubleSolenoid::InitSolenoid() {
- m_table = NULL;
+DoubleSolenoid::DoubleSolenoid(uint32_t forwardChannel, uint32_t reverseChannel)
+ : DoubleSolenoid(GetDefaultSolenoidModule(), forwardChannel, reverseChannel) {}
+
+/**
+ * Constructor.
+ *
+ * @param moduleNumber The CAN ID of the PCM.
+ * @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)
+ : SolenoidBase(moduleNumber),
+ m_forwardChannel(forwardChannel),
+ m_reverseChannel(reverseChannel) {
char buf[64];
if (!CheckSolenoidModule(m_moduleNumber)) {
snprintf(buf, 64, "Solenoid Module %d", m_moduleNumber);
@@ -59,34 +75,6 @@ void DoubleSolenoid::InitSolenoid() {
m_forwardChannel, this);
}
-/**
- * Constructor.
- * Uses the default PCM ID of 0
- * @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)
- : SolenoidBase(GetDefaultSolenoidModule()),
- m_forwardChannel(forwardChannel),
- m_reverseChannel(reverseChannel) {
- InitSolenoid();
-}
-
-/**
- * Constructor.
- *
- * @param moduleNumber The CAN ID of the PCM.
- * @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)
- : SolenoidBase(moduleNumber),
- m_forwardChannel(forwardChannel),
- m_reverseChannel(reverseChannel) {
- InitSolenoid();
-}
-
/**
* Destructor.
*/
@@ -171,7 +159,7 @@ void DoubleSolenoid::ValueChanged(ITable *source, const std::string &key,
}
void DoubleSolenoid::UpdateTable() {
- if (m_table != NULL) {
+ if (m_table != nullptr) {
m_table->PutString(
"Value", (Get() == kForward ? "Forward"
: (Get() == kReverse ? "Reverse" : "Off")));
@@ -180,14 +168,14 @@ void DoubleSolenoid::UpdateTable() {
void DoubleSolenoid::StartLiveWindowMode() {
Set(kOff);
- if (m_table != NULL) {
+ if (m_table != nullptr) {
m_table->AddTableListener("Value", this, true);
}
}
void DoubleSolenoid::StopLiveWindowMode() {
Set(kOff);
- if (m_table != NULL) {
+ if (m_table != nullptr) {
m_table->RemoveTableListener(this);
}
}
diff --git a/wpilibc/wpilibC++Devices/src/DriverStation.cpp b/wpilibc/wpilibC++Devices/src/DriverStation.cpp
index 372383bd2f..e072758c4f 100644
--- a/wpilibc/wpilibC++Devices/src/DriverStation.cpp
+++ b/wpilibc/wpilibC++Devices/src/DriverStation.cpp
@@ -28,23 +28,13 @@ const double JOYSTICK_UNPLUGGED_MESSAGE_INTERVAL = 1.0;
Log().Get(level)
const uint32_t DriverStation::kJoystickPorts;
-DriverStation* DriverStation::m_instance = NULL;
/**
* DriverStation constructor.
*
* This is only called once the first time GetInstance() is called
*/
-DriverStation::DriverStation()
- : m_task("DriverStation", (FUNCPTR)DriverStation::InitTask),
- m_newControlData(0),
- m_packetDataAvailableMultiWait(0),
- m_waitForDataSem(0),
- m_userInDisabled(false),
- m_userInAutonomous(false),
- m_userInTeleop(false),
- m_userInTest(false),
- m_nextMessageTime(0) {
+DriverStation::DriverStation() {
// All joysticks should default to having zero axes, povs and buttons, so
// uninitialized memory doesn't get sent to speed controllers.
for (unsigned int i = 0; i < kJoystickPorts; i++) {
@@ -82,10 +72,9 @@ DriverStation::DriverStation()
DriverStation::~DriverStation() {
m_task.Stop();
- m_instance = NULL;
deleteMultiWait(m_waitForDataSem);
// Unregister our semaphore.
- HALSetNewDataSem(0);
+ HALSetNewDataSem(nullptr);
deleteMultiWait(m_packetDataAvailableMultiWait);
deleteMutex(m_packetDataAvailableMutex);
deleteMutex(m_waitForDataMutex);
@@ -120,10 +109,8 @@ void DriverStation::Run() {
* @return Pointer to the DS instance
*/
DriverStation* DriverStation::GetInstance() {
- if (m_instance == NULL) {
- m_instance = new DriverStation();
- }
- return m_instance;
+ static DriverStation instance;
+ return &instance;
}
/**
diff --git a/wpilibc/wpilibC++Devices/src/Encoder.cpp b/wpilibc/wpilibC++Devices/src/Encoder.cpp
index 0ff27e251a..c254b5b34f 100644
--- a/wpilibc/wpilibC++Devices/src/Encoder.cpp
+++ b/wpilibc/wpilibC++Devices/src/Encoder.cpp
@@ -31,9 +31,7 @@
* or be double (2x) the spec'd count.
*/
void Encoder::InitEncoder(bool reverseDirection, EncodingType encodingType) {
- m_table = NULL;
m_encodingType = encodingType;
- m_index = 0;
switch (encodingType) {
case k4X: {
m_encodingScale = 4;
@@ -53,7 +51,7 @@ void Encoder::InitEncoder(bool reverseDirection, EncodingType encodingType) {
m_bSource->GetAnalogTriggerForRouting(), reverseDirection, &m_index,
&status);
wpi_setErrorWithContext(status, getHALErrorMessage(status));
- m_counter = NULL;
+ m_counter = nullptr;
SetMaxPeriod(.5);
break;
}
@@ -69,8 +67,6 @@ void Encoder::InitEncoder(bool reverseDirection, EncodingType encodingType) {
wpi_setErrorWithContext(-1, "Invalid encodingType argument");
break;
}
- m_distancePerPulse = 1.0;
- m_pidSource = kDistance;
HALReport(HALUsageReporting::kResourceType_Encoder, m_index, encodingType);
LiveWindow::GetInstance()->AddSensor("Encoder",
@@ -101,8 +97,7 @@ void Encoder::InitEncoder(bool reverseDirection, EncodingType encodingType) {
* or be double (2x) the spec'd count.
*/
Encoder::Encoder(uint32_t aChannel, uint32_t bChannel, bool reverseDirection,
- EncodingType encodingType)
- : m_encoder(NULL), m_counter(NULL) {
+ EncodingType encodingType) {
m_aSource = new DigitalInput(aChannel);
m_bSource = new DigitalInput(bChannel);
InitEncoder(reverseDirection, encodingType);
@@ -136,13 +131,12 @@ Encoder::Encoder(uint32_t aChannel, uint32_t bChannel, bool reverseDirection,
* or be double (2x) the spec'd count.
*/
Encoder::Encoder(DigitalSource *aSource, DigitalSource *bSource,
- bool reverseDirection, EncodingType encodingType)
- : m_encoder(NULL), m_counter(NULL) {
+ bool reverseDirection, EncodingType encodingType) {
m_aSource = aSource;
m_bSource = bSource;
m_allocatedASource = false;
m_allocatedBSource = false;
- if (m_aSource == NULL || m_bSource == NULL)
+ if (m_aSource == nullptr || m_bSource == nullptr)
wpi_setWPIError(NullParameter);
else
InitEncoder(reverseDirection, encodingType);
@@ -174,8 +168,7 @@ Encoder::Encoder(DigitalSource *aSource, DigitalSource *bSource,
* or be double (2x) the spec'd count.
*/
Encoder::Encoder(DigitalSource &aSource, DigitalSource &bSource,
- bool reverseDirection, EncodingType encodingType)
- : m_encoder(NULL), m_counter(NULL) {
+ bool reverseDirection, EncodingType encodingType) {
m_aSource = &aSource;
m_bSource = &bSource;
m_allocatedASource = false;
@@ -555,7 +548,7 @@ void Encoder::SetIndexSource(DigitalSource &source,
}
void Encoder::UpdateTable() {
- if (m_table != NULL) {
+ if (m_table != nullptr) {
m_table->PutNumber("Speed", GetRate());
m_table->PutNumber("Distance", GetDistance());
m_table->PutNumber("Distance per Tick", m_distancePerPulse);
diff --git a/wpilibc/wpilibC++Devices/src/GearTooth.cpp b/wpilibc/wpilibC++Devices/src/GearTooth.cpp
index adc1fd8d83..5984e15bd1 100644
--- a/wpilibc/wpilibC++Devices/src/GearTooth.cpp
+++ b/wpilibc/wpilibC++Devices/src/GearTooth.cpp
@@ -61,9 +61,4 @@ GearTooth::GearTooth(DigitalSource &source, bool directionSensitive)
EnableDirectionSensing(directionSensitive);
}
-/**
- * Free the resources associated with a gear tooth sensor.
- */
-GearTooth::~GearTooth() {}
-
std::string GearTooth::GetSmartDashboardType() const { return "GearTooth"; }
diff --git a/wpilibc/wpilibC++Devices/src/Gyro.cpp b/wpilibc/wpilibC++Devices/src/Gyro.cpp
index becfb6156e..3652d35598 100644
--- a/wpilibc/wpilibC++Devices/src/Gyro.cpp
+++ b/wpilibc/wpilibC++Devices/src/Gyro.cpp
@@ -31,13 +31,12 @@ constexpr float Gyro::kDefaultVoltsPerDegreePerSecond;
* rest before the competition starts.
*/
void Gyro::InitGyro() {
- m_table = NULL;
if (!m_analog->IsAccumulatorChannel()) {
wpi_setWPIErrorWithContext(ParameterOutOfRange,
" channel (must be accumulator channel)");
if (m_channelAllocated) {
delete m_analog;
- m_analog = NULL;
+ m_analog = nullptr;
}
return;
}
@@ -96,7 +95,7 @@ Gyro::Gyro(int32_t channel) {
Gyro::Gyro(AnalogInput *channel) {
m_analog = channel;
m_channelAllocated = false;
- if (channel == NULL) {
+ if (channel == nullptr) {
wpi_setWPIError(NullParameter);
} else {
InitGyro();
@@ -230,7 +229,7 @@ double Gyro::PIDGet() const {
}
void Gyro::UpdateTable() {
- if (m_table != NULL) {
+ if (m_table != nullptr) {
m_table->PutNumber("Value", GetAngle());
}
}
diff --git a/wpilibc/wpilibC++Devices/src/I2C.cpp b/wpilibc/wpilibC++Devices/src/I2C.cpp
index 50c3ea71c9..258da4ee68 100644
--- a/wpilibc/wpilibC++Devices/src/I2C.cpp
+++ b/wpilibc/wpilibC++Devices/src/I2C.cpp
@@ -72,7 +72,7 @@ bool I2C::Transaction(uint8_t *dataToSend, uint8_t sendSize,
*/
bool I2C::AddressOnly() {
int32_t status = 0;
- status = Transaction(NULL, 0, NULL, 0);
+ status = Transaction(nullptr, 0, nullptr, 0);
return status < 0;
}
@@ -131,7 +131,7 @@ bool I2C::Read(uint8_t registerAddress, uint8_t count, uint8_t *buffer) {
wpi_setWPIErrorWithContext(ParameterOutOfRange, "count");
return true;
}
- if (buffer == NULL) {
+ if (buffer == nullptr) {
wpi_setWPIErrorWithContext(NullParameter, "buffer");
return true;
}
@@ -160,7 +160,7 @@ bool I2C::ReadOnly(uint8_t count, uint8_t *buffer) {
wpi_setWPIErrorWithContext(ParameterOutOfRange, "count");
return true;
}
- if (buffer == NULL) {
+ if (buffer == nullptr) {
wpi_setWPIErrorWithContext(NullParameter, "buffer");
return true;
}
diff --git a/wpilibc/wpilibC++Devices/src/InterruptableSensorBase.cpp b/wpilibc/wpilibC++Devices/src/InterruptableSensorBase.cpp
index 4ea14021a0..d4551d3127 100644
--- a/wpilibc/wpilibC++Devices/src/InterruptableSensorBase.cpp
+++ b/wpilibc/wpilibC++Devices/src/InterruptableSensorBase.cpp
@@ -9,15 +9,12 @@
#include "Utility.h"
#include "WPIErrors.h"
-Resource *InterruptableSensorBase::m_interrupts = NULL;
+Resource *InterruptableSensorBase::m_interrupts = nullptr;
InterruptableSensorBase::InterruptableSensorBase() {
- m_interrupt = NULL;
Resource::CreateResourceObject(&m_interrupts, interrupt_kNumSystems);
}
-InterruptableSensorBase::~InterruptableSensorBase() {}
-
/**
* Request one of the 8 interrupts asynchronously on this digital input.
* Request interrupts in asynchronous mode where the user's interrupt handler
@@ -74,7 +71,7 @@ void InterruptableSensorBase::RequestInterrupts() {
}
void InterruptableSensorBase::AllocateInterrupts(bool watcher) {
- wpi_assert(m_interrupt == NULL);
+ wpi_assert(m_interrupt == nullptr);
// Expects the calling leaf class to allocate an interrupt index.
int32_t status = 0;
m_interrupt = initializeInterrupts(m_interruptIndex, watcher, &status);
@@ -87,11 +84,11 @@ void InterruptableSensorBase::AllocateInterrupts(bool watcher) {
*/
void InterruptableSensorBase::CancelInterrupts() {
if (StatusIsFatal()) return;
- wpi_assert(m_interrupt != NULL);
+ wpi_assert(m_interrupt != nullptr);
int32_t status = 0;
cleanInterrupts(m_interrupt, &status);
wpi_setErrorWithContext(status, getHALErrorMessage(status));
- m_interrupt = NULL;
+ m_interrupt = nullptr;
m_interrupts->Free(m_interruptIndex);
}
@@ -109,7 +106,7 @@ void InterruptableSensorBase::CancelInterrupts() {
InterruptableSensorBase::WaitResult InterruptableSensorBase::WaitForInterrupt(
float timeout, bool ignorePrevious) {
if (StatusIsFatal()) return InterruptableSensorBase::kTimeout;
- wpi_assert(m_interrupt != NULL);
+ wpi_assert(m_interrupt != nullptr);
int32_t status = 0;
uint32_t result;
@@ -127,7 +124,7 @@ InterruptableSensorBase::WaitResult InterruptableSensorBase::WaitForInterrupt(
*/
void InterruptableSensorBase::EnableInterrupts() {
if (StatusIsFatal()) return;
- wpi_assert(m_interrupt != NULL);
+ wpi_assert(m_interrupt != nullptr);
int32_t status = 0;
enableInterrupts(m_interrupt, &status);
wpi_setErrorWithContext(status, getHALErrorMessage(status));
@@ -138,7 +135,7 @@ void InterruptableSensorBase::EnableInterrupts() {
*/
void InterruptableSensorBase::DisableInterrupts() {
if (StatusIsFatal()) return;
- wpi_assert(m_interrupt != NULL);
+ wpi_assert(m_interrupt != nullptr);
int32_t status = 0;
disableInterrupts(m_interrupt, &status);
wpi_setErrorWithContext(status, getHALErrorMessage(status));
@@ -153,7 +150,7 @@ void InterruptableSensorBase::DisableInterrupts() {
*/
double InterruptableSensorBase::ReadRisingTimestamp() {
if (StatusIsFatal()) return 0.0;
- wpi_assert(m_interrupt != NULL);
+ wpi_assert(m_interrupt != nullptr);
int32_t status = 0;
double timestamp = readRisingTimestamp(m_interrupt, &status);
wpi_setErrorWithContext(status, getHALErrorMessage(status));
@@ -169,7 +166,7 @@ double InterruptableSensorBase::ReadRisingTimestamp() {
*/
double InterruptableSensorBase::ReadFallingTimestamp() {
if (StatusIsFatal()) return 0.0;
- wpi_assert(m_interrupt != NULL);
+ wpi_assert(m_interrupt != nullptr);
int32_t status = 0;
double timestamp = readFallingTimestamp(m_interrupt, &status);
wpi_setErrorWithContext(status, getHALErrorMessage(status));
@@ -187,13 +184,13 @@ double InterruptableSensorBase::ReadFallingTimestamp() {
void InterruptableSensorBase::SetUpSourceEdge(bool risingEdge,
bool fallingEdge) {
if (StatusIsFatal()) return;
- if (m_interrupt == NULL) {
+ if (m_interrupt == nullptr) {
wpi_setWPIErrorWithContext(
NullParameter,
"You must call RequestInterrupts before SetUpSourceEdge");
return;
}
- if (m_interrupt != NULL) {
+ if (m_interrupt != nullptr) {
int32_t status = 0;
setInterruptUpSourceEdge(m_interrupt, risingEdge, fallingEdge, &status);
wpi_setErrorWithContext(status, getHALErrorMessage(status));
diff --git a/wpilibc/wpilibC++Devices/src/IterativeRobot.cpp b/wpilibc/wpilibC++Devices/src/IterativeRobot.cpp
index 3486e02784..a5a5c0f9ab 100644
--- a/wpilibc/wpilibC++Devices/src/IterativeRobot.cpp
+++ b/wpilibc/wpilibC++Devices/src/IterativeRobot.cpp
@@ -16,23 +16,6 @@
constexpr double IterativeRobot::kDefaultPeriod;
-/**
- * Constructor for RobotIterativeBase
- *
- * The constructor initializes the instance variables for the robot to indicate
- * the status of initialization for disabled, autonomous, teleop, and test code.
- */
-IterativeRobot::IterativeRobot()
- : m_disabledInitialized(false),
- m_autonomousInitialized(false),
- m_teleopInitialized(false),
- m_testInitialized(false) {}
-
-/**
- * Free the resources for a RobotIterativeBase class.
- */
-IterativeRobot::~IterativeRobot() {}
-
void IterativeRobot::Prestart() {
// Don't immediately say that the robot's ready to be enabled.
// See below.
diff --git a/wpilibc/wpilibC++Devices/src/Jaguar.cpp b/wpilibc/wpilibC++Devices/src/Jaguar.cpp
index e0d4520274..9b02302eb9 100644
--- a/wpilibc/wpilibC++Devices/src/Jaguar.cpp
+++ b/wpilibc/wpilibC++Devices/src/Jaguar.cpp
@@ -10,9 +10,11 @@
#include "LiveWindow/LiveWindow.h"
/**
- * Common initialization code called by all constructors.
+ * Constructor for a Jaguar connected via PWM
+ * @param channel The PWM channel that the Jaguar is attached to. 0-9 are
+ * on-board, 10-19 are on the MXP port
*/
-void Jaguar::InitJaguar() {
+Jaguar::Jaguar(uint32_t channel) : SafePWM(channel) {
/**
* Input profile defined by Luminary Micro.
*
@@ -29,18 +31,8 @@ void Jaguar::InitJaguar() {
HALReport(HALUsageReporting::kResourceType_Jaguar, GetChannel());
LiveWindow::GetInstance()->AddActuator("Jaguar", GetChannel(), this);
- m_isInverted = false;
}
-/**
- * Constructor for a Jaguar connected via PWM
- * @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) : SafePWM(channel) { InitJaguar(); }
-
-Jaguar::~Jaguar() {}
-
/**
* Set the PWM value.
*
diff --git a/wpilibc/wpilibC++Devices/src/Joystick.cpp b/wpilibc/wpilibC++Devices/src/Joystick.cpp
index ea18262bb1..6bf01fceda 100644
--- a/wpilibc/wpilibC++Devices/src/Joystick.cpp
+++ b/wpilibc/wpilibC++Devices/src/Joystick.cpp
@@ -30,15 +30,7 @@ static bool joySticksInitialized = false;
* (0-5).
*/
Joystick::Joystick(uint32_t port)
- : m_ds(NULL),
- m_port(port),
- m_axes(NULL),
- m_buttons(NULL),
- m_outputs(0),
- m_leftRumble(0),
- m_rightRumble(0) {
- InitJoystick(kNumAxisTypes, kNumButtonTypes);
-
+ : Joystick(port, kNumAxisTypes, kNumButtonTypes) {
m_axes[kXAxis] = kDefaultXAxis;
m_axes[kYAxis] = kDefaultYAxis;
m_axes[kZAxis] = kDefaultZAxis;
@@ -63,14 +55,9 @@ Joystick::Joystick(uint32_t port)
*/
Joystick::Joystick(uint32_t port, uint32_t numAxisTypes,
uint32_t numButtonTypes)
- : m_ds(NULL), m_port(port), m_axes(NULL), m_buttons(NULL) {
- InitJoystick(numAxisTypes, numButtonTypes);
-}
-
-void Joystick::InitJoystick(uint32_t numAxisTypes, uint32_t numButtonTypes) {
+ : m_port(port) {
if (!joySticksInitialized) {
- for (unsigned i = 0; i < DriverStation::kJoystickPorts; i++)
- joysticks[i] = NULL;
+ for (auto& joystick : joysticks) joystick = nullptr;
joySticksInitialized = true;
}
if (m_port >= DriverStation::kJoystickPorts) {
@@ -86,7 +73,7 @@ void Joystick::InitJoystick(uint32_t numAxisTypes, uint32_t numButtonTypes) {
Joystick *Joystick::GetStickForPort(uint32_t port) {
Joystick *stick = joysticks[port];
- if (stick == NULL) {
+ if (stick == nullptr) {
stick = new Joystick(port);
joysticks[port] = stick;
}
diff --git a/wpilibc/wpilibC++Devices/src/MotorSafetyHelper.cpp b/wpilibc/wpilibC++Devices/src/MotorSafetyHelper.cpp
index 2fbc04a8f2..9271ee7b3b 100644
--- a/wpilibc/wpilibC++Devices/src/MotorSafetyHelper.cpp
+++ b/wpilibc/wpilibC++Devices/src/MotorSafetyHelper.cpp
@@ -14,7 +14,7 @@
#include
-MotorSafetyHelper *MotorSafetyHelper::m_headHelper = NULL;
+MotorSafetyHelper *MotorSafetyHelper::m_headHelper = nullptr;
ReentrantSemaphore MotorSafetyHelper::m_listMutex;
/**
@@ -46,9 +46,9 @@ MotorSafetyHelper::~MotorSafetyHelper() {
if (m_headHelper == this) {
m_headHelper = m_nextHelper;
} else {
- MotorSafetyHelper *prev = NULL;
+ MotorSafetyHelper *prev = nullptr;
MotorSafetyHelper *cur = m_headHelper;
- while (cur != this && cur != NULL) prev = cur, cur = cur->m_nextHelper;
+ while (cur != this && cur != nullptr) prev = cur, cur = cur->m_nextHelper;
if (cur == this) prev->m_nextHelper = cur->m_nextHelper;
}
}
@@ -141,7 +141,7 @@ bool MotorSafetyHelper::IsSafetyEnabled() const {
*/
void MotorSafetyHelper::CheckMotors() {
Synchronized sync(m_listMutex);
- for (MotorSafetyHelper *msh = m_headHelper; msh != NULL;
+ for (MotorSafetyHelper *msh = m_headHelper; msh != nullptr;
msh = msh->m_nextHelper) {
msh->Check();
}
diff --git a/wpilibc/wpilibC++Devices/src/Notifier.cpp b/wpilibc/wpilibC++Devices/src/Notifier.cpp
index 3511bb3f63..edfa08f19c 100644
--- a/wpilibc/wpilibC++Devices/src/Notifier.cpp
+++ b/wpilibc/wpilibC++Devices/src/Notifier.cpp
@@ -11,9 +11,9 @@
#include "WPIErrors.h"
#include "HAL/HAL.hpp"
-Notifier *Notifier::timerQueueHead = NULL;
+Notifier *Notifier::timerQueueHead = nullptr;
ReentrantSemaphore Notifier::queueSemaphore;
-void *Notifier::m_notifier = NULL;
+void *Notifier::m_notifier = nullptr;
int Notifier::refcount = 0;
/**
@@ -22,15 +22,10 @@ int Notifier::refcount = 0;
* using StartSingle or StartPeriodic.
*/
Notifier::Notifier(TimerEventHandler handler, void *param) {
- if (handler == NULL)
- wpi_setWPIErrorWithContext(NullParameter, "handler must not be NULL");
+ if (handler == nullptr)
+ wpi_setWPIErrorWithContext(NullParameter, "handler must not be nullptr");
m_handler = handler;
m_param = param;
- m_periodic = false;
- m_expirationTime = 0;
- m_period = 0;
- m_nextEvent = NULL;
- m_queued = false;
m_handlerSemaphore = initializeSemaphore(SEMAPHORE_FULL);
{
Synchronized sync(queueSemaphore);
@@ -79,7 +74,7 @@ Notifier::~Notifier() {
* that is taking care of synchronizing access to the queue.
*/
void Notifier::UpdateAlarm() {
- if (timerQueueHead != NULL) {
+ if (timerQueueHead != nullptr) {
int32_t status = 0;
updateNotifierAlarm(m_notifier,
(uint32_t)(timerQueueHead->m_expirationTime * 1e6),
@@ -104,7 +99,7 @@ void Notifier::ProcessQueue(uint32_t mask, void *params) {
Synchronized sync(queueSemaphore);
double currentTime = GetClock();
current = timerQueueHead;
- if (current == NULL || current->m_expirationTime > currentTime) {
+ if (current == nullptr || current->m_expirationTime > currentTime) {
break; // no more timer events to process
}
// need to process this entry
@@ -152,7 +147,7 @@ void Notifier::InsertInQueue(bool reschedule) {
if (m_expirationTime > Timer::kRolloverTime) {
m_expirationTime -= Timer::kRolloverTime;
}
- if (timerQueueHead == NULL ||
+ if (timerQueueHead == nullptr ||
timerQueueHead->m_expirationTime >= this->m_expirationTime) {
// the queue is empty or greater than the new entry
// the new entry becomes the first element
@@ -167,7 +162,7 @@ void Notifier::InsertInQueue(bool reschedule) {
for (Notifier **npp = &(timerQueueHead->m_nextEvent);;
npp = &(*npp)->m_nextEvent) {
Notifier *n = *npp;
- if (n == NULL || n->m_expirationTime > this->m_expirationTime) {
+ if (n == nullptr || n->m_expirationTime > this->m_expirationTime) {
*npp = this;
this->m_nextEvent = n;
break;
@@ -189,13 +184,13 @@ void Notifier::InsertInQueue(bool reschedule) {
void Notifier::DeleteFromQueue() {
if (m_queued) {
m_queued = false;
- wpi_assert(timerQueueHead != NULL);
+ wpi_assert(timerQueueHead != nullptr);
if (timerQueueHead == this) {
// remove the first item in the list - update the alarm
timerQueueHead = this->m_nextEvent;
UpdateAlarm();
} else {
- for (Notifier *n = timerQueueHead; n != NULL; n = n->m_nextEvent) {
+ for (Notifier *n = timerQueueHead; n != nullptr; n = n->m_nextEvent) {
if (n->m_nextEvent == this) {
// this element is the next element from *n from the queue
n->m_nextEvent = this->m_nextEvent; // point around this one
diff --git a/wpilibc/wpilibC++Devices/src/PIDController.cpp b/wpilibc/wpilibC++Devices/src/PIDController.cpp
index 321db72eec..4555c3830c 100644
--- a/wpilibc/wpilibC++Devices/src/PIDController.cpp
+++ b/wpilibc/wpilibC++Devices/src/PIDController.cpp
@@ -33,8 +33,7 @@ static const char *kEnabled = "enabled";
* integral and differental terms. The default is 50ms.
*/
PIDController::PIDController(float Kp, float Ki, float Kd, PIDSource *source,
- PIDOutput *output, float period)
- : m_semaphore(0) {
+ PIDOutput *output, float period) {
Initialize(Kp, Ki, Kd, 0.0f, source, output, period);
}
@@ -50,16 +49,13 @@ PIDController::PIDController(float Kp, float Ki, float Kd, PIDSource *source,
* integral and differental terms. The default is 50ms.
*/
PIDController::PIDController(float Kp, float Ki, float Kd, float Kf,
- PIDSource *source, PIDOutput *output, float period)
- : m_semaphore(0) {
+ PIDSource *source, PIDOutput *output, float period) {
Initialize(Kp, Ki, Kd, Kf, source, output, period);
}
void PIDController::Initialize(float Kp, float Ki, float Kd, float Kf,
PIDSource *source, PIDOutput *output,
float period) {
- m_table = NULL;
-
m_semaphore = initializeMutexNormal();
m_controlLoop = new Notifier(PIDController::CallCalculate, this);
@@ -69,22 +65,6 @@ void PIDController::Initialize(float Kp, float Ki, float Kd, float Kf,
m_D = Kd;
m_F = Kf;
- m_maximumOutput = 1.0;
- m_minimumOutput = -1.0;
-
- m_maximumInput = 0;
- m_minimumInput = 0;
-
- m_continuous = false;
- m_enabled = false;
- m_setpoint = 0;
-
- m_prevError = 0;
- m_totalError = 0;
- m_tolerance = .05;
-
- m_result = 0;
-
m_pidInput = source;
m_pidOutput = output;
m_period = period;
@@ -94,8 +74,6 @@ void PIDController::Initialize(float Kp, float Ki, float Kd, float Kf,
static int32_t instances = 0;
instances++;
HALReport(HALUsageReporting::kResourceType_PIDController, instances);
-
- m_toleranceType = kNoTolerance;
}
/**
@@ -140,8 +118,8 @@ void PIDController::Calculate() {
}
END_REGION;
- if (pidInput == NULL) return;
- if (pidOutput == NULL) return;
+ if (pidInput == nullptr) return;
+ if (pidOutput == nullptr) return;
if (enabled) {
{
@@ -205,7 +183,7 @@ void PIDController::SetPID(double p, double i, double d) {
}
END_REGION;
- if (m_table != NULL) {
+ if (m_table != nullptr) {
m_table->PutNumber("p", m_P);
m_table->PutNumber("i", m_I);
m_table->PutNumber("d", m_D);
@@ -229,7 +207,7 @@ void PIDController::SetPID(double p, double i, double d, double f) {
}
END_REGION;
- if (m_table != NULL) {
+ if (m_table != nullptr) {
m_table->PutNumber("p", m_P);
m_table->PutNumber("i", m_I);
m_table->PutNumber("d", m_D);
@@ -346,7 +324,7 @@ void PIDController::SetSetpoint(float setpoint) {
}
END_REGION;
- if (m_table != NULL) {
+ if (m_table != nullptr) {
m_table->PutNumber("setpoint", m_setpoint);
}
}
@@ -451,7 +429,7 @@ void PIDController::Enable() {
CRITICAL_REGION(m_semaphore) { m_enabled = true; }
END_REGION;
- if (m_table != NULL) {
+ if (m_table != nullptr) {
m_table->PutBoolean("enabled", true);
}
}
@@ -466,7 +444,7 @@ void PIDController::Disable() {
}
END_REGION;
- if (m_table != NULL) {
+ if (m_table != nullptr) {
m_table->PutBoolean("enabled", false);
}
}
@@ -500,9 +478,9 @@ std::string PIDController::GetSmartDashboardType() const {
}
void PIDController::InitTable(ITable *table) {
- if (m_table != NULL) m_table->RemoveTableListener(this);
+ if (m_table != nullptr) m_table->RemoveTableListener(this);
m_table = table;
- if (m_table != NULL) {
+ if (m_table != nullptr) {
m_table->PutNumber(kP, GetP());
m_table->PutNumber(kI, GetI());
m_table->PutNumber(kD, GetD());
diff --git a/wpilibc/wpilibC++Devices/src/PWM.cpp b/wpilibc/wpilibC++Devices/src/PWM.cpp
index 468db5c0f9..e5efc069ac 100644
--- a/wpilibc/wpilibC++Devices/src/PWM.cpp
+++ b/wpilibc/wpilibC++Devices/src/PWM.cpp
@@ -19,18 +19,15 @@ const int32_t PWM::kDefaultPwmStepsDown;
const int32_t PWM::kPwmDisabled;
/**
- * Initialize PWMs given a channel.
+ * Allocate a PWM given a channel number.
*
- * This method is private and is the common path for all the constructors for
- * creating PWM
- * instances. Checks channel value range and allocates the appropriate channel.
+ * Checks channel value range and allocates the appropriate channel.
* The allocation is only done to help users ensure that they don't double
* assign channels.
* @param channel The PWM channel number. 0-9 are on-board, 10-19 are on the MXP
* port
*/
-void PWM::InitPWM(uint32_t channel) {
- m_table = NULL;
+PWM::PWM(uint32_t channel) {
char buf[64];
if (!CheckPWMChannel(channel)) {
@@ -53,13 +50,6 @@ void PWM::InitPWM(uint32_t channel) {
HALReport(HALUsageReporting::kResourceType_PWM, channel);
}
-/**
- * Allocate a PWM given a channel number.
- *
- * @param channel The PWM channel.
- */
-PWM::PWM(uint32_t channel) { InitPWM(channel); }
-
/**
* Free the PWM channel.
*
@@ -351,21 +341,21 @@ void PWM::ValueChanged(ITable* source, const std::string& key, EntryValue value,
}
void PWM::UpdateTable() {
- if (m_table != NULL) {
+ if (m_table != nullptr) {
m_table->PutNumber("Value", GetSpeed());
}
}
void PWM::StartLiveWindowMode() {
SetSpeed(0);
- if (m_table != NULL) {
+ if (m_table != nullptr) {
m_table->AddTableListener("Value", this, true);
}
}
void PWM::StopLiveWindowMode() {
SetSpeed(0);
- if (m_table != NULL) {
+ if (m_table != nullptr) {
m_table->RemoveTableListener(this);
}
}
diff --git a/wpilibc/wpilibC++Devices/src/PowerDistributionPanel.cpp b/wpilibc/wpilibC++Devices/src/PowerDistributionPanel.cpp
index e2daa83534..d127cb9b0a 100644
--- a/wpilibc/wpilibC++Devices/src/PowerDistributionPanel.cpp
+++ b/wpilibc/wpilibC++Devices/src/PowerDistributionPanel.cpp
@@ -16,7 +16,7 @@ PowerDistributionPanel::PowerDistributionPanel() : PowerDistributionPanel(0) {}
* Initialize the PDP.
*/
PowerDistributionPanel::PowerDistributionPanel(uint8_t module)
- : m_table(nullptr), m_module(module) {
+ : m_module(module) {
initializePDP(m_module);
}
@@ -150,7 +150,7 @@ void PowerDistributionPanel::ClearStickyFaults() {
}
void PowerDistributionPanel::UpdateTable() {
- if (m_table != NULL) {
+ if (m_table != nullptr) {
m_table->PutNumber("Chan0", GetCurrent(0));
m_table->PutNumber("Chan1", GetCurrent(1));
m_table->PutNumber("Chan2", GetCurrent(2));
diff --git a/wpilibc/wpilibC++Devices/src/Preferences.cpp b/wpilibc/wpilibC++Devices/src/Preferences.cpp
index aadc7c6f01..e7d395820e 100644
--- a/wpilibc/wpilibC++Devices/src/Preferences.cpp
+++ b/wpilibc/wpilibC++Devices/src/Preferences.cpp
@@ -24,14 +24,9 @@ static const char *kFileName = "/home/lvuser/wpilib-preferences.ini";
static const char *kValuePrefix = "=\"";
/** The characters to put after the value */
static const char *kValueSuffix = "\"\n";
-/** The singleton instance */
-Preferences *Preferences::_instance = NULL;
Preferences::Preferences()
- : m_fileLock(NULL),
- m_fileOpStarted(NULL),
- m_tableLock(NULL),
- m_readTask("PreferencesReadTask", (FUNCPTR)Preferences::InitReadTask),
+ : m_readTask("PreferencesReadTask", (FUNCPTR)Preferences::InitReadTask),
m_writeTask("PreferencesWriteTask", (FUNCPTR)Preferences::InitWriteTask) {
m_fileLock = initializeMutexRecursive();
m_fileOpStarted = initializeSemaphore(SEMAPHORE_EMPTY);
@@ -57,8 +52,8 @@ Preferences::~Preferences() {
* @return pointer to the {@link Preferences}
*/
Preferences *Preferences::GetInstance() {
- if (_instance == NULL) _instance = new Preferences;
- return _instance;
+ static Preferences instance;
+ return &instance;
}
/**
@@ -106,7 +101,7 @@ int Preferences::GetInt(const char *key, int defaultValue) {
std::string value = Get(key);
if (value.empty()) return defaultValue;
- return strtol(value.c_str(), NULL, 0);
+ return strtol(value.c_str(), nullptr, 0);
}
/**
@@ -120,7 +115,7 @@ double Preferences::GetDouble(const char *key, double defaultValue) {
std::string value = Get(key);
if (value.empty()) return defaultValue;
- return strtod(value.c_str(), NULL);
+ return strtod(value.c_str(), nullptr);
}
/**
@@ -134,7 +129,7 @@ float Preferences::GetFloat(const char *key, float defaultValue) {
std::string value = Get(key);
if (value.empty()) return defaultValue;
- return strtod(value.c_str(), NULL);
+ return strtod(value.c_str(), nullptr);
}
/**
@@ -172,7 +167,7 @@ int64_t Preferences::GetLong(const char *key, int64_t defaultValue) {
if (value.empty()) return defaultValue;
// Ummm... not available in our VxWorks...
- // return strtoll(value.c_str(), NULL, 0);
+ // return strtoll(value.c_str(), nullptr, 0);
int64_t intVal;
sscanf(value.c_str(), "%lld", &intVal);
return intVal;
@@ -192,7 +187,7 @@ int64_t Preferences::GetLong(const char *key, int64_t defaultValue) {
* @param value the value
*/
void Preferences::PutString(const char *key, const char *value) {
- if (value == NULL) {
+ if (value == nullptr) {
wpi_setWPIErrorWithContext(NullParameter, "value");
return;
}
@@ -323,7 +318,7 @@ bool Preferences::ContainsKey(const char *key) { return !Get(key).empty(); }
*/
void Preferences::Remove(const char *key) {
m_values.erase(std::string(key));
- std::vector::iterator it = m_keys.begin();
+ auto it = m_keys.begin();
for (; it != m_keys.end(); it++) {
if (it->compare(key) == 0) {
m_keys.erase(it);
@@ -339,7 +334,7 @@ void Preferences::Remove(const char *key) {
*/
std::string Preferences::Get(const char *key) {
Synchronized sync(m_tableLock);
- if (key == NULL) {
+ if (key == nullptr) {
wpi_setWPIErrorWithContext(NullParameter, "key");
return std::string("");
}
@@ -353,7 +348,7 @@ std::string Preferences::Get(const char *key) {
*/
void Preferences::Put(const char *key, std::string value) {
Synchronized sync(m_tableLock);
- if (key == NULL) {
+ if (key == nullptr) {
wpi_setWPIErrorWithContext(NullParameter, "key");
return;
}
@@ -385,10 +380,10 @@ void Preferences::ReadTaskRun() {
std::string comment;
- FILE *file = NULL;
+ FILE *file = nullptr;
file = fopen(kFileName, "r");
- if (file != NULL) {
+ if (file != nullptr) {
std::string buffer;
while (true) {
char value;
@@ -469,7 +464,7 @@ void Preferences::ReadTaskRun() {
wpi_setErrnoErrorWithContext("Opening preferences file");
}
- if (file != NULL) fclose(file);
+ if (file != nullptr) fclose(file);
if (!comment.empty()) m_endComment = comment;
@@ -486,11 +481,11 @@ void Preferences::WriteTaskRun() {
Synchronized sync(m_tableLock);
giveSemaphore(m_fileOpStarted);
- FILE *file = NULL;
+ FILE *file = nullptr;
file = fopen(kFileName, "w");
fputs("[Preferences]\n", file);
- std::vector::iterator it = m_keys.begin();
+ auto it = m_keys.begin();
for (; it != m_keys.end(); it++) {
std::string key = *it;
std::string value = m_values[key];
@@ -506,14 +501,13 @@ void Preferences::WriteTaskRun() {
if (!m_endComment.empty()) fputs(m_endComment.c_str(), file);
- if (file != NULL) fclose(file);
+ if (file != nullptr) fclose(file);
NetworkTable::GetTable(kTableName)->PutBoolean(kSaveField, false);
}
static bool isKeyAcceptable(const std::string &value) {
- for (unsigned int i = 0; i < value.length(); i++) {
- char letter = value.at(i);
+ for (auto letter : value) {
switch (letter) {
case '=':
case '\n':
@@ -538,7 +532,7 @@ void Preferences::ValueChanged(ITable *table, const std::string &key,
table->GetString(key, "").find('"') != std::string::npos) {
if (m_values.find(key) != m_values.end()) {
m_values.erase(key);
- std::vector::iterator it = m_keys.begin();
+ auto it = m_keys.begin();
for (; it != m_keys.end(); it++) {
if (key == *it) {
m_keys.erase(it);
diff --git a/wpilibc/wpilibC++Devices/src/Relay.cpp b/wpilibc/wpilibC++Devices/src/Relay.cpp
index 2813da5f1f..98948e5818 100644
--- a/wpilibc/wpilibC++Devices/src/Relay.cpp
+++ b/wpilibc/wpilibC++Devices/src/Relay.cpp
@@ -15,17 +15,18 @@
#include "HAL/HAL.hpp"
// Allocate each direction separately.
-static Resource *relayChannels = NULL;
+static Resource *relayChannels = nullptr;
/**
- * Common relay initialization method.
- * This code is common to all Relay constructors and initializes the relay and
- * reserves
- * all resources that need to be locked. Initially the relay is set to both
- * lines at 0v.
+ * Relay constructor given a channel.
+ *
+ * This code initializes the relay and reserves all resources that need to be
+ * locked. Initially the relay is set to both lines at 0v.
+ * @param channel The channel number (0-3).
+ * @param direction The direction that the Relay object will control.
*/
-void Relay::InitRelay() {
- m_table = NULL;
+Relay::Relay(uint32_t channel, Relay::Direction direction)
+ : m_channel(channel), m_direction(direction) {
char buf[64];
Resource::CreateResourceObject(&relayChannels,
dio_kNumSystems * kRelayChannels * 2);
@@ -62,16 +63,6 @@ void Relay::InitRelay() {
LiveWindow::GetInstance()->AddActuator("Relay", 1, m_channel, this);
}
-/**
- * Relay constructor given a channel.
- * @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)
- : m_channel(channel), m_direction(direction) {
- InitRelay();
-}
-
/**
* Free the resource associated with a relay.
* The relay channels are set to free and the relay output is turned off.
@@ -210,7 +201,7 @@ void Relay::ValueChanged(ITable *source, const std::string &key,
}
void Relay::UpdateTable() {
- if (m_table != NULL) {
+ if (m_table != nullptr) {
if (Get() == kOn) {
m_table->PutString("Value", "On");
} else if (Get() == kForward) {
@@ -224,13 +215,13 @@ void Relay::UpdateTable() {
}
void Relay::StartLiveWindowMode() {
- if (m_table != NULL) {
+ if (m_table != nullptr) {
m_table->AddTableListener("Value", this, true);
}
}
void Relay::StopLiveWindowMode() {
- if (m_table != NULL) {
+ if (m_table != nullptr) {
m_table->RemoveTableListener(this);
}
}
diff --git a/wpilibc/wpilibC++Devices/src/RobotBase.cpp b/wpilibc/wpilibC++Devices/src/RobotBase.cpp
index 1ce3953f9c..36488e4447 100644
--- a/wpilibc/wpilibC++Devices/src/RobotBase.cpp
+++ b/wpilibc/wpilibC++Devices/src/RobotBase.cpp
@@ -26,10 +26,10 @@
#include
#endif
-RobotBase *RobotBase::m_instance = NULL;
+RobotBase *RobotBase::m_instance = nullptr;
void RobotBase::setInstance(RobotBase *robot) {
- wpi_assert(m_instance == NULL);
+ wpi_assert(m_instance == nullptr);
m_instance = robot;
}
@@ -52,18 +52,18 @@ void RobotBase::robotSetup(RobotBase *robot) {
* nice to put this code into it's own task that loads on boot so ensure that it
* runs.
*/
-RobotBase::RobotBase() : m_task(NULL), m_ds(NULL) {
+RobotBase::RobotBase() {
m_ds = DriverStation::GetInstance();
RobotState::SetImplementation(DriverStation::GetInstance());
HLUsageReporting::SetImplementation(new HardwareHLReporting());
RobotBase::setInstance(this);
- FILE *file = NULL;
+ FILE *file = nullptr;
file = fopen("/tmp/frc_versions/FRC_Lib_Version.ini", "w");
fputs("2015 C++ 1.2.0", file);
- if (file != NULL) fclose(file);
+ if (file != nullptr) fclose(file);
}
/**
@@ -75,8 +75,8 @@ RobotBase::RobotBase() : m_task(NULL), m_ds(NULL) {
RobotBase::~RobotBase() {
SensorBase::DeleteSingletons();
delete m_task;
- m_task = NULL;
- m_instance = NULL;
+ m_task = nullptr;
+ m_instance = nullptr;
}
/**
diff --git a/wpilibc/wpilibC++Devices/src/RobotDrive.cpp b/wpilibc/wpilibC++Devices/src/RobotDrive.cpp
index 1c42aedada..5d1f648515 100644
--- a/wpilibc/wpilibC++Devices/src/RobotDrive.cpp
+++ b/wpilibc/wpilibC++Devices/src/RobotDrive.cpp
@@ -37,15 +37,8 @@ const int32_t RobotDrive::kMaxNumberOfMotors;
* robot drive.
*/
void RobotDrive::InitRobotDrive() {
- m_frontLeftMotor = NULL;
- m_frontRightMotor = NULL;
- m_rearRightMotor = NULL;
- m_rearLeftMotor = NULL;
- m_sensitivity = 0.5;
- m_maxOutput = 1.0;
m_safetyHelper = new MotorSafetyHelper(this);
m_safetyHelper->SetSafetyEnabled(true);
- m_syncGroup = 0;
}
/**
@@ -105,9 +98,9 @@ RobotDrive::RobotDrive(uint32_t frontLeftMotor, uint32_t rearLeftMotor,
RobotDrive::RobotDrive(SpeedController *leftMotor,
SpeedController *rightMotor) {
InitRobotDrive();
- if (leftMotor == NULL || rightMotor == NULL) {
+ if (leftMotor == nullptr || rightMotor == nullptr) {
wpi_setWPIError(NullParameter);
- m_rearLeftMotor = m_rearRightMotor = NULL;
+ m_rearLeftMotor = m_rearRightMotor = nullptr;
return;
}
m_rearLeftMotor = leftMotor;
@@ -141,8 +134,8 @@ RobotDrive::RobotDrive(SpeedController *frontLeftMotor,
SpeedController *frontRightMotor,
SpeedController *rearRightMotor) {
InitRobotDrive();
- if (frontLeftMotor == NULL || rearLeftMotor == NULL ||
- frontRightMotor == NULL || rearRightMotor == NULL) {
+ if (frontLeftMotor == nullptr || rearLeftMotor == nullptr ||
+ frontRightMotor == nullptr || rearRightMotor == nullptr) {
wpi_setWPIError(NullParameter);
return;
}
@@ -230,7 +223,7 @@ void RobotDrive::Drive(float outputMagnitude, float curve) {
*/
void RobotDrive::TankDrive(GenericHID *leftStick, GenericHID *rightStick,
bool squaredInputs) {
- if (leftStick == NULL || rightStick == NULL) {
+ if (leftStick == nullptr || rightStick == nullptr) {
wpi_setWPIError(NullParameter);
return;
}
@@ -255,7 +248,7 @@ void RobotDrive::TankDrive(GenericHID &leftStick, GenericHID &rightStick,
void RobotDrive::TankDrive(GenericHID *leftStick, uint32_t leftAxis,
GenericHID *rightStick, uint32_t rightAxis,
bool squaredInputs) {
- if (leftStick == NULL || rightStick == NULL) {
+ if (leftStick == nullptr || rightStick == nullptr) {
wpi_setWPIError(NullParameter);
return;
}
@@ -591,13 +584,13 @@ void RobotDrive::HolonomicDrive(float magnitude, float direction,
* @param rightOutput The speed to send to the right side of the robot.
*/
void RobotDrive::SetLeftRightMotorOutputs(float leftOutput, float rightOutput) {
- wpi_assert(m_rearLeftMotor != NULL && m_rearRightMotor != NULL);
+ wpi_assert(m_rearLeftMotor != nullptr && m_rearRightMotor != nullptr);
- if (m_frontLeftMotor != NULL)
+ if (m_frontLeftMotor != nullptr)
m_frontLeftMotor->Set(Limit(leftOutput) * m_maxOutput, m_syncGroup);
m_rearLeftMotor->Set(Limit(leftOutput) * m_maxOutput, m_syncGroup);
- if (m_frontRightMotor != NULL)
+ if (m_frontRightMotor != nullptr)
m_frontRightMotor->Set(-Limit(rightOutput) * m_maxOutput, m_syncGroup);
m_rearRightMotor->Set(-Limit(rightOutput) * m_maxOutput, m_syncGroup);
@@ -734,9 +727,9 @@ void RobotDrive::GetDescription(char *desc) const {
}
void RobotDrive::StopMotor() {
- if (m_frontLeftMotor != NULL) m_frontLeftMotor->Disable();
- if (m_frontRightMotor != NULL) m_frontRightMotor->Disable();
- if (m_rearLeftMotor != NULL) m_rearLeftMotor->Disable();
- if (m_rearRightMotor != NULL) m_rearRightMotor->Disable();
+ if (m_frontLeftMotor != nullptr) m_frontLeftMotor->Disable();
+ if (m_frontRightMotor != nullptr) m_frontRightMotor->Disable();
+ if (m_rearLeftMotor != nullptr) m_rearLeftMotor->Disable();
+ if (m_rearRightMotor != nullptr) m_rearRightMotor->Disable();
m_safetyHelper->Feed();
}
diff --git a/wpilibc/wpilibC++Devices/src/SPI.cpp b/wpilibc/wpilibC++Devices/src/SPI.cpp
index 3d00828fd8..c0ac0975d1 100644
--- a/wpilibc/wpilibC++Devices/src/SPI.cpp
+++ b/wpilibc/wpilibC++Devices/src/SPI.cpp
@@ -151,7 +151,7 @@ int32_t SPI::Write(uint8_t* data, uint8_t size) {
int32_t SPI::Read(bool initiate, uint8_t* dataReceived, uint8_t size) {
int32_t retVal = 0;
if (initiate) {
- uint8_t* dataToSend = new uint8_t[size];
+ auto dataToSend = new uint8_t[size];
memset(dataToSend, 0, size);
retVal = spiTransaction(m_port, dataToSend, dataReceived, size);
} else
diff --git a/wpilibc/wpilibC++Devices/src/SafePWM.cpp b/wpilibc/wpilibC++Devices/src/SafePWM.cpp
index dd4d1aba07..09689eddbd 100644
--- a/wpilibc/wpilibC++Devices/src/SafePWM.cpp
+++ b/wpilibc/wpilibC++Devices/src/SafePWM.cpp
@@ -9,20 +9,15 @@
#include "MotorSafetyHelper.h"
-/**
- * Initialize a SafePWM object by setting defaults
- */
-void SafePWM::InitSafePWM() {
- m_safetyHelper = new MotorSafetyHelper(this);
- m_safetyHelper->SetSafetyEnabled(false);
-}
-
/**
* Constructor for a SafePWM object taking a channel number.
* @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) { InitSafePWM(); }
+SafePWM::SafePWM(uint32_t channel) : PWM(channel) {
+ m_safetyHelper = new MotorSafetyHelper(this);
+ m_safetyHelper->SetSafetyEnabled(false);
+}
SafePWM::~SafePWM() { delete m_safetyHelper; }
diff --git a/wpilibc/wpilibC++Devices/src/SensorBase.cpp b/wpilibc/wpilibC++Devices/src/SensorBase.cpp
index 991cc950c9..26b06981de 100644
--- a/wpilibc/wpilibC++Devices/src/SensorBase.cpp
+++ b/wpilibc/wpilibC++Devices/src/SensorBase.cpp
@@ -19,7 +19,7 @@ const uint32_t SensorBase::kPwmChannels;
const uint32_t SensorBase::kRelayChannels;
const uint32_t SensorBase::kPDPChannels;
const uint32_t SensorBase::kChassisSlots;
-SensorBase* SensorBase::m_singletonList = NULL;
+SensorBase* SensorBase::m_singletonList = nullptr;
static bool portsInitialized = false;
void* SensorBase::m_digital_ports[kDigitalChannels];
@@ -54,11 +54,6 @@ SensorBase::SensorBase() {
}
}
-/**
- * Frees the resources for a SensorBase.
- */
-SensorBase::~SensorBase() {}
-
/**
* Add sensor to the singleton list.
* Add this sensor to the list of singletons that need to be deleted when
@@ -80,12 +75,12 @@ void SensorBase::AddToSingletonList() {
* their resources can be freed.
*/
void SensorBase::DeleteSingletons() {
- for (SensorBase* next = m_singletonList; next != NULL;) {
+ for (SensorBase* next = m_singletonList; next != nullptr;) {
SensorBase* tmp = next;
next = next->m_nextSingleton;
delete tmp;
}
- m_singletonList = NULL;
+ m_singletonList = nullptr;
}
/**
diff --git a/wpilibc/wpilibC++Devices/src/SerialPort.cpp b/wpilibc/wpilibC++Devices/src/SerialPort.cpp
index 80b0089eee..d1a6c28b5e 100644
--- a/wpilibc/wpilibC++Devices/src/SerialPort.cpp
+++ b/wpilibc/wpilibC++Devices/src/SerialPort.cpp
@@ -27,7 +27,7 @@
*/
SerialPort::SerialPort(uint32_t baudRate, Port port, uint8_t dataBits,
SerialPort::Parity parity, SerialPort::StopBits stopBits)
- : m_resourceManagerHandle(0), m_portHandle(0), m_consoleModeEnabled(false) {
+{
int32_t status = 0;
m_port = port;
@@ -53,7 +53,7 @@ SerialPort::SerialPort(uint32_t baudRate, Port port, uint8_t dataBits,
// viInstallHandler(m_portHandle, VI_EVENT_IO_COMPLETION, ioCompleteHandler,
// this);
- // viEnableEvent(m_portHandle, VI_EVENT_IO_COMPLETION, VI_HNDLR, VI_NULL);
+ // viEnableEvent(m_portHandle, VI_EVENT_IO_COMPLETION, VI_HNDLR, VI_nullptr);
HALReport(HALUsageReporting::kResourceType_SerialPort, 0);
}
@@ -226,4 +226,4 @@ void SerialPort::Reset() {
int32_t status = 0;
serialClear(m_port, &status);
wpi_setErrorWithContext(status, getHALErrorMessage(status));
-}
\ No newline at end of file
+}
diff --git a/wpilibc/wpilibC++Devices/src/Servo.cpp b/wpilibc/wpilibC++Devices/src/Servo.cpp
index 0ab2c2179d..304c97cb32 100644
--- a/wpilibc/wpilibC++Devices/src/Servo.cpp
+++ b/wpilibc/wpilibC++Devices/src/Servo.cpp
@@ -16,28 +16,17 @@ constexpr float Servo::kMinServoAngle;
constexpr float Servo::kDefaultMaxServoPWM;
constexpr float Servo::kDefaultMinServoPWM;
-/**
- * Common initialization code called by all constructors.
- *
- * InitServo() assigns defaults for the period multiplier for the servo PWM
- * control signal, as
- * well as the minimum and maximum PWM values supported by the servo.
- */
-void Servo::InitServo() {
- m_table = NULL;
- SetBounds(kDefaultMaxServoPWM, 0.0, 0.0, 0.0, kDefaultMinServoPWM);
- SetPeriodMultiplier(kPeriodMultiplier_4X);
-
- LiveWindow::GetInstance()->AddActuator("Servo", GetChannel(), this);
- HALReport(HALUsageReporting::kResourceType_Servo, GetChannel());
-}
-
/**
* @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) {
- InitServo();
+ // Set minimum and maximum PWM values supported by the servo
+ SetBounds(kDefaultMaxServoPWM, 0.0, 0.0, 0.0, kDefaultMinServoPWM);
+
+ // Assign defaults for period multiplier for the servo PWM control signal
+ SetPeriodMultiplier(kPeriodMultiplier_4X);
+
// printf("Done initializing servo %d\n", channel);
}
@@ -112,19 +101,19 @@ void Servo::ValueChanged(ITable* source, const std::string& key,
}
void Servo::UpdateTable() {
- if (m_table != NULL) {
+ if (m_table != nullptr) {
m_table->PutNumber("Value", Get());
}
}
void Servo::StartLiveWindowMode() {
- if (m_table != NULL) {
+ if (m_table != nullptr) {
m_table->AddTableListener("Value", this, true);
}
}
void Servo::StopLiveWindowMode() {
- if (m_table != NULL) {
+ if (m_table != nullptr) {
m_table->RemoveTableListener(this);
}
}
diff --git a/wpilibc/wpilibC++Devices/src/Solenoid.cpp b/wpilibc/wpilibC++Devices/src/Solenoid.cpp
index ab84754390..422c5adeeb 100644
--- a/wpilibc/wpilibC++Devices/src/Solenoid.cpp
+++ b/wpilibc/wpilibC++Devices/src/Solenoid.cpp
@@ -11,10 +11,21 @@
#include "LiveWindow/LiveWindow.h"
/**
- * Common function to implement constructor behavior.
+ * Constructor using the default PCM ID (0).
+ *
+ * @param channel The channel on the PCM to control (0..7).
*/
-void Solenoid::InitSolenoid() {
- m_table = NULL;
+Solenoid::Solenoid(uint32_t channel)
+ : Solenoid(GetDefaultSolenoidModule(), channel) {}
+
+/**
+ * Constructor.
+ *
+ * @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)
+ : SolenoidBase(moduleNumber), m_channel(channel) {
char buf[64];
if (!CheckSolenoidModule(m_moduleNumber)) {
snprintf(buf, 64, "Solenoid Module %d", m_moduleNumber);
@@ -41,27 +52,6 @@ void Solenoid::InitSolenoid() {
m_moduleNumber);
}
-/**
- * Constructor using the default PCM ID (0).
- *
- * @param channel The channel on the PCM to control (0..7).
- */
-Solenoid::Solenoid(uint32_t channel)
- : SolenoidBase(GetDefaultSolenoidModule()), m_channel(channel) {
- InitSolenoid();
-}
-
-/**
- * Constructor.
- *
- * @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)
- : SolenoidBase(moduleNumber), m_channel(channel) {
- InitSolenoid();
-}
-
/**
* Destructor.
*/
@@ -113,21 +103,21 @@ void Solenoid::ValueChanged(ITable* source, const std::string& key,
}
void Solenoid::UpdateTable() {
- if (m_table != NULL) {
+ if (m_table != nullptr) {
m_table->PutBoolean("Value", Get());
}
}
void Solenoid::StartLiveWindowMode() {
Set(false);
- if (m_table != NULL) {
+ if (m_table != nullptr) {
m_table->AddTableListener("Value", this, true);
}
}
void Solenoid::StopLiveWindowMode() {
Set(false);
- if (m_table != NULL) {
+ if (m_table != nullptr) {
m_table->RemoveTableListener(this);
}
}
diff --git a/wpilibc/wpilibC++Devices/src/SolenoidBase.cpp b/wpilibc/wpilibC++Devices/src/SolenoidBase.cpp
index 8d8dfc3b7a..9ce51b5e60 100644
--- a/wpilibc/wpilibC++Devices/src/SolenoidBase.cpp
+++ b/wpilibc/wpilibC++Devices/src/SolenoidBase.cpp
@@ -8,7 +8,7 @@
#include "SolenoidBase.h"
// Needs to be global since the protected resource spans all Solenoid objects.
-Resource* SolenoidBase::m_allocated = NULL;
+Resource* SolenoidBase::m_allocated = nullptr;
void* SolenoidBase::m_ports[m_maxModules][m_maxPorts];
/**
@@ -27,11 +27,6 @@ SolenoidBase::SolenoidBase(uint8_t moduleNumber)
}
}
-/**
- * Destructor.
- */
-SolenoidBase::~SolenoidBase() {}
-
/**
* Set the value of a solenoid.
*
diff --git a/wpilibc/wpilibC++Devices/src/Talon.cpp b/wpilibc/wpilibC++Devices/src/Talon.cpp
index 8e63b7fffe..1270af839b 100644
--- a/wpilibc/wpilibC++Devices/src/Talon.cpp
+++ b/wpilibc/wpilibC++Devices/src/Talon.cpp
@@ -11,24 +11,24 @@
#include "LiveWindow/LiveWindow.h"
/**
- * Common initialization code called by all constructors.
- *
- * 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 saturate the controller in either direction,
- * calibration is recommended.
- * The calibration procedure can be found in the Talon User Manual available
- * from CTRE.
- *
- * 2.037ms = full "forward"
- * 1.539ms = the "high end" of the deadband range
- * 1.513ms = center of the deadband range (off)
- * 1.487ms = the "low end" of the deadband range
- * 0.989ms = full "reverse"
+ * Constructor for a Talon (original or Talon SR)
+ * @param channel The PWM channel number that the Talon is attached to. 0-9 are
+ * on-board, 10-19 are on the MXP port
*/
-void Talon::InitTalon() {
+Talon::Talon(uint32_t 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
+ * saturate the controller in either direction, calibration is recommended.
+ * The calibration procedure can be found in the Talon User Manual available
+ * from CTRE.
+ *
+ * 2.037ms = full "forward"
+ * 1.539ms = the "high end" of the deadband range
+ * 1.513ms = center of the deadband range (off)
+ * 1.487ms = the "low end" of the deadband range
+ * 0.989ms = full "reverse"
+ */
SetBounds(2.037, 1.539, 1.513, 1.487, .989);
SetPeriodMultiplier(kPeriodMultiplier_1X);
SetRaw(m_centerPwm);
@@ -36,18 +36,8 @@ void Talon::InitTalon() {
HALReport(HALUsageReporting::kResourceType_Talon, GetChannel());
LiveWindow::GetInstance()->AddActuator("Talon", GetChannel(), this);
- m_isInverted = false;
}
-/**
- * Constructor for a Talon (original or Talon SR)
- * @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) : SafePWM(channel) { InitTalon(); }
-
-Talon::~Talon() {}
-
/**
* Set the PWM value.
*
diff --git a/wpilibc/wpilibC++Devices/src/TalonSRX.cpp b/wpilibc/wpilibC++Devices/src/TalonSRX.cpp
index 246b35f258..6e6115f872 100644
--- a/wpilibc/wpilibC++Devices/src/TalonSRX.cpp
+++ b/wpilibc/wpilibC++Devices/src/TalonSRX.cpp
@@ -11,23 +11,23 @@
#include "LiveWindow/LiveWindow.h"
/**
- * Common initialization code called by all constructors.
- *
- * 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 behaviour
- * around
- * the deadband or inability to saturate the controller in either direction,
- * calibration is recommended.
- * The calibration procedure can be found in the TalonSRX User Manual available
- * from Cross The Road Electronics.
- * 2.004ms = full "forward"
- * 1.52ms = the "high end" of the deadband range
- * 1.50ms = center of the deadband range (off)
- * 1.48ms = the "low end" of the deadband range
- * 0.997ms = full "reverse"
+ * Construct a TalonSRX connected via PWM
+ * @param channel The PWM channel that the TalonSRX is attached to. 0-9 are
+ * on-board, 10-19 are on the MXP port
*/
-void TalonSRX::InitTalonSRX() {
+TalonSRX::TalonSRX(uint32_t channel) : SafePWM(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
+ * inability to saturate the controller in either direction, calibration is
+ * recommended. The calibration procedure can be found in the TalonSRX User
+ * Manual available from Cross The Road Electronics.
+ * 2.004ms = full "forward"
+ * 1.52ms = the "high end" of the deadband range
+ * 1.50ms = center of the deadband range (off)
+ * 1.48ms = the "low end" of the deadband range
+ * 0.997ms = full "reverse"
+ */
SetBounds(2.004, 1.52, 1.50, 1.48, .997);
SetPeriodMultiplier(kPeriodMultiplier_1X);
SetRaw(m_centerPwm);
@@ -35,18 +35,8 @@ void TalonSRX::InitTalonSRX() {
HALReport(HALUsageReporting::kResourceType_TalonSRX, GetChannel());
LiveWindow::GetInstance()->AddActuator("TalonSRX", GetChannel(), this);
- m_isInverted = false;
}
-/**
- * Construct a TalonSRX connected via PWM
- * @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) : SafePWM(channel) { InitTalonSRX(); }
-
-TalonSRX::~TalonSRX() {}
-
/**
* Set the PWM value.
*
diff --git a/wpilibc/wpilibC++Devices/src/Task.cpp b/wpilibc/wpilibC++Devices/src/Task.cpp
index 316eaf8e08..8c27151609 100644
--- a/wpilibc/wpilibC++Devices/src/Task.cpp
+++ b/wpilibc/wpilibC++Devices/src/Task.cpp
@@ -25,7 +25,6 @@ const uint32_t Task::kDefaultPriority;
*/
Task::Task(const char* name, FUNCPTR function, int32_t priority,
uint32_t stackSize) {
- m_taskID = NULL_TASK;
m_function = function;
m_priority = priority;
m_stackSize = stackSize;
@@ -41,7 +40,7 @@ Task::Task(const char* name, FUNCPTR function, int32_t priority,
Task::~Task() {
if (m_taskID != NULL_TASK) Stop();
delete[] m_taskName;
- m_taskName = NULL;
+ m_taskName = nullptr;
}
/**
@@ -144,7 +143,7 @@ bool Task::SetPriority(int32_t priority) {
/**
* Returns the name of the task.
- * @returns Pointer to the name of the task or NULL if not allocated
+ * @returns Pointer to the name of the task or nullptr if not allocated
*/
const char* Task::GetName() const { return m_taskName; }
diff --git a/wpilibc/wpilibC++Devices/src/Timer.cpp b/wpilibc/wpilibC++Devices/src/Timer.cpp
index 29440aa83c..acb794f4a4 100644
--- a/wpilibc/wpilibC++Devices/src/Timer.cpp
+++ b/wpilibc/wpilibC++Devices/src/Timer.cpp
@@ -59,11 +59,7 @@ double GetTime() {
* not running and
* must be started.
*/
-Timer::Timer()
- : m_startTime(0.0),
- m_accumulatedTime(0.0),
- m_running(false),
- m_semaphore(0) {
+Timer::Timer() {
// Creates a semaphore to control access to critical regions.
// Initially 'open'
m_semaphore = initializeMutexNormal();
diff --git a/wpilibc/wpilibC++Devices/src/USBCamera.cpp b/wpilibc/wpilibC++Devices/src/USBCamera.cpp
index 7e577a0f36..b6f1bd7f25 100644
--- a/wpilibc/wpilibC++Devices/src/USBCamera.cpp
+++ b/wpilibc/wpilibC++Devices/src/USBCamera.cpp
@@ -19,10 +19,6 @@
wpi_setImaqErrorWithContext(error, #funName); \
}
-// Constants for the manual and auto types
-static const std::string AUTO = "Auto";
-static const std::string MANUAL = "Manual";
-
/**
* Helper function to determine the size of a jpeg. The general structure of
* how to parse a jpeg for length can be found in this stackoverflow article:
@@ -76,23 +72,8 @@ unsigned int USBCamera::GetJpegSize(void* buffer, unsigned int buffSize) {
}
USBCamera::USBCamera(std::string name, bool useJpeg)
- : m_id(0),
- m_name(name),
- m_useJpeg(useJpeg),
- m_active(false),
- m_open(false),
- m_mutex(),
- m_width(320),
- m_height(240),
- m_fps(30),
- m_whiteBalance(AUTO),
- m_whiteBalanceValue(0),
- m_whiteBalanceValuePresent(false),
- m_exposure(MANUAL),
- m_exposureValue(50),
- m_exposureValuePresent(false),
- m_brightness(80),
- m_needSettingsUpdate(true) {}
+ : m_name(name),
+ m_useJpeg(useJpeg) {}
void USBCamera::OpenCamera() {
std::unique_lock lock(m_mutex);
@@ -148,7 +129,7 @@ void USBCamera::UpdateSettings() {
uInt32 count = 0;
uInt32 currentMode = 0;
- SAFE_IMAQ_CALL(IMAQdxEnumerateVideoModes, m_id, NULL, &count, ¤tMode);
+ SAFE_IMAQ_CALL(IMAQdxEnumerateVideoModes, m_id, nullptr, &count, ¤tMode);
IMAQdxVideoMode modes[count];
SAFE_IMAQ_CALL(IMAQdxEnumerateVideoModes, m_id, modes, &count, ¤tMode);
@@ -188,10 +169,10 @@ void USBCamera::UpdateSettings() {
if (m_whiteBalance.compare(AUTO) == 0) {
SAFE_IMAQ_CALL(IMAQdxSetAttribute, m_id, ATTR_WB_MODE,
- IMAQdxValueTypeString, AUTO.c_str());
+ IMAQdxValueTypeString, AUTO);
} else {
SAFE_IMAQ_CALL(IMAQdxSetAttribute, m_id, ATTR_WB_MODE,
- IMAQdxValueTypeString, MANUAL.c_str());
+ IMAQdxValueTypeString, MANUAL);
if (m_whiteBalanceValuePresent)
SAFE_IMAQ_CALL(IMAQdxSetAttribute, m_id, ATTR_WB_VALUE,
IMAQdxValueTypeU32, m_whiteBalanceValue);
@@ -203,7 +184,7 @@ void USBCamera::UpdateSettings() {
std::string("AutoAperaturePriority").c_str());
} else {
SAFE_IMAQ_CALL(IMAQdxSetAttribute, m_id, ATTR_EX_MODE,
- IMAQdxValueTypeString, MANUAL.c_str());
+ IMAQdxValueTypeString, MANUAL);
if (m_exposureValuePresent) {
double minv = 0.0;
double maxv = 0.0;
@@ -218,7 +199,7 @@ void USBCamera::UpdateSettings() {
}
SAFE_IMAQ_CALL(IMAQdxSetAttribute, m_id, ATTR_BR_MODE, IMAQdxValueTypeString,
- MANUAL.c_str());
+ MANUAL);
double minv = 0.0;
double maxv = 0.0;
SAFE_IMAQ_CALL(IMAQdxGetAttributeMinimum, m_id, ATTR_BR_VALUE,
diff --git a/wpilibc/wpilibC++Devices/src/Ultrasonic.cpp b/wpilibc/wpilibC++Devices/src/Ultrasonic.cpp
index 82b8c8713a..9f5fe77934 100644
--- a/wpilibc/wpilibC++Devices/src/Ultrasonic.cpp
+++ b/wpilibc/wpilibC++Devices/src/Ultrasonic.cpp
@@ -28,9 +28,9 @@ Task Ultrasonic::m_task(
(FUNCPTR)
UltrasonicChecker); // task doing the round-robin automatic sensing
Ultrasonic *Ultrasonic::m_firstSensor =
- NULL; // head of the ultrasonic sensor list
+ nullptr; // head of the ultrasonic sensor list
bool Ultrasonic::m_automaticEnabled = false; // automatic round robin mode
-SEMAPHORE_ID Ultrasonic::m_semaphore = 0;
+SEMAPHORE_ID Ultrasonic::m_semaphore = nullptr;
/**
* Background task that goes through the list of ultrasonic sensors and pings
@@ -45,10 +45,10 @@ SEMAPHORE_ID Ultrasonic::m_semaphore = 0;
* anything with the sensors!!
*/
void Ultrasonic::UltrasonicChecker() {
- Ultrasonic *u = NULL;
+ Ultrasonic *u = nullptr;
while (m_automaticEnabled) {
- if (u == NULL) u = m_firstSensor;
- if (u == NULL) return;
+ if (u == nullptr) u = m_firstSensor;
+ if (u == nullptr) return;
if (u->IsEnabled()) u->m_pingChannel->Pulse(kPingTime); // do the ping
u = u->m_nextSensor;
Wait(0.1); // wait for ping to return
@@ -66,9 +66,8 @@ void Ultrasonic::UltrasonicChecker() {
* restored.
*/
void Ultrasonic::Initialize() {
- m_table = NULL;
bool originalMode = m_automaticEnabled;
- if (m_semaphore == 0) m_semaphore = initializeSemaphore(SEMAPHORE_FULL);
+ if (m_semaphore == nullptr) m_semaphore = initializeSemaphore(SEMAPHORE_FULL);
SetAutomaticMode(false); // kill task when adding a new sensor
takeSemaphore(m_semaphore); // link this instance on the list
{
@@ -124,7 +123,7 @@ Ultrasonic::Ultrasonic(uint32_t pingChannel, uint32_t echoChannel,
*/
Ultrasonic::Ultrasonic(DigitalOutput *pingChannel, DigitalInput *echoChannel,
DistanceUnit units) {
- if (pingChannel == NULL || echoChannel == NULL) {
+ if (pingChannel == nullptr || echoChannel == nullptr) {
wpi_setWPIError(NullParameter);
return;
}
@@ -169,18 +168,18 @@ Ultrasonic::~Ultrasonic() {
delete m_pingChannel;
delete m_echoChannel;
}
- wpi_assert(m_firstSensor != NULL);
+ wpi_assert(m_firstSensor != nullptr);
takeSemaphore(m_semaphore);
{
if (this == m_firstSensor) {
m_firstSensor = m_nextSensor;
- if (m_firstSensor == NULL) {
+ if (m_firstSensor == nullptr) {
SetAutomaticMode(false);
}
} else {
- wpi_assert(m_firstSensor->m_nextSensor != NULL);
- for (Ultrasonic *s = m_firstSensor; s != NULL; s = s->m_nextSensor) {
+ wpi_assert(m_firstSensor->m_nextSensor != nullptr);
+ for (Ultrasonic *s = m_firstSensor; s != nullptr; s = s->m_nextSensor) {
if (this == s->m_nextSensor) {
s->m_nextSensor = s->m_nextSensor->m_nextSensor;
break;
@@ -189,7 +188,7 @@ Ultrasonic::~Ultrasonic() {
}
}
giveSemaphore(m_semaphore);
- if (m_firstSensor != NULL && wasAutomaticMode) SetAutomaticMode(true);
+ if (m_firstSensor != nullptr && wasAutomaticMode) SetAutomaticMode(true);
}
/**
@@ -211,7 +210,7 @@ void Ultrasonic::SetAutomaticMode(bool enabling) {
if (enabling) {
// enabling automatic mode.
// Clear all the counters so no data is valid
- for (Ultrasonic *u = m_firstSensor; u != NULL; u = u->m_nextSensor) {
+ for (Ultrasonic *u = m_firstSensor; u != nullptr; u = u->m_nextSensor) {
u->m_counter->Reset();
}
// Start round robin task
@@ -225,7 +224,7 @@ void Ultrasonic::SetAutomaticMode(bool enabling) {
// stop
// clear all the counters (data now invalid) since automatic mode is stopped
- for (Ultrasonic *u = m_firstSensor; u != NULL; u = u->m_nextSensor) {
+ for (Ultrasonic *u = m_firstSensor; u != nullptr; u = u->m_nextSensor) {
u->m_counter->Reset();
}
m_task.Stop();
@@ -313,7 +312,7 @@ Ultrasonic::DistanceUnit Ultrasonic::GetDistanceUnits() const {
}
void Ultrasonic::UpdateTable() {
- if (m_table != NULL) {
+ if (m_table != nullptr) {
m_table->PutNumber("Value", GetRangeInches());
}
}
diff --git a/wpilibc/wpilibC++Devices/src/Utility.cpp b/wpilibc/wpilibC++Devices/src/Utility.cpp
index ee8b5e6ad4..73bb0ef981 100644
--- a/wpilibc/wpilibC++Devices/src/Utility.cpp
+++ b/wpilibc/wpilibC++Devices/src/Utility.cpp
@@ -62,7 +62,7 @@ bool wpi_assert_impl(bool conditionValue, const char *conditionText,
std::cout << error << std::endl;
HALSetErrorData(error.c_str(), error.size(), 100);
- if (suspendOnAssertEnabled) suspendTask(0);
+ if (suspendOnAssertEnabled) suspendTask(nullptr);
}
return conditionValue;
@@ -99,7 +99,7 @@ void wpi_assertEqual_common_impl(const char *valueA, const char *valueB,
std::cout << error << std::endl;
HALSetErrorData(error.c_str(), error.size(), 100);
- if (suspendOnAssertEnabled) suspendTask(0);
+ if (suspendOnAssertEnabled) suspendTask(nullptr);
}
/**
@@ -200,7 +200,7 @@ static std::string demangle(char const *mangledSymbol) {
int status;
if (sscanf(mangledSymbol, "%*[^(]%*[(]%255[^)+]", buffer)) {
- char *symbol = abi::__cxa_demangle(buffer, NULL, &length, &status);
+ char *symbol = abi::__cxa_demangle(buffer, nullptr, &length, &status);
if (status == 0) {
return symbol;
} else {
diff --git a/wpilibc/wpilibC++Devices/src/Victor.cpp b/wpilibc/wpilibC++Devices/src/Victor.cpp
index 63b6c8b30c..30202db528 100644
--- a/wpilibc/wpilibC++Devices/src/Victor.cpp
+++ b/wpilibc/wpilibC++Devices/src/Victor.cpp
@@ -11,46 +11,34 @@
#include "LiveWindow/LiveWindow.h"
/**
- * Common initialization code called by all constructors.
- *
- * 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 experience issues such as
- * asymmetric behaviour around
- * the deadband or inability to saturate the controller in either direction,
- * calibration is recommended.
- * The calibration procedure can be found in the Victor 884 User Manual
- * available from IFI.
- *
- * 2.027ms = full "forward"
- * 1.525ms = the "high end" of the deadband range
- * 1.507ms = center of the deadband range (off)
- * 1.49ms = the "low end" of the deadband range
- * 1.026ms = full "reverse"
+ * Constructor for a Victor
+ * @param channel The PWM channel number that the Victor is attached to. 0-9 are
+ * on-board, 10-19 are on the MXP port
*/
-void Victor::InitVictor() {
+Victor::Victor(uint32_t 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 experience issues such as asymmetric behaviour around the deadband
+ * or inability to saturate the controller in either direction, calibration is
+ * recommended. The calibration procedure can be found in the Victor 884 User
+ * Manual available from IFI.
+ *
+ * 2.027ms = full "forward"
+ * 1.525ms = the "high end" of the deadband range
+ * 1.507ms = center of the deadband range (off)
+ * 1.49ms = the "low end" of the deadband range
+ * 1.026ms = full "reverse"
+ */
SetBounds(2.027, 1.525, 1.507, 1.49, 1.026);
-
SetPeriodMultiplier(kPeriodMultiplier_2X);
SetRaw(m_centerPwm);
SetZeroLatch();
LiveWindow::GetInstance()->AddActuator("Victor", GetChannel(), this);
HALReport(HALUsageReporting::kResourceType_Victor, GetChannel());
- m_isInverted = false;
}
-/**
- * Constructor for a Victor
- * @param channel The PWM channel number that the Victor is attached to. 0-9 are
- * on-board, 10-19 are on the MXP port
- */
-Victor::Victor(uint32_t channel) : SafePWM(channel) { InitVictor(); }
-
-Victor::~Victor() {}
-
/**
* Set the PWM value.
*
diff --git a/wpilibc/wpilibC++Devices/src/VictorSP.cpp b/wpilibc/wpilibC++Devices/src/VictorSP.cpp
index 0416061a2d..5341ccfb93 100644
--- a/wpilibc/wpilibC++Devices/src/VictorSP.cpp
+++ b/wpilibc/wpilibC++Devices/src/VictorSP.cpp
@@ -11,8 +11,6 @@
#include "LiveWindow/LiveWindow.h"
/**
- * Common initialization code called by all constructors.
- *
* Note that the VictorSP 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
@@ -28,7 +26,13 @@
* 1.48ms = the "low end" of the deadband range
* 0.997ms = full "reverse"
*/
-void VictorSP::InitVictorSP() {
+
+/**
+ * Constructor for a VictorSP
+ * @param channel The PWM channel that the VictorSP is attached to. 0-9 are
+ * on-board, 10-19 are on the MXP port
+ */
+VictorSP::VictorSP(uint32_t channel) : SafePWM(channel) {
SetBounds(2.004, 1.52, 1.50, 1.48, .997);
SetPeriodMultiplier(kPeriodMultiplier_1X);
SetRaw(m_centerPwm);
@@ -36,18 +40,8 @@ void VictorSP::InitVictorSP() {
HALReport(HALUsageReporting::kResourceType_VictorSP, GetChannel());
LiveWindow::GetInstance()->AddActuator("VictorSP", GetChannel(), this);
- m_isInverted = false;
}
-/**
- * Constructor for a VictorSP
- * @param channel The PWM channel that the VictorSP is attached to. 0-9 are
- * on-board, 10-19 are on the MXP port
- */
-VictorSP::VictorSP(uint32_t channel) : SafePWM(channel) { InitVictorSP(); }
-
-VictorSP::~VictorSP() {}
-
/**
* Set the PWM value.
*
diff --git a/wpilibc/wpilibC++Devices/src/Vision/AxisCamera.cpp b/wpilibc/wpilibC++Devices/src/Vision/AxisCamera.cpp
index babeeadd55..67d39d7707 100644
--- a/wpilibc/wpilibC++Devices/src/Vision/AxisCamera.cpp
+++ b/wpilibc/wpilibC++Devices/src/Vision/AxisCamera.cpp
@@ -43,21 +43,7 @@ static const std::string kRotationStrings[] = {
* @param cameraHost The host to find the camera at, typically an IP address
*/
AxisCamera::AxisCamera(std::string const &cameraHost)
- : m_cameraHost(cameraHost),
- m_cameraSocket(-1),
- m_freshImage(false),
- m_brightness(50),
- m_whiteBalance(kWhiteBalance_Automatic),
- m_colorLevel(50),
- m_exposureControl(kExposureControl_Automatic),
- m_exposurePriority(50),
- m_maxFPS(0),
- m_resolution(kResolution_640x480),
- m_compression(50),
- m_rotation(kRotation_0),
- m_parametersDirty(true),
- m_streamDirty(true),
- m_done(false) {
+ : m_cameraHost(cameraHost) {
m_captureThread = std::thread(&AxisCamera::Capture, this);
}
@@ -112,7 +98,7 @@ int AxisCamera::GetImage(ColorImage *image) {
* @return a pointer to an HSLImage object
*/
HSLImage *AxisCamera::GetImage() {
- HSLImage *image = new HSLImage();
+ auto image = new HSLImage();
GetImage(image);
return image;
}
@@ -131,22 +117,22 @@ HSLImage *AxisCamera::GetImage() {
int AxisCamera::CopyJPEG(char **destImage, unsigned int &destImageSize,
unsigned int &destImageBufferSize) {
std::lock_guard lock(m_imageDataMutex);
- if (destImage == NULL)
- wpi_setWPIErrorWithContext(NullParameter, "destImage must not be NULL");
+ if (destImage == nullptr)
+ wpi_setWPIErrorWithContext(NullParameter, "destImage must not be nullptr");
if (m_imageData.size() == 0) return 0; // if no source image
if (destImageBufferSize <
m_imageData.size()) // if current destination buffer too small
{
- if (*destImage != NULL) delete[] * destImage;
+ if (*destImage != nullptr) delete[] * destImage;
destImageBufferSize = m_imageData.size() + kImageBufferAllocationIncrement;
*destImage = new char[destImageBufferSize];
- if (*destImage == NULL) return 0;
+ if (*destImage == nullptr) return 0;
}
// copy this image into destination buffer
- if (*destImage == NULL) {
- wpi_setWPIErrorWithContext(NullParameter, "*destImage must not be NULL");
+ if (*destImage == nullptr) {
+ wpi_setWPIErrorWithContext(NullParameter, "*destImage must not be nullptr");
}
std::copy(m_imageData.begin(), m_imageData.end(), *destImage);
@@ -415,7 +401,7 @@ void AxisCamera::Capture() {
* This function actually reads the images from the camera.
*/
void AxisCamera::ReadImagesFromCamera() {
- char *imgBuffer = NULL;
+ char *imgBuffer = nullptr;
int imgBufferLength = 0;
// TODO: these recv calls must be non-blocking. Otherwise if the camera
@@ -441,7 +427,7 @@ void AxisCamera::ReadImagesFromCamera() {
// after
// there is at least 4 bytes total. Kind of obscure.
// look for 2 blank lines (\r\n)
- if (NULL != strstr(trailingPtr, "\r\n\r\n")) {
+ if (nullptr != strstr(trailingPtr, "\r\n\r\n")) {
--counter;
}
if (++trailingCounter >= 4) {
@@ -450,7 +436,7 @@ void AxisCamera::ReadImagesFromCamera() {
}
counter = 1;
char *contentLength = strstr(initialReadBuffer, "Content-Length: ");
- if (contentLength == NULL) {
+ if (contentLength == nullptr) {
wpi_setWPIErrorWithContext(IncompatibleMode,
"No content-length token found in packet");
close(m_cameraSocket);
@@ -464,7 +450,7 @@ void AxisCamera::ReadImagesFromCamera() {
if (imgBuffer) delete[] imgBuffer;
imgBufferLength = readLength + kImageBufferAllocationIncrement;
imgBuffer = new char[imgBufferLength];
- if (imgBuffer == NULL) {
+ if (imgBuffer == nullptr) {
imgBufferLength = 0;
continue;
}
@@ -567,7 +553,7 @@ bool AxisCamera::WriteParameters() {
*/
int AxisCamera::CreateCameraSocket(std::string const &requestString,
bool setError) {
- struct addrinfo *address = 0;
+ struct addrinfo *address = nullptr;
int camSocket;
/* create socket */
@@ -577,7 +563,7 @@ int AxisCamera::CreateCameraSocket(std::string const &requestString,
return -1;
}
- if (getaddrinfo(m_cameraHost.c_str(), "80", 0, &address) == -1) {
+ if (getaddrinfo(m_cameraHost.c_str(), "80", nullptr, &address) == -1) {
if (setError)
wpi_setErrnoErrorWithContext("Failed to create the camera socket");
return -1;
diff --git a/wpilibc/wpilibC++Devices/src/Vision/BaeUtilities.cpp b/wpilibc/wpilibC++Devices/src/Vision/BaeUtilities.cpp
index fe2944a7ed..5059e1e5cc 100644
--- a/wpilibc/wpilibC++Devices/src/Vision/BaeUtilities.cpp
+++ b/wpilibc/wpilibC++Devices/src/Vision/BaeUtilities.cpp
@@ -129,7 +129,7 @@ void dprintf(const char *tempString, ...) /* Variable argument list */
break;
case DEBUG_MOSTLY_OFF:
if (fatalFlag) {
- if ((outfile_fd = fopen(filepath, "a+")) != NULL) {
+ if ((outfile_fd = fopen(filepath, "a+")) != nullptr) {
fwrite(outtext, sizeof(char), strlen(outtext), outfile_fd);
fclose(outfile_fd);
}
@@ -139,14 +139,14 @@ void dprintf(const char *tempString, ...) /* Variable argument list */
printf("%s", outtext);
break;
case DEBUG_FILE_ONLY:
- if ((outfile_fd = fopen(filepath, "a+")) != NULL) {
+ if ((outfile_fd = fopen(filepath, "a+")) != nullptr) {
fwrite(outtext, sizeof(char), strlen(outtext), outfile_fd);
fclose(outfile_fd);
}
break;
case DEBUG_SCREEN_AND_FILE: // BOTH
printf("%s", outtext);
- if ((outfile_fd = fopen(filepath, "a+")) != NULL) {
+ if ((outfile_fd = fopen(filepath, "a+")) != nullptr) {
fwrite(outtext, sizeof(char), strlen(outtext), outfile_fd);
fclose(outfile_fd);
}
@@ -223,7 +223,7 @@ double SinPosition(double *period, double sinStart) {
double sinArg;
// 1st call
- if (period != NULL) {
+ if (period != nullptr) {
sinePeriod = *period;
timestamp = GetTime();
return 0.0;
@@ -270,7 +270,7 @@ void panInit(double period) {
void panForTarget(Servo *panServo) { panForTarget(panServo, 0.0); }
void panForTarget(Servo *panServo, double sinStart) {
- float normalizedSinPosition = (float)SinPosition(NULL, sinStart);
+ float normalizedSinPosition = (float)SinPosition(nullptr, sinStart);
float newServoPosition = NormalizeToRange(normalizedSinPosition);
panServo->Set(newServoPosition);
// ShowActivity ("pan x: normalized %f newServoPosition = %f" ,
@@ -296,13 +296,13 @@ int processFile(char *inputFile, char *outputString, int lineNumber) {
if (lineNumber < 0) return (-1);
- if ((infile = fopen(inputFile, "r")) == NULL) {
+ if ((infile = fopen(inputFile, "r")) == nullptr) {
printf("Fatal error opening file %s\n", inputFile);
return (0);
}
while (!feof(infile)) {
- if (fgets(inputStr, stringSize, infile) != NULL) {
+ if (fgets(inputStr, stringSize, infile) != nullptr) {
// Skip empty lines
if (emptyString(inputStr)) continue;
// Skip comment lines
@@ -339,7 +339,7 @@ int processFile(char *inputFile, char *outputString, int lineNumber) {
int emptyString(char *string) {
int i, len;
- if (string == NULL) return (1);
+ if (string == nullptr) return (1);
len = strlen(string);
for (i = 0; i < len; i++) {
@@ -358,7 +358,7 @@ int emptyString(char *string) {
void stripString(char *string) {
int i, j, len;
- if (string == NULL) return;
+ if (string == nullptr) return;
len = strlen(string);
for (i = 0, j = 0; i < len; i++) {
diff --git a/wpilibc/wpilibC++Devices/src/Vision/BinaryImage.cpp b/wpilibc/wpilibC++Devices/src/Vision/BinaryImage.cpp
index 541a69729b..ea14cbcfba 100644
--- a/wpilibc/wpilibC++Devices/src/Vision/BinaryImage.cpp
+++ b/wpilibc/wpilibC++Devices/src/Vision/BinaryImage.cpp
@@ -11,10 +11,6 @@
using namespace std;
-BinaryImage::BinaryImage() : MonoImage() {}
-
-BinaryImage::~BinaryImage() {}
-
/**
* Get then number of particles for the image.
* @returns the number of particles found for the image.
@@ -107,8 +103,7 @@ void BinaryImage::GetParticleAnalysisReport(int particleNumber,
*/
vector *
BinaryImage::GetOrderedParticleAnalysisReports() {
- vector *particles =
- new vector;
+ auto particles = new vector;
int particleCount = GetNumberParticles();
for (int particleIndex = 0; particleIndex < particleCount; particleIndex++) {
particles->push_back(GetParticleAnalysisReport(particleIndex));
@@ -197,23 +192,23 @@ bool BinaryImage::CompareParticleSizes(ParticleAnalysisReport particle1,
}
BinaryImage *BinaryImage::RemoveSmallObjects(bool connectivity8, int erosions) {
- BinaryImage *result = new BinaryImage();
+ auto result = new BinaryImage();
int success = imaqSizeFilter(result->GetImaqImage(), m_imaqImage,
- connectivity8, erosions, IMAQ_KEEP_LARGE, NULL);
+ connectivity8, erosions, IMAQ_KEEP_LARGE, nullptr);
wpi_setImaqErrorWithContext(success, "Error in RemoveSmallObjects");
return result;
}
BinaryImage *BinaryImage::RemoveLargeObjects(bool connectivity8, int erosions) {
- BinaryImage *result = new BinaryImage();
+ auto result = new BinaryImage();
int success = imaqSizeFilter(result->GetImaqImage(), m_imaqImage,
- connectivity8, erosions, IMAQ_KEEP_SMALL, NULL);
+ connectivity8, erosions, IMAQ_KEEP_SMALL, nullptr);
wpi_setImaqErrorWithContext(success, "Error in RemoveLargeObjects");
return result;
}
BinaryImage *BinaryImage::ConvexHull(bool connectivity8) {
- BinaryImage *result = new BinaryImage();
+ auto result = new BinaryImage();
int success =
imaqConvexHull(result->GetImaqImage(), m_imaqImage, connectivity8);
wpi_setImaqErrorWithContext(success, "Error in convex hull operation");
@@ -222,12 +217,12 @@ BinaryImage *BinaryImage::ConvexHull(bool connectivity8) {
BinaryImage *BinaryImage::ParticleFilter(ParticleFilterCriteria2 *criteria,
int criteriaCount) {
- BinaryImage *result = new BinaryImage();
+ auto result = new BinaryImage();
int numParticles;
ParticleFilterOptions2 filterOptions = {0, 0, 0, 1};
int success =
imaqParticleFilter4(result->GetImaqImage(), m_imaqImage, criteria,
- criteriaCount, &filterOptions, NULL, &numParticles);
+ criteriaCount, &filterOptions, nullptr, &numParticles);
wpi_setImaqErrorWithContext(success, "Error in particle filter operation");
return result;
}
diff --git a/wpilibc/wpilibC++Devices/src/Vision/ColorImage.cpp b/wpilibc/wpilibC++Devices/src/Vision/ColorImage.cpp
index 3a52337a78..bbbc242919 100644
--- a/wpilibc/wpilibC++Devices/src/Vision/ColorImage.cpp
+++ b/wpilibc/wpilibC++Devices/src/Vision/ColorImage.cpp
@@ -10,8 +10,6 @@
ColorImage::ColorImage(ImageType type) : ImageBase(type) {}
-ColorImage::~ColorImage() {}
-
/**
* Perform a threshold operation on a ColorImage.
* Perform a threshold operation on a ColorImage using the ColorMode supplied
@@ -22,7 +20,7 @@ ColorImage::~ColorImage() {}
BinaryImage *ColorImage::ComputeThreshold(ColorMode colorMode, int low1,
int high1, int low2, int high2,
int low3, int high3) {
- BinaryImage *result = new BinaryImage();
+ auto result = new BinaryImage();
Range range1 = {low1, high1}, range2 = {low2, high2}, range3 = {low3, high3};
int success = imaqColorThreshold(result->GetImaqImage(), m_imaqImage, 1,
@@ -154,12 +152,12 @@ BinaryImage *ColorImage::ThresholdHSI(Threshold &t) {
* @returns A pointer to a MonoImage that represents the extracted plane.
*/
MonoImage *ColorImage::ExtractColorPlane(ColorMode mode, int planeNumber) {
- MonoImage *result = new MonoImage();
- if (m_imaqImage == NULL) wpi_setWPIError(NullParameter);
+ auto result = new MonoImage();
+ if (m_imaqImage == nullptr) wpi_setWPIError(NullParameter);
int success = imaqExtractColorPlanes(
- m_imaqImage, mode, (planeNumber == 1) ? result->GetImaqImage() : NULL,
- (planeNumber == 2) ? result->GetImaqImage() : NULL,
- (planeNumber == 3) ? result->GetImaqImage() : NULL);
+ m_imaqImage, mode, (planeNumber == 1) ? result->GetImaqImage() : nullptr,
+ (planeNumber == 2) ? result->GetImaqImage() : nullptr,
+ (planeNumber == 3) ? result->GetImaqImage() : nullptr);
wpi_setImaqErrorWithContext(success, "Imaq ExtractColorPlanes failed");
return result;
}
@@ -274,9 +272,9 @@ void ColorImage::ReplacePlane(ColorMode mode, MonoImage *plane,
int planeNumber) {
int success =
imaqReplaceColorPlanes(m_imaqImage, (const Image *)m_imaqImage, mode,
- (planeNumber == 1) ? plane->GetImaqImage() : NULL,
- (planeNumber == 2) ? plane->GetImaqImage() : NULL,
- (planeNumber == 3) ? plane->GetImaqImage() : NULL);
+ (planeNumber == 1) ? plane->GetImaqImage() : nullptr,
+ (planeNumber == 2) ? plane->GetImaqImage() : nullptr,
+ (planeNumber == 3) ? plane->GetImaqImage() : nullptr);
wpi_setImaqErrorWithContext(success, "Imaq ReplaceColorPlanes failed");
}
diff --git a/wpilibc/wpilibC++Devices/src/Vision/FrcError.cpp b/wpilibc/wpilibC++Devices/src/Vision/FrcError.cpp
index 7cd1fbf512..f0b4725c61 100644
--- a/wpilibc/wpilibC++Devices/src/Vision/FrcError.cpp
+++ b/wpilibc/wpilibC++Devices/src/Vision/FrcError.cpp
@@ -319,7 +319,7 @@ const char* GetVisionErrorText(int errorCode) {
break;
}
case -1074395269: {
- errorText = "ERR_NULL_POINTER";
+ errorText = "ERR_nullptr_POINTER";
break;
}
case -1074395270: {
@@ -563,7 +563,7 @@ const char* GetVisionErrorText(int errorCode) {
break;
}
case -1074395343: {
- errorText = "ERR_FILE_FILENAME_NULL";
+ errorText = "ERR_FILE_FILENAME_nullptr";
break;
}
case -1074395345: {
@@ -2083,7 +2083,7 @@ const char* GetVisionErrorText(int errorCode) {
break;
}
case -1074396098: {
- errorText = "ERR_RESERVED_MUST_BE_NULL";
+ errorText = "ERR_RESERVED_MUST_BE_nullptr";
break;
}
case -1074396099: {
diff --git a/wpilibc/wpilibC++Devices/src/Vision/HSLImage.cpp b/wpilibc/wpilibC++Devices/src/Vision/HSLImage.cpp
index 11670a8325..5b114c488f 100644
--- a/wpilibc/wpilibC++Devices/src/Vision/HSLImage.cpp
+++ b/wpilibc/wpilibC++Devices/src/Vision/HSLImage.cpp
@@ -16,8 +16,6 @@ HSLImage::HSLImage() : ColorImage(IMAQ_IMAGE_HSL) {}
* @param fileName The path of the file to load.
*/
HSLImage::HSLImage(const char *fileName) : ColorImage(IMAQ_IMAGE_HSL) {
- int success = imaqReadFile(m_imaqImage, fileName, NULL, NULL);
+ int success = imaqReadFile(m_imaqImage, fileName, nullptr, nullptr);
wpi_setImaqErrorWithContext(success, "Imaq ReadFile error");
}
-
-HSLImage::~HSLImage() {}
diff --git a/wpilibc/wpilibC++Devices/src/Vision/ImageBase.cpp b/wpilibc/wpilibC++Devices/src/Vision/ImageBase.cpp
index 8b6adaf195..f35234adab 100644
--- a/wpilibc/wpilibC++Devices/src/Vision/ImageBase.cpp
+++ b/wpilibc/wpilibC++Devices/src/Vision/ImageBase.cpp
@@ -31,7 +31,7 @@ ImageBase::~ImageBase() {
* @param fileName The name of the file to write
*/
void ImageBase::Write(const char *fileName) {
- int success = imaqWriteFile(m_imaqImage, fileName, NULL);
+ int success = imaqWriteFile(m_imaqImage, fileName, nullptr);
wpi_setImaqErrorWithContext(success, "Imaq Image writeFile error");
}
@@ -41,7 +41,7 @@ void ImageBase::Write(const char *fileName) {
*/
int ImageBase::GetHeight() {
int height;
- imaqGetImageSize(m_imaqImage, NULL, &height);
+ imaqGetImageSize(m_imaqImage, nullptr, &height);
return height;
}
@@ -51,7 +51,7 @@ int ImageBase::GetHeight() {
*/
int ImageBase::GetWidth() {
int width;
- imaqGetImageSize(m_imaqImage, &width, NULL);
+ imaqGetImageSize(m_imaqImage, &width, nullptr);
return width;
}
diff --git a/wpilibc/wpilibC++Devices/src/Vision/MonoImage.cpp b/wpilibc/wpilibC++Devices/src/Vision/MonoImage.cpp
index 1351939cba..90703c0d30 100644
--- a/wpilibc/wpilibC++Devices/src/Vision/MonoImage.cpp
+++ b/wpilibc/wpilibC++Devices/src/Vision/MonoImage.cpp
@@ -11,8 +11,6 @@ using namespace std;
MonoImage::MonoImage() : ImageBase(IMAQ_IMAGE_U8) {}
-MonoImage::~MonoImage() {}
-
/**
* Look for ellipses in an image.
* Given some input parameters, look for any number of ellipses in an image.
@@ -29,8 +27,8 @@ vector *MonoImage::DetectEllipses(
EllipseMatch *e =
imaqDetectEllipses(m_imaqImage, ellipseDescriptor, curveOptions,
shapeDetectionOptions, roi, &numberOfMatches);
- vector *ellipses = new vector;
- if (e == NULL) {
+ auto ellipses = new vector;
+ if (e == nullptr) {
return ellipses;
}
for (int i = 0; i < numberOfMatches; i++) {
@@ -43,6 +41,6 @@ vector *MonoImage::DetectEllipses(
vector *MonoImage::DetectEllipses(
EllipseDescriptor *ellipseDescriptor) {
vector *ellipses =
- DetectEllipses(ellipseDescriptor, NULL, NULL, NULL);
+ DetectEllipses(ellipseDescriptor, nullptr, nullptr, nullptr);
return ellipses;
}
diff --git a/wpilibc/wpilibC++Devices/src/Vision/RGBImage.cpp b/wpilibc/wpilibC++Devices/src/Vision/RGBImage.cpp
index ef2dffe1ad..5469122923 100644
--- a/wpilibc/wpilibC++Devices/src/Vision/RGBImage.cpp
+++ b/wpilibc/wpilibC++Devices/src/Vision/RGBImage.cpp
@@ -16,8 +16,6 @@ RGBImage::RGBImage() : ColorImage(IMAQ_IMAGE_RGB) {}
* @param fileName The path of the file to load.
*/
RGBImage::RGBImage(const char *fileName) : ColorImage(IMAQ_IMAGE_RGB) {
- int success = imaqReadFile(m_imaqImage, fileName, NULL, NULL);
+ int success = imaqReadFile(m_imaqImage, fileName, nullptr, nullptr);
wpi_setImaqErrorWithContext(success, "Imaq ReadFile error");
}
-
-RGBImage::~RGBImage() {}
diff --git a/wpilibc/wpilibC++Devices/src/Vision/VisionAPI.cpp b/wpilibc/wpilibC++Devices/src/Vision/VisionAPI.cpp
index 6e0b7ada3a..32bab7f48e 100644
--- a/wpilibc/wpilibC++Devices/src/Vision/VisionAPI.cpp
+++ b/wpilibc/wpilibC++Devices/src/Vision/VisionAPI.cpp
@@ -31,7 +31,7 @@ int VisionAPI_debugFlag = 1;
*
* @param type Type of image to create
* @return Image* On success, this function returns the created image. On
-* failure, it returns NULL.
+* failure, it returns nullptr.
*/
Image* frcCreateImage(ImageType type) {
return imaqCreateImage(type, DEFAULT_BORDER_SIZE);
@@ -50,7 +50,7 @@ int frcDispose(void* object) { return imaqDispose(object); }
*
* @param functionName The name of the function
* @param ... A list of pointers to structures that need to be disposed of.
-* The last pointer in the list should always be set to NULL.
+* The last pointer in the list should always be set to nullptr.
*
* @return On success: 1. On failure: 0. To get extended error information, call
* GetLastError().
@@ -63,7 +63,7 @@ int frcDispose(const char* functionName, ...) /* Variable argument list */
va_start(disposalPtrList, functionName); /* start of variable list */
disposalPtr = va_arg(disposalPtrList, void*);
- while (disposalPtr != NULL) {
+ while (disposalPtr != nullptr) {
success = imaqDispose(disposalPtr);
if (!success) {
returnValue = 0;
@@ -78,7 +78,7 @@ int frcDispose(const char* functionName, ...) /* Variable argument list */
* Supports IMAQ_IMAGE_U8, IMAQ_IMAGE_I16, IMAQ_IMAGE_SGL, IMAQ_IMAGE_RGB,
* IMAQ_IMAGE_HSL.
*
-* @param dest Copy of image. On failure, dest is NULL. Must have already been
+* @param dest Copy of image. On failure, dest is nullptr. Must have already been
* created using frcCreateImage().
* When you are finished with the created image, dispose of it by calling
* frcDispose().
@@ -135,13 +135,13 @@ int frcScale(Image* dest, const Image* source, int xScale, int yScale,
* IMAQ_IMAGE_RGB, IMAQ_IMAGE_HSL, IMAQ_IMAGE_RGB_U64.
*
* @param image Image read in
- * @param fileName File to read. Cannot be NULL
+ * @param fileName File to read. Cannot be nullptr
*
* @return On success: 1. On failure: 0. To get extended error information, call
* GetLastError().
*/
int frcReadImage(Image* image, const char* fileName) {
- return imaqReadFile(image, fileName, NULL, NULL);
+ return imaqReadFile(image, fileName, nullptr, nullptr);
}
/**
@@ -168,14 +168,14 @@ int frcReadImage(Image* image, const char* fileName) {
* PNG, TIFF, JPEG2000 8-bit, 16-bit, RGB, RGBU64
*
* @param image Image to write
-* @param fileName File to read. Cannot be NULL. The extension determines the
+* @param fileName File to read. Cannot be nullptr. The extension determines the
* file format that is written.
*
* @return On success: 1. On failure: 0. To get extended error information, call
* GetLastError().
*/
int frcWriteImage(const Image* image, const char* fileName) {
- RGBValue* colorTable = NULL;
+ RGBValue* colorTable = nullptr;
return imaqWriteFile(image, fileName, colorTable);
}
@@ -214,7 +214,7 @@ int frcWriteImage(const Image* image, const char* fileName) {
* @return On success, this function returns a report describing the pixel value
* classification.
* When you are finished with the report, dispose of it by calling frcDispose().
-* On failure, this function returns NULL. To get extended error information,
+* On failure, this function returns nullptr. To get extended error information,
* call GetLastError().
*
*/
@@ -233,24 +233,24 @@ HistogramReport* frcHistogram(const Image* image, int numClasses, float min,
success = imaqAddRectContour(pRoi, rect);
if (!success) {
GetLastVisionError();
- return NULL;
+ return nullptr;
}
/* make a mask from the ROI */
Image* pMask = frcCreateImage(IMAQ_IMAGE_U8);
- success = imaqROIToMask(pMask, pRoi, fillValue, NULL, NULL);
+ success = imaqROIToMask(pMask, pRoi, fillValue, nullptr, nullptr);
if (!success) {
GetLastVisionError();
- frcDispose(__FUNCTION__, pRoi, NULL);
- return NULL;
+ frcDispose(__FUNCTION__, pRoi, nullptr);
+ return nullptr;
}
/* get a histogram report */
- HistogramReport* pHr = NULL;
+ HistogramReport* pHr = nullptr;
pHr = imaqHistogram(image, numClasses, min, max, pMask);
/* clean up */
- frcDispose(__FUNCTION__, pRoi, pMask, NULL);
+ frcDispose(__FUNCTION__, pRoi, pMask, nullptr);
return pHr;
}
@@ -268,7 +268,7 @@ HistogramReport* frcHistogram(const Image* image, int numClasses, float min,
* @param mask An optional mask image. This image must be an IMAQ_IMAGE_U8 image.
* The function calculates the histogram using only those pixels in the image
* whose
-* corresponding pixels in the mask are non-zero. Set this parameter to NULL to
+* corresponding pixels in the mask are non-zero. Set this parameter to nullptr to
* calculate
* the histogram of the entire image, or use the simplified call.
*
@@ -276,17 +276,17 @@ HistogramReport* frcHistogram(const Image* image, int numClasses, float min,
* classification
* of each plane in a HistogramReport.
* When you are finished with the report, dispose of it by calling frcDispose().
-* On failure, this function returns NULL.
+* On failure, this function returns nullptr.
* To get extended error information, call imaqGetLastError().
*/
ColorHistogramReport* frcColorHistogram(const Image* image, int numClasses,
ColorMode mode) {
- return frcColorHistogram(image, numClasses, mode, NULL);
+ return frcColorHistogram(image, numClasses, mode, nullptr);
}
ColorHistogramReport* frcColorHistogram(const Image* image, int numClasses,
ColorMode mode, Image* mask) {
- return imaqColorHistogram2((Image*)image, numClasses, mode, NULL, mask);
+ return imaqColorHistogram2((Image*)image, numClasses, mode, nullptr, mask);
}
/**
@@ -299,7 +299,7 @@ ColorHistogramReport* frcColorHistogram(const Image* image, int numClasses,
* @param image The image whose pixel value the function queries
* @param pixel The coordinates of the pixel that the function queries
* @param value On return, the value of the specified image pixel. This parameter
-* cannot be NULL.
+* cannot be nullptr.
* This data structure contains either grayscale, RGB, HSL, Complex or
* RGBU64Value depending on the type of image.
* @return On success: 1. On failure: 0. To get extended error information, call
@@ -319,7 +319,7 @@ int frcGetPixelValue(const Image* image, Point pixel, PixelValue* value) {
* as the Source image. It will contain only the filtered particles.
* @param source The image containing the particles to filter.
* @param criteria An array of criteria to apply to the particles in the source
-* image. This array cannot be NULL.
+* image. This array cannot be nullptr.
* See the NIVisionCVI.chm help file for definitions of criteria.
* @param criteriaCount The number of elements in the criteria array.
* @param options Binary filter options, including rejectMatches, rejectBorder,
@@ -371,7 +371,7 @@ int frcParticleFilter(Image* dest, Image* source,
* GetLastError().
*/
int frcMorphology(Image* dest, Image* source, MorphologyMethod method) {
- return imaqMorphology(dest, source, method, NULL);
+ return imaqMorphology(dest, source, method, nullptr);
}
int frcMorphology(Image* dest, Image* source, MorphologyMethod method,
@@ -539,7 +539,7 @@ int frcParticleAnalysis(Image* image, int particleNumber,
* will be copied. Only those pixels in the Image Src (Small) image that
* correspond to an equivalent non-zero pixel in the mask image are copied. All
* other pixels keep their original values. The entire image is processed if Image
-* Mask is NULL or this parameter is omitted.
+* Mask is nullptr or this parameter is omitted.
* @return On success: 1. On failure: 0. To get extended error information, call
* GetLastError().
*
@@ -548,7 +548,7 @@ int frcParticleAnalysis(Image* image, int particleNumber,
* minMatchScore = DEFAULT_MINMAX_SCORE (800)
*/
int frcEqualize(Image* dest, const Image* source, float min, float max) {
- return frcEqualize(dest, source, min, max, NULL);
+ return frcEqualize(dest, source, min, max, nullptr);
}
int frcEqualize(Image* dest, const Image* source, float min, float max,
@@ -695,11 +695,11 @@ int frcSimpleThreshold(Image* dest, const Image* source, float rangeMin,
* @param mode The color space to perform the threshold in. valid values are:
* IMAQ_RGB, IMAQ_HSL.
* @param plane1Range The selection range for the first plane of the image. Set
-* this parameter to NULL to use a selection range from 0 to 255.
+* this parameter to nullptr to use a selection range from 0 to 255.
* @param plane2Range The selection range for the second plane of the image. Set
-* this parameter to NULL to use a selection range from 0 to 255.
+* this parameter to nullptr to use a selection range from 0 to 255.
* @param plane3Range The selection range for the third plane of the image. Set
-* this parameter to NULL to use a selection range from 0 to 255.
+* this parameter to nullptr to use a selection range from 0 to 255.
*
* @return On success: 1. On failure: 0. To get extended error information, call
* GetLastError().
@@ -726,11 +726,11 @@ int frcColorThreshold(Image* dest, const Image* source, ColorMode mode,
* @param mode The color space to perform the threshold in. valid values are:
* IMAQ_RGB, IMAQ_HSL.
* @param plane1Range The selection range for the first plane of the image. Set
-* this parameter to NULL to use a selection range from 0 to 255.
+* this parameter to nullptr to use a selection range from 0 to 255.
* @param plane2Range The selection range for the second plane of the image. Set
-* this parameter to NULL to use a selection range from 0 to 255.
+* this parameter to nullptr to use a selection range from 0 to 255.
* @param plane3Range The selection range for the third plane of the image. Set
-* this parameter to NULL to use a selection range from 0 to 255.
+* this parameter to nullptr to use a selection range from 0 to 255.
*
* @return On success: 1. On failure: 0. To get extended error information, call
* GetLastError().
@@ -784,11 +784,11 @@ int frcHueThreshold(Image* dest, const Image* source, const Range* hueRange,
* @param image The source image that the function extracts the planes from.
* @param mode The color space that the function extracts the planes from. Valid
* values are IMAQ_RGB, IMAQ_HSL, IMAQ_HSV, IMAQ_HSI.
-* @param plane1 On return, the first extracted plane. Set this parameter to NULL
+* @param plane1 On return, the first extracted plane. Set this parameter to nullptr
* if you do not need this information. RGB-Red, HSL/HSV/HSI-Hue.
* @param plane2 On return, the second extracted plane. Set this parameter to
-* NULL if you do not need this information. RGB-Green, HSL/HSV/HSI-Saturation.
-* @param plane3 On return, the third extracted plane. Set this parameter to NULL
+* nullptr if you do not need this information. RGB-Green, HSL/HSV/HSI-Saturation.
+* @param plane3 On return, the third extracted plane. Set this parameter to nullptr
* if you do not need this information. RGB-Blue, HSL-Luminance, HSV-Value,
* HSI-Intensity.
*
@@ -816,5 +816,5 @@ int frcExtractHuePlane(const Image* image, Image* huePlane) {
}
int frcExtractHuePlane(const Image* image, Image* huePlane, int minSaturation) {
- return frcExtractColorPlanes(image, IMAQ_HSL, huePlane, NULL, NULL);
+ return frcExtractColorPlanes(image, IMAQ_HSL, huePlane, nullptr, nullptr);
}
diff --git a/wpilibc/wpilibC++IntegrationTests/src/CANJaguarTest.cpp b/wpilibc/wpilibC++IntegrationTests/src/CANJaguarTest.cpp
index 5066375458..7d600fcce6 100644
--- a/wpilibc/wpilibC++IntegrationTests/src/CANJaguarTest.cpp
+++ b/wpilibc/wpilibC++IntegrationTests/src/CANJaguarTest.cpp
@@ -297,9 +297,7 @@ TEST_F(CANJaguarTest, VoltageModeWorks) {
float setpoints[] = {M_PI, 8.0f, -10.0f};
- for (unsigned int i = 0; i < sizeof(setpoints) / sizeof(setpoints[0]); i++) {
- float setpoint = setpoints[i];
-
+ for (auto setpoint : setpoints) {
SetJaguar(kMotorTime, setpoint);
EXPECT_NEAR(setpoint, m_jaguar->GetOutputVoltage(), kVoltageTolerance);
}
@@ -354,9 +352,9 @@ TEST_F(CANJaguarTest, DISABLED_CurrentModeWorks) {
float setpoints[] = {1.6f, 2.0f, -1.6f};
- for (unsigned int i = 0; i < sizeof(setpoints) / sizeof(setpoints[0]); i++) {
- float setpoint = setpoints[i];
- float expectedCurrent = std::abs(setpoints[i]);
+ for (auto& setpoints_i : setpoints) {
+ float setpoint = setpoints_i;
+ float expectedCurrent = std::abs(setpoints_i);
/* It should get to each setpoint within 10 seconds */
for (int j = 0; j < 10; j++) {
diff --git a/wpilibc/wpilibC++IntegrationTests/src/DIOLoopTest.cpp b/wpilibc/wpilibC++IntegrationTests/src/DIOLoopTest.cpp
index 3a920eaf73..8075ed7997 100644
--- a/wpilibc/wpilibC++IntegrationTests/src/DIOLoopTest.cpp
+++ b/wpilibc/wpilibC++IntegrationTests/src/DIOLoopTest.cpp
@@ -104,7 +104,7 @@ static void *InterruptTriggerer(void *data) {
output->Set(false);
Wait(kSynchronousInterruptTime);
output->Set(true);
- return NULL;
+ return nullptr;
}
TEST_F(DIOLoopTest, SynchronousInterruptWorks) {
@@ -113,7 +113,7 @@ TEST_F(DIOLoopTest, SynchronousInterruptWorks) {
// If we have another thread trigger the interrupt in a few seconds
pthread_t interruptTriggererLoop;
- pthread_create(&interruptTriggererLoop, NULL, InterruptTriggerer, m_output);
+ pthread_create(&interruptTriggererLoop, nullptr, InterruptTriggerer, m_output);
// Then this thread should pause and resume after that number of seconds
Timer timer;
diff --git a/wpilibc/wpilibC++IntegrationTests/src/MotorInvertingTest.cpp b/wpilibc/wpilibC++IntegrationTests/src/MotorInvertingTest.cpp
index 475693fc09..7c4da8aa20 100644
--- a/wpilibc/wpilibC++IntegrationTests/src/MotorInvertingTest.cpp
+++ b/wpilibc/wpilibC++IntegrationTests/src/MotorInvertingTest.cpp
@@ -32,7 +32,7 @@ class MotorInvertingTest
protected:
SpeedController *m_speedController;
Encoder *m_encoder;
- virtual void SetUp() {
+ virtual void SetUp() override {
switch (GetParam()) {
case TEST_VICTOR:
m_speedController = new Victor(TestBench::kVictorChannel);
@@ -53,7 +53,7 @@ class MotorInvertingTest
break;
}
}
- virtual void TearDown() {
+ virtual void TearDown() override {
delete m_speedController;
delete m_encoder;
}
diff --git a/wpilibc/wpilibC++IntegrationTests/src/NotifierTest.cpp b/wpilibc/wpilibC++IntegrationTests/src/NotifierTest.cpp
index 8258ad1b9d..18f69a63db 100644
--- a/wpilibc/wpilibC++IntegrationTests/src/NotifierTest.cpp
+++ b/wpilibc/wpilibC++IntegrationTests/src/NotifierTest.cpp
@@ -19,8 +19,8 @@ void notifierHandler(void *) { notifierCounter++; }
TEST(NotifierTest, DISABLED_TestTimerNotifications) {
std::cout << "NotifierTest..." << std::endl;
notifierCounter = 0;
- std::cout << "notifier(notifierHandler, NULL)..." << std::endl;
- Notifier notifier(notifierHandler, NULL);
+ std::cout << "notifier(notifierHandler, nullptr)..." << std::endl;
+ Notifier notifier(notifierHandler, nullptr);
std::cout << "Start Periodic..." << std::endl;
notifier.StartPeriodic(1.0);
diff --git a/wpilibc/wpilibC++IntegrationTests/src/PreferencesTest.cpp b/wpilibc/wpilibC++IntegrationTests/src/PreferencesTest.cpp
index 69b939cf6e..796f45a0ec 100644
--- a/wpilibc/wpilibC++IntegrationTests/src/PreferencesTest.cpp
+++ b/wpilibc/wpilibC++IntegrationTests/src/PreferencesTest.cpp
@@ -63,14 +63,14 @@ TEST(PreferencesTest, WritePreferencesToFile) {
"testFileGetLong=\"1000000000000000000\""};
std::ifstream preferencesFile(kFileName);
- for (int i = 0; i < 7; i++) {
+ for (auto& kExpectedFileContent : kExpectedFileContents) {
ASSERT_FALSE(preferencesFile.eof())
<< "Preferences file prematurely reached EOF";
std::string line;
std::getline(preferencesFile, line);
- ASSERT_EQ(kExpectedFileContents[i], line)
+ ASSERT_EQ(kExpectedFileContent, line)
<< "A line in wpilib-preferences.ini was not correct";
}
}
diff --git a/wpilibc/wpilibC++IntegrationTests/src/TestEnvironment.cpp b/wpilibc/wpilibC++IntegrationTests/src/TestEnvironment.cpp
index 4dd71a93d8..2d21303c4a 100644
--- a/wpilibc/wpilibC++IntegrationTests/src/TestEnvironment.cpp
+++ b/wpilibc/wpilibC++IntegrationTests/src/TestEnvironment.cpp
@@ -9,11 +9,9 @@
#include "WPILib.h"
class TestEnvironment : public testing::Environment {
- bool m_alreadySetUp;
+ bool m_alreadySetUp = false;
public:
- TestEnvironment() : m_alreadySetUp(false) {}
-
virtual void SetUp() override {
/* Only set up once. This allows gtest_repeat to be used to
automatically repeat tests. */
diff --git a/wpilibc/wpilibC++IntegrationTests/src/TiltPanCameraTest.cpp b/wpilibc/wpilibC++IntegrationTests/src/TiltPanCameraTest.cpp
index caa5c42b1d..078044332c 100644
--- a/wpilibc/wpilibC++IntegrationTests/src/TiltPanCameraTest.cpp
+++ b/wpilibc/wpilibC++IntegrationTests/src/TiltPanCameraTest.cpp
@@ -58,7 +58,7 @@ class TiltPanCameraTest : public testing::Test {
}
};
-Gyro *TiltPanCameraTest::m_gyro = 0;
+Gyro *TiltPanCameraTest::m_gyro = nullptr;
/**
* Test if the gyro angle defaults to 0 immediately after being reset.
diff --git a/wpilibc/wpilibC++IntegrationTests/src/command/CommandTest.cpp b/wpilibc/wpilibC++IntegrationTests/src/command/CommandTest.cpp
index 9c7ede98ce..4b62fa35b4 100644
--- a/wpilibc/wpilibC++IntegrationTests/src/command/CommandTest.cpp
+++ b/wpilibc/wpilibC++IntegrationTests/src/command/CommandTest.cpp
@@ -41,13 +41,13 @@ class CommandTest : public testing::Test {
class ASubsystem : public Subsystem {
private:
- Command *m_command;
+ Command *m_command = nullptr;
public:
- ASubsystem(const char *name) : Subsystem(name) { m_command = NULL; }
+ ASubsystem(const char *name) : Subsystem(name) {}
virtual void InitDefaultCommand() override {
- if (m_command != NULL) {
+ if (m_command != nullptr) {
SetDefaultCommand(m_command);
}
}
@@ -214,7 +214,7 @@ TEST_F(CommandTest, ThreeCommandOnSubSystem) {
// CommandSequentialGroupTest ported from CommandSequentialGroupTest.java
TEST_F(CommandTest, OneCommandSupersedingAnotherBecauseOfDependencies) {
- ASubsystem *subsystem = new ASubsystem("Command Superseding Test Subsystem");
+ auto subsystem = new ASubsystem("Command Superseding Test Subsystem");
MockCommand command1;
command1.Requires(subsystem);
MockCommand command2;
diff --git a/wpilibc/wpilibC++Sim/include/AnalogInput.h b/wpilibc/wpilibC++Sim/include/AnalogInput.h
index 90c11c043c..9b17ccd9a8 100644
--- a/wpilibc/wpilibC++Sim/include/AnalogInput.h
+++ b/wpilibc/wpilibC++Sim/include/AnalogInput.h
@@ -28,7 +28,7 @@ public:
static const uint32_t kAccumulatorChannels[kAccumulatorNumChannels];
explicit AnalogInput(uint32_t channel);
- virtual ~AnalogInput();
+ virtual ~AnalogInput() = default;
float GetVoltage() const;
float GetAverageVoltage() const;
@@ -45,10 +45,9 @@ public:
ITable * GetTable() const override;
private:
- void InitAnalogInput(uint32_t channel);
uint32_t m_channel;
SimFloatInput* m_impl;
int64_t m_accumulatorOffset;
- ITable *m_table;
+ ITable *m_table = nullptr;
};
diff --git a/wpilibc/wpilibC++Sim/include/Counter.h b/wpilibc/wpilibC++Sim/include/Counter.h
index 4ccee43b72..ade463ba47 100644
--- a/wpilibc/wpilibC++Sim/include/Counter.h
+++ b/wpilibc/wpilibC++Sim/include/Counter.h
@@ -5,6 +5,7 @@
/*----------------------------------------------------------------------------*/
#pragma once
+#include "HAL/HAL.hpp"
#include "CounterBase.h"
#include "SensorBase.h"
#include "LiveWindow/LiveWindowSendable.h"
@@ -22,7 +23,7 @@ class Counter : public SensorBase, public CounterBase, public LiveWindowSendable
{
public:
- Counter();
+ explicit Counter(Mode mode = kTwoPulse);
explicit Counter(uint32_t channel);
// TODO: [Not Supported] explicit Counter(DigitalSource *source);
// TODO: [Not Supported] explicit Counter(DigitalSource &source);
@@ -81,7 +82,6 @@ protected:
// TODO: [Not Supported] DigitalSource *m_downSource; ///< What makes the counter count down.
void* m_counter; ///< The FPGA counter object.
private:
- // TODO: [Not Supported] void InitCounter(Mode mode = kTwoPulse);
bool m_allocatedUpSource; ///< Was the upSource allocated locally?
bool m_allocatedDownSource; ///< Was the downSource allocated locally?
diff --git a/wpilibc/wpilibC++Sim/include/CounterBase.h b/wpilibc/wpilibC++Sim/include/CounterBase.h
index 5cb5ee5413..3352c29d8f 100644
--- a/wpilibc/wpilibC++Sim/include/CounterBase.h
+++ b/wpilibc/wpilibC++Sim/include/CounterBase.h
@@ -23,7 +23,7 @@ public:
k4X
};
- virtual ~CounterBase() {}
+ virtual ~CounterBase() = default;
virtual int32_t Get() const = 0;
virtual void Reset() = 0;
virtual double GetPeriod() const = 0;
diff --git a/wpilibc/wpilibC++Sim/include/DigitalInput.h b/wpilibc/wpilibC++Sim/include/DigitalInput.h
index f139c1892a..82066068f4 100644
--- a/wpilibc/wpilibC++Sim/include/DigitalInput.h
+++ b/wpilibc/wpilibC++Sim/include/DigitalInput.h
@@ -18,7 +18,7 @@
class DigitalInput : public LiveWindowSendable {
public:
explicit DigitalInput(uint32_t channel);
- virtual ~DigitalInput();
+ virtual ~DigitalInput() = default;
uint32_t Get() const;
uint32_t GetChannel() const;
@@ -30,10 +30,9 @@ public:
ITable * GetTable() const override;
private:
- void InitDigitalInput(uint32_t channel);
uint32_t m_channel;
bool m_lastValue;
SimDigitalInput *m_impl;
- ITable *m_table;
+ ITable *m_table = nullptr;
};
diff --git a/wpilibc/wpilibC++Sim/include/DoubleSolenoid.h b/wpilibc/wpilibC++Sim/include/DoubleSolenoid.h
index 007df72ad6..b9f15832a9 100644
--- a/wpilibc/wpilibC++Sim/include/DoubleSolenoid.h
+++ b/wpilibc/wpilibC++Sim/include/DoubleSolenoid.h
@@ -28,7 +28,7 @@ public:
explicit DoubleSolenoid(uint32_t forwardChannel, uint32_t reverseChannel);
DoubleSolenoid(uint8_t moduleNumber, uint32_t forwardChannel, uint32_t reverseChannel);
- virtual ~DoubleSolenoid();
+ virtual ~DoubleSolenoid() = default;
virtual void Set(Value value);
virtual Value Get() const;
@@ -41,7 +41,6 @@ public:
ITable * GetTable() const override;
private:
- void InitSolenoid(int slot, int channel1, int channel2);
SimContinuousOutput* m_impl;
Value m_value;
bool m_reversed;
diff --git a/wpilibc/wpilibC++Sim/include/DriverStation.h b/wpilibc/wpilibC++Sim/include/DriverStation.h
index c85fac8758..4fb92430f1 100644
--- a/wpilibc/wpilibC++Sim/include/DriverStation.h
+++ b/wpilibc/wpilibC++Sim/include/DriverStation.h
@@ -116,16 +116,16 @@ private:
void joystickCallback4(const msgs::ConstJoystickPtr &msg);
void joystickCallback5(const msgs::ConstJoystickPtr &msg);
- uint8_t m_digitalOut;
- MULTIWAIT_ID m_waitForDataSem;
+ uint8_t m_digitalOut = 0;
+ MULTIWAIT_ID m_waitForDataSem = 0;
MUTEX_ID m_waitForDataMutex;
MUTEX_ID m_stateSemaphore;
MUTEX_ID m_joystickSemaphore;
- double m_approxMatchTimeOffset;
- bool m_userInDisabled;
- bool m_userInAutonomous;
- bool m_userInTeleop;
- bool m_userInTest;
+ double m_approxMatchTimeOffset = -1.0;
+ bool m_userInDisabled = false;
+ bool m_userInAutonomous = false;
+ bool m_userInTeleop = false;
+ bool m_userInTest = false;
transport::SubscriberPtr stateSub;
transport::SubscriberPtr joysticksSub[6];
diff --git a/wpilibc/wpilibC++Sim/include/Encoder.h b/wpilibc/wpilibC++Sim/include/Encoder.h
index c8d2964b7c..3c136fd039 100644
--- a/wpilibc/wpilibC++Sim/include/Encoder.h
+++ b/wpilibc/wpilibC++Sim/include/Encoder.h
@@ -32,7 +32,7 @@ public:
EncodingType encodingType = k4X);
// TODO: [Not Supported] Encoder(DigitalSource *aSource, DigitalSource *bSource, bool reverseDirection=false, EncodingType encodingType = k4X);
// TODO: [Not Supported] Encoder(DigitalSource &aSource, DigitalSource &bSource, bool reverseDirection=false, EncodingType encodingType = k4X);
- virtual ~Encoder();
+ virtual ~Encoder() = default;
// CounterBase interface
int32_t Get() const override;
diff --git a/wpilibc/wpilibC++Sim/include/Gyro.h b/wpilibc/wpilibC++Sim/include/Gyro.h
index 3cae68bf07..a277bc7386 100644
--- a/wpilibc/wpilibC++Sim/include/Gyro.h
+++ b/wpilibc/wpilibC++Sim/include/Gyro.h
@@ -33,7 +33,7 @@ public:
static constexpr float kDefaultVoltsPerDegreePerSecond = 0.007;
explicit Gyro(uint32_t channel);
- virtual ~Gyro();
+ virtual ~Gyro() = default;
virtual float GetAngle() const;
virtual double GetRate() const;
void SetPIDSourceParameter(PIDSourceParameter pidSource);
@@ -55,5 +55,5 @@ private:
SimGyro* impl;
PIDSourceParameter m_pidSource;
- ITable *m_table;
+ ITable *m_table = nullptr;
};
diff --git a/wpilibc/wpilibC++Sim/include/IterativeRobot.h b/wpilibc/wpilibC++Sim/include/IterativeRobot.h
index b99a0e44b1..f0acaef618 100644
--- a/wpilibc/wpilibC++Sim/include/IterativeRobot.h
+++ b/wpilibc/wpilibC++Sim/include/IterativeRobot.h
@@ -64,16 +64,16 @@ public:
double GetLoopsPerSec();
protected:
- virtual ~IterativeRobot();
- IterativeRobot();
+ virtual ~IterativeRobot() = default;
+ IterativeRobot() = default;
private:
bool NextPeriodReady();
- bool m_disabledInitialized;
- bool m_autonomousInitialized;
- bool m_teleopInitialized;
- bool m_testInitialized;
- double m_period;
+ bool m_disabledInitialized = false;
+ bool m_autonomousInitialized = false;
+ bool m_teleopInitialized = false;
+ bool m_testInitialized = false;
+ double m_period = kDefaultPeriod;
Timer m_mainLoopTimer;
};
diff --git a/wpilibc/wpilibC++Sim/include/Jaguar.h b/wpilibc/wpilibC++Sim/include/Jaguar.h
index 91c7e3fd53..1f522d922e 100644
--- a/wpilibc/wpilibC++Sim/include/Jaguar.h
+++ b/wpilibc/wpilibC++Sim/include/Jaguar.h
@@ -16,13 +16,10 @@ class Jaguar : public SafePWM, public SpeedController
{
public:
explicit Jaguar(uint32_t channel);
- virtual ~Jaguar();
+ virtual ~Jaguar() = default;
virtual void Set(float value, uint8_t syncGroup = 0);
virtual float Get() const;
virtual void Disable();
virtual void PIDWrite(float output) override;
-
-private:
- void InitJaguar();
};
diff --git a/wpilibc/wpilibC++Sim/include/Joystick.h b/wpilibc/wpilibC++Sim/include/Joystick.h
index 672d898f42..998ad886c2 100644
--- a/wpilibc/wpilibC++Sim/include/Joystick.h
+++ b/wpilibc/wpilibC++Sim/include/Joystick.h
@@ -66,12 +66,11 @@ public:
private:
DISALLOW_COPY_AND_ASSIGN(Joystick);
- void InitJoystick(uint32_t numAxisTypes, uint32_t numButtonTypes);
- DriverStation *m_ds;
+ DriverStation *m_ds = nullptr;
uint32_t m_port;
- uint32_t *m_axes;
- uint32_t *m_buttons;
+ uint32_t *m_axes = nullptr;
+ uint32_t *m_buttons = nullptr;
};
#endif
diff --git a/wpilibc/wpilibC++Sim/include/PWM.h b/wpilibc/wpilibC++Sim/include/PWM.h
index aa09a89405..7a27684fd8 100644
--- a/wpilibc/wpilibC++Sim/include/PWM.h
+++ b/wpilibc/wpilibC++Sim/include/PWM.h
@@ -37,7 +37,7 @@ public:
};
explicit PWM(uint32_t channel);
- virtual ~PWM();
+ virtual ~PWM() = default;
virtual void SetRaw(unsigned short value);
void SetPeriodMultiplier(PeriodMultiplier mult);
void EnableDeadbandElimination(bool eliminateDeadband);
@@ -93,10 +93,9 @@ protected:
void InitTable(ITable *subTable) override;
ITable * GetTable() const override;
- ITable *m_table;
+ ITable *m_table = nullptr;
private:
- void InitPWM(uint32_t channel);
uint32_t m_channel;
SimContinuousOutput* impl;
};
diff --git a/wpilibc/wpilibC++Sim/include/Relay.h b/wpilibc/wpilibC++Sim/include/Relay.h
index 6311e4e925..7f90c34df8 100644
--- a/wpilibc/wpilibC++Sim/include/Relay.h
+++ b/wpilibc/wpilibC++Sim/include/Relay.h
@@ -53,11 +53,9 @@ public:
void InitTable(ITable *subTable) override;
ITable * GetTable() const override;
- ITable *m_table;
+ ITable *m_table = nullptr;
private:
- void InitRelay();
-
uint32_t m_channel;
Direction m_direction;
SimContinuousOutput* impl;
diff --git a/wpilibc/wpilibC++Sim/include/RobotBase.h b/wpilibc/wpilibC++Sim/include/RobotBase.h
index c90c3f58d4..eeda304fc3 100644
--- a/wpilibc/wpilibC++Sim/include/RobotBase.h
+++ b/wpilibc/wpilibC++Sim/include/RobotBase.h
@@ -38,7 +38,7 @@ public:
virtual void StartCompetition() = 0;
protected:
- virtual ~RobotBase();
+ virtual ~RobotBase() = default;
RobotBase();
DriverStation *m_ds;
diff --git a/wpilibc/wpilibC++Sim/include/RobotDrive.h b/wpilibc/wpilibC++Sim/include/RobotDrive.h
index 4391316f6f..14de22181c 100644
--- a/wpilibc/wpilibC++Sim/include/RobotDrive.h
+++ b/wpilibc/wpilibC++Sim/include/RobotDrive.h
@@ -83,13 +83,13 @@ protected:
static const int32_t kMaxNumberOfMotors = 4;
int32_t m_invertedMotors[kMaxNumberOfMotors];
- float m_sensitivity;
- double m_maxOutput;
+ float m_sensitivity = 0.5;
+ double m_maxOutput = 1.0;
bool m_deleteSpeedControllers;
- SpeedController *m_frontLeftMotor;
- SpeedController *m_frontRightMotor;
- SpeedController *m_rearLeftMotor;
- SpeedController *m_rearRightMotor;
+ SpeedController *m_frontLeftMotor = nullptr;
+ SpeedController *m_frontRightMotor = nullptr;
+ SpeedController *m_rearLeftMotor = nullptr;
+ SpeedController *m_rearRightMotor = nullptr;
// FIXME: MotorSafetyHelper *m_safetyHelper;
private:
diff --git a/wpilibc/wpilibC++Sim/include/SafePWM.h b/wpilibc/wpilibC++Sim/include/SafePWM.h
index 569665e9cd..d0d2d7bd93 100644
--- a/wpilibc/wpilibC++Sim/include/SafePWM.h
+++ b/wpilibc/wpilibC++Sim/include/SafePWM.h
@@ -33,6 +33,5 @@ public:
virtual void SetSpeed(float speed);
private:
- void InitSafePWM();
MotorSafetyHelper *m_safetyHelper;
};
diff --git a/wpilibc/wpilibC++Sim/include/SampleRobot.h b/wpilibc/wpilibC++Sim/include/SampleRobot.h
index 66842b6cf1..38cb37dead 100644
--- a/wpilibc/wpilibC++Sim/include/SampleRobot.h
+++ b/wpilibc/wpilibC++Sim/include/SampleRobot.h
@@ -11,7 +11,7 @@ class SampleRobot : public RobotBase
{
public:
SampleRobot();
- virtual ~SampleRobot() {}
+ virtual ~SampleRobot() = default;
virtual void RobotInit();
virtual void Disabled();
virtual void Autonomous();
diff --git a/wpilibc/wpilibC++Sim/include/Solenoid.h b/wpilibc/wpilibC++Sim/include/Solenoid.h
index 434351ec28..3cc6ab7adf 100644
--- a/wpilibc/wpilibC++Sim/include/Solenoid.h
+++ b/wpilibc/wpilibC++Sim/include/Solenoid.h
@@ -20,7 +20,7 @@ class Solenoid : public LiveWindowSendable, public ITableListener
public:
explicit Solenoid(uint32_t channel);
Solenoid(uint8_t moduleNumber, uint32_t channel);
- virtual ~Solenoid();
+ virtual ~Solenoid() = default;
virtual void Set(bool on);
virtual bool Get() const;
@@ -33,7 +33,6 @@ public:
ITable * GetTable() const override;
private:
- void InitSolenoid(int slot, int channel);
SimContinuousOutput* m_impl;
bool m_on;
diff --git a/wpilibc/wpilibC++Sim/include/SpeedController.h b/wpilibc/wpilibC++Sim/include/SpeedController.h
index 32356cc77b..96b6b17830 100644
--- a/wpilibc/wpilibC++Sim/include/SpeedController.h
+++ b/wpilibc/wpilibC++Sim/include/SpeedController.h
@@ -13,7 +13,7 @@
class SpeedController : public PIDOutput
{
public:
- virtual ~SpeedController() {}
+ virtual ~SpeedController() = default;
/**
* Common interface for setting the speed of a speed controller.
*
diff --git a/wpilibc/wpilibC++Sim/include/Talon.h b/wpilibc/wpilibC++Sim/include/Talon.h
index a86821409c..4b7794a8e1 100644
--- a/wpilibc/wpilibC++Sim/include/Talon.h
+++ b/wpilibc/wpilibC++Sim/include/Talon.h
@@ -16,13 +16,10 @@ class Talon : public SafePWM, public SpeedController
{
public:
explicit Talon(uint32_t channel);
- virtual ~Talon();
+ virtual ~Talon() = default;
virtual void Set(float value, uint8_t syncGroup = 0);
virtual float Get() const;
virtual void Disable();
virtual void PIDWrite(float output) override;
-
-private:
- void InitTalon();
};
diff --git a/wpilibc/wpilibC++Sim/include/Victor.h b/wpilibc/wpilibC++Sim/include/Victor.h
index acf0532247..b629bb4ade 100644
--- a/wpilibc/wpilibC++Sim/include/Victor.h
+++ b/wpilibc/wpilibC++Sim/include/Victor.h
@@ -16,13 +16,10 @@ class Victor : public SafePWM, public SpeedController
{
public:
explicit Victor(uint32_t channel);
- virtual ~Victor();
+ virtual ~Victor() = default;
virtual void Set(float value, uint8_t syncGroup = 0);
virtual float Get() const;
virtual void Disable();
virtual void PIDWrite(float output) override;
-
-private:
- void InitVictor();
};
diff --git a/wpilibc/wpilibC++Sim/include/simulation/MainNode.h b/wpilibc/wpilibC++Sim/include/simulation/MainNode.h
index 12923c893f..87a68d3d82 100644
--- a/wpilibc/wpilibC++Sim/include/simulation/MainNode.h
+++ b/wpilibc/wpilibC++Sim/include/simulation/MainNode.h
@@ -10,10 +10,8 @@ using namespace gazebo;
class MainNode {
public:
static MainNode* GetInstance() {
- if (instance == NULL) {
- instance = new MainNode();
- }
- return instance;
+ static MainNode instance;
+ return &instance;
}
template
@@ -39,8 +37,6 @@ public:
transport::NodePtr main;
private:
- static MainNode* instance;
-
MainNode() {
gazebo::transport::init();
main = transport::NodePtr(new transport::Node());
diff --git a/wpilibc/wpilibC++Sim/src/AnalogInput.cpp b/wpilibc/wpilibC++Sim/src/AnalogInput.cpp
index 479f586f4c..29032d818c 100644
--- a/wpilibc/wpilibC++Sim/src/AnalogInput.cpp
+++ b/wpilibc/wpilibC++Sim/src/AnalogInput.cpp
@@ -8,21 +8,6 @@
#include "WPIErrors.h"
#include "LiveWindow/LiveWindow.h"
-/**
- * Common initialization.
- */
-void AnalogInput::InitAnalogInput(uint32_t channel)
-{
- m_table = NULL;
-
- m_channel = channel;
- char buffer[50];
- int n = sprintf(buffer, "analog/%d", channel);
- m_impl = new SimFloatInput(buffer);
-
- LiveWindow::GetInstance()->AddSensor("AnalogInput", channel, this);
-}
-
/**
* Construct an analog input.
*
@@ -30,14 +15,12 @@ void AnalogInput::InitAnalogInput(uint32_t channel)
*/
AnalogInput::AnalogInput(uint32_t channel)
{
- InitAnalogInput(channel);
-}
+ m_channel = channel;
+ char buffer[50];
+ int n = sprintf(buffer, "analog/%d", channel);
+ m_impl = new SimFloatInput(buffer);
-/**
- * Channel destructor.
- */
-AnalogInput::~AnalogInput()
-{
+ LiveWindow::GetInstance()->AddSensor("AnalogInput", channel, this);
}
/**
@@ -82,7 +65,7 @@ double AnalogInput::PIDGet() const
}
void AnalogInput::UpdateTable() {
- if (m_table != NULL) {
+ if (m_table != nullptr) {
m_table->PutNumber("Value", GetAverageVoltage());
}
}
diff --git a/wpilibc/wpilibC++Sim/src/AnalogPotentiometer.cpp b/wpilibc/wpilibC++Sim/src/AnalogPotentiometer.cpp
index 97dac4374f..2685cbc98b 100644
--- a/wpilibc/wpilibC++Sim/src/AnalogPotentiometer.cpp
+++ b/wpilibc/wpilibC++Sim/src/AnalogPotentiometer.cpp
@@ -67,7 +67,7 @@ void AnalogPotentiometer::InitTable(ITable *subtable) {
}
void AnalogPotentiometer::UpdateTable() {
- if (m_table != NULL) {
+ if (m_table != nullptr) {
m_table->PutNumber("Value", Get());
}
}
diff --git a/wpilibc/wpilibC++Sim/src/DigitalInput.cpp b/wpilibc/wpilibC++Sim/src/DigitalInput.cpp
index cebbf80979..a4b15c065b 100644
--- a/wpilibc/wpilibC++Sim/src/DigitalInput.cpp
+++ b/wpilibc/wpilibC++Sim/src/DigitalInput.cpp
@@ -7,20 +7,6 @@
#include "DigitalInput.h"
#include "WPIErrors.h"
-/**
- * Create an instance of a DigitalInput.
- * Creates a digital input given a channel. Common creation routine for all
- * constructors.
- */
-void DigitalInput::InitDigitalInput(uint32_t channel)
-{
- m_table = NULL;
- char buf[64];
- m_channel = channel;
- int n = sprintf(buf, "dio/%d", channel);
- m_impl = new SimDigitalInput(buf);
-}
-
/**
* Create an instance of a Digital Input class.
* Creates a digital input given a channel and uses the default module.
@@ -29,14 +15,10 @@ void DigitalInput::InitDigitalInput(uint32_t channel)
*/
DigitalInput::DigitalInput(uint32_t channel)
{
- InitDigitalInput(channel);
-}
-
-/**
- * Free resources associated with the Digital Input class.
- */
-DigitalInput::~DigitalInput()
-{
+ char buf[64];
+ m_channel = channel;
+ int n = sprintf(buf, "dio/%d", channel);
+ m_impl = new SimDigitalInput(buf);
}
/*
@@ -57,7 +39,7 @@ uint32_t DigitalInput::GetChannel() const
}
void DigitalInput::UpdateTable() {
- if (m_table != NULL) {
+ if (m_table != nullptr) {
m_table->PutBoolean("Value", Get());
}
}
diff --git a/wpilibc/wpilibC++Sim/src/DoubleSolenoid.cpp b/wpilibc/wpilibC++Sim/src/DoubleSolenoid.cpp
index 0d418fc0dc..2fa6709c1f 100644
--- a/wpilibc/wpilibC++Sim/src/DoubleSolenoid.cpp
+++ b/wpilibc/wpilibC++Sim/src/DoubleSolenoid.cpp
@@ -9,26 +9,6 @@
#include
#include "LiveWindow/LiveWindow.h"
-/**
- * Common function to implement constructor behavior.
- */
-void DoubleSolenoid::InitSolenoid(int slot, int forwardChannel, int reverseChannel)
-{
- m_reversed = false;
- if (reverseChannel < forwardChannel) { // Swap ports to get the right address
- int channel = reverseChannel;
- reverseChannel = forwardChannel;
- forwardChannel = channel;
- m_reversed = true;
- }
- char buffer[50];
- int n = sprintf(buffer, "pneumatic/%d/%d/%d/%d", slot, forwardChannel,
- slot, reverseChannel);
- m_impl = new SimContinuousOutput(buffer);
-
- LiveWindow::GetInstance()->AddActuator("DoubleSolenoid", slot, forwardChannel, this);
-}
-
/**
* Constructor.
*
@@ -36,9 +16,7 @@ void DoubleSolenoid::InitSolenoid(int slot, int forwardChannel, int reverseChann
* @param reverseChannel The reverse channel on the module to control.
*/
DoubleSolenoid::DoubleSolenoid(uint32_t forwardChannel, uint32_t reverseChannel)
-{
- InitSolenoid(1, forwardChannel, reverseChannel);
-}
+ : DoubleSolenoid(1, forwardChannel, reverseChannel) {}
/**
* Constructor.
@@ -49,14 +27,20 @@ DoubleSolenoid::DoubleSolenoid(uint32_t forwardChannel, uint32_t reverseChannel)
*/
DoubleSolenoid::DoubleSolenoid(uint8_t moduleNumber, uint32_t forwardChannel, uint32_t reverseChannel)
{
- InitSolenoid(moduleNumber, forwardChannel, reverseChannel);
-}
-
-/**
- * Destructor.
- */
-DoubleSolenoid::~DoubleSolenoid()
-{
+ m_reversed = false;
+ if (reverseChannel < forwardChannel) { // Swap ports to get the right address
+ int channel = reverseChannel;
+ reverseChannel = forwardChannel;
+ forwardChannel = channel;
+ m_reversed = true;
+ }
+ char buffer[50];
+ int n = sprintf(buffer, "pneumatic/%d/%d/%d/%d", moduleNumber,
+ forwardChannel, moduleNumber, reverseChannel);
+ m_impl = new SimContinuousOutput(buffer);
+
+ LiveWindow::GetInstance()->AddActuator("DoubleSolenoid", moduleNumber,
+ forwardChannel, this);
}
/**
@@ -102,21 +86,21 @@ void DoubleSolenoid::ValueChanged(ITable* source, const std::string& key, EntryV
}
void DoubleSolenoid::UpdateTable() {
- if (m_table != NULL) {
+ if (m_table != nullptr) {
m_table->PutString("Value", (Get() == kForward ? "Forward" : (Get() == kReverse ? "Reverse" : "Off")));
}
}
void DoubleSolenoid::StartLiveWindowMode() {
Set(kOff);
- if (m_table != NULL) {
+ if (m_table != nullptr) {
m_table->AddTableListener("Value", this, true);
}
}
void DoubleSolenoid::StopLiveWindowMode() {
Set(kOff);
- if (m_table != NULL) {
+ if (m_table != nullptr) {
m_table->RemoveTableListener(this);
}
}
diff --git a/wpilibc/wpilibC++Sim/src/DriverStation.cpp b/wpilibc/wpilibC++Sim/src/DriverStation.cpp
index da75f4249e..cf3d4203d3 100644
--- a/wpilibc/wpilibC++Sim/src/DriverStation.cpp
+++ b/wpilibc/wpilibC++Sim/src/DriverStation.cpp
@@ -26,7 +26,6 @@ const uint32_t DriverStation::kBatteryChannel;
const uint32_t DriverStation::kJoystickPorts;
const uint32_t DriverStation::kJoystickAxes;
constexpr float DriverStation::kUpdatePeriod;
-DriverStation* DriverStation::m_instance = NULL;
uint8_t DriverStation::m_updateNumber = 0;
/**
@@ -35,13 +34,6 @@ uint8_t DriverStation::m_updateNumber = 0;
* This is only called once the first time GetInstance() is called
*/
DriverStation::DriverStation()
- : m_digitalOut (0)
- , m_waitForDataSem(0)
- , m_approxMatchTimeOffset(-1.0)
- , m_userInDisabled(false)
- , m_userInAutonomous(false)
- , m_userInTeleop(false)
- , m_userInTest(false)
{
// Create a new semaphore
m_waitForDataSem = initializeMultiWait();
@@ -77,7 +69,6 @@ DriverStation::DriverStation()
DriverStation::~DriverStation()
{
- m_instance = NULL;
deleteMultiWait(m_waitForDataSem);
deleteMutex(m_waitForDataMutex);
// TODO: Release m_stateSemaphore and m_joystickSemaphore?
@@ -88,11 +79,8 @@ DriverStation::~DriverStation()
*/
DriverStation* DriverStation::GetInstance()
{
- if (m_instance == NULL)
- {
- m_instance = new DriverStation();
- }
- return m_instance;
+ static DriverStation instance;
+ return &instance;
}
/**
@@ -126,7 +114,7 @@ float DriverStation::GetStickAxis(uint32_t stick, uint32_t axis)
return 0.0;
}
CRITICAL_REGION(m_joystickSemaphore)
- if (joysticks[stick] == NULL || axis >= joysticks[stick]->axes().size())
+ if (joysticks[stick] == nullptr || axis >= joysticks[stick]->axes().size())
{
return 0.0;
}
@@ -150,7 +138,7 @@ bool DriverStation::GetStickButton(uint32_t stick, uint32_t button)
return false;
}
CRITICAL_REGION(m_joystickSemaphore)
- if (joysticks[stick] == NULL || button >= joysticks[stick]->buttons().size())
+ if (joysticks[stick] == nullptr || button >= joysticks[stick]->buttons().size())
{
return false;
}
@@ -243,7 +231,7 @@ bool DriverStation::GetDigitalOut(uint32_t channel)
bool DriverStation::IsEnabled() const
{
CRITICAL_REGION(m_stateSemaphore)
- return state != NULL ? state->enabled() : false;
+ return state != nullptr ? state->enabled() : false;
END_REGION
}
@@ -255,7 +243,7 @@ bool DriverStation::IsDisabled() const
bool DriverStation::IsAutonomous() const
{
CRITICAL_REGION(m_stateSemaphore)
- return state != NULL ?
+ return state != nullptr ?
state->state() == msgs::DriverStation_State_AUTO : false;
END_REGION;
}
@@ -268,7 +256,7 @@ bool DriverStation::IsOperatorControl() const
bool DriverStation::IsTest() const
{
CRITICAL_REGION(m_stateSemaphore)
- return state != NULL ?
+ return state != nullptr ?
state->state() == msgs::DriverStation_State_TEST : false;
END_REGION;
}
diff --git a/wpilibc/wpilibC++Sim/src/Encoder.cpp b/wpilibc/wpilibC++Sim/src/Encoder.cpp
index fc40ead0e4..e3f8e961c6 100644
--- a/wpilibc/wpilibC++Sim/src/Encoder.cpp
+++ b/wpilibc/wpilibC++Sim/src/Encoder.cpp
@@ -24,7 +24,7 @@
*/
void Encoder::InitEncoder(int channelA, int channelB, bool reverseDirection, EncodingType encodingType)
{
- m_table = NULL;
+ m_table = nullptr;
this->channelA = channelA;
this->channelB = channelB;
m_encodingType = encodingType;
@@ -92,14 +92,14 @@ Encoder::Encoder(uint32_t aChannel, uint32_t bChannel, bool reverseDirection, En
* or be double (2x) the spec'd count.
*/
/* TODO: [Not Supported] Encoder::Encoder(DigitalSource *aSource, DigitalSource *bSource, bool reverseDirection, EncodingType encodingType) :
- m_encoder(NULL),
- m_counter(NULL)
+ m_encoder(nullptr),
+ m_counter(nullptr)
{
m_aSource = aSource;
m_bSource = bSource;
m_allocatedASource = false;
m_allocatedBSource = false;
- if (m_aSource == NULL || m_bSource == NULL)
+ if (m_aSource == nullptr || m_bSource == nullptr)
wpi_setWPIError(NullParameter);
else
InitEncoder(reverseDirection, encodingType);
@@ -124,8 +124,8 @@ Encoder::Encoder(uint32_t aChannel, uint32_t bChannel, bool reverseDirection, En
* or be double (2x) the spec'd count.
*/
/*// TODO: [Not Supported] Encoder::Encoder(DigitalSource &aSource, DigitalSource &bSource, bool reverseDirection, EncodingType encodingType) :
- m_encoder(NULL),
- m_counter(NULL)
+ m_encoder(nullptr),
+ m_counter(nullptr)
{
m_aSource = &aSource;
m_bSource = &bSource;
@@ -134,15 +134,6 @@ Encoder::Encoder(uint32_t aChannel, uint32_t bChannel, bool reverseDirection, En
InitEncoder(reverseDirection, encodingType);
}*/
-/**
- * Free the resources for an Encoder.
- * Frees the FPGA resources associated with an Encoder.
- */
-Encoder::~Encoder()
-{
-
-}
-
/**
* Reset the Encoder distance to zero.
* Resets the current count to zero on the encoder.
@@ -342,7 +333,7 @@ double Encoder::PIDGet() const
}
void Encoder::UpdateTable() {
- if (m_table != NULL) {
+ if (m_table != nullptr) {
m_table->PutNumber("Speed", GetRate());
m_table->PutNumber("Distance", GetDistance());
m_table->PutNumber("Distance per Tick", m_reverseDirection ? -m_distancePerPulse : m_distancePerPulse);
diff --git a/wpilibc/wpilibC++Sim/src/Gyro.cpp b/wpilibc/wpilibC++Sim/src/Gyro.cpp
index 63c6427376..717b42e7d1 100644
--- a/wpilibc/wpilibC++Sim/src/Gyro.cpp
+++ b/wpilibc/wpilibC++Sim/src/Gyro.cpp
@@ -25,7 +25,6 @@ constexpr float Gyro::kDefaultVoltsPerDegreePerSecond;
*/
void Gyro::InitGyro(int channel)
{
- m_table = NULL;
SetPIDSourceParameter(kAngle);
char buffer[50];
@@ -55,13 +54,6 @@ void Gyro::Reset()
impl->Reset();
}
-/**
- * Delete (free) the accumulator and the analog components used for the gyro.
- */
-Gyro::~Gyro()
-{
-}
-
/**
* Return the actual angle in degrees that the robot is currently facing.
*
@@ -116,7 +108,7 @@ double Gyro::PIDGet() const
}
void Gyro::UpdateTable() {
- if (m_table != NULL) {
+ if (m_table != nullptr) {
m_table->PutNumber("Value", GetAngle());
}
}
diff --git a/wpilibc/wpilibC++Sim/src/IterativeRobot.cpp b/wpilibc/wpilibC++Sim/src/IterativeRobot.cpp
index caa1052433..c81e9d0b0b 100644
--- a/wpilibc/wpilibC++Sim/src/IterativeRobot.cpp
+++ b/wpilibc/wpilibC++Sim/src/IterativeRobot.cpp
@@ -14,28 +14,6 @@
constexpr double IterativeRobot::kDefaultPeriod;
-/**
- * Constructor for RobotIterativeBase
- *
- * The constructor initializes the instance variables for the robot to indicate
- * the status of initialization for disabled, autonomous, teleop, and test code.
- */
-IterativeRobot::IterativeRobot()
- : m_disabledInitialized (false)
- , m_autonomousInitialized (false)
- , m_teleopInitialized (false)
- , m_testInitialized (false)
- , m_period (kDefaultPeriod)
-{
-}
-
-/**
- * Free the resources for a RobotIterativeBase class.
- */
-IterativeRobot::~IterativeRobot()
-{
-}
-
/**
* Set the period for the periodic functions.
*
diff --git a/wpilibc/wpilibC++Sim/src/Jaguar.cpp b/wpilibc/wpilibC++Sim/src/Jaguar.cpp
index f3bbee6491..fab109d578 100644
--- a/wpilibc/wpilibC++Sim/src/Jaguar.cpp
+++ b/wpilibc/wpilibC++Sim/src/Jaguar.cpp
@@ -10,9 +10,9 @@
#include "LiveWindow/LiveWindow.h"
/**
- * Common initialization code called by all constructors.
+ * @param channel The PWM channel that the Jaguar is attached to.
*/
-void Jaguar::InitJaguar()
+Jaguar::Jaguar(uint32_t channel) : SafePWM(channel)
{
/*
* Input profile defined by Luminary Micro.
@@ -30,18 +30,6 @@ void Jaguar::InitJaguar()
LiveWindow::GetInstance()->AddActuator("Jaguar", GetChannel(), this);
}
-/**
- * @param channel The PWM channel that the Jaguar is attached to.
- */
-Jaguar::Jaguar(uint32_t channel) : SafePWM(channel)
-{
- InitJaguar();
-}
-
-Jaguar::~Jaguar()
-{
-}
-
/**
* Set the PWM value.
*
diff --git a/wpilibc/wpilibC++Sim/src/Joystick.cpp b/wpilibc/wpilibC++Sim/src/Joystick.cpp
index 372f7cc9b1..01439dafe0 100644
--- a/wpilibc/wpilibC++Sim/src/Joystick.cpp
+++ b/wpilibc/wpilibC++Sim/src/Joystick.cpp
@@ -26,13 +26,8 @@ static bool joySticksInitialized = false;
* @param port The port on the driver station that the joystick is plugged into.
*/
Joystick::Joystick(uint32_t port)
- : m_ds (NULL)
- , m_port (port)
- , m_axes (NULL)
- , m_buttons (NULL)
+ : Joystick(port, kNumAxisTypes, kNumButtonTypes)
{
- InitJoystick(kNumAxisTypes, kNumButtonTypes);
-
m_axes[kXAxis] = kDefaultXAxis;
m_axes[kYAxis] = kDefaultYAxis;
m_axes[kZAxis] = kDefaultZAxis;
@@ -54,20 +49,12 @@ Joystick::Joystick(uint32_t port)
* @param numButtonTypes The number of button types in the enum.
*/
Joystick::Joystick(uint32_t port, uint32_t numAxisTypes, uint32_t numButtonTypes)
- : m_ds (NULL)
- , m_port (port)
- , m_axes (NULL)
- , m_buttons (NULL)
-{
- InitJoystick(numAxisTypes, numButtonTypes);
-}
-
-void Joystick::InitJoystick(uint32_t numAxisTypes, uint32_t numButtonTypes)
+ : m_port (port)
{
if ( !joySticksInitialized )
{
for (unsigned i = 0; i < DriverStation::kJoystickPorts; i++)
- joysticks[i] = NULL;
+ joysticks[i] = nullptr;
joySticksInitialized = true;
}
joysticks[m_port] = this;
@@ -80,7 +67,7 @@ void Joystick::InitJoystick(uint32_t numAxisTypes, uint32_t numButtonTypes)
Joystick * Joystick::GetStickForPort(uint32_t port)
{
Joystick *stick = joysticks[port];
- if (stick == NULL)
+ if (stick == nullptr)
{
stick = new Joystick(port);
joysticks[port] = stick;
diff --git a/wpilibc/wpilibC++Sim/src/MotorSafetyHelper.cpp b/wpilibc/wpilibC++Sim/src/MotorSafetyHelper.cpp
index 040ff10edc..8af177a15b 100644
--- a/wpilibc/wpilibC++Sim/src/MotorSafetyHelper.cpp
+++ b/wpilibc/wpilibC++Sim/src/MotorSafetyHelper.cpp
@@ -13,7 +13,7 @@
#include
-MotorSafetyHelper *MotorSafetyHelper::m_headHelper = NULL;
+MotorSafetyHelper *MotorSafetyHelper::m_headHelper = nullptr;
ReentrantSemaphore MotorSafetyHelper::m_listMutex;
/**
@@ -47,9 +47,9 @@ MotorSafetyHelper::~MotorSafetyHelper()
}
else
{
- MotorSafetyHelper *prev = NULL;
+ MotorSafetyHelper *prev = nullptr;
MotorSafetyHelper *cur = m_headHelper;
- while (cur != this && cur != NULL)
+ while (cur != this && cur != nullptr)
prev = cur, cur = cur->m_nextHelper;
if (cur == this)
prev->m_nextHelper = cur->m_nextHelper;
@@ -149,7 +149,7 @@ bool MotorSafetyHelper::IsSafetyEnabled() const
void MotorSafetyHelper::CheckMotors()
{
Synchronized sync(m_listMutex);
- for (MotorSafetyHelper *msh = m_headHelper; msh != NULL; msh = msh->m_nextHelper)
+ for (MotorSafetyHelper *msh = m_headHelper; msh != nullptr; msh = msh->m_nextHelper)
{
msh->Check();
}
diff --git a/wpilibc/wpilibC++Sim/src/Notifier.cpp b/wpilibc/wpilibC++Sim/src/Notifier.cpp
index bf16c1002a..4ad630ae15 100644
--- a/wpilibc/wpilibC++Sim/src/Notifier.cpp
+++ b/wpilibc/wpilibC++Sim/src/Notifier.cpp
@@ -9,9 +9,9 @@
#include "Utility.h"
#include "WPIErrors.h"
-Notifier *Notifier::timerQueueHead = NULL;
+Notifier *Notifier::timerQueueHead = nullptr;
ReentrantSemaphore Notifier::queueSemaphore;
-Task* Notifier::task = NULL;
+Task* Notifier::task = nullptr;
int Notifier::refcount = 0;
/**
@@ -21,14 +21,14 @@ int Notifier::refcount = 0;
*/
Notifier::Notifier(TimerEventHandler handler, void *param)
{
- if (handler == NULL)
- wpi_setWPIErrorWithContext(NullParameter, "handler must not be NULL");
+ if (handler == nullptr)
+ wpi_setWPIErrorWithContext(NullParameter, "handler must not be nullptr");
m_handler = handler;
m_param = param;
m_periodic = false;
m_expirationTime = 0;
m_period = 0;
- m_nextEvent = NULL;
+ m_nextEvent = nullptr;
m_queued = false;
m_handlerSemaphore = initializeSemaphore(SEMAPHORE_FULL);
{
@@ -95,7 +95,7 @@ void Notifier::ProcessQueue(uint32_t mask, void *params)
Synchronized sync(queueSemaphore);
double currentTime = GetClock();
current = timerQueueHead;
- if (current == NULL || current->m_expirationTime > currentTime)
+ if (current == nullptr || current->m_expirationTime > currentTime)
{
break; // no more timer events to process
}
@@ -144,7 +144,7 @@ void Notifier::InsertInQueue(bool reschedule)
{
m_expirationTime = GetClock() + m_period;
}
- if (timerQueueHead == NULL || timerQueueHead->m_expirationTime >= this->m_expirationTime)
+ if (timerQueueHead == nullptr || timerQueueHead->m_expirationTime >= this->m_expirationTime)
{
// the queue is empty or greater than the new entry
// the new entry becomes the first element
@@ -161,7 +161,7 @@ void Notifier::InsertInQueue(bool reschedule)
for (Notifier **npp = &(timerQueueHead->m_nextEvent); ; npp = &(*npp)->m_nextEvent)
{
Notifier *n = *npp;
- if (n == NULL || n->m_expirationTime > this->m_expirationTime)
+ if (n == nullptr || n->m_expirationTime > this->m_expirationTime)
{
*npp = this;
this->m_nextEvent = n;
@@ -184,7 +184,7 @@ void Notifier::DeleteFromQueue()
if (m_queued)
{
m_queued = false;
- wpi_assert(timerQueueHead != NULL);
+ wpi_assert(timerQueueHead != nullptr);
if (timerQueueHead == this)
{
// remove the first item in the list - update the alarm
@@ -193,7 +193,7 @@ void Notifier::DeleteFromQueue()
}
else
{
- for (Notifier *n = timerQueueHead; n != NULL; n = n->m_nextEvent)
+ for (Notifier *n = timerQueueHead; n != nullptr; n = n->m_nextEvent)
{
if (n->m_nextEvent == this)
{
@@ -253,8 +253,8 @@ void Notifier::Stop()
void Notifier::Run() {
while (true) {
- Notifier::ProcessQueue(0, NULL);
- if (timerQueueHead != NULL)
+ Notifier::ProcessQueue(0, nullptr);
+ if (timerQueueHead != nullptr)
{
Wait(timerQueueHead->m_expirationTime - GetClock());
}
diff --git a/wpilibc/wpilibC++Sim/src/PIDController.cpp b/wpilibc/wpilibC++Sim/src/PIDController.cpp
index 97f5b233b9..e929b594a0 100644
--- a/wpilibc/wpilibC++Sim/src/PIDController.cpp
+++ b/wpilibc/wpilibC++Sim/src/PIDController.cpp
@@ -60,7 +60,7 @@ void PIDController::Initialize(float Kp, float Ki, float Kd, float Kf,
PIDSource *source, PIDOutput *output,
float period)
{
- m_table = NULL;
+ m_table = nullptr;
m_P = Kp;
m_I = Ki;
@@ -211,7 +211,7 @@ void PIDController::SetPID(double p, double i, double d)
}
END_REGION;
- if (m_table != NULL) {
+ if (m_table != nullptr) {
m_table->PutNumber("p", m_P);
m_table->PutNumber("i", m_I);
m_table->PutNumber("d", m_D);
@@ -237,7 +237,7 @@ void PIDController::SetPID(double p, double i, double d, double f)
}
END_REGION;
- if (m_table != NULL) {
+ if (m_table != nullptr) {
m_table->PutNumber("p", m_P);
m_table->PutNumber("i", m_I);
m_table->PutNumber("d", m_D);
@@ -386,9 +386,9 @@ void PIDController::SetSetpoint(float setpoint)
m_setpoint = setpoint;
}
}
- END_REGION;
-
- if (m_table != NULL) {
+ END_REGION;
+
+ if (m_table != nullptr) {
m_table->PutNumber("setpoint", m_setpoint);
}
}
@@ -504,9 +504,9 @@ void PIDController::Enable()
{
m_enabled = true;
}
- END_REGION;
-
- if (m_table != NULL) {
+ END_REGION;
+
+ if (m_table != nullptr) {
m_table->PutBoolean("enabled", true);
}
}
@@ -522,8 +522,8 @@ void PIDController::Disable()
m_enabled = false;
}
END_REGION;
-
- if (m_table != NULL) {
+
+ if (m_table != nullptr) {
m_table->PutBoolean("enabled", false);
}
}
@@ -563,10 +563,10 @@ std::string PIDController::GetSmartDashboardType() const {
}
void PIDController::InitTable(ITable* table){
- if(m_table!=NULL)
+ if(m_table!=nullptr)
m_table->RemoveTableListener(this);
m_table = table;
- if(m_table!=NULL){
+ if(m_table!=nullptr){
m_table->PutNumber(kP, GetP());
m_table->PutNumber(kI, GetI());
m_table->PutNumber(kD, GetD());
diff --git a/wpilibc/wpilibC++Sim/src/PWM.cpp b/wpilibc/wpilibC++Sim/src/PWM.cpp
index 2f63f93abf..6e5078b43e 100644
--- a/wpilibc/wpilibC++Sim/src/PWM.cpp
+++ b/wpilibc/wpilibC++Sim/src/PWM.cpp
@@ -16,15 +16,16 @@ const int32_t PWM::kDefaultPwmStepsDown;
const int32_t PWM::kPwmDisabled;
/**
- * Initialize PWMs given a channel.
+ * Allocate a PWM given a channel number.
*
- * This method is private and is the common path for all the constructors for creating PWM
- * instances. Checks channel value range and allocates the appropriate channel.
- * The allocation is only done to help users ensure that they don't double assign channels.
+ * Checks channel value range and allocates the appropriate channel.
+ * The allocation is only done to help users ensure that they don't double
+ * assign channels.
+ * @param channel The PWM channel number. 0-9 are on-board, 10-19 are on the MXP
+ * port
*/
-void PWM::InitPWM(uint32_t channel)
+PWM::PWM(uint32_t channel)
{
- m_table = NULL;
char buf[64];
if (!CheckPWMChannel(channel))
@@ -42,25 +43,6 @@ void PWM::InitPWM(uint32_t channel)
m_centerPwm = kPwmDisabled; // In simulation, the same thing.
}
-/**
- * Allocate a PWM given a channel number.
- *
- * @param channel The PWM channel.
- */
-PWM::PWM(uint32_t channel)
-{
- InitPWM(channel);
-}
-
-/**
- * Free the PWM channel.
- *
- * Free the resource associated with the PWM channel and set the value to 0.
- */
-PWM::~PWM()
-{
-}
-
/**
* Optionally eliminate the deadband from a speed controller.
* @param eliminateDeadband If true, set the motor curve on the Jaguar to eliminate
@@ -240,21 +222,21 @@ void PWM::ValueChanged(ITable* source, const std::string& key, EntryValue value,
}
void PWM::UpdateTable() {
- if (m_table != NULL) {
+ if (m_table != nullptr) {
m_table->PutNumber("Value", GetSpeed());
}
}
void PWM::StartLiveWindowMode() {
SetSpeed(0);
- if (m_table != NULL) {
+ if (m_table != nullptr) {
m_table->AddTableListener("Value", this, true);
}
}
void PWM::StopLiveWindowMode() {
SetSpeed(0);
- if (m_table != NULL) {
+ if (m_table != nullptr) {
m_table->RemoveTableListener(this);
}
}
diff --git a/wpilibc/wpilibC++Sim/src/Relay.cpp b/wpilibc/wpilibC++Sim/src/Relay.cpp
index bbcd4425ba..9f92a8fb54 100644
--- a/wpilibc/wpilibC++Sim/src/Relay.cpp
+++ b/wpilibc/wpilibC++Sim/src/Relay.cpp
@@ -11,13 +11,17 @@
#include "LiveWindow/LiveWindow.h"
/**
- * Common relay initialization method.
- * This code is common to all Relay constructors and initializes the relay and reserves
- * all resources that need to be locked. Initially the relay is set to both lines at 0v.
+ * Relay constructor given a channel.
+ *
+ * This code initializes the relay and reserves all resources that need to be
+ * locked. Initially the relay is set to both lines at 0v.
+ * @param channel The channel number (0-3).
+ * @param direction The direction that the Relay object will control.
*/
-void Relay::InitRelay()
+Relay::Relay(uint32_t channel, Relay::Direction direction)
+ : m_channel (channel)
+ , m_direction (direction)
{
- m_table = NULL;
char buf[64];
if (!SensorBase::CheckRelayChannel(m_channel))
{
@@ -32,18 +36,6 @@ void Relay::InitRelay()
go_pos = go_neg = false;
}
-/**
- * Relay constructor given a channel.
- * @param channel The channel number.
- * @param direction The direction that the Relay object will control.
- */
-Relay::Relay(uint32_t channel, Relay::Direction direction)
- : m_channel (channel)
- , m_direction (direction)
-{
- InitRelay();
-}
-
/**
* Free the resource associated with a relay.
* The relay channels are set to free and the relay output is turned off.
@@ -156,7 +148,7 @@ void Relay::ValueChanged(ITable* source, const std::string& key, EntryValue valu
}
void Relay::UpdateTable() {
- if(m_table != NULL){
+ if(m_table != nullptr){
if (Get() == kOn) {
m_table->PutString("Value", "On");
}
@@ -173,13 +165,13 @@ void Relay::UpdateTable() {
}
void Relay::StartLiveWindowMode() {
- if(m_table != NULL){
+ if(m_table != nullptr){
m_table->AddTableListener("Value", this, true);
}
}
void Relay::StopLiveWindowMode() {
- if(m_table != NULL){
+ if(m_table != nullptr){
m_table->RemoveTableListener(this);
}
}
diff --git a/wpilibc/wpilibC++Sim/src/RobotBase.cpp b/wpilibc/wpilibC++Sim/src/RobotBase.cpp
index 1fb710a42e..e0858e92c9 100644
--- a/wpilibc/wpilibC++Sim/src/RobotBase.cpp
+++ b/wpilibc/wpilibC++Sim/src/RobotBase.cpp
@@ -10,11 +10,11 @@
#include
-RobotBase* RobotBase::m_instance = NULL;
+RobotBase* RobotBase::m_instance = nullptr;
void RobotBase::setInstance(RobotBase* robot)
{
- wpi_assert(m_instance == NULL);
+ wpi_assert(m_instance == nullptr);
m_instance = robot;
}
@@ -37,15 +37,6 @@ RobotBase::RobotBase()
RobotState::SetImplementation(DriverStation::GetInstance());
}
-/**
- * Free the resources for a RobotBase class.
- * This includes deleting all classes that might have been allocated as Singletons to they
- * would never be deleted except here.
- */
-RobotBase::~RobotBase()
-{
-}
-
/**
* Determine if the Robot is currently enabled.
* @return True if the Robot is currently enabled by the field controls.
@@ -109,7 +100,6 @@ bool RobotBase::IsTest() const
class RobotDeleter
{
public:
- RobotDeleter() {}
~RobotDeleter()
{
delete &RobotBase::getInstance();
diff --git a/wpilibc/wpilibC++Sim/src/RobotDrive.cpp b/wpilibc/wpilibC++Sim/src/RobotDrive.cpp
index 58468b73a5..5631134b61 100644
--- a/wpilibc/wpilibC++Sim/src/RobotDrive.cpp
+++ b/wpilibc/wpilibC++Sim/src/RobotDrive.cpp
@@ -32,12 +32,6 @@ const int32_t RobotDrive::kMaxNumberOfMotors;
* initialize all the motor assignments. The default timeout is set for the robot drive.
*/
void RobotDrive::InitRobotDrive() {
- m_frontLeftMotor = NULL;
- m_frontRightMotor = NULL;
- m_rearRightMotor = NULL;
- m_rearLeftMotor = NULL;
- m_sensitivity = 0.5;
- m_maxOutput = 1.0;
// FIXME: m_safetyHelper = new MotorSafetyHelper(this);
// FIXME: m_safetyHelper->SetSafetyEnabled(true);
}
@@ -99,10 +93,10 @@ RobotDrive::RobotDrive(uint32_t frontLeftMotor, uint32_t rearLeftMotor,
RobotDrive::RobotDrive(SpeedController *leftMotor, SpeedController *rightMotor)
{
InitRobotDrive();
- if (leftMotor == NULL || rightMotor == NULL)
+ if (leftMotor == nullptr || rightMotor == nullptr)
{
wpi_setWPIError(NullParameter);
- m_rearLeftMotor = m_rearRightMotor = NULL;
+ m_rearLeftMotor = m_rearRightMotor = nullptr;
return;
}
m_rearLeftMotor = leftMotor;
@@ -138,7 +132,7 @@ RobotDrive::RobotDrive(SpeedController *frontLeftMotor, SpeedController *rearLef
SpeedController *frontRightMotor, SpeedController *rearRightMotor)
{
InitRobotDrive();
- if (frontLeftMotor == NULL || rearLeftMotor == NULL || frontRightMotor == NULL || rearRightMotor == NULL)
+ if (frontLeftMotor == nullptr || rearLeftMotor == nullptr || frontRightMotor == nullptr || rearRightMotor == nullptr)
{
wpi_setWPIError(NullParameter);
return;
@@ -239,7 +233,7 @@ void RobotDrive::Drive(float outputMagnitude, float curve)
*/
void RobotDrive::TankDrive(GenericHID *leftStick, GenericHID *rightStick, bool squaredInputs)
{
- if (leftStick == NULL || rightStick == NULL)
+ if (leftStick == nullptr || rightStick == nullptr)
{
wpi_setWPIError(NullParameter);
return;
@@ -264,7 +258,7 @@ void RobotDrive::TankDrive(GenericHID &leftStick, GenericHID &rightStick, bool s
void RobotDrive::TankDrive(GenericHID *leftStick, uint32_t leftAxis,
GenericHID *rightStick, uint32_t rightAxis, bool squaredInputs)
{
- if (leftStick == NULL || rightStick == NULL)
+ if (leftStick == nullptr || rightStick == nullptr)
{
wpi_setWPIError(NullParameter);
return;
@@ -586,15 +580,15 @@ void RobotDrive::HolonomicDrive(float magnitude, float direction, float rotation
*/
void RobotDrive::SetLeftRightMotorOutputs(float leftOutput, float rightOutput)
{
- wpi_assert(m_rearLeftMotor != NULL && m_rearRightMotor != NULL);
+ wpi_assert(m_rearLeftMotor != nullptr && m_rearRightMotor != nullptr);
uint8_t syncGroup = 0x80;
- if (m_frontLeftMotor != NULL)
+ if (m_frontLeftMotor != nullptr)
m_frontLeftMotor->Set(Limit(leftOutput) * m_invertedMotors[kFrontLeftMotor] * m_maxOutput, syncGroup);
m_rearLeftMotor->Set(Limit(leftOutput) * m_invertedMotors[kRearLeftMotor] * m_maxOutput, syncGroup);
- if (m_frontRightMotor != NULL)
+ if (m_frontRightMotor != nullptr)
m_frontRightMotor->Set(-Limit(rightOutput) * m_invertedMotors[kFrontRightMotor] * m_maxOutput, syncGroup);
m_rearRightMotor->Set(-Limit(rightOutput) * m_invertedMotors[kRearRightMotor] * m_maxOutput, syncGroup);
@@ -725,8 +719,8 @@ void RobotDrive::GetDescription(char *desc) const
void RobotDrive::StopMotor()
{
- if (m_frontLeftMotor != NULL) m_frontLeftMotor->Disable();
- if (m_frontRightMotor != NULL) m_frontRightMotor->Disable();
- if (m_rearLeftMotor != NULL) m_rearLeftMotor->Disable();
- if (m_rearRightMotor != NULL) m_rearRightMotor->Disable();
+ if (m_frontLeftMotor != nullptr) m_frontLeftMotor->Disable();
+ if (m_frontRightMotor != nullptr) m_frontRightMotor->Disable();
+ if (m_rearLeftMotor != nullptr) m_rearLeftMotor->Disable();
+ if (m_rearRightMotor != nullptr) m_rearRightMotor->Disable();
}
diff --git a/wpilibc/wpilibC++Sim/src/SafePWM.cpp b/wpilibc/wpilibC++Sim/src/SafePWM.cpp
index b5c4c42022..ab57c21c14 100644
--- a/wpilibc/wpilibC++Sim/src/SafePWM.cpp
+++ b/wpilibc/wpilibC++Sim/src/SafePWM.cpp
@@ -8,22 +8,14 @@
#include "MotorSafetyHelper.h"
-/**
- * Initialize a SafePWM object by setting defaults
- */
-void SafePWM::InitSafePWM()
-{
- m_safetyHelper = new MotorSafetyHelper(this);
- m_safetyHelper->SetSafetyEnabled(false);
-}
-
/**
* Constructor for a SafePWM object taking a channel number.
* @param channel The PWM channel number (0..19).
*/
SafePWM::SafePWM(uint32_t channel): PWM(channel)
{
- InitSafePWM();
+ m_safetyHelper = new MotorSafetyHelper(this);
+ m_safetyHelper->SetSafetyEnabled(false);
}
SafePWM::~SafePWM()
diff --git a/wpilibc/wpilibC++Sim/src/SensorBase.cpp b/wpilibc/wpilibC++Sim/src/SensorBase.cpp
index 80db28c5c3..fa3086f423 100644
--- a/wpilibc/wpilibC++Sim/src/SensorBase.cpp
+++ b/wpilibc/wpilibC++Sim/src/SensorBase.cpp
@@ -16,7 +16,7 @@ const uint32_t SensorBase::kPwmChannels;
const uint32_t SensorBase::kRelayChannels;
const uint32_t SensorBase::kPDPChannels;
const uint32_t SensorBase::kChassisSlots;
-SensorBase *SensorBase::m_singletonList = NULL;
+SensorBase *SensorBase::m_singletonList = nullptr;
/**
* Creates an instance of the sensor base and gets an FPGA handle
@@ -25,13 +25,6 @@ SensorBase::SensorBase()
{
}
-/**
- * Frees the resources for a SensorBase.
- */
-SensorBase::~SensorBase()
-{
-}
-
/**
* Add sensor to the singleton list.
* Add this sensor to the list of singletons that need to be deleted when
@@ -54,13 +47,13 @@ void SensorBase::AddToSingletonList()
*/
void SensorBase::DeleteSingletons()
{
- for (SensorBase *next = m_singletonList; next != NULL;)
+ for (SensorBase *next = m_singletonList; next != nullptr;)
{
SensorBase *tmp = next;
next = next->m_nextSingleton;
delete tmp;
}
- m_singletonList = NULL;
+ m_singletonList = nullptr;
}
/**
diff --git a/wpilibc/wpilibC++Sim/src/Solenoid.cpp b/wpilibc/wpilibC++Sim/src/Solenoid.cpp
index c3622992ab..9cfbc945ec 100644
--- a/wpilibc/wpilibC++Sim/src/Solenoid.cpp
+++ b/wpilibc/wpilibC++Sim/src/Solenoid.cpp
@@ -9,27 +9,12 @@
#include "LiveWindow/LiveWindow.h"
#include "simulation/simTime.h"
-/**
- * Common function to implement constructor behavior.
- */
-void Solenoid::InitSolenoid(int slot, int channel)
-{
- char buffer[50];
- int n = sprintf(buffer, "pneumatic/%d/%d", slot, channel);
- m_impl = new SimContinuousOutput(buffer);
-
- LiveWindow::GetInstance()->AddActuator("Solenoid", slot, channel, this);
-}
-
/**
* Constructor.
*
* @param channel The channel on the solenoid module to control (1..8).
*/
-Solenoid::Solenoid(uint32_t channel)
-{
- InitSolenoid(1, channel);
-}
+Solenoid::Solenoid(uint32_t channel) : Solenoid(1, channel) {}
/**
* Constructor.
@@ -39,14 +24,12 @@ Solenoid::Solenoid(uint32_t channel)
*/
Solenoid::Solenoid(uint8_t moduleNumber, uint32_t channel)
{
- InitSolenoid(moduleNumber, channel);
-}
-
-/**
- * Destructor.
- */
-Solenoid::~Solenoid()
-{
+ char buffer[50];
+ int n = sprintf(buffer, "pneumatic/%d/%d", moduleNumber, channel);
+ m_impl = new SimContinuousOutput(buffer);
+
+ LiveWindow::GetInstance()->AddActuator("Solenoid", moduleNumber, channel,
+ this);
}
/**
@@ -76,21 +59,21 @@ void Solenoid::ValueChanged(ITable* source, const std::string& key, EntryValue v
}
void Solenoid::UpdateTable() {
- if (m_table != NULL) {
+ if (m_table != nullptr) {
m_table->PutBoolean("Value", Get());
}
}
void Solenoid::StartLiveWindowMode() {
Set(false);
- if (m_table != NULL) {
+ if (m_table != nullptr) {
m_table->AddTableListener("Value", this, true);
}
}
void Solenoid::StopLiveWindowMode() {
Set(false);
- if (m_table != NULL) {
+ if (m_table != nullptr) {
m_table->RemoveTableListener(this);
}
}
diff --git a/wpilibc/wpilibC++Sim/src/Talon.cpp b/wpilibc/wpilibC++Sim/src/Talon.cpp
index dcd0fa2f1d..0e9505dbf4 100644
--- a/wpilibc/wpilibC++Sim/src/Talon.cpp
+++ b/wpilibc/wpilibC++Sim/src/Talon.cpp
@@ -9,38 +9,29 @@
//#include "NetworkCommunication/UsageReporting.h"
#include "LiveWindow/LiveWindow.h"
-/**
- * Common initialization code called by all constructors.
- *
- * 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 saturate the controller in either direction, calibration is recommended.
- * The calibration procedure can be found in the Talon User Manual available from CTRE.
- *
- * - 211 = full "forward"
- * - 133 = the "high end" of the deadband range
- * - 129 = center of the deadband range (off)
- * - 125 = the "low end" of the deadband range
- * - 49 = full "reverse"
- */
-void Talon::InitTalon() {
- SetBounds(2.037, 1.539, 1.513, 1.487, .989);
- SetPeriodMultiplier(kPeriodMultiplier_2X);
- SetRaw(m_centerPwm);
-
- LiveWindow::GetInstance()->AddActuator("Talon", GetChannel(), this);
-}
-
/**
* @param channel The PWM channel that the Talon is attached to.
*/
Talon::Talon(uint32_t channel) : SafePWM(channel)
{
- InitTalon();
-}
+ /* 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
+ * saturate the controller in either direction, calibration is recommended.
+ * The calibration procedure can be found in the Talon User Manual available
+ * from CTRE.
+ *
+ * - 211 = full "forward"
+ * - 133 = the "high end" of the deadband range
+ * - 129 = center of the deadband range (off)
+ * - 125 = the "low end" of the deadband range
+ * - 49 = full "reverse"
+ */
+ SetBounds(2.037, 1.539, 1.513, 1.487, .989);
+ SetPeriodMultiplier(kPeriodMultiplier_2X);
+ SetRaw(m_centerPwm);
-Talon::~Talon()
-{
+ LiveWindow::GetInstance()->AddActuator("Talon", GetChannel(), this);
}
/**
diff --git a/wpilibc/wpilibC++Sim/src/Task.cpp b/wpilibc/wpilibC++Sim/src/Task.cpp
index 7b603c470e..80a212e08d 100644
--- a/wpilibc/wpilibC++Sim/src/Task.cpp
+++ b/wpilibc/wpilibC++Sim/src/Task.cpp
@@ -38,7 +38,7 @@ Task::~Task()
{
if (m_taskID != NULL_TASK) Stop();
delete [] m_taskName;
- m_taskName = NULL;
+ m_taskName = nullptr;
}
/**
@@ -159,7 +159,7 @@ bool Task::SetPriority(int32_t priority)
/**
* Returns the name of the task.
- * @returns Pointer to the name of the task or NULL if not allocated
+ * @returns Pointer to the name of the task or nullptr if not allocated
*/
const char* Task::GetName() const
{
diff --git a/wpilibc/wpilibC++Sim/src/Utility.cpp b/wpilibc/wpilibC++Sim/src/Utility.cpp
index e1bf26d554..c5e78c2d8e 100644
--- a/wpilibc/wpilibC++Sim/src/Utility.cpp
+++ b/wpilibc/wpilibC++Sim/src/Utility.cpp
@@ -71,7 +71,7 @@ bool wpi_assert_impl(bool conditionValue,
// If an error message was specified, include it
// Build error string
- if(message != NULL) {
+ if(message != nullptr) {
sprintf(error, "Assertion failed: \"%s\", \"%s\" failed in %s() in %s at line %dd\n",
message, conditionText, funcName, fileName, lineNumber);
} else {
@@ -106,7 +106,7 @@ void wpi_assertEqual_common_impl(int valueA,
// If an error message was specified, include it
// Build error string
- if(message != NULL) {
+ if(message != nullptr) {
sprintf(error, "Assertion failed: \"%s\", \"%d\" %s \"%d\" in %s() in %s at line %d\n",
message, valueA, equalityType, valueB, funcName, fileName, lineNumber);
} else {
@@ -183,7 +183,7 @@ static std::string demangle(char const *mangledSymbol)
if(sscanf(mangledSymbol, "%*[^(]%*[^_]%255[^)+]", buffer))
{
- char *symbol = abi::__cxa_demangle(buffer, NULL, &length, &status);
+ char *symbol = abi::__cxa_demangle(buffer, nullptr, &length, &status);
if(status == 0)
{
diff --git a/wpilibc/wpilibC++Sim/src/Victor.cpp b/wpilibc/wpilibC++Sim/src/Victor.cpp
index f4ab50cb0e..54ba61fd8d 100644
--- a/wpilibc/wpilibC++Sim/src/Victor.cpp
+++ b/wpilibc/wpilibC++Sim/src/Victor.cpp
@@ -9,40 +9,31 @@
//#include "NetworkCommunication/UsageReporting.h"
#include "LiveWindow/LiveWindow.h"
-/**
- * Common initialization code called by all constructors.
- *
- * 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 experience issues such as asymmetric behavior around
- * the deadband or inability to saturate the controller in either direction, calibration is recommended.
- * The calibration procedure can be found in the Victor 884 User Manual available from IFI.
- *
- * - 206 = full "forward"
- * - 131 = the "high end" of the deadband range
- * - 128 = center of the deadband range (off)
- * - 125 = the "low end" of the deadband range
- * - 56 = full "reverse"
- */
-void Victor::InitVictor() {
- SetBounds(2.027, 1.525, 1.507, 1.49, 1.026);
-
- SetPeriodMultiplier(kPeriodMultiplier_2X);
- SetRaw(m_centerPwm);
-
- LiveWindow::GetInstance()->AddActuator("Victor", GetChannel(), this);
-}
-
/**
* @param channel The PWM channel that the Victor is attached to.
*/
Victor::Victor(uint32_t channel) : SafePWM(channel)
{
- InitVictor();
-}
+ /* 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
+ * experience issues such as asymmetric behavior around the deadband or
+ * inability to saturate the controller in either direction, calibration is
+ * recommended. The calibration procedure can be found in the Victor 884 User
+ * Manual available from IFI.
+ *
+ * - 206 = full "forward"
+ * - 131 = the "high end" of the deadband range
+ * - 128 = center of the deadband range (off)
+ * - 125 = the "low end" of the deadband range
+ * - 56 = full "reverse"
+ */
-Victor::~Victor()
-{
+ SetBounds(2.027, 1.525, 1.507, 1.49, 1.026);
+ SetPeriodMultiplier(kPeriodMultiplier_2X);
+ SetRaw(m_centerPwm);
+
+ LiveWindow::GetInstance()->AddActuator("Victor", GetChannel(), this);
}
/**
diff --git a/wpilibc/wpilibC++Sim/src/simulation/MainNode.cpp b/wpilibc/wpilibC++Sim/src/simulation/MainNode.cpp
deleted file mode 100644
index dafbac2ff6..0000000000
--- a/wpilibc/wpilibC++Sim/src/simulation/MainNode.cpp
+++ /dev/null
@@ -1,3 +0,0 @@
-
-#include "simulation/MainNode.h"
-MainNode* MainNode::instance = NULL;
diff --git a/wpilibc/wpilibC++Sim/src/simulation/msgs/bool.pb.cpp b/wpilibc/wpilibC++Sim/src/simulation/msgs/bool.pb.cpp
index de7a6ca657..c22631fed2 100644
--- a/wpilibc/wpilibC++Sim/src/simulation/msgs/bool.pb.cpp
+++ b/wpilibc/wpilibC++Sim/src/simulation/msgs/bool.pb.cpp
@@ -21,9 +21,9 @@ namespace msgs {
namespace {
-const ::google::protobuf::Descriptor* Bool_descriptor_ = NULL;
+const ::google::protobuf::Descriptor* Bool_descriptor_ = nullptr;
const ::google::protobuf::internal::GeneratedMessageReflection*
- Bool_reflection_ = NULL;
+ Bool_reflection_ = nullptr;
} // namespace
@@ -33,7 +33,7 @@ void protobuf_AssignDesc_msgs_2fbool_2eproto() {
const ::google::protobuf::FileDescriptor* file =
::google::protobuf::DescriptorPool::generated_pool()->FindFileByName(
"msgs/bool.proto");
- GOOGLE_CHECK(file != NULL);
+ GOOGLE_CHECK(file != nullptr);
Bool_descriptor_ = file->message_type(0);
static const int Bool_offsets_[1] = {
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Bool, data_),
@@ -141,11 +141,11 @@ const ::google::protobuf::Descriptor* Bool::descriptor() {
}
const Bool& Bool::default_instance() {
- if (default_instance_ == NULL) protobuf_AddDesc_msgs_2fbool_2eproto();
+ if (default_instance_ == nullptr) protobuf_AddDesc_msgs_2fbool_2eproto();
return *default_instance_;
}
-Bool* Bool::default_instance_ = NULL;
+Bool* Bool::default_instance_ = nullptr;
Bool* Bool::New() const {
return new Bool;
@@ -249,7 +249,7 @@ void Bool::MergeFrom(const ::google::protobuf::Message& from) {
const Bool* source =
::google::protobuf::internal::dynamic_cast_if_available(
&from);
- if (source == NULL) {
+ if (source == nullptr) {
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
MergeFrom(*source);
diff --git a/wpilibc/wpilibC++Sim/src/simulation/msgs/driver-station.pb.cpp b/wpilibc/wpilibC++Sim/src/simulation/msgs/driver-station.pb.cpp
index 01ca2daaa0..4f5289139f 100644
--- a/wpilibc/wpilibC++Sim/src/simulation/msgs/driver-station.pb.cpp
+++ b/wpilibc/wpilibC++Sim/src/simulation/msgs/driver-station.pb.cpp
@@ -21,10 +21,10 @@ namespace msgs {
namespace {
-const ::google::protobuf::Descriptor* DriverStation_descriptor_ = NULL;
+const ::google::protobuf::Descriptor* DriverStation_descriptor_ = nullptr;
const ::google::protobuf::internal::GeneratedMessageReflection*
- DriverStation_reflection_ = NULL;
-const ::google::protobuf::EnumDescriptor* DriverStation_State_descriptor_ = NULL;
+ DriverStation_reflection_ = nullptr;
+const ::google::protobuf::EnumDescriptor* DriverStation_State_descriptor_ = nullptr;
} // namespace
@@ -34,7 +34,7 @@ void protobuf_AssignDesc_msgs_2fdriver_2dstation_2eproto() {
const ::google::protobuf::FileDescriptor* file =
::google::protobuf::DescriptorPool::generated_pool()->FindFileByName(
"msgs/driver-station.proto");
- GOOGLE_CHECK(file != NULL);
+ GOOGLE_CHECK(file != nullptr);
DriverStation_descriptor_ = file->message_type(0);
static const int DriverStation_offsets_[2] = {
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(DriverStation, enabled_),
@@ -172,11 +172,11 @@ const ::google::protobuf::Descriptor* DriverStation::descriptor() {
}
const DriverStation& DriverStation::default_instance() {
- if (default_instance_ == NULL) protobuf_AddDesc_msgs_2fdriver_2dstation_2eproto();
+ if (default_instance_ == nullptr) protobuf_AddDesc_msgs_2fdriver_2dstation_2eproto();
return *default_instance_;
}
-DriverStation* DriverStation::default_instance_ = NULL;
+DriverStation* DriverStation::default_instance_ = nullptr;
DriverStation* DriverStation::New() const {
return new DriverStation;
@@ -320,7 +320,7 @@ void DriverStation::MergeFrom(const ::google::protobuf::Message& from) {
const DriverStation* source =
::google::protobuf::internal::dynamic_cast_if_available(
&from);
- if (source == NULL) {
+ if (source == nullptr) {
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
MergeFrom(*source);
diff --git a/wpilibc/wpilibC++Sim/src/simulation/msgs/float64.pb.cpp b/wpilibc/wpilibC++Sim/src/simulation/msgs/float64.pb.cpp
index e9462c04f4..37701e1dbb 100644
--- a/wpilibc/wpilibC++Sim/src/simulation/msgs/float64.pb.cpp
+++ b/wpilibc/wpilibC++Sim/src/simulation/msgs/float64.pb.cpp
@@ -21,9 +21,9 @@ namespace msgs {
namespace {
-const ::google::protobuf::Descriptor* Float64_descriptor_ = NULL;
+const ::google::protobuf::Descriptor* Float64_descriptor_ = nullptr;
const ::google::protobuf::internal::GeneratedMessageReflection*
- Float64_reflection_ = NULL;
+ Float64_reflection_ = nullptr;
} // namespace
@@ -33,7 +33,7 @@ void protobuf_AssignDesc_msgs_2ffloat64_2eproto() {
const ::google::protobuf::FileDescriptor* file =
::google::protobuf::DescriptorPool::generated_pool()->FindFileByName(
"msgs/float64.proto");
- GOOGLE_CHECK(file != NULL);
+ GOOGLE_CHECK(file != nullptr);
Float64_descriptor_ = file->message_type(0);
static const int Float64_offsets_[1] = {
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Float64, data_),
@@ -141,11 +141,11 @@ const ::google::protobuf::Descriptor* Float64::descriptor() {
}
const Float64& Float64::default_instance() {
- if (default_instance_ == NULL) protobuf_AddDesc_msgs_2ffloat64_2eproto();
+ if (default_instance_ == nullptr) protobuf_AddDesc_msgs_2ffloat64_2eproto();
return *default_instance_;
}
-Float64* Float64::default_instance_ = NULL;
+Float64* Float64::default_instance_ = nullptr;
Float64* Float64::New() const {
return new Float64;
@@ -249,7 +249,7 @@ void Float64::MergeFrom(const ::google::protobuf::Message& from) {
const Float64* source =
::google::protobuf::internal::dynamic_cast_if_available(
&from);
- if (source == NULL) {
+ if (source == nullptr) {
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
MergeFrom(*source);
diff --git a/wpilibc/wpilibC++Sim/src/simulation/msgs/joystick.pb.cpp b/wpilibc/wpilibC++Sim/src/simulation/msgs/joystick.pb.cpp
index 11a2d5ea3d..8677b26a14 100644
--- a/wpilibc/wpilibC++Sim/src/simulation/msgs/joystick.pb.cpp
+++ b/wpilibc/wpilibC++Sim/src/simulation/msgs/joystick.pb.cpp
@@ -21,9 +21,9 @@ namespace msgs {
namespace {
-const ::google::protobuf::Descriptor* Joystick_descriptor_ = NULL;
+const ::google::protobuf::Descriptor* Joystick_descriptor_ = nullptr;
const ::google::protobuf::internal::GeneratedMessageReflection*
- Joystick_reflection_ = NULL;
+ Joystick_reflection_ = nullptr;
} // namespace
@@ -33,7 +33,7 @@ void protobuf_AssignDesc_msgs_2fjoystick_2eproto() {
const ::google::protobuf::FileDescriptor* file =
::google::protobuf::DescriptorPool::generated_pool()->FindFileByName(
"msgs/joystick.proto");
- GOOGLE_CHECK(file != NULL);
+ GOOGLE_CHECK(file != nullptr);
Joystick_descriptor_ = file->message_type(0);
static const int Joystick_offsets_[2] = {
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(Joystick, axes_),
@@ -143,11 +143,11 @@ const ::google::protobuf::Descriptor* Joystick::descriptor() {
}
const Joystick& Joystick::default_instance() {
- if (default_instance_ == NULL) protobuf_AddDesc_msgs_2fjoystick_2eproto();
+ if (default_instance_ == nullptr) protobuf_AddDesc_msgs_2fjoystick_2eproto();
return *default_instance_;
}
-Joystick* Joystick::default_instance_ = NULL;
+Joystick* Joystick::default_instance_ = nullptr;
Joystick* Joystick::New() const {
return new Joystick;
@@ -300,7 +300,7 @@ void Joystick::MergeFrom(const ::google::protobuf::Message& from) {
const Joystick* source =
::google::protobuf::internal::dynamic_cast_if_available(
&from);
- if (source == NULL) {
+ if (source == nullptr) {
::google::protobuf::internal::ReflectionOps::Merge(from, this);
} else {
MergeFrom(*source);