mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-02 02:51:42 +00:00
Add format script which invokes clang-format on the C++ source code (#41)
On Windows machines, clang-format.exe must be in the PATH environment variable.
This commit is contained in:
committed by
Peter Johnson
parent
68690643d2
commit
e14e45da76
@@ -11,55 +11,54 @@
|
||||
// (currently) only actually using the move constructors in non-MSVC situations
|
||||
// (ie, wpilibC++Devices), we can just ignore it in MSVC.
|
||||
#if !defined(_MSC_VER)
|
||||
#define DEFAULT_MOVE_CONSTRUCTOR(ClassName) \
|
||||
ClassName(ClassName &&) = default
|
||||
#define DEFAULT_MOVE_CONSTRUCTOR(ClassName) ClassName(ClassName&&) = default
|
||||
#else
|
||||
#define DEFAULT_MOVE_CONSTRUCTOR(ClassName)
|
||||
#endif
|
||||
|
||||
#if (__cplusplus < 201103L)
|
||||
#if !defined(_MSC_VER)
|
||||
#define nullptr NULL
|
||||
#endif
|
||||
#define constexpr const
|
||||
#if !defined(_MSC_VER)
|
||||
#define nullptr NULL
|
||||
#endif
|
||||
#define constexpr const
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#define noexcept throw()
|
||||
#define noexcept throw()
|
||||
#endif
|
||||
|
||||
// [[deprecated(msg)]] is a C++14 feature not supported by MSVC or GCC < 4.9.
|
||||
// We provide an equivalent warning implementation for those compilers here.
|
||||
#if defined(_MSC_VER)
|
||||
#define DEPRECATED(msg) __declspec(deprecated(msg))
|
||||
#define DEPRECATED(msg) __declspec(deprecated(msg))
|
||||
#elif defined(__GNUC__)
|
||||
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 8)
|
||||
#define DEPRECATED(msg) [[deprecated(msg)]]
|
||||
#else
|
||||
#define DEPRECATED(msg) __attribute__((deprecated(msg)))
|
||||
#endif
|
||||
#elif __cplusplus > 201103L
|
||||
#define DEPRECATED(msg) [[deprecated(msg)]]
|
||||
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 8)
|
||||
#define DEPRECATED(msg) [[deprecated(msg)]]
|
||||
#else
|
||||
#define DEPRECATED(msg) /*nothing*/
|
||||
#define DEPRECATED(msg) __attribute__((deprecated(msg)))
|
||||
#endif
|
||||
#elif __cplusplus > 201103L
|
||||
#define DEPRECATED(msg) [[deprecated(msg)]]
|
||||
#else
|
||||
#define DEPRECATED(msg) /*nothing*/
|
||||
#endif
|
||||
|
||||
// Provide std::decay_t when using GCC < 4.9
|
||||
#if defined(__GNUC__)
|
||||
#if __GNUC__ == 4 && __GNUC_MINOR__ < 9
|
||||
#include <type_traits>
|
||||
namespace std {
|
||||
template <class T> using decay_t = typename decay<T>::type;
|
||||
}
|
||||
#endif
|
||||
#if __GNUC__ == 4 && __GNUC_MINOR__ < 9
|
||||
#include <type_traits>
|
||||
namespace std {
|
||||
template <class T>
|
||||
using decay_t = typename decay<T>::type;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// A struct to use as a deleter when a std::shared_ptr must wrap a raw pointer
|
||||
// that is being deleted by someone else.
|
||||
template<class T>
|
||||
struct
|
||||
NullDeleter {
|
||||
void operator()(T *) const noexcept {};
|
||||
template <class T>
|
||||
struct NullDeleter {
|
||||
void operator()(T*) const noexcept {};
|
||||
};
|
||||
|
||||
#include <atomic>
|
||||
@@ -101,7 +100,7 @@ struct _Unique_if<T[N]> {
|
||||
};
|
||||
|
||||
template <class T, class... Args>
|
||||
typename _Unique_if<T>::_Single_object make_unique(Args &&... args) {
|
||||
typename _Unique_if<T>::_Single_object make_unique(Args&&... args) {
|
||||
return unique_ptr<T>(new T(std::forward<Args>(args)...));
|
||||
}
|
||||
|
||||
@@ -112,6 +111,6 @@ typename _Unique_if<T>::_Unknown_bound make_unique(size_t n) {
|
||||
}
|
||||
|
||||
template <class T, class... Args>
|
||||
typename _Unique_if<T>::_Known_bound make_unique(Args &&...) = delete;
|
||||
typename _Unique_if<T>::_Known_bound make_unique(Args&&...) = delete;
|
||||
} // namespace std
|
||||
#endif
|
||||
|
||||
@@ -27,11 +27,11 @@
|
||||
*/
|
||||
class Button : public Trigger {
|
||||
public:
|
||||
virtual void WhenPressed(Command *command);
|
||||
virtual void WhileHeld(Command *command);
|
||||
virtual void WhenReleased(Command *command);
|
||||
virtual void CancelWhenPressed(Command *command);
|
||||
virtual void ToggleWhenPressed(Command *command);
|
||||
virtual void WhenPressed(Command* command);
|
||||
virtual void WhileHeld(Command* command);
|
||||
virtual void WhenReleased(Command* command);
|
||||
virtual void CancelWhenPressed(Command* command);
|
||||
virtual void ToggleWhenPressed(Command* command);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -13,15 +13,15 @@ class Command;
|
||||
|
||||
class ButtonScheduler {
|
||||
public:
|
||||
ButtonScheduler(bool last, Trigger *button, Command *orders);
|
||||
ButtonScheduler(bool last, Trigger* button, Command* orders);
|
||||
virtual ~ButtonScheduler() = default;
|
||||
virtual void Execute() = 0;
|
||||
void Start();
|
||||
|
||||
protected:
|
||||
bool m_pressedLast;
|
||||
Trigger *m_button;
|
||||
Command *m_command;
|
||||
Trigger* m_button;
|
||||
Command* m_command;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -15,7 +15,7 @@ class Command;
|
||||
|
||||
class CancelButtonScheduler : public ButtonScheduler {
|
||||
public:
|
||||
CancelButtonScheduler(bool last, Trigger *button, Command *orders);
|
||||
CancelButtonScheduler(bool last, Trigger* button, Command* orders);
|
||||
virtual ~CancelButtonScheduler() = default;
|
||||
virtual void Execute();
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ class Command;
|
||||
|
||||
class HeldButtonScheduler : public ButtonScheduler {
|
||||
public:
|
||||
HeldButtonScheduler(bool last, Trigger *button, Command *orders);
|
||||
HeldButtonScheduler(bool last, Trigger* button, Command* orders);
|
||||
virtual ~HeldButtonScheduler() = default;
|
||||
virtual void Execute();
|
||||
};
|
||||
|
||||
@@ -8,18 +8,18 @@
|
||||
#ifndef __JOYSTICK_BUTTON_H__
|
||||
#define __JOYSTICK_BUTTON_H__
|
||||
|
||||
#include "GenericHID.h"
|
||||
#include "Buttons/Button.h"
|
||||
#include "GenericHID.h"
|
||||
|
||||
class JoystickButton : public Button {
|
||||
public:
|
||||
JoystickButton(GenericHID *joystick, int buttonNumber);
|
||||
JoystickButton(GenericHID* joystick, int buttonNumber);
|
||||
virtual ~JoystickButton() = default;
|
||||
|
||||
virtual bool Get();
|
||||
|
||||
private:
|
||||
GenericHID *m_joystick;
|
||||
GenericHID* m_joystick;
|
||||
int m_buttonNumber;
|
||||
};
|
||||
|
||||
|
||||
@@ -8,14 +8,14 @@
|
||||
#ifndef __NETWORK_BUTTON_H__
|
||||
#define __NETWORK_BUTTON_H__
|
||||
|
||||
#include "Buttons/Button.h"
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include "Buttons/Button.h"
|
||||
|
||||
class NetworkButton : public Button {
|
||||
public:
|
||||
NetworkButton(const std::string &tableName, const std::string &field);
|
||||
NetworkButton(std::shared_ptr<ITable> table, const std::string &field);
|
||||
NetworkButton(const std::string& tableName, const std::string& field);
|
||||
NetworkButton(std::shared_ptr<ITable> table, const std::string& field);
|
||||
virtual ~NetworkButton() = default;
|
||||
|
||||
virtual bool Get();
|
||||
|
||||
@@ -15,7 +15,7 @@ class Command;
|
||||
|
||||
class PressedButtonScheduler : public ButtonScheduler {
|
||||
public:
|
||||
PressedButtonScheduler(bool last, Trigger *button, Command *orders);
|
||||
PressedButtonScheduler(bool last, Trigger* button, Command* orders);
|
||||
virtual ~PressedButtonScheduler() = default;
|
||||
virtual void Execute();
|
||||
};
|
||||
|
||||
@@ -15,7 +15,7 @@ class Command;
|
||||
|
||||
class ReleasedButtonScheduler : public ButtonScheduler {
|
||||
public:
|
||||
ReleasedButtonScheduler(bool last, Trigger *button, Command *orders);
|
||||
ReleasedButtonScheduler(bool last, Trigger* button, Command* orders);
|
||||
virtual ~ReleasedButtonScheduler() = default;
|
||||
virtual void Execute();
|
||||
};
|
||||
|
||||
@@ -15,7 +15,7 @@ class Command;
|
||||
|
||||
class ToggleButtonScheduler : public ButtonScheduler {
|
||||
public:
|
||||
ToggleButtonScheduler(bool last, Trigger *button, Command *orders);
|
||||
ToggleButtonScheduler(bool last, Trigger* button, Command* orders);
|
||||
virtual ~ToggleButtonScheduler() = default;
|
||||
virtual void Execute();
|
||||
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
#ifndef __TRIGGER_H__
|
||||
#define __TRIGGER_H__
|
||||
|
||||
#include "SmartDashboard/Sendable.h"
|
||||
#include <memory>
|
||||
#include "SmartDashboard/Sendable.h"
|
||||
|
||||
class Command;
|
||||
|
||||
@@ -36,11 +36,11 @@ class Trigger : public Sendable {
|
||||
virtual ~Trigger() = default;
|
||||
bool Grab();
|
||||
virtual bool Get() = 0;
|
||||
void WhenActive(Command *command);
|
||||
void WhileActive(Command *command);
|
||||
void WhenInactive(Command *command);
|
||||
void CancelWhenActive(Command *command);
|
||||
void ToggleWhenActive(Command *command);
|
||||
void WhenActive(Command* command);
|
||||
void WhileActive(Command* command);
|
||||
void WhenInactive(Command* command);
|
||||
void CancelWhenActive(Command* command);
|
||||
void ToggleWhenActive(Command* command);
|
||||
|
||||
virtual void InitTable(std::shared_ptr<ITable> table);
|
||||
virtual std::shared_ptr<ITable> GetTable() const;
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <cstddef>
|
||||
#include <vector>
|
||||
|
||||
/**
|
||||
* This is a simple circular buffer so we don't need to "bucket brigade" copy
|
||||
|
||||
@@ -8,12 +8,12 @@
|
||||
#ifndef __COMMAND_H__
|
||||
#define __COMMAND_H__
|
||||
|
||||
#include <memory>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include "ErrorBase.h"
|
||||
#include "SmartDashboard/NamedSendable.h"
|
||||
#include "tables/ITableListener.h"
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <memory>
|
||||
|
||||
class CommandGroup;
|
||||
class Subsystem;
|
||||
@@ -22,31 +22,27 @@ class Subsystem;
|
||||
* The Command class is at the very core of the entire command framework.
|
||||
* Every command can be started with a call to {@link Command#Start() Start()}.
|
||||
* Once a command is started it will call {@link Command#Initialize()
|
||||
* Initialize()}, and then
|
||||
* will repeatedly call {@link Command#Execute() Execute()} until the {@link
|
||||
*Command#IsFinished() IsFinished()}
|
||||
* returns true. Once it does, {@link Command#End() End()} will be called.
|
||||
* Initialize()}, and then will repeatedly call
|
||||
* {@link Command#Execute() Execute()} until the
|
||||
* {@link Command#IsFinished() IsFinished()} returns true. Once it does,
|
||||
* {@link Command#End() End()} will be called.
|
||||
*
|
||||
* <p>However, if at any point while it is running {@link Command#Cancel()
|
||||
* Cancel()} is called, then
|
||||
* the command will be stopped and {@link Command#Interrupted() Interrupted()}
|
||||
* will be called.</p>
|
||||
* Cancel()} is called, then the command will be stopped and
|
||||
* {@link Command#Interrupted() Interrupted()} will be called.</p>
|
||||
*
|
||||
* <p>If a command uses a {@link Subsystem}, then it should specify that it does
|
||||
* so by
|
||||
* calling the {@link Command#Requires(Subsystem) Requires(...)} method
|
||||
* so by calling the {@link Command#Requires(Subsystem) Requires(...)} method
|
||||
* in its constructor. Note that a Command may have multiple requirements, and
|
||||
* {@link Command#Requires(Subsystem) Requires(...)} should be
|
||||
* called for each one.</p>
|
||||
* {@link Command#Requires(Subsystem) Requires(...)} should be called for each
|
||||
* one.</p>
|
||||
*
|
||||
* <p>If a command is running and a new command with shared requirements is
|
||||
* started,
|
||||
* then one of two things will happen. If the active command is interruptible,
|
||||
* then {@link Command#Cancel() Cancel()} will be called and the command will be
|
||||
* removed
|
||||
* to make way for the new one. If the active command is not interruptible, the
|
||||
* other one will not even be started, and the active one will continue
|
||||
* functioning.</p>
|
||||
* started, then one of two things will happen. If the active command is
|
||||
* interruptible, then {@link Command#Cancel() Cancel()} will be called and the
|
||||
* command will be removed to make way for the new one. If the active command
|
||||
* is not interruptible, the other one will not even be started, and the active
|
||||
* one will continue functioning.</p>
|
||||
*
|
||||
* @see CommandGroup
|
||||
* @see Subsystem
|
||||
@@ -57,12 +53,12 @@ class Command : public ErrorBase, public NamedSendable, public ITableListener {
|
||||
|
||||
public:
|
||||
Command();
|
||||
Command(const std::string &name);
|
||||
Command(const std::string& name);
|
||||
Command(double timeout);
|
||||
Command(const std::string &name, double timeout);
|
||||
Command(const std::string& name, double timeout);
|
||||
virtual ~Command();
|
||||
double TimeSinceInitialized() const;
|
||||
void Requires(Subsystem *s);
|
||||
void Requires(Subsystem* s);
|
||||
bool IsCanceled() const;
|
||||
void Start();
|
||||
bool Run();
|
||||
@@ -70,10 +66,10 @@ class Command : public ErrorBase, public NamedSendable, public ITableListener {
|
||||
bool IsRunning() const;
|
||||
bool IsInterruptible() const;
|
||||
void SetInterruptible(bool interruptible);
|
||||
bool DoesRequire(Subsystem *subsystem) const;
|
||||
typedef std::set<Subsystem *> SubsystemSet;
|
||||
bool DoesRequire(Subsystem* subsystem) const;
|
||||
typedef std::set<Subsystem*> SubsystemSet;
|
||||
SubsystemSet GetRequirements() const;
|
||||
CommandGroup *GetGroup() const;
|
||||
CommandGroup* GetGroup() const;
|
||||
void SetRunWhenDisabled(bool run);
|
||||
bool WillRunWhenDisabled() const;
|
||||
int GetID() const;
|
||||
@@ -81,8 +77,8 @@ class Command : public ErrorBase, public NamedSendable, public ITableListener {
|
||||
protected:
|
||||
void SetTimeout(double timeout);
|
||||
bool IsTimedOut() const;
|
||||
bool AssertUnlocked(const std::string &message);
|
||||
void SetParent(CommandGroup *parent);
|
||||
bool AssertUnlocked(const std::string& message);
|
||||
void SetParent(CommandGroup* parent);
|
||||
/**
|
||||
* The initialize method is called the first time this Command is run after
|
||||
* being started.
|
||||
@@ -95,12 +91,11 @@ class Command : public ErrorBase, public NamedSendable, public ITableListener {
|
||||
virtual void Execute() = 0;
|
||||
/**
|
||||
* Returns whether this command is finished.
|
||||
* If it is, then the command will be removed
|
||||
* and {@link Command#end() end()} will be called.
|
||||
* If it is, then the command will be removed and {@link Command#end() end()}
|
||||
* will be called.
|
||||
*
|
||||
* <p>It may be useful for a team to reference the {@link Command#isTimedOut()
|
||||
* isTimedOut()} method
|
||||
* for time-sensitive commands.</p>
|
||||
* isTimedOut()} method for time-sensitive commands.</p>
|
||||
* @return whether this command is finished.
|
||||
* @see Command#isTimedOut() isTimedOut()
|
||||
*/
|
||||
@@ -112,18 +107,15 @@ class Command : public ErrorBase, public NamedSendable, public ITableListener {
|
||||
*/
|
||||
virtual void End() = 0;
|
||||
/**
|
||||
* Called when the command ends because somebody called {@link
|
||||
*Command#cancel() cancel()}
|
||||
* or another command shared the same requirements as this one, and booted
|
||||
* it out.
|
||||
* Called when the command ends because somebody called
|
||||
* {@link Command#cancel() cancel()} or another command shared the same
|
||||
* requirements as this one, and booted it out.
|
||||
*
|
||||
* <p>This is where you may want
|
||||
* to wrap up loose ends, like shutting off a motor that was being used
|
||||
* in the command.</p>
|
||||
* <p>This is where you may want to wrap up loose ends, like shutting off a
|
||||
* motor that was being used in the command.</p>
|
||||
*
|
||||
* <p>Generally, it is useful to simply call the {@link Command#end() end()}
|
||||
* method
|
||||
* within this method</p>
|
||||
* method within this method</p>
|
||||
*/
|
||||
virtual void Interrupted() = 0;
|
||||
virtual void _Initialize();
|
||||
@@ -170,7 +162,7 @@ class Command : public ErrorBase, public NamedSendable, public ITableListener {
|
||||
bool m_runWhenDisabled = false;
|
||||
|
||||
/** The {@link CommandGroup} this is in */
|
||||
CommandGroup *m_parent = nullptr;
|
||||
CommandGroup* m_parent = nullptr;
|
||||
|
||||
int m_commandID = m_commandCounter++;
|
||||
static int m_commandCounter;
|
||||
|
||||
@@ -8,25 +8,24 @@
|
||||
#ifndef __COMMAND_GROUP_H__
|
||||
#define __COMMAND_GROUP_H__
|
||||
|
||||
#include "Commands/Command.h"
|
||||
#include "Commands/CommandGroupEntry.h"
|
||||
#include <list>
|
||||
#include <vector>
|
||||
#include "Commands/Command.h"
|
||||
#include "Commands/CommandGroupEntry.h"
|
||||
|
||||
/**
|
||||
* A {@link CommandGroup} is a list of commands which are executed in sequence.
|
||||
*
|
||||
* <p>Commands in a {@link CommandGroup} are added using the {@link
|
||||
* CommandGroup#AddSequential(Command) AddSequential(...)} method
|
||||
* and are called sequentially.
|
||||
* {@link CommandGroup CommandGroups} are themselves {@link Command Commands}
|
||||
* and can be given to other {@link CommandGroup CommandGroups}.</p>
|
||||
* CommandGroup#AddSequential(Command) AddSequential(...)} method and are
|
||||
* called sequentially. {@link CommandGroup CommandGroups} are themselves
|
||||
* {@link Command Commands} and can be given to other
|
||||
* {@link CommandGroup CommandGroups}.</p>
|
||||
*
|
||||
* <p>{@link CommandGroup CommandGroups} will carry all of the requirements of
|
||||
* their {@link Command subcommands}. Additional
|
||||
* requirements can be specified by calling {@link
|
||||
*CommandGroup#Requires(Subsystem) Requires(...)}
|
||||
* normally in the constructor.</P>
|
||||
* their {@link Command subcommands}. Additional requirements can be specified
|
||||
* by calling {@link CommandGroup#Requires(Subsystem) Requires(...)} normally
|
||||
* in the constructor.</P>
|
||||
*
|
||||
* <p>CommandGroups can also execute commands in parallel, simply by adding them
|
||||
* using {@link CommandGroup#AddParallel(Command) AddParallel(...)}.</p>
|
||||
@@ -37,13 +36,13 @@
|
||||
class CommandGroup : public Command {
|
||||
public:
|
||||
CommandGroup() = default;
|
||||
CommandGroup(const std::string &name);
|
||||
CommandGroup(const std::string& name);
|
||||
virtual ~CommandGroup() = default;
|
||||
|
||||
void AddSequential(Command *command);
|
||||
void AddSequential(Command *command, double timeout);
|
||||
void AddParallel(Command *command);
|
||||
void AddParallel(Command *command, double timeout);
|
||||
void AddSequential(Command* command);
|
||||
void AddSequential(Command* command, double timeout);
|
||||
void AddParallel(Command* command);
|
||||
void AddParallel(Command* command, double timeout);
|
||||
bool IsInterruptible() const;
|
||||
int GetSize() const;
|
||||
|
||||
@@ -59,7 +58,7 @@ class CommandGroup : public Command {
|
||||
virtual void _End();
|
||||
|
||||
private:
|
||||
void CancelConflicts(Command *command);
|
||||
void CancelConflicts(Command* command);
|
||||
|
||||
/** The commands in this group (stored in entries) */
|
||||
std::vector<CommandGroupEntry> m_commands;
|
||||
|
||||
@@ -19,11 +19,11 @@ class CommandGroupEntry {
|
||||
} Sequence;
|
||||
|
||||
CommandGroupEntry() = default;
|
||||
CommandGroupEntry(Command *command, Sequence state, double timeout = -1.0);
|
||||
CommandGroupEntry(Command* command, Sequence state, double timeout = -1.0);
|
||||
bool IsTimedOut() const;
|
||||
|
||||
double m_timeout = -1.0;
|
||||
Command *m_command = nullptr;
|
||||
Command* m_command = nullptr;
|
||||
Sequence m_state = kSequence_InSequence;
|
||||
};
|
||||
|
||||
|
||||
@@ -10,16 +10,17 @@
|
||||
|
||||
#include "Commands/Command.h"
|
||||
#include "PIDController.h"
|
||||
#include "PIDSource.h"
|
||||
#include "PIDOutput.h"
|
||||
#include "PIDSource.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
class PIDCommand : public Command, public PIDOutput, public PIDSource {
|
||||
public:
|
||||
PIDCommand(const std::string &name, double p, double i, double d);
|
||||
PIDCommand(const std::string &name, double p, double i, double d, double period);
|
||||
PIDCommand(const std::string &name, double p, double i, double d, double f,
|
||||
PIDCommand(const std::string& name, double p, double i, double d);
|
||||
PIDCommand(const std::string& name, double p, double i, double d,
|
||||
double period);
|
||||
PIDCommand(const std::string& name, double p, double i, double d, double f,
|
||||
double period);
|
||||
PIDCommand(double p, double i, double d);
|
||||
PIDCommand(double p, double i, double d, double period);
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
|
||||
#include "Commands/Subsystem.h"
|
||||
#include "PIDController.h"
|
||||
#include "PIDSource.h"
|
||||
#include "PIDOutput.h"
|
||||
#include "PIDSource.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
@@ -21,17 +21,15 @@
|
||||
* an elevator which attempts to stay at a constant height).
|
||||
*
|
||||
* <p>It provides some convenience methods to run an internal {@link
|
||||
* PIDController}.
|
||||
* It also allows access to the internal {@link PIDController} in order to give
|
||||
* total control
|
||||
* to the programmer.</p>
|
||||
* PIDController}. It also allows access to the internal {@link PIDController}
|
||||
* in order to give total control to the programmer.</p>
|
||||
*
|
||||
*/
|
||||
class PIDSubsystem : public Subsystem, public PIDOutput, public PIDSource {
|
||||
public:
|
||||
PIDSubsystem(const std::string &name, double p, double i, double d);
|
||||
PIDSubsystem(const std::string &name, double p, double i, double d, double f);
|
||||
PIDSubsystem(const std::string &name, double p, double i, double d, double f,
|
||||
PIDSubsystem(const std::string& name, double p, double i, double d);
|
||||
PIDSubsystem(const std::string& name, double p, double i, double d, double f);
|
||||
PIDSubsystem(const std::string& name, double p, double i, double d, double f,
|
||||
double period);
|
||||
PIDSubsystem(double p, double i, double d);
|
||||
PIDSubsystem(double p, double i, double d, double f);
|
||||
|
||||
@@ -8,12 +8,12 @@
|
||||
#ifndef __PRINT_COMMAND_H__
|
||||
#define __PRINT_COMMAND_H__
|
||||
|
||||
#include "Commands/Command.h"
|
||||
#include <string>
|
||||
#include "Commands/Command.h"
|
||||
|
||||
class PrintCommand : public Command {
|
||||
public:
|
||||
PrintCommand(const std::string &message);
|
||||
PrintCommand(const std::string& message);
|
||||
virtual ~PrintCommand() = default;
|
||||
|
||||
protected:
|
||||
|
||||
@@ -8,31 +8,31 @@
|
||||
#ifndef __SCHEDULER_H__
|
||||
#define __SCHEDULER_H__
|
||||
|
||||
#include "Commands/Command.h"
|
||||
#include "ErrorBase.h"
|
||||
#include "SmartDashboard/NamedSendable.h"
|
||||
#include "networktables/NetworkTable.h"
|
||||
#include "SmartDashboard/SmartDashboard.h"
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "Commands/Command.h"
|
||||
#include "ErrorBase.h"
|
||||
#include "HAL/cpp/priority_mutex.h"
|
||||
#include "SmartDashboard/NamedSendable.h"
|
||||
#include "SmartDashboard/SmartDashboard.h"
|
||||
#include "networktables/NetworkTable.h"
|
||||
|
||||
class ButtonScheduler;
|
||||
class Subsystem;
|
||||
|
||||
class Scheduler : public ErrorBase, public NamedSendable {
|
||||
public:
|
||||
static Scheduler *GetInstance();
|
||||
static Scheduler* GetInstance();
|
||||
|
||||
void AddCommand(Command *command);
|
||||
void AddButton(ButtonScheduler *button);
|
||||
void RegisterSubsystem(Subsystem *subsystem);
|
||||
void AddCommand(Command* command);
|
||||
void AddButton(ButtonScheduler* button);
|
||||
void RegisterSubsystem(Subsystem* subsystem);
|
||||
void Run();
|
||||
void Remove(Command *command);
|
||||
void Remove(Command* command);
|
||||
void RemoveAll();
|
||||
void ResetAll();
|
||||
void SetEnabled(bool enabled);
|
||||
@@ -48,16 +48,16 @@ class Scheduler : public ErrorBase, public NamedSendable {
|
||||
Scheduler();
|
||||
virtual ~Scheduler() = default;
|
||||
|
||||
void ProcessCommandAddition(Command *command);
|
||||
void ProcessCommandAddition(Command* command);
|
||||
|
||||
Command::SubsystemSet m_subsystems;
|
||||
priority_mutex m_buttonsLock;
|
||||
typedef std::vector<ButtonScheduler *> ButtonVector;
|
||||
typedef std::vector<ButtonScheduler*> ButtonVector;
|
||||
ButtonVector m_buttons;
|
||||
typedef std::vector<Command *> CommandVector;
|
||||
typedef std::vector<Command*> CommandVector;
|
||||
priority_mutex m_additionsLock;
|
||||
CommandVector m_additions;
|
||||
typedef std::set<Command *> CommandSet;
|
||||
typedef std::set<Command*> CommandSet;
|
||||
CommandSet m_commands;
|
||||
bool m_adding = false;
|
||||
bool m_enabled = true;
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
class StartCommand : public Command {
|
||||
public:
|
||||
StartCommand(Command *commandToStart);
|
||||
StartCommand(Command* commandToStart);
|
||||
virtual ~StartCommand() = default;
|
||||
|
||||
protected:
|
||||
@@ -23,7 +23,7 @@ class StartCommand : public Command {
|
||||
virtual void Interrupted();
|
||||
|
||||
private:
|
||||
Command *m_commandToFork;
|
||||
Command* m_commandToFork;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -8,10 +8,10 @@
|
||||
#ifndef __SUBSYSTEM_H__
|
||||
#define __SUBSYSTEM_H__
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include "ErrorBase.h"
|
||||
#include "SmartDashboard/NamedSendable.h"
|
||||
#include <string>
|
||||
#include <memory>
|
||||
|
||||
class Command;
|
||||
|
||||
@@ -19,21 +19,21 @@ class Subsystem : public ErrorBase, public NamedSendable {
|
||||
friend class Scheduler;
|
||||
|
||||
public:
|
||||
Subsystem(const std::string &name);
|
||||
Subsystem(const std::string& name);
|
||||
virtual ~Subsystem() = default;
|
||||
|
||||
void SetDefaultCommand(Command *command);
|
||||
Command *GetDefaultCommand();
|
||||
void SetCurrentCommand(Command *command);
|
||||
Command *GetCurrentCommand() const;
|
||||
void SetDefaultCommand(Command* command);
|
||||
Command* GetDefaultCommand();
|
||||
void SetCurrentCommand(Command* command);
|
||||
Command* GetCurrentCommand() const;
|
||||
virtual void InitDefaultCommand();
|
||||
|
||||
private:
|
||||
void ConfirmCommand();
|
||||
|
||||
Command *m_currentCommand = nullptr;
|
||||
Command* m_currentCommand = nullptr;
|
||||
bool m_currentCommandChanged = true;
|
||||
Command *m_defaultCommand = nullptr;
|
||||
Command* m_defaultCommand = nullptr;
|
||||
std::string m_name;
|
||||
bool m_initializedDefaultCommand = false;
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
class WaitCommand : public Command {
|
||||
public:
|
||||
WaitCommand(double timeout);
|
||||
WaitCommand(const std::string &name, double timeout);
|
||||
WaitCommand(const std::string& name, double timeout);
|
||||
virtual ~WaitCommand() = default;
|
||||
|
||||
protected:
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
class WaitForChildren : public Command {
|
||||
public:
|
||||
WaitForChildren(double timeout);
|
||||
WaitForChildren(const std::string &name, double timeout);
|
||||
WaitForChildren(const std::string& name, double timeout);
|
||||
virtual ~WaitForChildren() = default;
|
||||
|
||||
protected:
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
class WaitUntilCommand : public Command {
|
||||
public:
|
||||
WaitUntilCommand(double time);
|
||||
WaitUntilCommand(const std::string &name, double time);
|
||||
WaitUntilCommand(const std::string& name, double time);
|
||||
virtual ~WaitUntilCommand() = default;
|
||||
|
||||
protected:
|
||||
|
||||
@@ -8,12 +8,10 @@
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* Interface for Controllers
|
||||
* Interface for Controllers.
|
||||
* Common interface for controllers. Controllers run control loops, the most
|
||||
* common
|
||||
* are PID controllers and their variants, but this includes anything that is
|
||||
* controlling
|
||||
* an actuator in a separate thread.
|
||||
* common are PID controllers and their variants, but this includes anything
|
||||
* that is controlling an actuator in a separate thread.
|
||||
*/
|
||||
class Controller {
|
||||
public:
|
||||
|
||||
@@ -10,13 +10,14 @@
|
||||
#include "Base.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <Windows.h>
|
||||
//Windows.h defines #define GetMessage GetMessageW, which is stupid and we don't want it.
|
||||
#undef GetMessage
|
||||
#include <Windows.h>
|
||||
// Windows.h defines #define GetMessage GetMessageW, which is stupid and we
|
||||
// don't want it.
|
||||
#undef GetMessage
|
||||
#endif
|
||||
|
||||
#include <string>
|
||||
#include <stdint.h>
|
||||
#include <string>
|
||||
#include "llvm/StringRef.h"
|
||||
|
||||
// Forward declarations
|
||||
@@ -43,9 +44,9 @@ class Error {
|
||||
const ErrorBase* GetOriginatingObject() const;
|
||||
double GetTimestamp() const;
|
||||
void Clear();
|
||||
void Set(Code code, llvm::StringRef contextMessage,
|
||||
llvm::StringRef filename, llvm::StringRef function,
|
||||
uint32_t lineNumber, const ErrorBase* originatingObject);
|
||||
void Set(Code code, llvm::StringRef contextMessage, llvm::StringRef filename,
|
||||
llvm::StringRef function, uint32_t lineNumber,
|
||||
const ErrorBase* originatingObject);
|
||||
|
||||
private:
|
||||
void Report();
|
||||
|
||||
@@ -53,8 +53,7 @@
|
||||
#define wpi_setGlobalWPIErrorWithContext(error, context) \
|
||||
ErrorBase::SetGlobalWPIError((wpi_error_s_##error), (context), __FILE__, \
|
||||
__FUNCTION__, __LINE__)
|
||||
#define wpi_setGlobalWPIError(error) \
|
||||
wpi_setGlobalWPIErrorWithContext(error, "")
|
||||
#define wpi_setGlobalWPIError(error) wpi_setGlobalWPIErrorWithContext(error, "")
|
||||
|
||||
/**
|
||||
* Base class for most objects.
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
#include <initializer_list>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include "Filter.h"
|
||||
#include "CircularBuffer.h"
|
||||
#include "Filter.h"
|
||||
|
||||
/**
|
||||
* This class implements a linear, digital filter. All types of FIR and IIR
|
||||
@@ -19,7 +19,8 @@
|
||||
* used types of filters.
|
||||
*
|
||||
* Filters are of the form:
|
||||
* y[n] = (b0*x[n] + b1*x[n-1] + ... + bP*x[n-P) - (a0*y[n-1] + a2*y[n-2] + ... + aQ*y[n-Q])
|
||||
* y[n] = (b0*x[n] + b1*x[n-1] + ... + bP*x[n-P) - (a0*y[n-1] + a2*y[n-2] + ...
|
||||
* + aQ*y[n-Q])
|
||||
*
|
||||
* Where:
|
||||
* y[n] is the output at time "n"
|
||||
|
||||
@@ -9,7 +9,8 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/** GenericHID Interface
|
||||
/**
|
||||
* GenericHID Interface.
|
||||
*/
|
||||
class GenericHID {
|
||||
public:
|
||||
|
||||
@@ -7,10 +7,10 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "SensorBase.h"
|
||||
#include "PIDSource.h"
|
||||
#include "interfaces/Gyro.h"
|
||||
#include "LiveWindow/LiveWindowSendable.h"
|
||||
#include "PIDSource.h"
|
||||
#include "SensorBase.h"
|
||||
#include "interfaces/Gyro.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
@@ -18,7 +18,10 @@
|
||||
* GyroBase is the common base class for Gyro implementations such as
|
||||
* AnalogGyro.
|
||||
*/
|
||||
class GyroBase : public Gyro, public SensorBase, public PIDSource, public LiveWindowSendable {
|
||||
class GyroBase : public Gyro,
|
||||
public SensorBase,
|
||||
public PIDSource,
|
||||
public LiveWindowSendable {
|
||||
public:
|
||||
virtual ~GyroBase() = default;
|
||||
|
||||
|
||||
@@ -8,12 +8,12 @@
|
||||
#ifndef _LIVE_WINDOW_H
|
||||
#define _LIVE_WINDOW_H
|
||||
|
||||
#include "LiveWindow/LiveWindowSendable.h"
|
||||
#include "tables/ITable.h"
|
||||
#include "Commands/Scheduler.h"
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include "Commands/Scheduler.h"
|
||||
#include "LiveWindow/LiveWindowSendable.h"
|
||||
#include "tables/ITable.h"
|
||||
|
||||
struct LiveWindowComponent {
|
||||
std::string subsystem;
|
||||
@@ -37,26 +37,26 @@ struct LiveWindowComponent {
|
||||
*/
|
||||
class LiveWindow {
|
||||
public:
|
||||
static LiveWindow *GetInstance();
|
||||
static LiveWindow* GetInstance();
|
||||
void Run();
|
||||
void AddSensor(const std::string &subsystem, const std::string &name,
|
||||
LiveWindowSendable *component);
|
||||
void AddSensor(const std::string &subsystem, const std::string &name,
|
||||
LiveWindowSendable &component);
|
||||
void AddSensor(const std::string &subsystem, const std::string &name,
|
||||
void AddSensor(const std::string& subsystem, const std::string& name,
|
||||
LiveWindowSendable* component);
|
||||
void AddSensor(const std::string& subsystem, const std::string& name,
|
||||
LiveWindowSendable& component);
|
||||
void AddSensor(const std::string& subsystem, const std::string& name,
|
||||
std::shared_ptr<LiveWindowSendable> component);
|
||||
void AddActuator(const std::string &subsystem, const std::string &name,
|
||||
LiveWindowSendable *component);
|
||||
void AddActuator(const std::string &subsystem, const std::string &name,
|
||||
LiveWindowSendable &component);
|
||||
void AddActuator(const std::string &subsystem, const std::string &name,
|
||||
void AddActuator(const std::string& subsystem, const std::string& name,
|
||||
LiveWindowSendable* component);
|
||||
void AddActuator(const std::string& subsystem, const std::string& name,
|
||||
LiveWindowSendable& component);
|
||||
void AddActuator(const std::string& subsystem, const std::string& name,
|
||||
std::shared_ptr<LiveWindowSendable> component);
|
||||
|
||||
void AddSensor(std::string type, int channel, LiveWindowSendable *component);
|
||||
void AddSensor(std::string type, int channel, LiveWindowSendable* component);
|
||||
void AddActuator(std::string type, int channel,
|
||||
LiveWindowSendable *component);
|
||||
LiveWindowSendable* component);
|
||||
void AddActuator(std::string type, int module, int channel,
|
||||
LiveWindowSendable *component);
|
||||
LiveWindowSendable* component);
|
||||
|
||||
bool IsEnabled() const { return m_enabled; }
|
||||
void SetEnabled(bool enabled);
|
||||
@@ -71,12 +71,13 @@ class LiveWindow {
|
||||
void InitializeLiveWindowComponents();
|
||||
|
||||
std::vector<std::shared_ptr<LiveWindowSendable>> m_sensors;
|
||||
std::map<std::shared_ptr<LiveWindowSendable>, LiveWindowComponent> m_components;
|
||||
std::map<std::shared_ptr<LiveWindowSendable>, LiveWindowComponent>
|
||||
m_components;
|
||||
|
||||
std::shared_ptr<ITable> m_liveWindowTable;
|
||||
std::shared_ptr<ITable> m_statusTable;
|
||||
|
||||
Scheduler *m_scheduler;
|
||||
Scheduler* m_scheduler;
|
||||
|
||||
bool m_enabled = false;
|
||||
bool m_firstTime = true;
|
||||
|
||||
@@ -9,11 +9,11 @@
|
||||
|
||||
#include "Base.h"
|
||||
#include "Controller.h"
|
||||
#include "HAL/cpp/priority_mutex.h"
|
||||
#include "LiveWindow/LiveWindow.h"
|
||||
#include "Notifier.h"
|
||||
#include "PIDInterface.h"
|
||||
#include "PIDSource.h"
|
||||
#include "Notifier.h"
|
||||
#include "HAL/cpp/priority_mutex.h"
|
||||
#include "Timer.h"
|
||||
|
||||
#include <memory>
|
||||
@@ -27,17 +27,16 @@ class PIDOutput;
|
||||
* Class implements a PID Control Loop.
|
||||
*
|
||||
* Creates a separate thread which reads the given PIDSource and takes
|
||||
* care of the integral calculations, as well as writing the given
|
||||
* PIDOutput
|
||||
* care of the integral calculations, as well as writing the given PIDOutput.
|
||||
*/
|
||||
class PIDController : public LiveWindowSendable,
|
||||
public PIDInterface,
|
||||
public ITableListener {
|
||||
public:
|
||||
PIDController(float p, float i, float d, PIDSource *source, PIDOutput *output,
|
||||
PIDController(float p, float i, float d, PIDSource* source, PIDOutput* output,
|
||||
float period = 0.05);
|
||||
PIDController(float p, float i, float d, float f, PIDSource *source,
|
||||
PIDOutput *output, float period = 0.05);
|
||||
PIDController(float p, float i, float d, float f, PIDSource* source,
|
||||
PIDOutput* output, float period = 0.05);
|
||||
virtual ~PIDController();
|
||||
|
||||
PIDController(const PIDController&) = delete;
|
||||
@@ -79,26 +78,38 @@ class PIDController : public LiveWindowSendable,
|
||||
virtual void InitTable(std::shared_ptr<ITable> table) override;
|
||||
|
||||
protected:
|
||||
PIDSource *m_pidInput;
|
||||
PIDOutput *m_pidOutput;
|
||||
PIDSource* m_pidInput;
|
||||
PIDOutput* m_pidOutput;
|
||||
|
||||
std::shared_ptr<ITable> m_table;
|
||||
virtual void Calculate();
|
||||
virtual double CalculateFeedForward();
|
||||
|
||||
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 = 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
|
||||
float m_prevError = 0; // the prior error (used to compute velocity)
|
||||
double m_totalError = 0; // the sum of the errors for use in the integral calc
|
||||
// factor for "proportional" control
|
||||
float m_P;
|
||||
// factor for "integral" control
|
||||
float m_I;
|
||||
// factor for "derivative" control
|
||||
float m_D;
|
||||
// factor for "feed forward" control
|
||||
float m_F;
|
||||
// |maximum output|
|
||||
float m_maximumOutput = 1.0;
|
||||
// |minimum output|
|
||||
float m_minimumOutput = -1.0;
|
||||
// maximum input - limit setpoint to this
|
||||
float m_maximumInput = 0;
|
||||
// minimum input - limit setpoint to this
|
||||
float m_minimumInput = 0;
|
||||
// do the endpoints wrap around? eg. Absolute encoder
|
||||
bool m_continuous = false;
|
||||
// is the pid controller enabled
|
||||
bool m_enabled = false;
|
||||
// the prior error (used to compute velocity)
|
||||
float m_prevError = 0;
|
||||
// the sum of the errors for use in the integral calc
|
||||
double m_totalError = 0;
|
||||
enum {
|
||||
kAbsoluteTolerance,
|
||||
kPercentTolerance,
|
||||
@@ -123,12 +134,12 @@ class PIDController : public LiveWindowSendable,
|
||||
std::unique_ptr<Notifier> m_controlLoop;
|
||||
Timer m_setpointTimer;
|
||||
|
||||
void Initialize(float p, float i, float d, float f, PIDSource *source,
|
||||
PIDOutput *output, float period = 0.05);
|
||||
void Initialize(float p, float i, float d, float f, PIDSource* source,
|
||||
PIDOutput* output, float period = 0.05);
|
||||
|
||||
virtual std::shared_ptr<ITable> GetTable() const override;
|
||||
virtual std::string GetSmartDashboardType() const override;
|
||||
virtual void ValueChanged(ITable *source, llvm::StringRef key,
|
||||
virtual void ValueChanged(ITable* source, llvm::StringRef key,
|
||||
std::shared_ptr<nt::Value> value,
|
||||
bool isNew) override;
|
||||
virtual void UpdateTable() override;
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
* PIDOutput interface is a generic output for the PID class.
|
||||
* PWMs use this class.
|
||||
* Users implement this interface to allow for a PIDController to
|
||||
* read directly from the inputs
|
||||
* read directly from the inputs.
|
||||
*/
|
||||
class PIDOutput {
|
||||
public:
|
||||
|
||||
@@ -12,8 +12,7 @@ enum class PIDSourceType { kDisplacement, kRate };
|
||||
/**
|
||||
* PIDSource interface is a generic sensor source for the PID class.
|
||||
* All sensors that can be used with the PID class will implement the PIDSource
|
||||
* that
|
||||
* returns a standard value that will be used in the PID code.
|
||||
* that returns a standard value that will be used in the PID code.
|
||||
*/
|
||||
class PIDSource {
|
||||
public:
|
||||
|
||||
@@ -7,10 +7,10 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "ErrorBase.h"
|
||||
#include <stdint.h>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include "ErrorBase.h"
|
||||
|
||||
#include "HAL/cpp/priority_mutex.h"
|
||||
|
||||
@@ -30,10 +30,11 @@ class Resource : public ErrorBase {
|
||||
Resource(const Resource&) = delete;
|
||||
Resource& operator=(const Resource&) = delete;
|
||||
|
||||
static void CreateResourceObject(std::unique_ptr<Resource>& r, uint32_t elements);
|
||||
static void CreateResourceObject(std::unique_ptr<Resource>& r,
|
||||
uint32_t elements);
|
||||
explicit Resource(uint32_t size);
|
||||
uint32_t Allocate(const std::string &resourceDesc);
|
||||
uint32_t Allocate(uint32_t index, const std::string &resourceDesc);
|
||||
uint32_t Allocate(const std::string& resourceDesc);
|
||||
uint32_t Allocate(uint32_t index, const std::string& resourceDesc);
|
||||
void Free(uint32_t index);
|
||||
|
||||
private:
|
||||
|
||||
@@ -7,15 +7,14 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "ErrorBase.h"
|
||||
#include <stdio.h>
|
||||
#include "Base.h"
|
||||
#include "ErrorBase.h"
|
||||
|
||||
/**
|
||||
* Base class for all sensors.
|
||||
* Stores most recent status information as well as containing utility functions
|
||||
* for checking
|
||||
* channels and error processing.
|
||||
* for checking channels and error processing.
|
||||
*/
|
||||
class SensorBase : public ErrorBase {
|
||||
public:
|
||||
|
||||
@@ -20,7 +20,7 @@ class NamedSendable : public Sendable {
|
||||
public:
|
||||
/**
|
||||
* @return the name of the subtable of SmartDashboard that the Sendable object
|
||||
* will use
|
||||
* will use
|
||||
*/
|
||||
virtual std::string GetName() const = 0;
|
||||
};
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
#ifndef __SMART_DASHBOARD_DATA__
|
||||
#define __SMART_DASHBOARD_DATA__
|
||||
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include "tables/ITable.h"
|
||||
|
||||
class Sendable {
|
||||
@@ -27,7 +27,7 @@ class Sendable {
|
||||
|
||||
/**
|
||||
* @return the string representation of the named data type that will be used
|
||||
* by the smart dashboard for this sendable
|
||||
* by the smart dashboard for this sendable
|
||||
*/
|
||||
virtual std::string GetSmartDashboardType() const = 0;
|
||||
};
|
||||
|
||||
@@ -8,26 +8,22 @@
|
||||
#ifndef __SENDABLE_CHOOSER_H__
|
||||
#define __SENDABLE_CHOOSER_H__
|
||||
|
||||
#include "SmartDashboard/Sendable.h"
|
||||
#include "tables/ITable.h"
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include "SmartDashboard/Sendable.h"
|
||||
#include "tables/ITable.h"
|
||||
|
||||
/**
|
||||
* The {@link SendableChooser} class is a useful tool for presenting a selection
|
||||
* of options
|
||||
* to the {@link SmartDashboard}.
|
||||
* of options to the {@link SmartDashboard}.
|
||||
*
|
||||
* <p>For instance, you may wish to be able to select between multiple
|
||||
* autonomous modes.
|
||||
* You can do this by putting every possible {@link Command} you want to run as
|
||||
* an autonomous into
|
||||
* a {@link SendableChooser} and then put it into the {@link SmartDashboard} to
|
||||
* have a list of options
|
||||
* appear on the laptop. Once autonomous starts, simply ask the {@link
|
||||
* SendableChooser} what the selected
|
||||
* value is.</p>
|
||||
* autonomous modes. You can do this by putting every possible {@link Command}
|
||||
* you want to run as an autonomous into a {@link SendableChooser} and then put
|
||||
* it into the {@link SmartDashboard} to have a list of options appear on the
|
||||
* laptop. Once autonomous starts, simply ask the {@link SendableChooser} what
|
||||
* the selected value is.</p>
|
||||
*
|
||||
* @see SmartDashboard
|
||||
*/
|
||||
@@ -35,9 +31,9 @@ class SendableChooser : public Sendable {
|
||||
public:
|
||||
virtual ~SendableChooser() = default;
|
||||
|
||||
void AddObject(const std::string &name, void *object);
|
||||
void AddDefault(const std::string &name, void *object);
|
||||
void *GetSelected();
|
||||
void AddObject(const std::string& name, void* object);
|
||||
void AddDefault(const std::string& name, void* object);
|
||||
void* GetSelected();
|
||||
|
||||
virtual void InitTable(std::shared_ptr<ITable> subtable);
|
||||
virtual std::shared_ptr<ITable> GetTable() const;
|
||||
@@ -45,7 +41,7 @@ class SendableChooser : public Sendable {
|
||||
|
||||
private:
|
||||
std::string m_defaultChoice;
|
||||
std::map<std::string, void *> m_choices;
|
||||
std::map<std::string, void*> m_choices;
|
||||
std::shared_ptr<ITable> m_table;
|
||||
};
|
||||
|
||||
|
||||
@@ -8,20 +8,20 @@
|
||||
#ifndef __SMART_DASHBOARD_H__
|
||||
#define __SMART_DASHBOARD_H__
|
||||
|
||||
#include "SensorBase.h"
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include "SmartDashboard/Sendable.h"
|
||||
#include "SensorBase.h"
|
||||
#include "SmartDashboard/NamedSendable.h"
|
||||
#include "SmartDashboard/Sendable.h"
|
||||
#include "tables/ITable.h"
|
||||
|
||||
class SmartDashboard : public SensorBase {
|
||||
public:
|
||||
static void init();
|
||||
|
||||
static void PutData(llvm::StringRef key, Sendable *data);
|
||||
static void PutData(NamedSendable *value);
|
||||
static Sendable *GetData(llvm::StringRef keyName);
|
||||
static void PutData(llvm::StringRef key, Sendable* data);
|
||||
static void PutData(NamedSendable* value);
|
||||
static Sendable* GetData(llvm::StringRef keyName);
|
||||
|
||||
static void PutBoolean(llvm::StringRef keyName, bool value);
|
||||
static bool GetBoolean(llvm::StringRef keyName, bool defaultValue);
|
||||
@@ -44,11 +44,10 @@ class SmartDashboard : public SensorBase {
|
||||
static std::shared_ptr<ITable> m_table;
|
||||
|
||||
/**
|
||||
* A map linking tables in the SmartDashboard to the {@link
|
||||
* SmartDashboardData} objects
|
||||
* they came from.
|
||||
* A map linking tables in the SmartDashboard to the
|
||||
* {@link SmartDashboardData} objects they came from.
|
||||
*/
|
||||
static std::map<std::shared_ptr<ITable> , Sendable *> m_tablesToData;
|
||||
static std::map<std::shared_ptr<ITable>, Sendable*> m_tablesToData;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -7,11 +7,11 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "ErrorBase.h"
|
||||
#include "HAL/Task.hpp"
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
#include "ErrorBase.h"
|
||||
#include "HAL/Task.hpp"
|
||||
|
||||
/**
|
||||
* Wrapper class around std::thread that allows changing thread priority
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#include "HAL/HAL.hpp"
|
||||
#include <atomic>
|
||||
#include "HAL/HAL.hpp"
|
||||
|
||||
/**
|
||||
* Create and launch a task.
|
||||
@@ -24,10 +24,11 @@ Task::Task(const std::string& name, Function&& function, Args&&... args) {
|
||||
|
||||
m_thread = std::thread(std::forward<std::decay_t<Function>>(function),
|
||||
std::forward<Args>(args)...);
|
||||
//TODO: lvuser does not currently have permissions to set the priority.
|
||||
//SetPriority(kDefaultPriority);
|
||||
// TODO: lvuser does not currently have permissions to set the priority.
|
||||
// SetPriority(kDefaultPriority);
|
||||
|
||||
static std::atomic<int32_t> instances{0};
|
||||
instances++;
|
||||
HALReport(HALUsageReporting::kResourceType_Task, instances, 0, m_taskName.c_str());
|
||||
HALReport(HALUsageReporting::kResourceType_Task, instances, 0,
|
||||
m_taskName.c_str());
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include "Base.h"
|
||||
#include "HAL/cpp/priority_mutex.h"
|
||||
|
||||
typedef void (*TimerInterruptHandler)(void *param);
|
||||
typedef void (*TimerInterruptHandler)(void* param);
|
||||
|
||||
void Wait(double seconds);
|
||||
double GetClock();
|
||||
@@ -19,12 +19,10 @@ double GetTime();
|
||||
/**
|
||||
* Timer objects measure accumulated time in seconds.
|
||||
* The timer object functions like a stopwatch. It can be started, stopped, and
|
||||
* cleared. When the
|
||||
* timer is running its value counts up in seconds. When stopped, the timer
|
||||
* holds the current
|
||||
* value. The implementation simply records the time when started and subtracts
|
||||
* the current time
|
||||
* whenever the value is requested.
|
||||
* cleared. When the timer is running its value counts up in seconds. When
|
||||
* stopped, the timer holds the current value. The implementation simply records
|
||||
* the time when started and subtracts the current time whenever the value is
|
||||
* requested.
|
||||
*/
|
||||
class Timer {
|
||||
public:
|
||||
|
||||
@@ -31,17 +31,17 @@
|
||||
wpi_assertNotEqual_impl(a, b, #a, #b, message, __FILE__, __LINE__, \
|
||||
__FUNCTION__)
|
||||
|
||||
bool wpi_assert_impl(bool conditionValue, const char *conditionText,
|
||||
const char *message, const char *fileName,
|
||||
uint32_t lineNumber, const char *funcName);
|
||||
bool wpi_assertEqual_impl(int valueA, int valueB, const char *valueAString,
|
||||
const char *valueBString, const char *message,
|
||||
const char *fileName, uint32_t lineNumber,
|
||||
const char *funcName);
|
||||
bool wpi_assertNotEqual_impl(int valueA, int valueB, const char *valueAString,
|
||||
const char *valueBString, const char *message,
|
||||
const char *fileName, uint32_t lineNumber,
|
||||
const char *funcName);
|
||||
bool wpi_assert_impl(bool conditionValue, const char* conditionText,
|
||||
const char* message, const char* fileName,
|
||||
uint32_t lineNumber, const char* funcName);
|
||||
bool wpi_assertEqual_impl(int valueA, int valueB, const char* valueAString,
|
||||
const char* valueBString, const char* message,
|
||||
const char* fileName, uint32_t lineNumber,
|
||||
const char* funcName);
|
||||
bool wpi_assertNotEqual_impl(int valueA, int valueB, const char* valueAString,
|
||||
const char* valueBString, const char* message,
|
||||
const char* fileName, uint32_t lineNumber,
|
||||
const char* funcName);
|
||||
|
||||
void wpi_suspendOnAssertEnabled(bool enabled);
|
||||
|
||||
|
||||
@@ -11,11 +11,11 @@
|
||||
|
||||
#ifdef WPI_ERRORS_DEFINE_STRINGS
|
||||
#define S(label, offset, message) \
|
||||
const char * wpi_error_s_##label = message; \
|
||||
const char* wpi_error_s_##label = message; \
|
||||
const int32_t wpi_error_value_##label = offset
|
||||
#else
|
||||
#define S(label, offset, message) \
|
||||
extern const char * wpi_error_s_##label; \
|
||||
extern const char* wpi_error_s_##label; \
|
||||
const int32_t wpi_error_value_##label = offset
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user