mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-29 02:21:44 +00:00
Reflowed comments and removed commented out code (#735)
This commit is contained in:
committed by
Peter Johnson
parent
1e8d18b328
commit
c663d7cd16
@@ -21,40 +21,19 @@ namespace frc {
|
||||
* ADXL345 Accelerometer on I2C.
|
||||
*
|
||||
* This class allows access to a Analog Devices ADXL345 3-axis accelerometer on
|
||||
* an I2C bus.
|
||||
* This class assumes the default (not alternate) sensor address of 0x1D (7-bit
|
||||
* address).
|
||||
* an I2C bus. This class assumes the default (not alternate) sensor address of
|
||||
* 0x1D (7-bit address).
|
||||
*/
|
||||
class ADXL345_I2C : public Accelerometer, public LiveWindowSendable {
|
||||
protected:
|
||||
static const int kAddress = 0x1D;
|
||||
static const int kPowerCtlRegister = 0x2D;
|
||||
static const int kDataFormatRegister = 0x31;
|
||||
static const int kDataRegister = 0x32;
|
||||
static constexpr double kGsPerLSB = 0.00390625;
|
||||
enum PowerCtlFields {
|
||||
kPowerCtl_Link = 0x20,
|
||||
kPowerCtl_AutoSleep = 0x10,
|
||||
kPowerCtl_Measure = 0x08,
|
||||
kPowerCtl_Sleep = 0x04
|
||||
};
|
||||
enum DataFormatFields {
|
||||
kDataFormat_SelfTest = 0x80,
|
||||
kDataFormat_SPI = 0x40,
|
||||
kDataFormat_IntInvert = 0x20,
|
||||
kDataFormat_FullRes = 0x08,
|
||||
kDataFormat_Justify = 0x04
|
||||
};
|
||||
|
||||
public:
|
||||
enum Axes { kAxis_X = 0x00, kAxis_Y = 0x02, kAxis_Z = 0x04 };
|
||||
|
||||
struct AllAxes {
|
||||
double XAxis;
|
||||
double YAxis;
|
||||
double ZAxis;
|
||||
};
|
||||
|
||||
public:
|
||||
explicit ADXL345_I2C(I2C::Port port, Range range = kRange_2G,
|
||||
int deviceAddress = kAddress);
|
||||
virtual ~ADXL345_I2C() = default;
|
||||
@@ -80,6 +59,27 @@ class ADXL345_I2C : public Accelerometer, public LiveWindowSendable {
|
||||
protected:
|
||||
I2C m_i2c;
|
||||
|
||||
static const int kAddress = 0x1D;
|
||||
static const int kPowerCtlRegister = 0x2D;
|
||||
static const int kDataFormatRegister = 0x31;
|
||||
static const int kDataRegister = 0x32;
|
||||
static constexpr double kGsPerLSB = 0.00390625;
|
||||
|
||||
enum PowerCtlFields {
|
||||
kPowerCtl_Link = 0x20,
|
||||
kPowerCtl_AutoSleep = 0x10,
|
||||
kPowerCtl_Measure = 0x08,
|
||||
kPowerCtl_Sleep = 0x04
|
||||
};
|
||||
|
||||
enum DataFormatFields {
|
||||
kDataFormat_SelfTest = 0x80,
|
||||
kDataFormat_SPI = 0x40,
|
||||
kDataFormat_IntInvert = 0x20,
|
||||
kDataFormat_FullRes = 0x08,
|
||||
kDataFormat_Justify = 0x04
|
||||
};
|
||||
|
||||
private:
|
||||
nt::NetworkTableEntry m_xEntry;
|
||||
nt::NetworkTableEntry m_yEntry;
|
||||
|
||||
@@ -25,32 +25,12 @@ class DigitalOutput;
|
||||
* ADXL345 Accelerometer on SPI.
|
||||
*
|
||||
* This class allows access to an Analog Devices ADXL345 3-axis accelerometer
|
||||
* via SPI.
|
||||
* This class assumes the sensor is wired in 4-wire SPI mode.
|
||||
* via SPI. This class assumes the sensor is wired in 4-wire SPI mode.
|
||||
*/
|
||||
class ADXL345_SPI : public Accelerometer, public LiveWindowSendable {
|
||||
protected:
|
||||
static const int kPowerCtlRegister = 0x2D;
|
||||
static const int kDataFormatRegister = 0x31;
|
||||
static const int kDataRegister = 0x32;
|
||||
static constexpr double kGsPerLSB = 0.00390625;
|
||||
enum SPIAddressFields { kAddress_Read = 0x80, kAddress_MultiByte = 0x40 };
|
||||
enum PowerCtlFields {
|
||||
kPowerCtl_Link = 0x20,
|
||||
kPowerCtl_AutoSleep = 0x10,
|
||||
kPowerCtl_Measure = 0x08,
|
||||
kPowerCtl_Sleep = 0x04
|
||||
};
|
||||
enum DataFormatFields {
|
||||
kDataFormat_SelfTest = 0x80,
|
||||
kDataFormat_SPI = 0x40,
|
||||
kDataFormat_IntInvert = 0x20,
|
||||
kDataFormat_FullRes = 0x08,
|
||||
kDataFormat_Justify = 0x04
|
||||
};
|
||||
|
||||
public:
|
||||
enum Axes { kAxis_X = 0x00, kAxis_Y = 0x02, kAxis_Z = 0x04 };
|
||||
|
||||
struct AllAxes {
|
||||
double XAxis;
|
||||
double YAxis;
|
||||
@@ -82,6 +62,28 @@ class ADXL345_SPI : public Accelerometer, public LiveWindowSendable {
|
||||
protected:
|
||||
SPI m_spi;
|
||||
|
||||
static const int kPowerCtlRegister = 0x2D;
|
||||
static const int kDataFormatRegister = 0x31;
|
||||
static const int kDataRegister = 0x32;
|
||||
static constexpr double kGsPerLSB = 0.00390625;
|
||||
|
||||
enum SPIAddressFields { kAddress_Read = 0x80, kAddress_MultiByte = 0x40 };
|
||||
|
||||
enum PowerCtlFields {
|
||||
kPowerCtl_Link = 0x20,
|
||||
kPowerCtl_AutoSleep = 0x10,
|
||||
kPowerCtl_Measure = 0x08,
|
||||
kPowerCtl_Sleep = 0x04
|
||||
};
|
||||
|
||||
enum DataFormatFields {
|
||||
kDataFormat_SelfTest = 0x80,
|
||||
kDataFormat_SPI = 0x40,
|
||||
kDataFormat_IntInvert = 0x20,
|
||||
kDataFormat_FullRes = 0x08,
|
||||
kDataFormat_Justify = 0x04
|
||||
};
|
||||
|
||||
private:
|
||||
nt::NetworkTableEntry m_xEntry;
|
||||
nt::NetworkTableEntry m_yEntry;
|
||||
|
||||
@@ -16,6 +16,7 @@ namespace frc {
|
||||
|
||||
/**
|
||||
* Use a rate gyro to return the robots heading relative to a starting position.
|
||||
*
|
||||
* The Gyro class tracks the robots heading based on the starting position. As
|
||||
* the robot rotates the new heading is computed by integrating the rate of
|
||||
* rotation returned by the sensor. When the class is instantiated, it does a
|
||||
|
||||
@@ -20,6 +20,7 @@ namespace frc {
|
||||
|
||||
/**
|
||||
* Handle operation of an analog accelerometer.
|
||||
*
|
||||
* The accelerometer reads acceleration directly through the sensor. Many
|
||||
* sensors have multiple axis and can be treated as multiple devices. Each is
|
||||
* calibrated by finding the center value over a period of time.
|
||||
|
||||
@@ -26,8 +26,8 @@ namespace frc {
|
||||
*
|
||||
* Connected to each analog channel is an averaging and oversampling engine.
|
||||
* This engine accumulates the specified ( by SetAverageBits() and
|
||||
* SetOversampleBits() ) number of samples before returning a new value. This
|
||||
* is not a sliding window average. The only difference between the oversampled
|
||||
* SetOversampleBits() ) number of samples before returning a new value. This is
|
||||
* not a sliding window average. The only difference between the oversampled
|
||||
* samples and the averaged samples is that the oversampled samples are simply
|
||||
* accumulated effectively increasing the resolution, while the averaged samples
|
||||
* are divided by the number of samples to retain the resolution, but get more
|
||||
|
||||
@@ -18,30 +18,30 @@
|
||||
namespace frc {
|
||||
|
||||
/**
|
||||
* Class for reading analog potentiometers. Analog potentiometers read
|
||||
* in an analog voltage that corresponds to a position. The position is
|
||||
* in whichever units you choose, by way of the scaling and offset
|
||||
* constants passed to the constructor.
|
||||
* Class for reading analog potentiometers. Analog potentiometers read in an
|
||||
* analog voltage that corresponds to a position. The position is in whichever
|
||||
* units you choose, by way of the scaling and offset constants passed to the
|
||||
* constructor.
|
||||
*/
|
||||
class AnalogPotentiometer : public Potentiometer, public LiveWindowSendable {
|
||||
public:
|
||||
/**
|
||||
* AnalogPotentiometer constructor.
|
||||
*
|
||||
* Use the fullRange and offset values so that the output produces
|
||||
* meaningful values. I.E: you have a 270 degree potentiometer and
|
||||
* you want the output to be degrees with the halfway point as 0
|
||||
* degrees. The fullRange value is 270.0(degrees) and the offset is
|
||||
* -135.0 since the halfway point after scaling is 135 degrees.
|
||||
* Use the fullRange and offset values so that the output produces meaningful
|
||||
* values. I.E: you have a 270 degree potentiometer and you want the output to
|
||||
* be degrees with the halfway point as 0 degrees. The fullRange value is
|
||||
* 270.0 degrees and the offset is -135.0 since the halfway point after
|
||||
* scaling is 135 degrees.
|
||||
*
|
||||
* This will calculate the result from the fullRange times the
|
||||
* fraction of the supply voltage, plus the offset.
|
||||
* This will calculate the result from the fullRange times the fraction of the
|
||||
* supply voltage, plus the offset.
|
||||
*
|
||||
* @param channel The analog channel this potentiometer is plugged into.
|
||||
* @param channel The analog channel this potentiometer is plugged into.
|
||||
* @param fullRange The scaling to multiply the voltage by to get a meaningful
|
||||
* unit.
|
||||
* @param offset The offset to add to the scaled value for controlling the
|
||||
* zero value
|
||||
* unit.
|
||||
* @param offset The offset to add to the scaled value for controlling the
|
||||
* zero value.
|
||||
*/
|
||||
explicit AnalogPotentiometer(int channel, double fullRange = 1.0,
|
||||
double offset = 0.0);
|
||||
|
||||
@@ -15,14 +15,13 @@ namespace frc {
|
||||
/**
|
||||
* This class provides an easy way to link commands to OI inputs.
|
||||
*
|
||||
* It is very easy to link a button to a command. For instance, you could
|
||||
* link the trigger button of a joystick to a "score" command.
|
||||
* It is very easy to link a button to a command. For instance, you could link
|
||||
* the trigger button of a joystick to a "score" command.
|
||||
*
|
||||
* This class represents a subclass of Trigger that is specifically aimed at
|
||||
* buttons on an operator interface as a common use case of the more generalized
|
||||
* Trigger objects. This is a simple wrapper around Trigger with the method
|
||||
* names
|
||||
* renamed to fit the Button object use.
|
||||
* names renamed to fit the Button object use.
|
||||
*/
|
||||
class Button : public Trigger {
|
||||
public:
|
||||
|
||||
@@ -20,17 +20,15 @@ class Command;
|
||||
/**
|
||||
* This class provides an easy way to link commands to inputs.
|
||||
*
|
||||
* It is very easy to link a polled input to a command. For instance, you could
|
||||
* It is very easy to link a polled input to a command. For instance, you could
|
||||
* link the trigger button of a joystick to a "score" command or an encoder
|
||||
* reaching
|
||||
* a particular value.
|
||||
* reaching a particular value.
|
||||
*
|
||||
* It is encouraged that teams write a subclass of Trigger if they want to have
|
||||
* something unusual (for instance, if they want to react to the user holding
|
||||
* a button while the robot is reading a certain sensor input). For this, they
|
||||
* a button while the robot is reading a certain sensor input). For this, they
|
||||
* only have to write the {@link Trigger#Get()} method to get the full
|
||||
* functionality
|
||||
* of the Trigger class.
|
||||
* functionality of the Trigger class.
|
||||
*/
|
||||
class Trigger : public Sendable {
|
||||
public:
|
||||
|
||||
@@ -36,7 +36,7 @@ class CANSpeedController : public SpeedController {
|
||||
kTemperatureFault = 2,
|
||||
kBusVoltageFault = 4,
|
||||
kGateDriverFault = 8,
|
||||
/* SRX extensions */
|
||||
// SRX extensions
|
||||
kFwdLimitSwitch = 0x10,
|
||||
kRevLimitSwitch = 0x20,
|
||||
kFwdSoftLimit = 0x40,
|
||||
@@ -46,22 +46,34 @@ class CANSpeedController : public SpeedController {
|
||||
enum Limits { kForwardLimit = 1, kReverseLimit = 2 };
|
||||
|
||||
enum NeutralMode {
|
||||
/** Use the NeutralMode that is set by the jumper wire on the CAN device */
|
||||
/**
|
||||
* Use the NeutralMode that is set by the jumper wire on the CAN device
|
||||
*/
|
||||
kNeutralMode_Jumper = 0,
|
||||
/** Stop the motor's rotation by applying a force. */
|
||||
/**
|
||||
* Stop the motor's rotation by applying a force.
|
||||
*/
|
||||
kNeutralMode_Brake = 1,
|
||||
/** Do not attempt to stop the motor. Instead allow it to coast to a stop
|
||||
without applying resistance. */
|
||||
/**
|
||||
* Do not attempt to stop the motor. Instead allow it to coast to a stop
|
||||
* without applying resistance.
|
||||
*/
|
||||
kNeutralMode_Coast = 2
|
||||
};
|
||||
|
||||
enum LimitMode {
|
||||
/** Only use switches for limits */
|
||||
/**
|
||||
* Only use switches for limits
|
||||
*/
|
||||
kLimitMode_SwitchInputsOnly = 0,
|
||||
/** Use both switches and soft limits */
|
||||
/**
|
||||
* Use both switches and soft limits
|
||||
*/
|
||||
kLimitMode_SoftPositionLimits = 1,
|
||||
/* SRX extensions */
|
||||
/** Disable switches and disable soft limits */
|
||||
// SRX extensions
|
||||
/**
|
||||
* Disable switches and disable soft limits
|
||||
*/
|
||||
kLimitMode_SrxDisableSwitchInputs = 2,
|
||||
};
|
||||
|
||||
@@ -98,9 +110,6 @@ class CANSpeedController : public SpeedController {
|
||||
virtual void ConfigReverseLimit(double reverseLimitPosition) = 0;
|
||||
virtual void ConfigMaxOutputVoltage(double voltage) = 0;
|
||||
virtual void ConfigFaultTime(double faultTime) = 0;
|
||||
// Hold off on interface until we figure out ControlMode enums.
|
||||
// virtual void SetControlMode(ControlMode mode) = 0;
|
||||
// virtual ControlMode GetControlMode() const = 0;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
|
||||
@@ -27,6 +27,7 @@ namespace frc {
|
||||
|
||||
/**
|
||||
* Singleton class for creating and keeping camera servers.
|
||||
*
|
||||
* Also publishes camera information to NetworkTables.
|
||||
*/
|
||||
class CameraServer : public ErrorBase {
|
||||
@@ -42,26 +43,25 @@ class CameraServer : public ErrorBase {
|
||||
static CameraServer* GetInstance();
|
||||
|
||||
#ifdef __linux__
|
||||
// USBCamera does not work on anything except linux
|
||||
// USBCamera does not work on anything except Linux.
|
||||
/**
|
||||
* Start automatically capturing images to send to the dashboard.
|
||||
*
|
||||
* <p>You should call this method to see a camera feed on the dashboard.
|
||||
* If you also want to perform vision processing on the roboRIO, use
|
||||
* getVideo() to get access to the camera images.
|
||||
* You should call this method to see a camera feed on the dashboard. If you
|
||||
* also want to perform vision processing on the roboRIO, use getVideo() to
|
||||
* get access to the camera images.
|
||||
*
|
||||
* The first time this overload is called, it calls
|
||||
* {@link #StartAutomaticCapture(int)} with device 0, creating a camera
|
||||
* named "USB Camera 0". Subsequent calls increment the device number
|
||||
* (e.g. 1, 2, etc).
|
||||
* The first time this overload is called, it calls StartAutomaticCapture()
|
||||
* with device 0, creating a camera named "USB Camera 0". Subsequent calls
|
||||
* increment the device number (e.g. 1, 2, etc).
|
||||
*/
|
||||
cs::UsbCamera StartAutomaticCapture();
|
||||
|
||||
/**
|
||||
* Start automatically capturing images to send to the dashboard.
|
||||
*
|
||||
* <p>This overload calls {@link #StartAutomaticCapture(String, int)} with
|
||||
* a name of "USB Camera {dev}".
|
||||
* This overload calls StartAutomaticCapture() with a name of "USB Camera
|
||||
* {dev}".
|
||||
*
|
||||
* @param dev The device number of the camera interface
|
||||
*/
|
||||
@@ -71,7 +71,7 @@ class CameraServer : public ErrorBase {
|
||||
* Start automatically capturing images to send to the dashboard.
|
||||
*
|
||||
* @param name The name to give the camera
|
||||
* @param dev The device number of the camera interface
|
||||
* @param dev The device number of the camera interface
|
||||
*/
|
||||
cs::UsbCamera StartAutomaticCapture(llvm::StringRef name, int dev);
|
||||
|
||||
@@ -96,8 +96,7 @@ class CameraServer : public ErrorBase {
|
||||
/**
|
||||
* Adds an Axis IP camera.
|
||||
*
|
||||
* <p>This overload calls {@link #AddAxisCamera(String, String)} with
|
||||
* name "Axis Camera".
|
||||
* This overload calls AddAxisCamera() with name "Axis Camera".
|
||||
*
|
||||
* @param host Camera host IP or DNS name (e.g. "10.x.y.11")
|
||||
*/
|
||||
@@ -106,8 +105,7 @@ class CameraServer : public ErrorBase {
|
||||
/**
|
||||
* Adds an Axis IP camera.
|
||||
*
|
||||
* <p>This overload calls {@link #AddAxisCamera(String, String)} with
|
||||
* name "Axis Camera".
|
||||
* This overload calls AddAxisCamera() with name "Axis Camera".
|
||||
*
|
||||
* @param host Camera host IP or DNS name (e.g. "10.x.y.11")
|
||||
*/
|
||||
@@ -116,8 +114,7 @@ class CameraServer : public ErrorBase {
|
||||
/**
|
||||
* Adds an Axis IP camera.
|
||||
*
|
||||
* <p>This overload calls {@link #AddAxisCamera(String, String)} with
|
||||
* name "Axis Camera".
|
||||
* This overload calls AddAxisCamera() with name "Axis Camera".
|
||||
*
|
||||
* @param host Camera host IP or DNS name (e.g. "10.x.y.11")
|
||||
*/
|
||||
@@ -126,8 +123,7 @@ class CameraServer : public ErrorBase {
|
||||
/**
|
||||
* Adds an Axis IP camera.
|
||||
*
|
||||
* <p>This overload calls {@link #AddAxisCamera(String, String[])} with
|
||||
* name "Axis Camera".
|
||||
* This overload calls AddAxisCamera() with name "Axis Camera".
|
||||
*
|
||||
* @param hosts Array of Camera host IPs/DNS names
|
||||
*/
|
||||
@@ -136,8 +132,7 @@ class CameraServer : public ErrorBase {
|
||||
/**
|
||||
* Adds an Axis IP camera.
|
||||
*
|
||||
* <p>This overload calls {@link #AddAxisCamera(String, String[])} with
|
||||
* name "Axis Camera".
|
||||
* This overload calls AddAxisCamera() with name "Axis Camera".
|
||||
*
|
||||
* @param hosts Array of Camera host IPs/DNS names
|
||||
*/
|
||||
@@ -253,8 +248,8 @@ class CameraServer : public ErrorBase {
|
||||
/**
|
||||
* Get server for the primary camera feed.
|
||||
*
|
||||
* <p>This is only valid to call after a camera feed has been added
|
||||
* with StartAutomaticCapture() or AddServer().
|
||||
* This is only valid to call after a camera feed has been added with
|
||||
* StartAutomaticCapture() or AddServer().
|
||||
*/
|
||||
cs::VideoSink GetServer();
|
||||
|
||||
@@ -285,7 +280,7 @@ class CameraServer : public ErrorBase {
|
||||
* StartAutomaticCapture method.
|
||||
*
|
||||
* @deprecated Use SetResolution on the UsbCamera returned by
|
||||
* StartAutomaticCapture() instead.
|
||||
* StartAutomaticCapture() instead.
|
||||
* @param size The size to use
|
||||
*/
|
||||
void SetSize(int size);
|
||||
|
||||
@@ -22,29 +22,24 @@ 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.
|
||||
*
|
||||
* <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>
|
||||
* Every command can be started with a call to Start(). Once a command is
|
||||
* started it will call Initialize(), and then will repeatedly call Execute()
|
||||
* until the IsFinished() returns true. Once it does,End() will be called.
|
||||
*
|
||||
* <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
|
||||
* in its constructor. Note that a Command may have multiple requirements, and
|
||||
* {@link Command#Requires(Subsystem) Requires(...)} should be called for each
|
||||
* one.</p>
|
||||
* However, if at any point while it is running Cancel() is called, then the
|
||||
* command will be stopped and Interrupted() will be called.
|
||||
*
|
||||
* <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>
|
||||
* If a command uses a Subsystem, then it should specify that it does so by
|
||||
* calling the Requires() method in its constructor. Note that a Command may
|
||||
* have multiple requirements, and Requires() should be called for each one.
|
||||
*
|
||||
* 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 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.
|
||||
*
|
||||
* @see CommandGroup
|
||||
* @see Subsystem
|
||||
@@ -88,19 +83,19 @@ class Command : public ErrorBase, public NamedSendable {
|
||||
|
||||
/**
|
||||
* Returns whether this command is finished.
|
||||
* 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>
|
||||
* If it is, then the command will be removed and End() will be called.
|
||||
*
|
||||
* <p>Returning false will result in the command never ending automatically.
|
||||
* It may be useful for a team to reference the IsTimedOut() method for
|
||||
* time-sensitive commands.
|
||||
*
|
||||
* Returning false will result in the command never ending automatically.
|
||||
* It may still be cancelled manually or interrupted by another command.
|
||||
* Returning true will result in the command executing once and finishing
|
||||
* immediately. We recommend using {@link InstantCommand} for this.</p>
|
||||
* immediately. We recommend using InstantCommand for this.
|
||||
*
|
||||
* @return whether this command is finished.
|
||||
* @see Command#isTimedOut() isTimedOut()
|
||||
* @return Whether this command is finished.
|
||||
* @see IsTimedOut()
|
||||
*/
|
||||
virtual bool IsFinished() = 0;
|
||||
|
||||
@@ -117,42 +112,41 @@ class Command : public ErrorBase, public NamedSendable {
|
||||
|
||||
private:
|
||||
void LockChanges();
|
||||
/*synchronized*/ void Removed();
|
||||
void Removed();
|
||||
void StartRunning();
|
||||
void StartTiming();
|
||||
|
||||
/** The name of this command */
|
||||
// The name of this command
|
||||
std::string m_name;
|
||||
|
||||
/** The time since this command was initialized */
|
||||
// The time since this command was initialized
|
||||
double m_startTime = -1;
|
||||
|
||||
/** The time (in seconds) before this command "times out" (or -1 if no
|
||||
* timeout) */
|
||||
// The time (in seconds) before this command "times out" (-1 if no timeout)
|
||||
double m_timeout;
|
||||
|
||||
/** Whether or not this command has been initialized */
|
||||
// Whether or not this command has been initialized
|
||||
bool m_initialized = false;
|
||||
|
||||
/** The requirements (or null if no requirements) */
|
||||
// The requirements (or null if no requirements)
|
||||
SubsystemSet m_requirements;
|
||||
|
||||
/** Whether or not it is running */
|
||||
// Whether or not it is running
|
||||
bool m_running = false;
|
||||
|
||||
/** Whether or not it is interruptible*/
|
||||
// Whether or not it is interruptible
|
||||
bool m_interruptible = true;
|
||||
|
||||
/** Whether or not it has been canceled */
|
||||
// Whether or not it has been canceled
|
||||
bool m_canceled = false;
|
||||
|
||||
/** Whether or not it has been locked */
|
||||
// Whether or not it has been locked
|
||||
bool m_locked = false;
|
||||
|
||||
/** Whether this command should run when the robot is disabled */
|
||||
// Whether this command should run when the robot is disabled
|
||||
bool m_runWhenDisabled = false;
|
||||
|
||||
/** The {@link CommandGroup} this is in */
|
||||
// The CommandGroup this is in
|
||||
CommandGroup* m_parent = nullptr;
|
||||
|
||||
int m_commandID = m_commandCounter++;
|
||||
|
||||
@@ -17,21 +17,18 @@
|
||||
namespace frc {
|
||||
|
||||
/**
|
||||
* A {@link CommandGroup} is a list of commands which are executed in sequence.
|
||||
* A 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>
|
||||
* Commands in a CommandGroup are added using the AddSequential() method and are
|
||||
* called sequentially. CommandGroups are themselves Commands and can be given
|
||||
* to other CommandGroups.
|
||||
*
|
||||
* <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>
|
||||
* CommandGroups will carry all of the requirements of their Command
|
||||
* subcommands. Additional requirements can be specified by calling Requires()
|
||||
* normally in the constructor.
|
||||
*
|
||||
* <p>CommandGroups can also execute commands in parallel, simply by adding them
|
||||
* using {@link CommandGroup#AddParallel(Command) AddParallel(...)}.</p>
|
||||
* CommandGroups can also execute commands in parallel, simply by adding them
|
||||
* using AddParallel().
|
||||
*
|
||||
* @see Command
|
||||
* @see Subsystem
|
||||
@@ -63,13 +60,13 @@ class CommandGroup : public Command {
|
||||
private:
|
||||
void CancelConflicts(Command* command);
|
||||
|
||||
/** The commands in this group (stored in entries) */
|
||||
// The commands in this group (stored in entries)
|
||||
std::vector<CommandGroupEntry> m_commands;
|
||||
|
||||
/** The active children in this group (stored in entries) */
|
||||
// The active children in this group (stored in entries)
|
||||
std::list<CommandGroupEntry> m_children;
|
||||
|
||||
/** The current command, -1 signifies that none have been run */
|
||||
// The current command, -1 signifies that none have been run
|
||||
int m_currentCommandIndex = -1;
|
||||
};
|
||||
|
||||
|
||||
@@ -15,25 +15,17 @@
|
||||
namespace frc {
|
||||
|
||||
/**
|
||||
* A {@link ConditionalCommand} is a {@link Command} that starts one of two
|
||||
* commands.
|
||||
* A ConditionalCommand is a Command that starts one of two commands.
|
||||
*
|
||||
* <p>
|
||||
* A {@link ConditionalCommand} uses m_condition to determine whether it should
|
||||
* run m_onTrue or m_onFalse.
|
||||
* </p>
|
||||
* A ConditionalCommand uses m_condition to determine whether it should run
|
||||
* m_onTrue or m_onFalse.
|
||||
*
|
||||
* <p>
|
||||
* A {@link ConditionalCommand} adds the proper {@link Command} to the {@link
|
||||
* Scheduler} during {@link ConditionalCommand#initialize()} and then {@link
|
||||
* ConditionalCommand#isFinished()} will return true once that {@link Command}
|
||||
* has finished executing.
|
||||
* </p>
|
||||
* A ConditionalCommand adds the proper Command to the Scheduler during
|
||||
* Initialize() and then IsFinished() will return true once that Command has
|
||||
* finished executing.
|
||||
*
|
||||
* <p>
|
||||
* If no {@link Command} is specified for m_onFalse, the occurrence of that
|
||||
* condition will be a no-op.
|
||||
* </p>
|
||||
* If no Command is specified for m_onFalse, the occurrence of that condition
|
||||
* will be a no-op.
|
||||
*
|
||||
* @see Command
|
||||
* @see Scheduler
|
||||
@@ -59,21 +51,13 @@ class ConditionalCommand : public Command {
|
||||
void Interrupted() override;
|
||||
|
||||
private:
|
||||
/**
|
||||
* The Command to execute if {@link ConditionalCommand#Condition()} returns
|
||||
* true
|
||||
*/
|
||||
// The Command to execute if Condition() returns true
|
||||
Command* m_onTrue;
|
||||
|
||||
/**
|
||||
* The Command to execute if {@link ConditionalCommand#Condition()} returns
|
||||
* false
|
||||
*/
|
||||
// The Command to execute if Condition() returns false
|
||||
Command* m_onFalse;
|
||||
|
||||
/**
|
||||
* Stores command chosen by condition
|
||||
*/
|
||||
// Stores command chosen by condition
|
||||
Command* m_chosenCommand = nullptr;
|
||||
};
|
||||
|
||||
|
||||
@@ -16,8 +16,7 @@ namespace frc {
|
||||
/**
|
||||
* This command will execute once, then finish immediately afterward.
|
||||
*
|
||||
* <p>Subclassing {@link InstantCommand} is shorthand for returning true from
|
||||
* {@link Command isFinished}.
|
||||
* Subclassing InstantCommand is shorthand for returning true from IsFinished().
|
||||
*/
|
||||
class InstantCommand : public Command {
|
||||
public:
|
||||
|
||||
@@ -50,7 +50,7 @@ class PIDCommand : public Command, public PIDOutput, public PIDSource {
|
||||
virtual void UsePIDOutput(double output) = 0;
|
||||
|
||||
private:
|
||||
/** The internal {@link PIDController} */
|
||||
// The internal PIDController
|
||||
std::shared_ptr<PIDController> m_controller;
|
||||
|
||||
public:
|
||||
|
||||
@@ -18,14 +18,13 @@
|
||||
namespace frc {
|
||||
|
||||
/**
|
||||
* This class is designed to handle the case where there is a {@link Subsystem}
|
||||
* which uses a single {@link PIDController} almost constantly (for instance,
|
||||
* 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>
|
||||
* This class is designed to handle the case where there is a Subsystem which
|
||||
* uses a single PIDController almost constantly (for instance, an elevator
|
||||
* which attempts to stay at a constant height).
|
||||
*
|
||||
* It provides some convenience methods to run an internal PIDController. It
|
||||
* also allows access to the internal PIDController in order to give total
|
||||
* control to the programmer.
|
||||
*/
|
||||
class PIDSubsystem : public Subsystem, public PIDOutput, public PIDSource {
|
||||
public:
|
||||
@@ -65,7 +64,7 @@ class PIDSubsystem : public Subsystem, public PIDOutput, public PIDSource {
|
||||
virtual void UsePIDOutput(double output) = 0;
|
||||
|
||||
private:
|
||||
/** The internal {@link PIDController} */
|
||||
// The internal PIDController
|
||||
std::shared_ptr<PIDController> m_controller;
|
||||
|
||||
public:
|
||||
|
||||
@@ -14,8 +14,9 @@
|
||||
namespace frc {
|
||||
|
||||
/**
|
||||
* A {@link TimedCommand} will wait for a timeout before finishing.
|
||||
* {@link TimedCommand} is used to execute a command for a given amount of time.
|
||||
* A TimedCommand will wait for a timeout before finishing.
|
||||
*
|
||||
* TimedCommand is used to execute a command for a given amount of time.
|
||||
*/
|
||||
class TimedCommand : public Command {
|
||||
public:
|
||||
|
||||
@@ -20,11 +20,13 @@ namespace frc {
|
||||
|
||||
/**
|
||||
* Class for operating a compressor connected to a %PCM (Pneumatic Control
|
||||
* Module). The %PCM will automatically run in closed loop mode by default
|
||||
* whenever a Solenoid object is created. For most cases, a Compressor object
|
||||
* does not need to be instantiated or used in a robot program. This class is
|
||||
* only required in cases where the robot program needs a more detailed status
|
||||
* of the compressor or to enable/disable closed loop control.
|
||||
* Module).
|
||||
*
|
||||
* The PCM will automatically run in closed loop mode by default whenever a
|
||||
* Solenoid object is created. For most cases, a Compressor object does not need
|
||||
* to be instantiated or used in a robot program. This class is only required in
|
||||
* cases where the robot program needs a more detailed status of the compressor
|
||||
* or to enable/disable closed loop control.
|
||||
*
|
||||
* Note: you cannot operate the compressor directly from this class as doing so
|
||||
* would circumvent the safety provided by using the pressure switch and closed
|
||||
|
||||
@@ -11,6 +11,7 @@ namespace frc {
|
||||
|
||||
/**
|
||||
* 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.
|
||||
|
||||
@@ -43,6 +43,7 @@ class Counter : public SensorBase,
|
||||
kPulseLength = 2,
|
||||
kExternalDirection = 3
|
||||
};
|
||||
|
||||
explicit Counter(Mode mode = kTwoPulse);
|
||||
explicit Counter(int channel);
|
||||
explicit Counter(DigitalSource* source);
|
||||
@@ -104,13 +105,15 @@ class Counter : public SensorBase,
|
||||
protected:
|
||||
// Makes the counter count up.
|
||||
std::shared_ptr<DigitalSource> m_upSource;
|
||||
|
||||
// Makes the counter count down.
|
||||
std::shared_ptr<DigitalSource> m_downSource;
|
||||
|
||||
// The FPGA counter object
|
||||
HAL_CounterHandle m_counter = HAL_kInvalidHandle;
|
||||
|
||||
private:
|
||||
int m_index = 0; ///< The index of this counter.
|
||||
int m_index = 0; // The index of this counter.
|
||||
|
||||
nt::NetworkTableEntry m_valueEntry;
|
||||
friend class DigitalGlitchFilter;
|
||||
|
||||
@@ -11,6 +11,7 @@ namespace frc {
|
||||
|
||||
/**
|
||||
* Interface for counting the number of ticks on a digital input channel.
|
||||
*
|
||||
* Encoders, Gear tooth sensors, and counters should all subclass this so it can
|
||||
* be used to build more advanced classes for control and driving.
|
||||
*
|
||||
|
||||
@@ -22,6 +22,7 @@ class Counter;
|
||||
|
||||
/**
|
||||
* Class to enable glitch filtering on a set of digital inputs.
|
||||
*
|
||||
* This class will manage adding and removing digital inputs from a FPGA glitch
|
||||
* filter. The filter lets the user configure the time that an input must remain
|
||||
* high or low before it is classified as high or low.
|
||||
@@ -46,7 +47,7 @@ class DigitalGlitchFilter : public SensorBase {
|
||||
uint64_t GetPeriodNanoSeconds();
|
||||
|
||||
private:
|
||||
// Sets the filter for the input to be the requested index. A value of 0
|
||||
// Sets the filter for the input to be the requested index. A value of 0
|
||||
// disables the filter, and the filter value must be between 1 and 3,
|
||||
// inclusive.
|
||||
void DoAdd(DigitalSource* input, int requested_index);
|
||||
|
||||
@@ -20,6 +20,7 @@ class DigitalGlitchFilter;
|
||||
|
||||
/**
|
||||
* Class to read a digital input.
|
||||
*
|
||||
* This class will read digital inputs and return the current value on the
|
||||
* channel. Other devices such as encoders, gear tooth sensors, etc. that are
|
||||
* implemented elsewhere will automatically allocate digital inputs and outputs
|
||||
|
||||
@@ -20,6 +20,7 @@ namespace frc {
|
||||
|
||||
/**
|
||||
* Class to write to digital outputs.
|
||||
*
|
||||
* Write values to the digital output channels. Other devices implemented
|
||||
* elsewhere will allocate channels automatically so for those devices it
|
||||
* shouldn't be done here.
|
||||
|
||||
@@ -15,13 +15,12 @@ namespace frc {
|
||||
|
||||
/**
|
||||
* DigitalSource Interface.
|
||||
*
|
||||
* The DigitalSource represents all the possible inputs for a counter or a
|
||||
* quadrature encoder. The source may be
|
||||
* either a digital input or an analog input. If the caller just provides a
|
||||
* channel, then a digital input will be
|
||||
* quadrature encoder. The source may be either a digital input or an analog
|
||||
* input. If the caller just provides a channel, then a digital input will be
|
||||
* constructed and freed when finished for the source. The source can either be
|
||||
* a digital input or analog trigger
|
||||
* but not both.
|
||||
* a digital input or analog trigger but not both.
|
||||
*/
|
||||
class DigitalSource : public InterruptableSensorBase {
|
||||
public:
|
||||
|
||||
@@ -44,10 +44,10 @@ class DoubleSolenoid : public SolenoidBase, public LiveWindowSendable {
|
||||
void InitTable(std::shared_ptr<nt::NetworkTable> subTable);
|
||||
|
||||
private:
|
||||
int m_forwardChannel; ///< The forward channel on the module to control.
|
||||
int m_reverseChannel; ///< The reverse channel on the module to control.
|
||||
int m_forwardMask; ///< The mask for the forward channel.
|
||||
int m_reverseMask; ///< The mask for the reverse channel.
|
||||
int m_forwardChannel; // The forward channel on the module to control.
|
||||
int m_reverseChannel; // The reverse channel on the module to control.
|
||||
int m_forwardMask; // The mask for the forward channel.
|
||||
int m_reverseMask; // The mask for the reverse channel.
|
||||
HAL_SolenoidHandle m_forwardHandle = HAL_kInvalidHandle;
|
||||
HAL_SolenoidHandle m_reverseHandle = HAL_kInvalidHandle;
|
||||
|
||||
|
||||
@@ -83,24 +83,39 @@ class DriverStation : public SensorBase, public RobotStateInterface {
|
||||
double GetMatchTime() const;
|
||||
double GetBatteryVoltage() const;
|
||||
|
||||
/** Only to be used to tell the Driver Station what code you claim to be
|
||||
* executing for diagnostic purposes only
|
||||
/**
|
||||
* Only to be used to tell the Driver Station what code you claim to be
|
||||
* executing for diagnostic purposes only.
|
||||
*
|
||||
* @param entering If true, starting disabled code; if false, leaving disabled
|
||||
* code */
|
||||
* code.
|
||||
*/
|
||||
void InDisabled(bool entering) { m_userInDisabled = entering; }
|
||||
/** Only to be used to tell the Driver Station what code you claim to be
|
||||
* executing for diagnostic purposes only
|
||||
|
||||
/**
|
||||
* Only to be used to tell the Driver Station what code you claim to be
|
||||
* executing for diagnostic purposes only.
|
||||
*
|
||||
* @param entering If true, starting autonomous code; if false, leaving
|
||||
* autonomous code */
|
||||
* autonomous code.
|
||||
*/
|
||||
void InAutonomous(bool entering) { m_userInAutonomous = entering; }
|
||||
/** Only to be used to tell the Driver Station what code you claim to be
|
||||
* executing for diagnostic purposes only
|
||||
|
||||
/**
|
||||
* Only to be used to tell the Driver Station what code you claim to be
|
||||
* executing for diagnostic purposes only.
|
||||
*
|
||||
* @param entering If true, starting teleop code; if false, leaving teleop
|
||||
* code */
|
||||
* code.
|
||||
*/
|
||||
void InOperatorControl(bool entering) { m_userInTeleop = entering; }
|
||||
/** Only to be used to tell the Driver Station what code you claim to be
|
||||
* executing for diagnostic purposes only
|
||||
* @param entering If true, starting test code; if false, leaving test code */
|
||||
|
||||
/**
|
||||
* Only to be used to tell the Driver Station what code you claim to be
|
||||
* executing for diagnostic purposes only.
|
||||
*
|
||||
* @param entering If true, starting test code; if false, leaving test code.
|
||||
*/
|
||||
void InTest(bool entering) { m_userInTest = entering; }
|
||||
|
||||
protected:
|
||||
@@ -108,6 +123,7 @@ class DriverStation : public SensorBase, public RobotStateInterface {
|
||||
|
||||
private:
|
||||
DriverStation();
|
||||
|
||||
void ReportJoystickUnpluggedError(llvm::StringRef message);
|
||||
void ReportJoystickUnpluggedWarning(llvm::StringRef message);
|
||||
void Run();
|
||||
|
||||
@@ -98,8 +98,8 @@ class Encoder : public SensorBase,
|
||||
|
||||
double DecodingScaleFactor() const;
|
||||
|
||||
std::shared_ptr<DigitalSource> m_aSource; // the A phase of the quad encoder
|
||||
std::shared_ptr<DigitalSource> m_bSource; // the B phase of the quad encoder
|
||||
std::shared_ptr<DigitalSource> m_aSource; // The A phase of the quad encoder
|
||||
std::shared_ptr<DigitalSource> m_bSource; // The B phase of the quad encoder
|
||||
std::unique_ptr<DigitalSource> m_indexSource = nullptr;
|
||||
HAL_EncoderHandle m_encoder = HAL_kInvalidHandle;
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
|
||||
namespace frc {
|
||||
|
||||
// Forward declarations
|
||||
class ErrorBase;
|
||||
|
||||
/**
|
||||
|
||||
@@ -65,10 +65,10 @@ namespace frc {
|
||||
|
||||
/**
|
||||
* Base class for most objects.
|
||||
*
|
||||
* ErrorBase is the base class for most objects since it holds the generated
|
||||
* error
|
||||
* for that object. In addition, there is a single instance of a global error
|
||||
* object
|
||||
* error for that object. In addition, there is a single instance of a global
|
||||
* error object.
|
||||
*/
|
||||
class ErrorBase {
|
||||
// TODO: Consider initializing instance variables and cleanup in destructor
|
||||
@@ -113,6 +113,7 @@ class ErrorBase {
|
||||
|
||||
protected:
|
||||
mutable Error m_error;
|
||||
|
||||
// TODO: Replace globalError with a global list of all errors.
|
||||
static wpi::mutex _globalErrorMutex;
|
||||
static Error _globalError;
|
||||
|
||||
@@ -16,19 +16,22 @@ namespace frc {
|
||||
|
||||
/**
|
||||
* Alias for counter class.
|
||||
* Implement the gear tooth sensor supplied by FIRST. Currently there is no
|
||||
*
|
||||
* Implements the gear tooth sensor supplied by FIRST. Currently there is no
|
||||
* reverse sensing on the gear tooth sensor, but in future versions we might
|
||||
* implement the necessary timing in the FPGA to sense direction.
|
||||
*/
|
||||
class GearTooth : public Counter {
|
||||
public:
|
||||
/// 55 uSec for threshold
|
||||
// 55 uSec for threshold
|
||||
static constexpr double kGearToothThreshold = 55e-6;
|
||||
|
||||
explicit GearTooth(int channel, bool directionSensitive = false);
|
||||
explicit GearTooth(DigitalSource* source, bool directionSensitive = false);
|
||||
explicit GearTooth(std::shared_ptr<DigitalSource> source,
|
||||
bool directionSensitive = false);
|
||||
virtual ~GearTooth() = default;
|
||||
|
||||
void EnableDirectionSensing(bool directionSensitive);
|
||||
|
||||
std::string GetSmartDashboardType() const override;
|
||||
|
||||
@@ -20,7 +20,6 @@ namespace frc {
|
||||
*
|
||||
* This class is intended to be used by sensor (and other I2C device) drivers.
|
||||
* It probably should not be used directly.
|
||||
*
|
||||
*/
|
||||
class I2C : SensorBase {
|
||||
public:
|
||||
@@ -39,7 +38,6 @@ class I2C : SensorBase {
|
||||
bool WriteBulk(uint8_t* data, int count);
|
||||
bool Read(int registerAddress, int count, uint8_t* data);
|
||||
bool ReadOnly(int count, uint8_t* buffer);
|
||||
// void Broadcast(int registerAddress, uint8_t data);
|
||||
bool VerifySensor(int registerAddress, int count, const uint8_t* expected);
|
||||
|
||||
private:
|
||||
|
||||
@@ -28,22 +28,33 @@ class InterruptableSensorBase : public SensorBase {
|
||||
|
||||
virtual HAL_Handle GetPortHandleForRouting() const = 0;
|
||||
virtual AnalogTriggerType GetAnalogTriggerTypeForRouting() const = 0;
|
||||
virtual void RequestInterrupts(
|
||||
HAL_InterruptHandlerFunction handler,
|
||||
void* param); ///< Asynchronus handler version.
|
||||
virtual void RequestInterrupts(); ///< Synchronus Wait version.
|
||||
virtual void
|
||||
CancelInterrupts(); ///< Free up the underlying chipobject functions.
|
||||
virtual WaitResult WaitForInterrupt(
|
||||
double timeout,
|
||||
bool ignorePrevious = true); ///< Synchronus version.
|
||||
virtual void
|
||||
EnableInterrupts(); ///< Enable interrupts - after finishing setup.
|
||||
virtual void DisableInterrupts(); ///< Disable, but don't deallocate.
|
||||
virtual double ReadRisingTimestamp(); ///< Return the timestamp for the
|
||||
/// rising interrupt that occurred.
|
||||
virtual double ReadFallingTimestamp(); ///< Return the timestamp for the
|
||||
/// falling interrupt that occurred.
|
||||
|
||||
// Asynchronous handler version.
|
||||
virtual void RequestInterrupts(HAL_InterruptHandlerFunction handler,
|
||||
void* param);
|
||||
|
||||
// Synchronous wait version.
|
||||
virtual void RequestInterrupts();
|
||||
|
||||
// Free up the underlying ChipObject functions.
|
||||
virtual void CancelInterrupts();
|
||||
|
||||
// Synchronous version.
|
||||
virtual WaitResult WaitForInterrupt(double timeout,
|
||||
bool ignorePrevious = true);
|
||||
|
||||
// Enable interrupts - after finishing setup.
|
||||
virtual void EnableInterrupts();
|
||||
|
||||
// Disable, but don't deallocate.
|
||||
virtual void DisableInterrupts();
|
||||
|
||||
// Return the timestamp for the rising interrupt that occurred.
|
||||
virtual double ReadRisingTimestamp();
|
||||
|
||||
// Return the timestamp for the falling interrupt that occurred.
|
||||
virtual double ReadFallingTimestamp();
|
||||
|
||||
virtual void SetUpSourceEdge(bool risingEdge, bool fallingEdge);
|
||||
|
||||
protected:
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace frc {
|
||||
|
||||
/**
|
||||
* Luminary Micro / Vex Robotics Jaguar Speed Controller with PWM control
|
||||
* Luminary Micro / Vex Robotics Jaguar Speed Controller with PWM control.
|
||||
*/
|
||||
class Jaguar : public PWMSpeedController {
|
||||
public:
|
||||
|
||||
@@ -34,8 +34,7 @@ struct LiveWindowComponent {
|
||||
|
||||
/**
|
||||
* The LiveWindow class is the public interface for putting sensors and
|
||||
* actuators
|
||||
* on the LiveWindow.
|
||||
* actuators on the LiveWindow.
|
||||
*/
|
||||
class LiveWindow {
|
||||
public:
|
||||
|
||||
@@ -17,20 +17,18 @@ namespace frc {
|
||||
class LiveWindowSendable : public Sendable {
|
||||
public:
|
||||
/**
|
||||
* Update the table for this sendable object with the latest
|
||||
* values.
|
||||
* Update the table for this sendable object with the latest values.
|
||||
*/
|
||||
virtual void UpdateTable() = 0;
|
||||
|
||||
/**
|
||||
* Start having this sendable object automatically respond to
|
||||
* value changes reflect the value on the table.
|
||||
* Start having this sendable object automatically respond to value changes
|
||||
* reflect the value on the table.
|
||||
*/
|
||||
virtual void StartLiveWindowMode() = 0;
|
||||
|
||||
/**
|
||||
* Stop having this sendable object automatically respond to value
|
||||
* changes.
|
||||
* Stop having this sendable object automatically respond to value changes.
|
||||
*/
|
||||
virtual void StopLiveWindowMode() = 0;
|
||||
};
|
||||
|
||||
@@ -31,19 +31,25 @@ class MotorSafetyHelper : public ErrorBase {
|
||||
static void CheckMotors();
|
||||
|
||||
private:
|
||||
// the expiration time for this object
|
||||
// The expiration time for this object
|
||||
double m_expiration;
|
||||
// true if motor safety is enabled for this motor
|
||||
|
||||
// True if motor safety is enabled for this motor
|
||||
bool m_enabled;
|
||||
// the FPGA clock value when this motor has expired
|
||||
|
||||
// The FPGA clock value when this motor has expired
|
||||
double m_stopTime;
|
||||
// protect accesses to the state for this object
|
||||
|
||||
// Protect accesses to the state for this object
|
||||
mutable wpi::mutex m_syncMutex;
|
||||
// the object that is using the helper
|
||||
|
||||
// The object that is using the helper
|
||||
MotorSafety* m_safeObject;
|
||||
|
||||
// List of all existing MotorSafetyHelper objects.
|
||||
static std::set<MotorSafetyHelper*> m_helperList;
|
||||
// protect accesses to the list of helpers
|
||||
|
||||
// Protect accesses to the list of helpers
|
||||
static wpi::mutex m_listMutex;
|
||||
};
|
||||
|
||||
|
||||
@@ -41,24 +41,31 @@ class Notifier : public ErrorBase {
|
||||
void Stop();
|
||||
|
||||
private:
|
||||
// update the HAL alarm
|
||||
// Update the HAL alarm
|
||||
void UpdateAlarm();
|
||||
|
||||
// HAL callback
|
||||
static void Notify(uint64_t currentTimeInt, HAL_NotifierHandle handle);
|
||||
|
||||
// used to constrain execution between destructors and callback
|
||||
// Used to constrain execution between destructors and callback
|
||||
static wpi::mutex m_destructorMutex;
|
||||
// held while updating process information
|
||||
|
||||
// Held while updating process information
|
||||
wpi::mutex m_processMutex;
|
||||
|
||||
// HAL handle, atomic for proper destruction
|
||||
std::atomic<HAL_NotifierHandle> m_notifier{0};
|
||||
// address of the handler
|
||||
|
||||
// Address of the handler
|
||||
TimerEventHandler m_handler;
|
||||
// the absolute expiration time
|
||||
|
||||
// The absolute expiration time
|
||||
double m_expirationTime = 0;
|
||||
// the relative time (either periodic or single)
|
||||
|
||||
// The relative time (either periodic or single)
|
||||
double m_period = 0;
|
||||
// true if this is a periodic event
|
||||
|
||||
// True if this is a periodic event
|
||||
bool m_periodic = false;
|
||||
};
|
||||
|
||||
|
||||
@@ -30,8 +30,8 @@ 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.
|
||||
* Creates a separate thread which reads the given PIDSource and takes care of
|
||||
* the integral calculations, as well as writing the given PIDOutput.
|
||||
*
|
||||
* This feedback controller runs in discrete time, so time deltas are not used
|
||||
* in the integral and derivative calculations. Therefore, the sample rate
|
||||
@@ -105,38 +105,51 @@ class PIDController : public LiveWindowSendable, public PIDInterface {
|
||||
double GetContinuousError(double error) const;
|
||||
|
||||
private:
|
||||
// factor for "proportional" control
|
||||
// Factor for "proportional" control
|
||||
double m_P;
|
||||
// factor for "integral" control
|
||||
|
||||
// Factor for "integral" control
|
||||
double m_I;
|
||||
// factor for "derivative" control
|
||||
|
||||
// Factor for "derivative" control
|
||||
double m_D;
|
||||
// factor for "feed forward" control
|
||||
|
||||
// Factor for "feed forward" control
|
||||
double m_F;
|
||||
|
||||
// |maximum output|
|
||||
double m_maximumOutput = 1.0;
|
||||
|
||||
// |minimum output|
|
||||
double m_minimumOutput = -1.0;
|
||||
// maximum input - limit setpoint to this
|
||||
|
||||
// Maximum input - limit setpoint to this
|
||||
double m_maximumInput = 0;
|
||||
// minimum input - limit setpoint to this
|
||||
|
||||
// Minimum input - limit setpoint to this
|
||||
double m_minimumInput = 0;
|
||||
// do the endpoints wrap around? eg. Absolute encoder
|
||||
|
||||
// Do the endpoints wrap around? eg. Absolute encoder
|
||||
bool m_continuous = false;
|
||||
// is the pid controller enabled
|
||||
|
||||
// Is the pid controller enabled
|
||||
bool m_enabled = false;
|
||||
// the prior error (used to compute velocity)
|
||||
|
||||
// The prior error (used to compute velocity)
|
||||
double m_prevError = 0;
|
||||
// the sum of the errors for use in the integral calc
|
||||
|
||||
// The sum of the errors for use in the integral calc
|
||||
double m_totalError = 0;
|
||||
|
||||
enum {
|
||||
kAbsoluteTolerance,
|
||||
kPercentTolerance,
|
||||
kNoTolerance
|
||||
} m_toleranceType = kNoTolerance;
|
||||
|
||||
// the percetage or absolute error that is considered on target.
|
||||
// The percetage or absolute error that is considered on target.
|
||||
double m_tolerance = 0.05;
|
||||
|
||||
double m_setpoint = 0;
|
||||
double m_prevSetpoint = 0;
|
||||
double m_error = 0;
|
||||
@@ -145,6 +158,7 @@ class PIDController : public LiveWindowSendable, public PIDInterface {
|
||||
|
||||
// Length of buffer for averaging for tolerances.
|
||||
std::atomic<unsigned> m_bufLength{1};
|
||||
|
||||
std::queue<double> m_buf;
|
||||
double m_bufTotal = 0;
|
||||
|
||||
|
||||
@@ -13,9 +13,9 @@ namespace frc {
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* PWMs use this class. Users implement this interface to allow for a
|
||||
* PIDController to read directly from the inputs.
|
||||
*/
|
||||
class PIDOutput {
|
||||
public:
|
||||
|
||||
@@ -13,6 +13,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.
|
||||
*/
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
namespace frc {
|
||||
|
||||
/**
|
||||
* Common base class for all PWM Speed Controllers
|
||||
* Common base class for all PWM Speed Controllers.
|
||||
*/
|
||||
class PWMSpeedController : public SafePWM, public SpeedController {
|
||||
public:
|
||||
|
||||
@@ -12,7 +12,8 @@
|
||||
namespace frc {
|
||||
|
||||
/**
|
||||
* Cross the Road Electronics (CTRE) Talon SRX Speed Controller with PWM control
|
||||
* Cross the Road Electronics (CTRE) Talon SRX Speed Controller with PWM
|
||||
* control.
|
||||
*/
|
||||
class PWMTalonSRX : public PWMSpeedController {
|
||||
public:
|
||||
|
||||
@@ -22,15 +22,15 @@ namespace frc {
|
||||
* The preferences class provides a relatively simple way to save important
|
||||
* values to the roboRIO to access the next time the roboRIO is booted.
|
||||
*
|
||||
* <p>This class loads and saves from a file inside the roboRIO. The user can
|
||||
* not access the file directly, but may modify values at specific fields which
|
||||
* will then be automatically periodically saved to the file by the NetworkTable
|
||||
* server.</p>
|
||||
* This class loads and saves from a file inside the roboRIO. The user cannot
|
||||
* access the file directly, but may modify values at specific fields which will
|
||||
* then be automatically periodically saved to the file by the NetworkTable
|
||||
* server.
|
||||
*
|
||||
* <p>This class is thread safe.</p>
|
||||
* This class is thread safe.
|
||||
*
|
||||
* <p>This will also interact with {@link NetworkTable} by creating a table
|
||||
* called "Preferences" with all the key-value pairs.</p>
|
||||
* This will also interact with {@link NetworkTable} by creating a table called
|
||||
* "Preferences" with all the key-value pairs.
|
||||
*/
|
||||
class Preferences : public ErrorBase {
|
||||
public:
|
||||
|
||||
@@ -24,12 +24,13 @@ class MotorSafetyHelper;
|
||||
|
||||
/**
|
||||
* Class for Spike style relay outputs.
|
||||
*
|
||||
* Relays are intended to be connected to spikes or similar relays. The relay
|
||||
* channels controls a pair of pins that are either both off, one on, the other
|
||||
* on, or both on. This translates into two spike outputs at 0v, one at 12v and
|
||||
* one at 0v, one at 0v and the other at 12v, or two spike outputs at 12V. This
|
||||
* allows off, full forward, or full reverse control of motors without variable
|
||||
* speed. It also allows the two channels (forward and reverse) to be used
|
||||
* speed. It also allows the two channels (forward and reverse) to be used
|
||||
* independently for something that does not care about voltage polarity (like
|
||||
* a solenoid).
|
||||
*/
|
||||
|
||||
@@ -21,12 +21,13 @@ namespace frc {
|
||||
|
||||
/**
|
||||
* The Resource class is a convenient way to track allocated resources.
|
||||
* It tracks them as indicies in the range [0 .. elements - 1].
|
||||
* E.g. the library uses this to track hardware channel allocation.
|
||||
*
|
||||
* It tracks them as indicies in the range [0 .. elements - 1]. E.g. the library
|
||||
* uses this to track hardware channel allocation.
|
||||
*
|
||||
* The Resource class does not allocate the hardware channels or other
|
||||
* resources; it just tracks which indices were marked in use by
|
||||
* Allocate and not yet freed by Free.
|
||||
* resources; it just tracks which indices were marked in use by Allocate and
|
||||
* not yet freed by Free.
|
||||
*/
|
||||
class Resource : public ErrorBase {
|
||||
public:
|
||||
|
||||
@@ -33,6 +33,7 @@ class DriverStation;
|
||||
|
||||
/**
|
||||
* Implement a Robot Program framework.
|
||||
*
|
||||
* The RobotBase class is intended to be subclassed by a user creating a robot
|
||||
* program. Overridden Autonomous() and OperatorControl() methods are called at
|
||||
* the appropriate time as the match proceeds. In the current implementation,
|
||||
|
||||
@@ -24,6 +24,7 @@ class GenericHID;
|
||||
/**
|
||||
* Utility class for handling Robot drive based on a definition of the motor
|
||||
* configuration.
|
||||
*
|
||||
* The robot drive class handles basic driving for a robot. Currently, 2 and 4
|
||||
* motor tank and mecanum drive trains are supported. In the future other drive
|
||||
* types like swerve might be implemented. Motor channel numbers are passed
|
||||
@@ -115,6 +116,7 @@ class RobotDrive : public MotorSafety, public ErrorBase {
|
||||
static const int kMaxNumberOfMotors = 4;
|
||||
double m_sensitivity = 0.5;
|
||||
double m_maxOutput = 1.0;
|
||||
|
||||
std::shared_ptr<SpeedController> m_frontLeftMotor;
|
||||
std::shared_ptr<SpeedController> m_frontRightMotor;
|
||||
std::shared_ptr<SpeedController> m_rearLeftMotor;
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace frc {
|
||||
|
||||
/**
|
||||
* Mindsensors SD540 Speed Controller
|
||||
* Mindsensors SD540 Speed Controller.
|
||||
*/
|
||||
class SD540 : public PWMSpeedController {
|
||||
public:
|
||||
|
||||
@@ -28,6 +28,7 @@ class DigitalInput;
|
||||
class SPI : public SensorBase {
|
||||
public:
|
||||
enum Port { kOnboardCS0 = 0, kOnboardCS1, kOnboardCS2, kOnboardCS3, kMXP };
|
||||
|
||||
explicit SPI(Port port);
|
||||
virtual ~SPI();
|
||||
|
||||
@@ -67,9 +68,9 @@ class SPI : public SensorBase {
|
||||
|
||||
protected:
|
||||
HAL_SPIPort m_port;
|
||||
bool m_msbFirst = false; // default little-endian
|
||||
bool m_sampleOnTrailing = false; // default data updated on falling edge
|
||||
bool m_clk_idle_high = false; // default clock active high
|
||||
bool m_msbFirst = false; // Default little-endian
|
||||
bool m_sampleOnTrailing = false; // Default data updated on falling edge
|
||||
bool m_clk_idle_high = false; // Default clock active high
|
||||
|
||||
private:
|
||||
void Init();
|
||||
|
||||
@@ -19,6 +19,7 @@ namespace frc {
|
||||
|
||||
/**
|
||||
* A safe version of the PWM class.
|
||||
*
|
||||
* It is safe because it implements the MotorSafety interface that provides
|
||||
* timeouts in the event that the motor value is not updated before the
|
||||
* expiration time. This delegates the actual work to a MotorSafetyHelper
|
||||
|
||||
@@ -14,6 +14,7 @@ namespace frc {
|
||||
|
||||
/**
|
||||
* Base class for all sensors.
|
||||
*
|
||||
* Stores most recent status information as well as containing utility functions
|
||||
* for checking channels and error processing.
|
||||
*/
|
||||
|
||||
@@ -36,18 +36,22 @@ class SerialPort : public ErrorBase {
|
||||
kParity_Mark = 3,
|
||||
kParity_Space = 4
|
||||
};
|
||||
|
||||
enum StopBits {
|
||||
kStopBits_One = 10,
|
||||
kStopBits_OnePointFive = 15,
|
||||
kStopBits_Two = 20
|
||||
};
|
||||
|
||||
enum FlowControl {
|
||||
kFlowControl_None = 0,
|
||||
kFlowControl_XonXoff = 1,
|
||||
kFlowControl_RtsCts = 2,
|
||||
kFlowControl_DtrDsr = 4
|
||||
};
|
||||
|
||||
enum WriteBufferMode { kFlushOnAccess = 1, kFlushWhenFull = 2 };
|
||||
|
||||
enum Port { kOnboard = 0, kMXP = 1, kUSB = 2, kUSB1 = 2, kUSB2 = 3 };
|
||||
|
||||
SerialPort(int baudRate, Port port = kOnboard, int dataBits = 8,
|
||||
|
||||
@@ -20,8 +20,7 @@ namespace frc {
|
||||
* Standard hobby style servo.
|
||||
*
|
||||
* The range parameters default to the appropriate values for the Hitec HS-322HD
|
||||
* servo provided
|
||||
* in the FIRST Kit of Parts in 2008.
|
||||
* servo provided in the FIRST Kit of Parts in 2008.
|
||||
*/
|
||||
class Servo : public SafePWM {
|
||||
public:
|
||||
|
||||
@@ -15,13 +15,12 @@ namespace frc {
|
||||
|
||||
/**
|
||||
* The interface for sendable objects that gives the sendable a default name in
|
||||
* the Smart Dashboard
|
||||
*
|
||||
* the Smart Dashboard.
|
||||
*/
|
||||
class NamedSendable : public Sendable {
|
||||
public:
|
||||
/**
|
||||
* @return the name of the subtable of SmartDashboard that the Sendable object
|
||||
* @return The name of the subtable of SmartDashboard that the Sendable object
|
||||
* will use
|
||||
*/
|
||||
virtual std::string GetName() const = 0;
|
||||
|
||||
@@ -18,12 +18,13 @@ class Sendable {
|
||||
public:
|
||||
/**
|
||||
* Initializes a table for this sendable object.
|
||||
*
|
||||
* @param subtable The table to put the values in.
|
||||
*/
|
||||
virtual void InitTable(std::shared_ptr<nt::NetworkTable> subtable) = 0;
|
||||
|
||||
/**
|
||||
* @return the string representation of the named data type that will be used
|
||||
* @return The string representation of the named data type that will be used
|
||||
* by the smart dashboard for this sendable
|
||||
*/
|
||||
virtual std::string GetSmartDashboardType() const = 0;
|
||||
|
||||
@@ -20,15 +20,14 @@
|
||||
namespace frc {
|
||||
|
||||
/**
|
||||
* The {@link SendableChooser} class is a useful tool for presenting a selection
|
||||
* of options to the {@link SmartDashboard}.
|
||||
* The SendableChooser class is a useful tool for presenting a selection of
|
||||
* options to the 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>
|
||||
* For instance, you may wish to be able to select between multiple autonomous
|
||||
* modes. You can do this by putting every possible Command you want to run as
|
||||
* an autonomous into a SendableChooser and then put it into the SmartDashboard
|
||||
* to have a list of options appear on the laptop. Once autonomous starts,
|
||||
* simply ask the SendableChooser what the selected value is.
|
||||
*
|
||||
* @tparam T The type of values to be stored
|
||||
* @see SmartDashboard
|
||||
|
||||
@@ -18,8 +18,8 @@ namespace frc {
|
||||
/**
|
||||
* Adds the given object to the list of options.
|
||||
*
|
||||
* On the {@link SmartDashboard} on the desktop, the object will appear as the
|
||||
* given name.
|
||||
* On the SmartDashboard on the desktop, the object will appear as the given
|
||||
* name.
|
||||
*
|
||||
* @param name the name of the option
|
||||
* @param object the option
|
||||
@@ -32,9 +32,8 @@ void SendableChooser<T>::AddObject(llvm::StringRef name, T object) {
|
||||
/**
|
||||
* Add the given object to the list of options and marks it as the default.
|
||||
*
|
||||
* Functionally, this is very close to {@link SendableChooser#AddObject(const
|
||||
* char *name, void *object) AddObject(...)} except that it will use this as
|
||||
* the default option if none other is explicitly selected.
|
||||
* Functionally, this is very close to AddObject() except that it will use this
|
||||
* as the default option if none other is explicitly selected.
|
||||
*
|
||||
* @param name the name of the option
|
||||
* @param object the option
|
||||
@@ -49,12 +48,12 @@ void SendableChooser<T>::AddDefault(llvm::StringRef name, T object) {
|
||||
* Returns a copy of the selected option (a raw pointer U* if T =
|
||||
* std::unique_ptr<U> or a std::weak_ptr<U> if T = std::shared_ptr<U>).
|
||||
*
|
||||
* If there is none selected, it will return the default. If there is none
|
||||
* If there is none selected, it will return the default. If there is none
|
||||
* selected and no default, then it will return a value-initialized instance.
|
||||
* For integer types, this is 0. For container types like std::string, this is
|
||||
* an empty string.
|
||||
*
|
||||
* @return the option selected
|
||||
* @return The option selected
|
||||
*/
|
||||
template <class T>
|
||||
auto SendableChooser<T>::GetSelected()
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
namespace frc {
|
||||
|
||||
/**
|
||||
* This class is a non-template base class for {@link SendableChooser}.
|
||||
* This class is a non-template base class for SendableChooser.
|
||||
*
|
||||
* It contains static, non-templated variables to avoid their duplication in the
|
||||
* template class.
|
||||
|
||||
@@ -41,7 +41,7 @@ class Solenoid : public SolenoidBase, public LiveWindowSendable {
|
||||
|
||||
private:
|
||||
HAL_SolenoidHandle m_solenoidHandle = HAL_kInvalidHandle;
|
||||
int m_channel; ///< The channel on the module to control.
|
||||
int m_channel; // The channel on the module to control
|
||||
nt::NetworkTableEntry m_valueEntry;
|
||||
NT_EntryListener m_valueListener = 0;
|
||||
};
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace frc {
|
||||
|
||||
/**
|
||||
* REV Robotics Speed Controller
|
||||
* REV Robotics Speed Controller.
|
||||
*/
|
||||
class Spark : public PWMSpeedController {
|
||||
public:
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace frc {
|
||||
|
||||
/**
|
||||
* Cross the Road Electronics (CTRE) Talon and Talon SR Speed Controller
|
||||
* Cross the Road Electronics (CTRE) Talon and Talon SR Speed Controller.
|
||||
*/
|
||||
class Talon : public PWMSpeedController {
|
||||
public:
|
||||
|
||||
@@ -21,6 +21,7 @@ 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
|
||||
|
||||
@@ -26,6 +26,7 @@ class DigitalOutput;
|
||||
|
||||
/**
|
||||
* Ultrasonic rangefinder class.
|
||||
*
|
||||
* The Ultrasonic rangefinder measures absolute distance based on the round-trip
|
||||
* time of a ping generated by the controller. These sensors use two
|
||||
* transducers, a speaker and a microphone both tuned to the ultrasonic range. A
|
||||
@@ -43,10 +44,8 @@ class Ultrasonic : public SensorBase,
|
||||
|
||||
Ultrasonic(DigitalOutput* pingChannel, DigitalInput* echoChannel,
|
||||
DistanceUnit units = kInches);
|
||||
|
||||
Ultrasonic(DigitalOutput& pingChannel, DigitalInput& echoChannel,
|
||||
DistanceUnit units = kInches);
|
||||
|
||||
Ultrasonic(std::shared_ptr<DigitalOutput> pingChannel,
|
||||
std::shared_ptr<DigitalInput> echoChannel,
|
||||
DistanceUnit units = kInches);
|
||||
@@ -79,16 +78,22 @@ class Ultrasonic : public SensorBase,
|
||||
|
||||
// Time (sec) for the ping trigger pulse.
|
||||
static constexpr double kPingTime = 10 * 1e-6;
|
||||
|
||||
// Priority that the ultrasonic round robin task runs.
|
||||
static const int kPriority = 64;
|
||||
|
||||
// Max time (ms) between readings.
|
||||
static constexpr double kMaxUltrasonicTime = 0.1;
|
||||
static constexpr double kSpeedOfSoundInchesPerSec = 1130.0 * 12.0;
|
||||
|
||||
static std::thread
|
||||
m_thread; // thread doing the round-robin automatic sensing
|
||||
static std::set<Ultrasonic*> m_sensors; // ultrasonic sensors
|
||||
static std::atomic<bool> m_automaticEnabled; // automatic round robin mode
|
||||
// Thread doing the round-robin automatic sensing
|
||||
static std::thread m_thread;
|
||||
|
||||
// Ultrasonic sensors
|
||||
static std::set<Ultrasonic*> m_sensors;
|
||||
|
||||
// Automatic round-robin mode
|
||||
static std::atomic<bool> m_automaticEnabled;
|
||||
|
||||
std::shared_ptr<DigitalOutput> m_pingChannel;
|
||||
std::shared_ptr<DigitalInput> m_echoChannel;
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
/** @file
|
||||
* Contains global utility functions
|
||||
/**
|
||||
* @file Contains global utility functions
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace frc {
|
||||
|
||||
/**
|
||||
* Vex Robotics Victor 888 Speed Controller
|
||||
* Vex Robotics Victor 888 Speed Controller.
|
||||
*
|
||||
* The Vex Robotics Victor 884 Speed Controller can also be used with this
|
||||
* class but may need to be calibrated per the Victor 884 user manual.
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace frc {
|
||||
|
||||
/**
|
||||
* Vex Robotics Victor SP Speed Controller
|
||||
* Vex Robotics Victor SP Speed Controller.
|
||||
*/
|
||||
class VictorSP : public PWMSpeedController {
|
||||
public:
|
||||
|
||||
@@ -19,9 +19,7 @@
|
||||
const int wpi_error_value_##label = offset
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Fatal errors
|
||||
*/
|
||||
// Fatal errors
|
||||
S(ModuleIndexOutOfRange, -1,
|
||||
"Allocating module that is out of range or not found");
|
||||
S(ChannelIndexOutOfRange, -1, "Allocating channel that is out of range");
|
||||
@@ -78,9 +76,7 @@ S(CommandIllegalUse, -50, "Illegal use of Command");
|
||||
S(UnsupportedInSimulation, -80, "Unsupported in simulation");
|
||||
S(CameraServerError, -90, "CameraServer error");
|
||||
|
||||
/*
|
||||
* Warnings
|
||||
*/
|
||||
// Warnings
|
||||
S(SampleRateTooHigh, 1, "Analog module sample rate is too high");
|
||||
S(VoltageOutOfRange, 2,
|
||||
"Voltage to convert to raw value is out of range [-10; 10]");
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
namespace frc {
|
||||
|
||||
/**
|
||||
* Interface for 3-axis accelerometers
|
||||
* Interface for 3-axis accelerometers.
|
||||
*/
|
||||
class Accelerometer {
|
||||
public:
|
||||
@@ -22,26 +22,27 @@ class Accelerometer {
|
||||
* Common interface for setting the measuring range of an accelerometer.
|
||||
*
|
||||
* @param range The maximum acceleration, positive or negative, that the
|
||||
* accelerometer will measure. Not all accelerometers support all ranges.
|
||||
* accelerometer will measure. Not all accelerometers support all
|
||||
* ranges.
|
||||
*/
|
||||
virtual void SetRange(Range range) = 0;
|
||||
|
||||
/**
|
||||
* Common interface for getting the x axis acceleration
|
||||
* Common interface for getting the x axis acceleration.
|
||||
*
|
||||
* @return The acceleration along the x axis in g-forces
|
||||
*/
|
||||
virtual double GetX() = 0;
|
||||
|
||||
/**
|
||||
* Common interface for getting the y axis acceleration
|
||||
* Common interface for getting the y axis acceleration.
|
||||
*
|
||||
* @return The acceleration along the y axis in g-forces
|
||||
*/
|
||||
virtual double GetY() = 0;
|
||||
|
||||
/**
|
||||
* Common interface for getting the z axis acceleration
|
||||
* Common interface for getting the z axis acceleration.
|
||||
*
|
||||
* @return The acceleration along the z axis in g-forces
|
||||
*/
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
namespace frc {
|
||||
|
||||
/**
|
||||
* Interface for yaw rate gyros
|
||||
* Interface for yaw rate gyros.
|
||||
*/
|
||||
class Gyro {
|
||||
public:
|
||||
@@ -48,9 +48,9 @@ class Gyro {
|
||||
virtual double GetAngle() const = 0;
|
||||
|
||||
/**
|
||||
* Return the rate of rotation of the gyro
|
||||
* Return the rate of rotation of the gyro.
|
||||
*
|
||||
* The rate is based on the most recent reading of the gyro analog value
|
||||
* The rate is based on the most recent reading of the gyro analog value.
|
||||
*
|
||||
* @return the current rate in degrees per second
|
||||
*/
|
||||
|
||||
@@ -21,7 +21,7 @@ class Potentiometer : public PIDSource {
|
||||
/**
|
||||
* Common interface for getting the current value of a potentiometer.
|
||||
*
|
||||
* @return The current set speed. Value is between -1.0 and 1.0.
|
||||
* @return The current set speed. Value is between -1.0 and 1.0.
|
||||
*/
|
||||
virtual double Get() const = 0;
|
||||
|
||||
|
||||
@@ -14,8 +14,8 @@ class Mat;
|
||||
namespace frc {
|
||||
|
||||
/**
|
||||
* A vision pipeline is responsible for running a group of
|
||||
* OpenCV algorithms to extract data from an image.
|
||||
* A vision pipeline is responsible for running a group of OpenCV algorithms to
|
||||
* extract data from an image.
|
||||
*
|
||||
* @see VisionRunner
|
||||
*/
|
||||
@@ -24,8 +24,8 @@ class VisionPipeline {
|
||||
virtual ~VisionPipeline() = default;
|
||||
|
||||
/**
|
||||
* Processes the image input and sets the result objects.
|
||||
* Implementations should make these objects accessible.
|
||||
* Processes the image input and sets the result objects. Implementations
|
||||
* should make these objects accessible.
|
||||
*/
|
||||
virtual void Process(cv::Mat& mat) = 0;
|
||||
};
|
||||
|
||||
@@ -15,10 +15,9 @@ namespace frc {
|
||||
* listener} when the pipeline has finished to alert user code when it is safe
|
||||
* to access the pipeline's outputs.
|
||||
*
|
||||
* @param videoSource the video source to use to supply images for the pipeline
|
||||
* @param pipeline the vision pipeline to run
|
||||
* @param listener a function to call after the pipeline has finished
|
||||
* running
|
||||
* @param videoSource The video source to use to supply images for the pipeline
|
||||
* @param pipeline The vision pipeline to run
|
||||
* @param listener A function to call after the pipeline has finished running
|
||||
*/
|
||||
template <typename T>
|
||||
VisionRunner<T>::VisionRunner(cs::VideoSource videoSource, T* pipeline,
|
||||
|
||||
Reference in New Issue
Block a user