#include <CANSparkLowLevel.h>
Inherits frc::MotorController.
Inherited by rev::CANSparkBase.
|
enum class | MotorType { kBrushed = 0
, kBrushless = 1
} |
|
enum class | ControlType {
kDutyCycle = 0
, kVelocity = 1
, kVoltage = 2
, kPosition = 3
,
kSmartMotion = 4
, kCurrent = 5
, kSmartVelocity = 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
} |
|
enum class | TelemetryID {
kBusVoltage = 0
, kOutputCurrent
, kVelocity
, kPosition
,
kIAccum
, kAppliedOutput
, kMotorTemp
, kFaults
,
kStickyFaults
, kAnalogVoltage
, kAnalogPosition
, kAnalogVelocity
,
kAltEncPosition
, kAltEncVelocity
, kTotalStreams
} |
|
enum class | SparkModel { kSparkMax = 0
, kSparkFlex = 1
, kUnknown = 255
} |
|
◆ MotorType
Enumerator |
---|
kBrushed | |
kBrushless | |
◆ ControlType
Enumerator |
---|
kDutyCycle | |
kVelocity | |
kVoltage | |
kPosition | |
kSmartMotion | |
kCurrent | |
kSmartVelocity | |
◆ ParameterStatus
Enumerator |
---|
kOK | |
kInvalidID | |
kMismatchType | |
kAccessMode | |
kInvalid | |
kNotImplementedDeprecated | |
◆ PeriodicFrame
Enumerator |
---|
kStatus0 | |
kStatus1 | |
kStatus2 | |
kStatus3 | |
kStatus4 | |
kStatus5 | |
kStatus6 | |
kStatus7 | |
◆ TelemetryID
Enumerator |
---|
kBusVoltage | |
kOutputCurrent | |
kVelocity | |
kPosition | |
kIAccum | |
kAppliedOutput | |
kMotorTemp | |
kFaults | |
kStickyFaults | |
kAnalogVoltage | |
kAnalogPosition | |
kAnalogVelocity | |
kAltEncPosition | |
kAltEncVelocity | |
kTotalStreams | |
◆ SparkModel
Enumerator |
---|
kSparkMax | |
kSparkFlex | |
kUnknown | |
◆ FeedbackSensorType
Enumerator |
---|
kNoSensor | |
kHallSensor | |
kQuadrature | |
kSensorless | |
kAnalog | |
kAltQuadrature | |
kDutyCycleSensor | |
◆ ~CANSparkLowLevel()
rev::CANSparkLowLevel::~CANSparkLowLevel |
( |
| ) |
|
|
virtual |
Closes the SPARK motor controller
◆ GetFirmwareVersion() [1/2]
uint32_t rev::CANSparkLowLevel::GetFirmwareVersion |
( |
| ) |
|
Get the firmware version of the SPARK.
- Returns
- uint32_t Firmware version integer. Value is represented as 4 bytes, Major.Minor.Build H.Build L
◆ GetFirmwareVersion() [2/2]
uint32_t rev::CANSparkLowLevel::GetFirmwareVersion |
( |
bool & |
isDebugBuild | ) |
|
◆ GetFirmwareString()
std::string rev::CANSparkLowLevel::GetFirmwareString |
( |
| ) |
|
Get the firmware version of the SPARK as a string.
- Returns
- std::string Human readable firmware version string
◆ GetSerialNumber()
std::vector< uint8_t > rev::CANSparkLowLevel::GetSerialNumber |
( |
| ) |
|
Get the unique serial number of the SPARK. Currently not implemented.
- Returns
- std::vector<uint8_t> Vector of bytes representig the unique serial number
◆ GetDeviceId()
int rev::CANSparkLowLevel::GetDeviceId |
( |
| ) |
const |
Get the configured Device ID of the SPARK.
- Returns
- int device ID
◆ GetInitialMotorType()
Get the motor type setting from when the SparkMax was created.
This does not use the Get Parameter API which means it does not read what motor type is stored on the SparkMax itself. Instead, it reads the stored motor type from when the SparkMax object was first created.
- Returns
- MotorType Motor type setting
- Deprecated:
- Use GetMotorType() instead
◆ GetMotorType()
Get the motor type setting for the SPARK.
- Returns
- MotorType Motor type setting
◆ SetPeriodicFramePeriod() [1/2]
Set the rate of transmission for periodic frames from the SPARK
Each motor controller sends back status frames with different data at set rates. Use this function to change the default rates.
Defaults: Status0 - 10ms Status1 - 20ms Status2 - 20ms Status3 - 50ms Status4 - 20ms Status5 - 200ms Status6 - 200ms Status7 - 250ms
This value is not stored in the FLASH after calling burnFlash() and is reset on powerup.
Refer to the SPARK reference manual on details for how and when to configure this parameter.
- Parameters
-
frame | Which periodic frame to change the period of |
periodMs | The rate the controller sends the frame to the controller. |
- Returns
- REVLibError::kOk if successful
◆ SetPeriodicFramePeriod() [2/2]
Set the rate of transmission for periodic frames from the SPARK
Each motor controller sends back status frames with different data at set rates. Use this function to change the default rates.
Defaults: Status0 - 10ms Status1 - 20ms Status2 - 20ms Status3 - 50ms Status4 - 20ms Status5 - 200ms Status6 - 200ms Status7 - 250ms
This value is not stored in the FLASH after calling burnFlash() and is reset on powerup.
Refer to the SPARK reference manual on details for how and when to configure this parameter.
- Parameters
-
frame | Which periodic frame to change the period of |
periodMs | The rate the controller sends the frame to the controller. |
- Returns
- REVLibError::kOk if successful
- Deprecated:
- Use SetPeriodicFramePeriod(CANSparkLowLevel::PeriodicFrame, int) instead
◆ SetPeriodicFrameTimeout()
void rev::CANSparkLowLevel::SetPeriodicFrameTimeout |
( |
int |
timeoutMs | ) |
|
Set the amount of time to wait for a periodic status frame before returning a timeout error. This timeout will apply to all periodic status frames for the SPARK motor controller.
To prevent invalid timeout errors, the minimum timeout for a given periodic status is 2.1 times its period. To use the minimum timeout for all status frames, set timeoutMs to 0.
The default timeout is 500ms.
- Parameters
-
timeoutMs | The timeout in milliseconds |
◆ SetCANMaxRetries()
void rev::CANSparkLowLevel::SetCANMaxRetries |
( |
int |
numRetries | ) |
|
Set the maximum number of times to retry an RTR CAN frame. This applies to calls such as SetParameter* and GetParameter* where a request is made to the SPARK motor controller and a response is expected. Anytime sending the request or receiving the response fails, it will retry the request a number of times, no more than the value set by this method. If an attempt succeeds, it will immediately return. The minimum number of retries is 0, where only a single attempt will be made and will return regardless of success or failure.
If the CAN timeout is set to 0 with CANSparkBase::setCANTimeout(), this will have no effect when getting the response from the SPARK motor controller fails. However, it will retry when sending the request from the roboRIO fails.
The default maximum is 5 retries.
- Parameters
-
numRetries | The maximum number of retries |
◆ SetControlFramePeriodMs()
void rev::CANSparkLowLevel::SetControlFramePeriodMs |
( |
int |
periodMs | ) |
|
Set the control frame send period for the native CAN Send thread. To disable periodic sends, set periodMs to 0.
- Parameters
-
periodMs | The send period in milliseconds between 1ms and 100ms or set to 0 to disable periodic sends. Note this is not updated until the next call to Set() or SetReference(). |
◆ RestoreFactoryDefaults()
REVLibError rev::CANSparkLowLevel::RestoreFactoryDefaults |
( |
bool |
persist = false | ) |
|
Restore motor controller parameters to factory default
- Parameters
-
persist | If true, burn the flash with the factory default parameters |
- Returns
- REVLibError::kOk if successful
◆ EnableExternalUSBControl()
void rev::CANSparkLowLevel::EnableExternalUSBControl |
( |
bool |
enable | ) |
|
|
static |
Allow external controllers to recieve control commands over USB. For example, a configuration where the heartbeat (and enable/disable) is sent by the main controller, but control frames are sent by other CAN devices over USB.
This is global for all controllers on the same bus.
This does not disable sending control frames from this device. To prevent conflicts, do not enable this feature and also send Set() for SetReference() from the controllers you wish to control.
- Parameters
-
enable | Enable or disable external control |
◆ SetEnable()
void rev::CANSparkLowLevel::SetEnable |
( |
bool |
enable | ) |
|
|
static |
Send enabled or disabled command to controllers. This is global for all controllers on the same bus, and will only work for non-roboRIO targets in non-competiton use. This function will also not work if a roboRIO is present on the CAN bus.
This does not disable sending control frames from this device. To prevent conflicts, do not enable this feature and also send Set() for SetReference() from the controllers you wish to control.
- Parameters
-
enable | Enable or disable external control |
◆ GetPeriodicStatus0()
◆ GetPeriodicStatus1()
◆ GetPeriodicStatus2()
◆ SetFollow()
◆ SetpointCommand()
◆ GetSafeFloat()
float rev::CANSparkLowLevel::GetSafeFloat |
( |
float |
f | ) |
|
|
protected |
◆ CANAnalog
◆ CANDigitalInput
◆ CANEncoder
◆ CANPIDController
◆ CANSensor
◆ CANSparkBase
◆ CANSparkMax
◆ CANSparkFlex
◆ MotorFeedbackSensor
◆ SparkMaxAnalogSensor
◆ SparkMaxAlternateEncoder
◆ SparkMaxLimitSwitch
◆ SparkMaxPIDController
◆ SparkMaxRelativeEncoder
◆ SparkMaxAbsoluteEncoder
◆ SparkFlexExternalEncoder
◆ ::ConfigBase
friend class ::ConfigBase |
|
friend |
◆ kAPIMajorVersion
const uint8_t rev::CANSparkLowLevel::kAPIMajorVersion = c_SparkMax_kAPIMajorVersion |
|
static |
◆ kAPIMinorVersion
const uint8_t rev::CANSparkLowLevel::kAPIMinorVersion = c_SparkMax_kAPIMinorVersion |
|
static |
◆ kAPIBuildVersion
const uint8_t rev::CANSparkLowLevel::kAPIBuildVersion = c_SparkMax_kAPIBuildVersion |
|
static |
◆ kAPIVersion
const uint32_t rev::CANSparkLowLevel::kAPIVersion = c_SparkMax_kAPIVersion |
|
static |
◆ m_motorType
◆ m_expectedSparkModel
SparkModel rev::CANSparkLowLevel::m_expectedSparkModel |
|
protected |
◆ m_sparkMaxHandle
void* rev::CANSparkLowLevel::m_sparkMaxHandle |
|
protected |
The documentation for this class was generated from the following files: