#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
,
kCurrent = 4
, kMAXMotionPositionControl = 5
, kMAXMotionVelocityControl = 6
} |
| |
| 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
,
kStatus8 = 8
, kStatus9 = 9
} |
| |
| enum class | SparkModel { kUnknown = 0
, kSparkFlex = 1
, kSparkMax = 2
} |
| |
◆ 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
-
| busID | The CAN bus ID this device will be on. |
| 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. |
| model | The model (kSparkMax or kSparkFlex) of the motor. |
◆ SetThrottle()
| void SparkBase::SetThrottle |
( |
double |
throttle | ) |
|
|
override |
Sets the throttle of the motor controller.
- Parameters
-
| throttle | The throttle where -1 indicates full reverse and 1 indicates full forward. |
◆ SetVoltage()
| void SparkBase::SetVoltage |
( |
wpi::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. |
◆ GetThrottle()
| double SparkBase::GetThrottle |
( |
| ) |
const |
|
override |
Gets the throttle of the motor controller.
- Returns
- The throttle where -1 represents full reverse and 1 represents full forward.
◆ 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. |
- Deprecated:
- Use SparkBaseConfig.Inverted() with Configure() instead
◆ GetInverted()
| bool SparkBase::GetInverted |
( |
| ) |
const |
|
override |
◆ Disable()
| void SparkBase::Disable |
( |
| ) |
|
|
override |
Common interface for disabling a motor.
◆ StopMotor()
| void SparkBase::StopMotor |
( |
| ) |
|
Common interface to stop the motor until Set is called again.
◆ Configure() [1/2]
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
- Deprecated:
- Use &, rev::ResetMode, rev::PersistMode) instead. This method will be removed in 2027.
Reimplemented in rev::spark::SparkMax.
◆ Configure() [2/2]
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.
◆ ConfigureAsync() [1/2]
Set the configuration for the SPARK without waiting for a response.
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.
NOTE: This method will immediately return REVLibError::kOk and the action will be done in the background. Any errors that occur will be reported to the driver station.
- 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
- See also
- Configure()
- Deprecated:
- Use &, rev::ResetMode, rev::PersistMode) instead. This method will be removed in 2027.
◆ ConfigureAsync() [2/2]
Set the configuration for the SPARK without waiting for a response.
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.
NOTE: This method will immediately return REVLibError::kOk and the action will be done in the background. Any errors that occur will be reported to the driver station.
- 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
- See also
- Configure()
◆ 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.
◆ GetForwardSoftLimit()
Returns an object for interfacing with the forward soft limit switch
◆ GetReverseSoftLimit()
Returns an object for interfacing with the reverse soft limit switch
◆ 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
◆ ResumeFollowerModeAsync()
Resume follower mode if the SPARK has a valid follower mode config without waiting for a response.
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.
NOTE: This method will immediately return REVLibError::kOk and the action will be done in the background. Any errors that occur will be reported to the driver station.
- Returns
- REVLibError::kOk
- See also
- ResumeFollowerMode()
◆ 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
◆ PauseFollowerModeAsync()
Pause follower mode without waiting for a response.
NOTE: If the SPARK experiences a power cycle and has follower mode configured, follower mode will automatically restart.
NOTE: This method will immediately return REVLibError::kOk and the action will be done in the background. Any errors that occur will be reported to the driver station.
- Returns
- REVLibError::kOk
- See also
- PauseFollowerMode()
◆ IsFollower()
| Signal< bool > SparkBase::IsFollower |
( |
| ) |
const |
Returns whether the controller is following another controller
- Returns
- Signal containing True if this device is following another controller false otherwise
◆ HasActiveFault()
| Signal< bool > SparkBase::HasActiveFault |
( |
| ) |
const |
Get whether the SPARK has one or more active faults.
- Returns
- Signal containing true if there is an active fault
- See also
- GetFaults()
◆ HasStickyFault()
| Signal< bool > SparkBase::HasStickyFault |
( |
| ) |
const |
Get whether the SPARK has one or more sticky faults.
- Returns
- Signal containing true if there is a sticky fault
- See also
- GetStickyFaults()
◆ HasActiveWarning()
| Signal< bool > SparkBase::HasActiveWarning |
( |
| ) |
const |
Get whether the SPARK has one or more active warnings.
- Returns
- Signal containing true if there is an active warning
- See also
- GetWarnings()
◆ HasStickyWarning()
| Signal< bool > SparkBase::HasStickyWarning |
( |
| ) |
const |
Get whether the SPARK has one or more sticky warnings.
- Returns
- Signal containing 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
- Signal containing 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
- Signal containing each fault and their sticky value
◆ GetWarnings()
Get the active warnings that are currently present on the SPARK. Warnings are non-fatal errors.
- Returns
- Signal containing 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
- Signal containing each warning and their sticky value
◆ GetBusVoltage()
| Signal< double > SparkBase::GetBusVoltage |
( |
| ) |
const |
Returns the voltage fed into the motor controller.
- Returns
- Signal containing the bus voltage
◆ GetAppliedOutput()
| Signal< double > SparkBase::GetAppliedOutput |
( |
| ) |
const |
Simulation note: this value will not be updated during simulation unless SparkSim#iterate is called
Returns motor controller's output duty cycle.
- Returns
- Signal containing the applied output duty cycle
◆ GetOutputCurrent()
| Signal< double > SparkBase::GetOutputCurrent |
( |
| ) |
const |
Returns motor controller's output current in Amps.
- Returns
- Signal containing the output current in Amps
◆ GetMotorTemperature()
| Signal< double > SparkBase::GetMotorTemperature |
( |
| ) |
const |
Returns the motor temperature in Celsius.
- Returns
- Signal containing the motor temperature in Celsius
◆ ClearFaults()
Clears all sticky faults.
◆ SetCANTimeout()
Sets the timeout duration for waiting for CAN responses from the device.
- 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
◆ SparkSoftLimit
◆ SparkRelativeEncoder
◆ SparkMaxAlternateEncoder
◆ SparkAbsoluteEncoder
◆ SparkSim
◆ SparkClosedLoopController
◆ ::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 |
◆ m_ForwardSoftLimit
◆ m_forwardSoftLimitCreated
| std::atomic<bool> rev::spark::SparkBase::m_forwardSoftLimitCreated {false} |
|
protected |
◆ m_ReverseSoftLimit
◆ m_reverseSoftLimitCreated
| std::atomic<bool> rev::spark::SparkBase::m_reverseSoftLimitCreated {false} |
|
protected |
The documentation for this class was generated from the following files: