#include <SparkBase.h>
Inherits rev::spark::SparkLowLevel.
Inherited by rev::spark::SparkFlex, and rev::spark::SparkMax.
|
enum class | IdleMode { kCoast = 0
, kBrake = 1
} |
|
enum class | SoftLimitDirection { kForward
, kReverse
} |
|
enum class | ResetMode { kNoResetSafeParameters
, kResetSafeParameters
} |
|
enum class | PersistMode { kNoPersistParameters
, kPersistParameters
} |
|
enum class | MotorType { kBrushed = 0
, kBrushless = 1
} |
|
enum class | ControlType {
kDutyCycle = 0
, kVelocity = 1
, kVoltage = 2
, kPosition = 3
,
kSmartMotion = 4
, kCurrent = 5
, kSmartVelocity = 6
, kMAXMotionPositionControl = 7
,
kMAXMotionVelocityControl = 8
} |
|
enum class | ParameterStatus {
kOK = 0
, kInvalidID = 1
, kMismatchType = 2
, kAccessMode = 3
,
kInvalid = 4
, kNotImplementedDeprecated = 5
} |
|
enum class | PeriodicFrame {
kStatus0 = 0
, kStatus1 = 1
, kStatus2 = 2
, kStatus3 = 3
,
kStatus4 = 4
, kStatus5 = 5
, kStatus6 = 6
, kStatus7 = 7
} |
|
enum class | SparkModel { kSparkMax = 0
, kSparkFlex = 1
, kUnknown = 255
} |
|
◆ IdleMode
◆ SoftLimitDirection
Enumerator |
---|
kForward | |
kReverse | |
◆ ResetMode
Enumerator |
---|
kNoResetSafeParameters | |
kResetSafeParameters | |
◆ PersistMode
Enumerator |
---|
kNoPersistParameters | |
kPersistParameters | |
◆ ~SparkBase()
rev::spark::SparkBase::~SparkBase |
( |
| ) |
|
|
overridedefault |
Closes the SPARK motor controller
◆ SparkBase()
Create a new object to control a SPARK motor Controller
- Parameters
-
deviceID | The device ID. |
type | The motor type connected to the controller. Brushless motor wires must be connected to their matching colors, and the hall sensor must be plugged in. Brushed motors must be connected to the Red and Black terminals only. |
◆ Set()
void SparkBase::Set |
( |
double |
speed | ) |
|
|
override |
Common interface for setting the speed of a speed controller.
- Parameters
-
speed | The speed to set. Value should be between -1.0 and 1.0. |
◆ SetVoltage()
void SparkBase::SetVoltage |
( |
units::volt_t |
output | ) |
|
|
override |
Sets the voltage output of the SpeedController. This is equivalent to a call to SetReference(output, SparkBase::ControlType::kVoltage). The behavior of this call differs slightly from the WPILib documentation for this call since the device internally sets the desired voltage (not a compensation value). That means that this can be a 'set-and-forget' call.
- Parameters
-
output | The voltage to output. |
◆ Get()
double SparkBase::Get |
( |
| ) |
const |
|
override |
Common interface for getting the current set speed of a speed controller.
- Returns
- The current set speed. Value is between -1.0 and 1.0.
◆ SetInverted()
void SparkBase::SetInverted |
( |
bool |
isInverted | ) |
|
|
override |
Common interface for inverting direction of a speed controller.
This call has no effect if the controller is a follower. To invert a follower, see the follow() method.
- Parameters
-
isInverted | The state of inversion, true is inverted. |
◆ GetInverted()
bool SparkBase::GetInverted |
( |
| ) |
const |
|
override |
Common interface for returning the inversion state of a speed controller.
This call has no effect if the controller is a follower.
- Returns
- isInverted The state of inversion, true is inverted.
◆ Disable()
void SparkBase::Disable |
( |
| ) |
|
|
override |
Common interface for disabling a motor.
◆ StopMotor()
void SparkBase::StopMotor |
( |
| ) |
|
|
override |
Common interface to stop the motor until Set is called again.
◆ Configure()
***** Extended Functions ****** Set the configuration for the SPARK.
If resetMode
is ResetMode::kResetSafeParameters, this method will reset safe writable parameters to their default values before setting the given configuration. The following parameters will not be reset by this action: CAN ID, Motor Type, Idle Mode, PWM Input Deadband, and Duty Cycle Offset.
If persistMode
is PersistMode::kPersistParameters, this method will save all parameters to the SPARK's non-volatile memory after setting the given configuration. This will allow parameters to persist across power cycles.
- Parameters
-
config | The desired SPARK configuration |
resetMode | Whether to reset safe parameters before setting the configuration |
persistMode | Whether to persist the parameters after setting the configuration |
- Returns
- REVLibError::kOk if successful
Reimplemented in rev::spark::SparkMax.
◆ GetEncoder()
Returns an object for interfacing with the encoder connected to the encoder pins or front port of the SPARK MAX or the motor interface of the SPARK Flex.
◆ GetAnalog()
Returns an object for interfacing with a connected analog sensor. By default, the mode is set to kAbsolute, thus treating the sensor as an absolute sensor.
◆ GetAbsoluteEncoder()
Returns an object for interfacing with a connected absolute encoder.
The default encoder type is assumed to be a duty cycle sensor.
Reimplemented in rev::spark::SparkMax.
◆ GetClosedLoopController()
Returns an object for interfacing with the integrated Closed Loop Controller.
◆ GetForwardLimitSwitch()
Returns an object for interfacing with the forward limit switch connected to the appropriate pins on the data port.
This call will disable support for the alternate encoder.
Reimplemented in rev::spark::SparkMax.
◆ GetReverseLimitSwitch()
Returns an object for interfacing with the reverse limit switch connected to the appropriate pins on the data port.
This call will disable support for the alternate encoder.
Reimplemented in rev::spark::SparkMax.
◆ ResumeFollowerMode()
Resume follower mode if the SPARK has a valid follower mode config.
NOTE: Follower mode will start automatically upon configuring follower mode. If the SPARK experiences a power cycle and has follower mode configured, follower mode will automatically restart. This method is only useful after PauseFollowerMode() has been called.
- Returns
- REVLibError::kOk if successful
◆ PauseFollowerMode()
Pause follower mode.
NOTE: If the SPARK experiences a power cycle and has follower mode configured, follower mode will automatically restart.
- Returns
- REVLibError::kOk if successful
◆ IsFollower()
bool SparkBase::IsFollower |
( |
| ) |
|
Returns whether the controller is following another controller
- Returns
- True if this device is following another controller false otherwise
◆ HasActiveFault()
bool SparkBase::HasActiveFault |
( |
| ) |
|
Get whether the SPARK has one or more active faults.
- Returns
- true if there is an active fault
- See also
- GetFaults()
◆ HasStickyFault()
bool SparkBase::HasStickyFault |
( |
| ) |
|
Get whether the SPARK has one or more sticky faults.
- Returns
- true if there is a sticky fault
- See also
- GetStickyFaults()
◆ HasActiveWarning()
bool SparkBase::HasActiveWarning |
( |
| ) |
|
Get whether the SPARK has one or more active warnings.
- Returns
- true if there is an active warning
- See also
- GetWarnings()
◆ HasStickyWarning()
bool SparkBase::HasStickyWarning |
( |
| ) |
|
Get whether the SPARK has one or more sticky warnings.
- Returns
- true if there is a sticky warning
- See also
- GetStickyWarnings()
◆ GetFaults()
Get the active faults that are currently present on the SPARK. Faults are fatal errors that prevent the motor from running.
- Returns
- A struct with each fault and their active value
◆ GetStickyFaults()
Get the sticky faults that were present on the SPARK at one point since the sticky faults were last cleared. Faults are fatal errors that prevent the motor from running.
Sticky faults can be cleared with SparkBase::ClearFaults().
- Returns
- A struct with each fault and their sticky value
◆ GetWarnings()
Get the active warnings that are currently present on the SPARK. Warnings are non-fatal errors.
- Returns
- A struct with each warning and their active value
◆ GetStickyWarnings()
Get the sticky warnings that were present on the SPARK at one point since the sticky warnings were last cleared. Warnings are non-fatal errors.
Sticky warnings can be cleared with SparkBase::clearFaults().
- Returns
- A struct with each warning and their sticky value
◆ GetBusVoltage()
double SparkBase::GetBusVoltage |
( |
| ) |
|
Returns the voltage fed into the motor controller.
◆ GetAppliedOutput()
double SparkBase::GetAppliedOutput |
( |
| ) |
|
Simulation note: this value will not be updated during simulation unless SparkSim#iterate is called
Returns motor controller's output duty cycle.
◆ GetOutputCurrent()
double SparkBase::GetOutputCurrent |
( |
| ) |
|
Returns motor controller's output current in Amps.
◆ GetMotorTemperature()
double SparkBase::GetMotorTemperature |
( |
| ) |
|
Returns the motor temperature in Celsius.
◆ ClearFaults()
Clears all non-sticky faults.
Sticky faults must be cleared by resetting the motor controller.
◆ SetCANTimeout()
Sets timeout for sending CAN messages. A timeout of 0 also means that error handling will be done automatically by registering calls and waiting for responses, rather than needing to call GetLastError().
- Parameters
-
milliseconds | The timeout in milliseconds. |
◆ GetLastError()
All device errors are tracked on a per thread basis for all devices in that thread. This is meant to be called immediately following another call that has the possibility of throwing an error to validate if an error has occurred.
- Returns
- the last error that was generated.
◆ GetEncoderEvenIfAlreadyCreated()
◆ GetMotorInterface()
uint8_t SparkBase::GetMotorInterface |
( |
| ) |
|
|
protected |
Get the current motor interface for the SPARK.
- Returns
◆ GetSparkModel()
Get the Model of this SPARK Device. Useful for determining if this is a Flex, MAX, or other device
- Returns
- the model of this device
◆ SparkMax
◆ SparkFlex
◆ SparkLimitSwitch
◆ SparkRelativeEncoder
◆ SparkMaxAlternateEncoder
◆ SparkAbsoluteEncoder
◆ SparkSim
◆ ::ConfigBase
friend class ::ConfigBase |
|
friend |
◆ m_setpoint
double rev::spark::SparkBase::m_setpoint {0.0} |
|
protected |
◆ m_RelativeEncoder
◆ m_relativeEncoderCreated
std::atomic<bool> rev::spark::SparkBase::m_relativeEncoderCreated {false} |
|
protected |
◆ m_AnalogSensor
◆ m_analogSensorCreated
std::atomic<bool> rev::spark::SparkBase::m_analogSensorCreated {false} |
|
protected |
◆ m_AbsoluteEncoder
◆ m_absoluteEncoderCreated
std::atomic<bool> rev::spark::SparkBase::m_absoluteEncoderCreated {false} |
|
protected |
◆ m_ClosedLoopController
◆ m_closedLoopControllerCreated
std::atomic<bool> rev::spark::SparkBase::m_closedLoopControllerCreated {false} |
|
protected |
◆ m_ForwardLimitSwitch
◆ m_forwardLimitSwitchCreated
std::atomic<bool> rev::spark::SparkBase::m_forwardLimitSwitchCreated {false} |
|
protected |
◆ m_ReverseLimitSwitch
◆ m_reverseLimitSwitchCreated
std::atomic<bool> rev::spark::SparkBase::m_reverseLimitSwitchCreated {false} |
|
protected |
The documentation for this class was generated from the following files: