|
sparkcan Documentation
1.0
|
A base class for controlling REV Robotics SPARK motor controllers via CAN bus. More...
#include <SparkBase.hpp>

Public Member Functions | |
| SparkBase (const std::string &interfaceName, uint8_t deviceId) | |
| Initializes SparkBase with the specified CAN interface and ID. More... | |
| virtual | ~SparkBase () |
| Destructor for SparkBase. More... | |
| void | ResetFaults () |
| Resets all faults on the SPARK controller. More... | |
| void | ClearStickyFaults () |
| Clears sticky faults on the SPARK controller. More... | |
| void | BurnFlash () |
| Burns the current configuration to the SPARK controller's flash memory. More... | |
| void | FactoryDefaults () |
| Resets the SPARK controller to factory default settings. More... | |
| void | FactoryReset () |
| Performs a factory reset on the SPARK controller. More... | |
| void | Identify () |
| Triggers the SPARK controller to identify itself. More... | |
| void | SetSetpoint (float setpoint) |
| Sets the value for the currently set control type. More... | |
| void | SetDutyCycle (float dutyCycle) |
| Sets the motor's applied output. More... | |
| void | SetVelocity (float velocity) |
| Sets the motor's velocity. More... | |
| void | SetSmartVelocity (float smartVelocity) |
| Sets the motor's smart velocity. More... | |
| void | SetPosition (float position) |
| Sets the motor's position. More... | |
| void | SetVoltage (float voltage) |
| Sets the motor's voltage. More... | |
| void | SetCurrent (float current) |
| Sets the motor's current. More... | |
| void | SetSmartMotion (float smartMotion) |
| Sets the motor's smart motion. More... | |
| float | GetDutyCycle () const |
| Retrieves the current applied output. More... | |
| uint16_t | GetFaults () const |
| Retrieves the current faults. More... | |
| uint16_t | GetStickyFaults () const |
| Retrieves the sticky faults. More... | |
| bool | GetInverted () const |
| Checks if the motor is inverted. More... | |
| bool | GetIdleMode () const |
| Gets the current idle mode. More... | |
| bool | IsFollower () const |
| Checks if the SPARK controller is in follower mode. More... | |
| float | GetVelocity () const |
| Gets the current velocity. More... | |
| float | GetTemperature () const |
| Gets the current temperature of the SPARK controller. More... | |
| float | GetVoltage () const |
| Gets the current voltage of the SPARK controller. More... | |
| float | GetCurrent () const |
| Gets the current drawn by the SPARK controller. More... | |
| float | GetPosition () const |
| Gets the current position of the motor. More... | |
| float | GetAnalogVoltage () const |
| Gets the current analog voltage. More... | |
| float | GetAnalogVelocity () const |
| Gets the current analog velocity. More... | |
| float | GetAnalogPosition () const |
| Gets the current analog position. More... | |
| float | GetAlternateEncoderVelocity () const |
| Gets the velocity from the alternate encoder. More... | |
| float | GetAlternateEncoderPosition () const |
| Gets the position from the alternate encoder. More... | |
| void | SetInputMode (uint8_t mode) |
| Sets the input mode. More... | |
| void | SetMotorType (MotorType type) |
| Sets the motor type. More... | |
| void | SetSensorType (SensorType sensor) |
| Sets the sensor type. More... | |
| void | SetIdleMode (IdleMode mode) |
| Sets the idle mode. More... | |
| void | SetInputDeadband (float deadband) |
| Sets the input deadband. More... | |
| void | SetInverted (bool inverted) |
| Sets whether the motor is inverted. More... | |
| void | SetRampRate (float rate) |
| Sets the ramp rate. More... | |
| void | SetMotorKv (uint16_t kv) |
| Sets the motor Kv (velocity constant) More... | |
| void | SetMotorR (uint16_t r) |
| Sets the motor resistance. More... | |
| void | SetMotorL (uint16_t l) |
| Sets the motor inductance. More... | |
| void | SetCtrlType (CtrlType type) |
| Sets the control type. More... | |
| void | SetFeedbackSensorPID0 (uint16_t sensor) |
| Sets the feedback sensor for PID0. More... | |
| void | SetClosedLoopVoltageMode (uint8_t mode) |
| Sets the closed loop voltage mode. More... | |
| void | SetCompensatedNominalVoltage (float voltage) |
| Sets the compensated nominal voltage. More... | |
| void | SetPositionPIDWrapEnable (bool enable) |
| Enables or disables position PID wrap. More... | |
| void | SetPositionPIDMinInput (float minInput) |
| Sets the minimum input for position PID. More... | |
| void | SetPositionPIDMaxInput (float maxInput) |
| Sets the maximum input for position PID. More... | |
| void | SetPolePairs (uint16_t pairs) |
| Sets the number of pole pairs for brushless motors. More... | |
| void | SetCurrentChop (float chop) |
| Sets the current chop limit. More... | |
| void | SetCurrentChopCycles (uint16_t cycles) |
| Sets the number of cycles for current chopping. More... | |
| void | SetSmartCurrentStallLimit (uint16_t limit) |
| Sets the smart current stall limit. More... | |
| void | SetSmartCurrentFreeLimit (uint16_t limit) |
| Sets the smart current free limit. More... | |
| void | SetSmartCurrentConfig (uint16_t config) |
| Sets the smart current configuration. More... | |
| void | SetP (uint8_t slot, float p) |
| Sets the proportional gain for the specified PID slot. More... | |
| void | SetI (uint8_t slot, float i) |
| Sets the integral gain for the specified PID slot. More... | |
| void | SetD (uint8_t slot, float d) |
| Sets the derivative gain for the specified PID slot. More... | |
| void | SetF (uint8_t slot, float f) |
| Sets the feedforward gain for the specified PID slot. More... | |
| void | SetIZone (uint8_t slot, float iZone) |
| Sets the integral zone for the specified PID slot. More... | |
| void | SetDFilter (uint8_t slot, float dFilter) |
| Sets the derivative filter for the specified PID slot. More... | |
| void | SetOutputMin (uint8_t slot, float min) |
| Sets the output minimum for the specified PID slot. More... | |
| void | SetOutputMax (uint8_t slot, float max) |
| Sets the output maximum for the specified PID slot. More... | |
| void | SetHardLimitFwdEn (bool enable) |
| Enables or disables the forward hard limit switch. More... | |
| void | SetHardLimitRevEn (bool enable) |
| Enables or disables the reverse hard limit switch. More... | |
| void | SetLimitSwitchFwdPolarity (bool polarity) |
| Sets the polarity of the forward limit switch. More... | |
| void | SetLimitSwitchRevPolarity (bool polarity) |
| Sets the polarity of the reverse limit switch. More... | |
| void | SetSoftLimitFwdEn (bool enable) |
| Enables or disables the forward soft limit. More... | |
| void | SetSoftLimitRevEn (bool enable) |
| Enables or disables the reverse soft limit. More... | |
| void | SetSoftLimitFwd (float limit) |
| Sets the forward soft limit. More... | |
| void | SetSoftLimitRev (float limit) |
| Sets the reverse soft limit. More... | |
| void | SetFollowerID (uint32_t id) |
| Sets the follower ID for this SparkBase. More... | |
| void | SetFollowerConfig (uint32_t config) |
| Sets the follower configuration. More... | |
| void | SetEncoderCountsPerRev (uint16_t counts) |
| Sets the encoder counts per revolution. More... | |
| void | SetEncoderAverageDepth (uint8_t depth) |
| Sets the encoder average depth. More... | |
| void | SetEncoderSampleDelta (uint8_t delta) |
| Sets the encoder sample delta. More... | |
| void | SetEncoderInverted (bool inverted) |
| Sets whether the encoder is inverted. More... | |
| void | SetPositionConversionFactor (float factor) |
| Sets the position conversion factor. More... | |
| void | SetVelocityConversionFactor (float factor) |
| Sets the velocity conversion factor. More... | |
| void | SetClosedLoopRampRate (float rampRate) |
| Sets the closed loop ramp rate. More... | |
| void | SetHallSensorSampleRate (float rate) |
| Sets the hall sensor sample rate. More... | |
| void | SetHallSensorAverageDepth (uint16_t depth) |
| Sets the hall sensor average depth. More... | |
| void | SetSmartMotionMaxVelocity (uint8_t slot, float maxVel) |
| Sets the maximum velocity for Smart Motion in the specified slot. More... | |
| void | SetSmartMotionMaxAccel (uint8_t slot, float maxAccel) |
| Sets the maximum acceleration for Smart Motion in the specified slot. More... | |
| void | SetSmartMotionMinVelOutput (uint8_t slot, float minVel) |
| Sets the minimum velocity output for Smart Motion in the specified slot. More... | |
| void | SetSmartMotionAllowedClosedLoopError (uint8_t slot, float error) |
| Sets the allowed closed loop error for Smart Motion in the specified slot. More... | |
| void | SetSmartMotionAccelStrategy (uint8_t slot, float strategy) |
| Sets the acceleration strategy for Smart Motion in the specified slot. More... | |
| void | SetIMaxAccum (uint8_t slot, float maxAccum) |
| Sets the maximum accumulator value for the I term in the specified slot. More... | |
| void | SetSlot3Placeholder1 (uint8_t slot, float value) |
| Sets a placeholder value for slot 3 (purpose undefined) More... | |
| void | SetSlot3Placeholder2 (uint8_t slot, float value) |
| Sets a placeholder value for slot 3 (purpose undefined) More... | |
| void | SetSlot3Placeholder3 (uint8_t slot, float value) |
| Sets a placeholder value for slot 3 (purpose undefined) More... | |
| void | SetAnalogPositionConversion (float factor) |
| Sets the conversion factor for analog position readings. More... | |
| void | SetAnalogVelocityConversion (float factor) |
| Sets the conversion factor for analog velocity readings. More... | |
| void | SetAnalogAverageDepth (uint16_t depth) |
| Sets the average depth for analog readings. More... | |
| void | SetAnalogSensorMode (uint8_t mode) |
| Sets the analog sensor mode. More... | |
| void | SetAnalogInverted (bool inverted) |
| Sets whether the analog sensor is inverted. More... | |
| void | SetAnalogSampleDelta (uint16_t delta) |
| Sets the sample delta for analog readings. More... | |
| void | SetDataPortConfig (uint8_t config) |
| Configures the data port. More... | |
| void | SetAltEncoderCountsPerRev (uint16_t counts) |
| Sets the counts per revolution for the alternate encoder. More... | |
| void | SetAltEncoderAverageDepth (uint8_t depth) |
| Sets the average depth for the alternate encoder. More... | |
| void | SetAltEncoderSampleDelta (uint8_t delta) |
| Sets the sample delta for the alternate encoder. More... | |
| void | SetAltEncoderInverted (bool inverted) |
| Sets whether the alternate encoder is inverted. More... | |
| void | SetAltEncoderPositionFactor (float factor) |
| Sets the position factor for the alternate encoder. More... | |
| void | SetAltEncoderVelocityFactor (float factor) |
| Sets the velocity factor for the alternate encoder. More... | |
| void | SetDutyCyclePositionFactor (float factor) |
| Sets the position factor for the duty cycle encoder. More... | |
| void | SetDutyCycleVelocityFactor (float factor) |
| Sets the velocity factor for the duty cycle encoder. More... | |
| void | SetDutyCycleInverted (bool inverted) |
| Sets whether the duty cycle encoder is inverted. More... | |
| void | SetDutyCycleAverageDepth (uint8_t depth) |
| Sets the average depth for the duty cycle encoder. More... | |
| void | SetDutyCyclePrescalar (uint8_t prescalar) |
| Sets the prescalar for the duty cycle encoder. More... | |
| void | SetDutyCycleZeroOffset (float offset) |
| Sets the zero offset for the duty cycle encoder. More... | |
| uint8_t | GetMotorType () |
| Get the motor type. More... | |
| uint8_t | GetSensorType () |
| Get the sensor type. More... | |
| uint8_t | GetIdleMode () |
| Get the idle mode. More... | |
| float | GetInputDeadband () |
| Get the input deadband. More... | |
| bool | GetInverted () |
| Get whether the motor is inverted. More... | |
| float | GetRampRate () |
| Get the ramp rate. More... | |
| uint16_t | GetMotorKv () |
| Get the motor Kv rating. More... | |
| uint16_t | GetMotorR () |
| Get the motor resistance. More... | |
| uint16_t | GetMotorL () |
| Get the motor inductance. More... | |
| uint8_t | GetCtrlType () |
| Get the control type. More... | |
| uint16_t | GetFeedbackSensorPID0 () |
| Get the feedback sensor PID0 value. More... | |
| uint8_t | GetClosedLoopVoltageMode () |
| Get the closed loop voltage mode. More... | |
| float | GetCompensatedNominalVoltage () |
| Get the compensated nominal voltage. More... | |
| bool | GetPositionPIDWrapEnable () |
| Get the position PID wrap enable state. More... | |
| float | GetPositionPIDMinInput () |
| Get the position PID minimum input. More... | |
| float | GetPositionPIDMaxInput () |
| Get the position PID maximum input. More... | |
| uint16_t | GetPolePairs () |
| Get the number of pole pairs. More... | |
| float | GetCurrentChop () |
| Get the current chop value. More... | |
| uint16_t | GetCurrentChopCycles () |
| Get the current chop cycles. More... | |
| uint16_t | GetSmartCurrentStallLimit () |
| Get the smart current stall limit. More... | |
| uint16_t | GetSmartCurrentFreeLimit () |
| Get the smart current free limit. More... | |
| uint16_t | GetSmartCurrentConfig () |
| Get the smart current configuration. More... | |
| float | GetP (uint8_t slot) |
| Get the proportional (P) constant for a given slot. More... | |
| float | GetI (uint8_t slot) |
| Get the integral (I) constant for a given slot. More... | |
| float | GetD (uint8_t slot) |
| Get the derivative (D) constant for a given slot. More... | |
| float | GetF (uint8_t slot) |
| Get the feedforward (F) constant for a given slot. More... | |
| float | GetIZone (uint8_t slot) |
| Get the IZone value for a given slot. More... | |
| float | GetDFilter (uint8_t slot) |
| Get the DFilter value for a given slot. More... | |
| float | GetOutputMin (uint8_t slot) |
| Get the output minimum value for a given slot. More... | |
| float | GetOutputMax (uint8_t slot) |
| Get the output maximum value for a given slot. More... | |
| bool | GetHardLimitFwdEn () |
| Get the forward hard limit enable state. More... | |
| bool | GetHardLimitRevEn () |
| Get the reverse hard limit enable state. More... | |
| bool | GetLimitSwitchFwdPolarity () |
| Get the forward limit switch polarity. More... | |
| bool | GetLimitSwitchRevPolarity () |
| Get the reverse limit switch polarity. More... | |
| bool | GetSoftLimitFwdEn () |
| Get the forward soft limit enable state. More... | |
| bool | GetSoftLimitRevEn () |
| Get the reverse soft limit enable state. More... | |
| float | GetSoftLimitFwd () |
| Get the forward soft limit value. More... | |
| float | GetSoftLimitRev () |
| Get the reverse soft limit value. More... | |
| uint32_t | GetFollowerID () |
| Get the follower ID. More... | |
| uint32_t | GetFollowerConfig () |
| Get the follower configuration. More... | |
| uint16_t | GetEncoderCountsPerRev () |
| Get the encoder counts per revolution. More... | |
| uint8_t | GetEncoderAverageDepth () |
| Get the encoder average depth. More... | |
| uint8_t | GetEncoderSampleDelta () |
| Get the encoder sample delta. More... | |
| bool | GetEncoderInverted () |
| Get the encoder inversion state. More... | |
| float | GetPositionConversionFactor () |
| Get the position conversion factor. More... | |
| float | GetVelocityConversionFactor () |
| Get the velocity conversion factor. More... | |
| float | GetClosedLoopRampRate () |
| Get the closed loop ramp rate. More... | |
| float | GetHallSensorSampleRate () |
| Get the Hall sensor sample rate. More... | |
| uint16_t | GetHallSensorAverageDepth () |
| Get the Hall sensor average depth. More... | |
| float | GetSmartMotionMaxVelocity (uint8_t slot) |
| Get the maximum velocity for Smart Motion in a given slot. More... | |
| float | GetSmartMotionMaxAccel (uint8_t slot) |
| Get the maximum acceleration for Smart Motion in a given slot. More... | |
| float | GetSmartMotionMinVelOutput (uint8_t slot) |
| Get the minimum velocity output for Smart Motion in a given slot. More... | |
| float | GetSmartMotionAllowedClosedLoopError (uint8_t slot) |
| Get the allowed closed-loop error for Smart Motion in a given slot. More... | |
| float | GetSmartMotionAccelStrategy (uint8_t slot) |
| Get the acceleration strategy for Smart Motion in a given slot. More... | |
| float | GetIMaxAccum (uint8_t slot) |
| Get the maximum accumulated I term for Smart Motion in a given slot. More... | |
| float | GetSlot3Placeholder1 (uint8_t slot) |
| Get the value for Slot 3 Placeholder 1 in a given slot. More... | |
| float | GetSlot3Placeholder2 (uint8_t slot) |
| Get the value for Slot 3 Placeholder 2 in a given slot. More... | |
| float | GetSlot3Placeholder3 (uint8_t slot) |
| Get the value for Slot 3 Placeholder 3 in a given slot. More... | |
| float | GetAnalogPositionConversion () |
| Get the analog position conversion factor. More... | |
| float | GetAnalogVelocityConversion () |
| Get the analog velocity conversion factor. More... | |
| uint16_t | GetAnalogAverageDepth () |
| Get the analog average depth. More... | |
| uint8_t | GetAnalogSensorMode () |
| Get the analog sensor mode. More... | |
| bool | GetAnalogInverted () |
| Get the analog inversion state. More... | |
| uint16_t | GetAnalogSampleDelta () |
| Get the analog sample delta. More... | |
| uint8_t | GetDataPortConfig () |
| Get the data port configuration. More... | |
| uint16_t | GetAltEncoderCountsPerRev () |
| Get the alternate encoder counts per revolution. More... | |
| uint8_t | GetAltEncoderAverageDepth () |
| Get the alternate encoder average depth. More... | |
| uint8_t | GetAltEncoderSampleDelta () |
| Get the alternate encoder sample delta. More... | |
| bool | GetAltEncoderInverted () |
| Get the alternate encoder inversion state. More... | |
| float | GetAltEncoderPositionFactor () |
| Get the alternate encoder position factor. More... | |
| float | GetAltEncoderVelocityFactor () |
| Get the alternate encoder velocity factor. More... | |
| float | GetDutyCyclePositionFactor () |
| Get the duty cycle position factor. More... | |
| float | GetDutyCycleVelocityFactor () |
| Get the duty cycle velocity factor. More... | |
| bool | GetDutyCycleInverted () |
| Get the duty cycle inversion state. More... | |
| uint8_t | GetDutyCycleAverageDepth () |
| Get the duty cycle average depth. More... | |
| uint8_t | GetDutyCyclePrescalar () |
| Get the duty cycle prescalar. More... | |
| float | GetDutyCycleZeroOffset () |
| Get the duty cycle zero offset. More... | |
Static Public Member Functions | |
| static void | Heartbeat () |
| Sends a heartbeat signal to keep all SPARK controllers active. More... | |
A base class for controlling REV Robotics SPARK motor controllers via CAN bus.
This class provides methods to configure, control, and monitor SPARK motor controllers. It supports various control modes, parameter settings, and status readings.
| SparkBase::SparkBase | ( | const std::string & | interfaceName, |
| uint8_t | deviceId | ||
| ) |
Initializes SparkBase with the specified CAN interface and ID.
| interfaceName | The name of the CAN interface (e.g., "can0") |
| deviceId | The CAN ID of the SPARK controller (0-62) |
| std::out_of_range | if deviceId is greater than 62 |
| std::system_error | if socket creation fails, with detailed error information |
| std::runtime_error | if IOCTL fails or binding to the interface fails, with detailed error information |
This constructor attempts to initialize the CAN bus connection. If it fails, it will throw an exception with a detailed error message that includes possible causes and suggested solutions. Common issues that may cause exceptions include:
|
virtual |
Destructor for SparkBase.
Closes the socket connection
| void SparkBase::BurnFlash | ( | ) |
Burns the current configuration to the SPARK controller's flash memory.
| void SparkBase::ClearStickyFaults | ( | ) |
Clears sticky faults on the SPARK controller.
| void SparkBase::FactoryDefaults | ( | ) |
Resets the SPARK controller to factory default settings.
| void SparkBase::FactoryReset | ( | ) |
Performs a factory reset on the SPARK controller.
| uint8_t SparkBase::GetAltEncoderAverageDepth | ( | ) |
Get the alternate encoder average depth.
| uint16_t SparkBase::GetAltEncoderCountsPerRev | ( | ) |
Get the alternate encoder counts per revolution.
| bool SparkBase::GetAltEncoderInverted | ( | ) |
Get the alternate encoder inversion state.
| float SparkBase::GetAltEncoderPositionFactor | ( | ) |
Get the alternate encoder position factor.
| uint8_t SparkBase::GetAltEncoderSampleDelta | ( | ) |
Get the alternate encoder sample delta.
| float SparkBase::GetAltEncoderVelocityFactor | ( | ) |
Get the alternate encoder velocity factor.
| float SparkBase::GetAlternateEncoderPosition | ( | ) | const |
Gets the position from the alternate encoder.
| float SparkBase::GetAlternateEncoderVelocity | ( | ) | const |
Gets the velocity from the alternate encoder.
| uint16_t SparkBase::GetAnalogAverageDepth | ( | ) |
Get the analog average depth.
| bool SparkBase::GetAnalogInverted | ( | ) |
Get the analog inversion state.
| float SparkBase::GetAnalogPosition | ( | ) | const |
Gets the current analog position.
| float SparkBase::GetAnalogPositionConversion | ( | ) |
Get the analog position conversion factor.
| uint16_t SparkBase::GetAnalogSampleDelta | ( | ) |
Get the analog sample delta.
| uint8_t SparkBase::GetAnalogSensorMode | ( | ) |
Get the analog sensor mode.
| float SparkBase::GetAnalogVelocity | ( | ) | const |
Gets the current analog velocity.
| float SparkBase::GetAnalogVelocityConversion | ( | ) |
Get the analog velocity conversion factor.
| float SparkBase::GetAnalogVoltage | ( | ) | const |
Gets the current analog voltage.
| float SparkBase::GetClosedLoopRampRate | ( | ) |
Get the closed loop ramp rate.
| uint8_t SparkBase::GetClosedLoopVoltageMode | ( | ) |
Get the closed loop voltage mode.
| float SparkBase::GetCompensatedNominalVoltage | ( | ) |
Get the compensated nominal voltage.
| uint8_t SparkBase::GetCtrlType | ( | ) |
Get the control type.
| float SparkBase::GetCurrent | ( | ) | const |
Gets the current drawn by the SPARK controller.
| float SparkBase::GetCurrentChop | ( | ) |
Get the current chop value.
| uint16_t SparkBase::GetCurrentChopCycles | ( | ) |
Get the current chop cycles.
| float SparkBase::GetD | ( | uint8_t | slot | ) |
Get the derivative (D) constant for a given slot.
| slot | The PID slot (0-3). |
| uint8_t SparkBase::GetDataPortConfig | ( | ) |
Get the data port configuration.
| float SparkBase::GetDFilter | ( | uint8_t | slot | ) |
Get the DFilter value for a given slot.
| slot | The PID slot (0-3). |
| float SparkBase::GetDutyCycle | ( | ) | const |
Retrieves the current applied output.
| uint8_t SparkBase::GetDutyCycleAverageDepth | ( | ) |
Get the duty cycle average depth.
| bool SparkBase::GetDutyCycleInverted | ( | ) |
Get the duty cycle inversion state.
| float SparkBase::GetDutyCyclePositionFactor | ( | ) |
Get the duty cycle position factor.
| uint8_t SparkBase::GetDutyCyclePrescalar | ( | ) |
Get the duty cycle prescalar.
| float SparkBase::GetDutyCycleVelocityFactor | ( | ) |
Get the duty cycle velocity factor.
| float SparkBase::GetDutyCycleZeroOffset | ( | ) |
Get the duty cycle zero offset.
| uint8_t SparkBase::GetEncoderAverageDepth | ( | ) |
Get the encoder average depth.
| uint16_t SparkBase::GetEncoderCountsPerRev | ( | ) |
Get the encoder counts per revolution.
| bool SparkBase::GetEncoderInverted | ( | ) |
Get the encoder inversion state.
| uint8_t SparkBase::GetEncoderSampleDelta | ( | ) |
Get the encoder sample delta.
| float SparkBase::GetF | ( | uint8_t | slot | ) |
Get the feedforward (F) constant for a given slot.
| slot | The PID slot (0-3). |
| uint16_t SparkBase::GetFaults | ( | ) | const |
Retrieves the current faults.
| uint16_t SparkBase::GetFeedbackSensorPID0 | ( | ) |
Get the feedback sensor PID0 value.
| uint32_t SparkBase::GetFollowerConfig | ( | ) |
Get the follower configuration.
| uint32_t SparkBase::GetFollowerID | ( | ) |
Get the follower ID.
| uint16_t SparkBase::GetHallSensorAverageDepth | ( | ) |
Get the Hall sensor average depth.
| float SparkBase::GetHallSensorSampleRate | ( | ) |
Get the Hall sensor sample rate.
| bool SparkBase::GetHardLimitFwdEn | ( | ) |
Get the forward hard limit enable state.
| bool SparkBase::GetHardLimitRevEn | ( | ) |
Get the reverse hard limit enable state.
| float SparkBase::GetI | ( | uint8_t | slot | ) |
Get the integral (I) constant for a given slot.
| slot | The PID slot (0-3). |
| uint8_t SparkBase::GetIdleMode | ( | ) |
Get the idle mode.
| bool SparkBase::GetIdleMode | ( | ) | const |
Gets the current idle mode.
| float SparkBase::GetIMaxAccum | ( | uint8_t | slot | ) |
Get the maximum accumulated I term for Smart Motion in a given slot.
| slot | The Smart Motion slot (0-3). |
| float SparkBase::GetInputDeadband | ( | ) |
Get the input deadband.
| bool SparkBase::GetInverted | ( | ) |
Get whether the motor is inverted.
| bool SparkBase::GetInverted | ( | ) | const |
Checks if the motor is inverted.
| float SparkBase::GetIZone | ( | uint8_t | slot | ) |
Get the IZone value for a given slot.
| slot | The PID slot (0-3). |
| bool SparkBase::GetLimitSwitchFwdPolarity | ( | ) |
Get the forward limit switch polarity.
| bool SparkBase::GetLimitSwitchRevPolarity | ( | ) |
Get the reverse limit switch polarity.
| uint16_t SparkBase::GetMotorKv | ( | ) |
Get the motor Kv rating.
| uint16_t SparkBase::GetMotorL | ( | ) |
Get the motor inductance.
| uint16_t SparkBase::GetMotorR | ( | ) |
Get the motor resistance.
| uint8_t SparkBase::GetMotorType | ( | ) |
Get the motor type.
| float SparkBase::GetOutputMax | ( | uint8_t | slot | ) |
Get the output maximum value for a given slot.
| slot | The PID slot (0-3). |
| float SparkBase::GetOutputMin | ( | uint8_t | slot | ) |
Get the output minimum value for a given slot.
| slot | The PID slot (0-3). |
| float SparkBase::GetP | ( | uint8_t | slot | ) |
Get the proportional (P) constant for a given slot.
| slot | The PID slot (0-3). |
| uint16_t SparkBase::GetPolePairs | ( | ) |
Get the number of pole pairs.
| float SparkBase::GetPosition | ( | ) | const |
Gets the current position of the motor.
| float SparkBase::GetPositionConversionFactor | ( | ) |
Get the position conversion factor.
| float SparkBase::GetPositionPIDMaxInput | ( | ) |
Get the position PID maximum input.
| float SparkBase::GetPositionPIDMinInput | ( | ) |
Get the position PID minimum input.
| bool SparkBase::GetPositionPIDWrapEnable | ( | ) |
Get the position PID wrap enable state.
| float SparkBase::GetRampRate | ( | ) |
Get the ramp rate.
| uint8_t SparkBase::GetSensorType | ( | ) |
Get the sensor type.
| float SparkBase::GetSlot3Placeholder1 | ( | uint8_t | slot | ) |
Get the value for Slot 3 Placeholder 1 in a given slot.
| slot | The slot (0-3). |
| float SparkBase::GetSlot3Placeholder2 | ( | uint8_t | slot | ) |
Get the value for Slot 3 Placeholder 2 in a given slot.
| slot | The slot (0-3). |
| float SparkBase::GetSlot3Placeholder3 | ( | uint8_t | slot | ) |
Get the value for Slot 3 Placeholder 3 in a given slot.
| slot | The slot (0-3). |
| uint16_t SparkBase::GetSmartCurrentConfig | ( | ) |
Get the smart current configuration.
| uint16_t SparkBase::GetSmartCurrentFreeLimit | ( | ) |
Get the smart current free limit.
| uint16_t SparkBase::GetSmartCurrentStallLimit | ( | ) |
Get the smart current stall limit.
| float SparkBase::GetSmartMotionAccelStrategy | ( | uint8_t | slot | ) |
Get the acceleration strategy for Smart Motion in a given slot.
| slot | The Smart Motion slot (0-3). |
| float SparkBase::GetSmartMotionAllowedClosedLoopError | ( | uint8_t | slot | ) |
Get the allowed closed-loop error for Smart Motion in a given slot.
| slot | The Smart Motion slot (0-3). |
| float SparkBase::GetSmartMotionMaxAccel | ( | uint8_t | slot | ) |
Get the maximum acceleration for Smart Motion in a given slot.
| slot | The Smart Motion slot (0-3). |
| float SparkBase::GetSmartMotionMaxVelocity | ( | uint8_t | slot | ) |
Get the maximum velocity for Smart Motion in a given slot.
| slot | The Smart Motion slot (0-3). |
| float SparkBase::GetSmartMotionMinVelOutput | ( | uint8_t | slot | ) |
Get the minimum velocity output for Smart Motion in a given slot.
| slot | The Smart Motion slot (0-3). |
| float SparkBase::GetSoftLimitFwd | ( | ) |
Get the forward soft limit value.
| bool SparkBase::GetSoftLimitFwdEn | ( | ) |
Get the forward soft limit enable state.
| float SparkBase::GetSoftLimitRev | ( | ) |
Get the reverse soft limit value.
| bool SparkBase::GetSoftLimitRevEn | ( | ) |
Get the reverse soft limit enable state.
| uint16_t SparkBase::GetStickyFaults | ( | ) | const |
Retrieves the sticky faults.
| float SparkBase::GetTemperature | ( | ) | const |
Gets the current temperature of the SPARK controller.
| float SparkBase::GetVelocity | ( | ) | const |
Gets the current velocity.
| float SparkBase::GetVelocityConversionFactor | ( | ) |
Get the velocity conversion factor.
| float SparkBase::GetVoltage | ( | ) | const |
Gets the current voltage of the SPARK controller.
|
static |
Sends a heartbeat signal to keep all SPARK controllers active.
| void SparkBase::Identify | ( | ) |
Triggers the SPARK controller to identify itself.
| bool SparkBase::IsFollower | ( | ) | const |
Checks if the SPARK controller is in follower mode.
| void SparkBase::ResetFaults | ( | ) |
Resets all faults on the SPARK controller.
| void SparkBase::SetAltEncoderAverageDepth | ( | uint8_t | depth | ) |
Sets the average depth for the alternate encoder.
| depth | The average depth (1-64) |
| void SparkBase::SetAltEncoderCountsPerRev | ( | uint16_t | counts | ) |
Sets the counts per revolution for the alternate encoder.
| counts | The number of counts per revolution |
| void SparkBase::SetAltEncoderInverted | ( | bool | inverted | ) |
Sets whether the alternate encoder is inverted.
| inverted | True to invert the encoder, false otherwise |
| void SparkBase::SetAltEncoderPositionFactor | ( | float | factor | ) |
Sets the position factor for the alternate encoder.
| factor | The position factor |
| void SparkBase::SetAltEncoderSampleDelta | ( | uint8_t | delta | ) |
Sets the sample delta for the alternate encoder.
| delta | The sample delta (1-255) |
| void SparkBase::SetAltEncoderVelocityFactor | ( | float | factor | ) |
Sets the velocity factor for the alternate encoder.
| factor | The velocity factor |
| void SparkBase::SetAnalogAverageDepth | ( | uint16_t | depth | ) |
Sets the average depth for analog readings.
| depth | The average depth |
| void SparkBase::SetAnalogInverted | ( | bool | inverted | ) |
Sets whether the analog sensor is inverted.
| inverted | True to invert the sensor, false otherwise |
| void SparkBase::SetAnalogPositionConversion | ( | float | factor | ) |
Sets the conversion factor for analog position readings.
| factor | The conversion factor to apply to raw analog readings |
| void SparkBase::SetAnalogSampleDelta | ( | uint16_t | delta | ) |
Sets the sample delta for analog readings.
| delta | The sample delta |
| void SparkBase::SetAnalogSensorMode | ( | uint8_t | mode | ) |
Sets the analog sensor mode.
| mode | 0 for Absolute, 1 for Relative |
| void SparkBase::SetAnalogVelocityConversion | ( | float | factor | ) |
Sets the conversion factor for analog velocity readings.
| factor | The conversion factor to apply to raw analog readings |
| void SparkBase::SetClosedLoopRampRate | ( | float | rampRate | ) |
Sets the closed loop ramp rate.
| rampRate | The ramp rate in seconds from neutral to full output |
| void SparkBase::SetClosedLoopVoltageMode | ( | uint8_t | mode | ) |
Sets the closed loop voltage mode.
| mode | 0 for Disabled, 1 for Control Loop Voltage Output Mode, 2 for Voltage Compensation Mode |
| void SparkBase::SetCompensatedNominalVoltage | ( | float | voltage | ) |
Sets the compensated nominal voltage.
| voltage | The nominal voltage to compensate for |
| void SparkBase::SetCtrlType | ( | CtrlType | type | ) |
Sets the control type.
| type | CtrlType::kDutyCycle for Duty Cycle, CtrlType::kVelocity for Velocity, CtrlType::kVoltage for Voltage, CtrlType::kPosition for Position |
| void SparkBase::SetCurrent | ( | float | current | ) |
Sets the motor's current.
| current | The desired current |
| void SparkBase::SetCurrentChop | ( | float | chop | ) |
Sets the current chop limit.
| chop | The current chop limit (0-125 amps) |
| void SparkBase::SetCurrentChopCycles | ( | uint16_t | cycles | ) |
Sets the number of cycles for current chopping.
| cycles | The number of cycles |
| void SparkBase::SetD | ( | uint8_t | slot, |
| float | d | ||
| ) |
Sets the derivative gain for the specified PID slot.
| slot | The PID slot (0-3) |
| d | The derivative gain value |
| std::out_of_range | if slot is greater than 3 |
| void SparkBase::SetDataPortConfig | ( | uint8_t | config | ) |
Configures the data port.
| config | 0 for Default, 1 for Alternate Encoder Mode |
| void SparkBase::SetDFilter | ( | uint8_t | slot, |
| float | dFilter | ||
| ) |
Sets the derivative filter for the specified PID slot.
| slot | The PID slot (0-3) |
| dFilter | The derivative filter value |
| std::invalid_argument | if slot is greater than 3 |
| void SparkBase::SetDutyCycle | ( | float | dutyCycle | ) |
Sets the motor's applied output.
| dutyCycle | The desired applied output, range: [-1.0, 1.0] |
| void SparkBase::SetDutyCycleAverageDepth | ( | uint8_t | depth | ) |
Sets the average depth for the duty cycle encoder.
| depth | The average depth (0-7) |
| void SparkBase::SetDutyCycleInverted | ( | bool | inverted | ) |
Sets whether the duty cycle encoder is inverted.
| inverted | True to invert the encoder, false otherwise |
| void SparkBase::SetDutyCyclePositionFactor | ( | float | factor | ) |
Sets the position factor for the duty cycle encoder.
| factor | The position factor |
| void SparkBase::SetDutyCyclePrescalar | ( | uint8_t | prescalar | ) |
Sets the prescalar for the duty cycle encoder.
| prescalar | The prescalar value (0-71) |
| void SparkBase::SetDutyCycleVelocityFactor | ( | float | factor | ) |
Sets the velocity factor for the duty cycle encoder.
| factor | The velocity factor |
| void SparkBase::SetDutyCycleZeroOffset | ( | float | offset | ) |
Sets the zero offset for the duty cycle encoder.
| offset | The zero offset (0-1) |
| void SparkBase::SetEncoderAverageDepth | ( | uint8_t | depth | ) |
Sets the encoder average depth.
| depth | The average depth (1-64) |
| void SparkBase::SetEncoderCountsPerRev | ( | uint16_t | counts | ) |
Sets the encoder counts per revolution.
| counts | The number of counts per revolution |
| void SparkBase::SetEncoderInverted | ( | bool | inverted | ) |
Sets whether the encoder is inverted.
| inverted | True to invert the encoder, false otherwise |
| void SparkBase::SetEncoderSampleDelta | ( | uint8_t | delta | ) |
Sets the encoder sample delta.
| delta | The sample delta (1-255) |
| void SparkBase::SetF | ( | uint8_t | slot, |
| float | f | ||
| ) |
Sets the feedforward gain for the specified PID slot.
| slot | The PID slot (0-3) |
| f | The feedforward gain value |
| std::out_of_range | if slot is greater than 3 |
| void SparkBase::SetFeedbackSensorPID0 | ( | uint16_t | sensor | ) |
Sets the feedback sensor for PID0.
| sensor | The sensor type |
| void SparkBase::SetFollowerConfig | ( | uint32_t | config | ) |
Sets the follower configuration.
| config | The follower configuration value |
| void SparkBase::SetFollowerID | ( | uint32_t | id | ) |
Sets the follower ID for this SparkBase.
| id | The CAN ID of the SPARK controller to follow |
| void SparkBase::SetHallSensorAverageDepth | ( | uint16_t | depth | ) |
Sets the hall sensor average depth.
| depth | The average depth |
| void SparkBase::SetHallSensorSampleRate | ( | float | rate | ) |
Sets the hall sensor sample rate.
| rate | The sample rate in Hz |
| void SparkBase::SetHardLimitFwdEn | ( | bool | enable | ) |
Enables or disables the forward hard limit switch.
| enable | True to enable, false to disable |
| void SparkBase::SetHardLimitRevEn | ( | bool | enable | ) |
Enables or disables the reverse hard limit switch.
| enable | True to enable, false to disable |
| void SparkBase::SetI | ( | uint8_t | slot, |
| float | i | ||
| ) |
Sets the integral gain for the specified PID slot.
| slot | The PID slot (0-3) |
| i | The integral gain value |
| std::out_of_range | if slot is greater than 3 |
| void SparkBase::SetIdleMode | ( | IdleMode | mode | ) |
Sets the idle mode.
| mode | IdleMode::kCoast for Coast, IdleMode::kBrake for Brake |
| void SparkBase::SetIMaxAccum | ( | uint8_t | slot, |
| float | maxAccum | ||
| ) |
Sets the maximum accumulator value for the I term in the specified slot.
| slot | The PID slot (0-3) |
| maxAccum | The maximum accumulator value |
| std::invalid_argument | if slot is greater than 3 |
| void SparkBase::SetInputDeadband | ( | float | deadband | ) |
Sets the input deadband.
| deadband | The deadband value |
| void SparkBase::SetInputMode | ( | uint8_t | mode | ) |
Sets the input mode.
| mode | The input mode |
| void SparkBase::SetInverted | ( | bool | inverted | ) |
Sets whether the motor is inverted.
| inverted | True to invert the motor, false otherwise |
| void SparkBase::SetIZone | ( | uint8_t | slot, |
| float | iZone | ||
| ) |
Sets the integral zone for the specified PID slot.
| slot | The PID slot (0-3) |
| iZone | The integral zone value |
| std::invalid_argument | if slot is greater than 3 |
| void SparkBase::SetLimitSwitchFwdPolarity | ( | bool | polarity | ) |
Sets the polarity of the forward limit switch.
| polarity | True for normally open, false for normally closed |
| void SparkBase::SetLimitSwitchRevPolarity | ( | bool | polarity | ) |
Sets the polarity of the reverse limit switch.
| polarity | True for normally open, false for normally closed |
| void SparkBase::SetMotorKv | ( | uint16_t | kv | ) |
Sets the motor Kv (velocity constant)
| kv | The Kv value |
| void SparkBase::SetMotorL | ( | uint16_t | l | ) |
Sets the motor inductance.
| l | The inductance value |
| void SparkBase::SetMotorR | ( | uint16_t | r | ) |
Sets the motor resistance.
| r | The resistance value |
| void SparkBase::SetMotorType | ( | MotorType | type | ) |
Sets the motor type.
| type | MotorType::kBrushed for Brushed, MotorType::kBrushless for Brushless |
| void SparkBase::SetOutputMax | ( | uint8_t | slot, |
| float | max | ||
| ) |
Sets the output maximum for the specified PID slot.
| slot | The PID slot (0-3) |
| max | The maximum output value |
| std::invalid_argument | if slot is greater than 3 |
| void SparkBase::SetOutputMin | ( | uint8_t | slot, |
| float | min | ||
| ) |
Sets the output minimum for the specified PID slot.
| slot | The PID slot (0-3) |
| min | The minimum output value |
| std::invalid_argument | if slot is greater than 3 |
| void SparkBase::SetP | ( | uint8_t | slot, |
| float | p | ||
| ) |
Sets the proportional gain for the specified PID slot.
| slot | The PID slot (0-3) |
| p | The proportional gain value |
| void SparkBase::SetPolePairs | ( | uint16_t | pairs | ) |
Sets the number of pole pairs for brushless motors.
| pairs | The number of pole pairs |
| void SparkBase::SetPosition | ( | float | position | ) |
Sets the motor's position.
| position | The desired position |
| void SparkBase::SetPositionConversionFactor | ( | float | factor | ) |
Sets the position conversion factor.
| factor | The position conversion factor |
| void SparkBase::SetPositionPIDMaxInput | ( | float | maxInput | ) |
Sets the maximum input for position PID.
| maxInput | The maximum input value |
| std::invalid_argument | if maxInput is not a finite number |
| void SparkBase::SetPositionPIDMinInput | ( | float | minInput | ) |
Sets the minimum input for position PID.
| minInput | The minimum input value |
| void SparkBase::SetPositionPIDWrapEnable | ( | bool | enable | ) |
Enables or disables position PID wrap.
| enable | True to enable, false to disable |
| void SparkBase::SetRampRate | ( | float | rate | ) |
Sets the ramp rate.
| rate | The ramp rate in seconds from neutral to full output |
| void SparkBase::SetSensorType | ( | SensorType | sensor | ) |
Sets the sensor type.
| sensor | SensorType::kNoSensor for No Sensor, SensorType::kHallSensor for Hall Sensor, SensorType::kEncoder for Encoder |
| void SparkBase::SetSetpoint | ( | float | setpoint | ) |
Sets the value for the currently set control type.
| setpoint | The desired value |
| void SparkBase::SetSlot3Placeholder1 | ( | uint8_t | slot, |
| float | value | ||
| ) |
Sets a placeholder value for slot 3 (purpose undefined)
| slot | The PID slot (0-3) |
| value | The placeholder value |
| std::invalid_argument | if slot is greater than 3 |
| void SparkBase::SetSlot3Placeholder2 | ( | uint8_t | slot, |
| float | value | ||
| ) |
Sets a placeholder value for slot 3 (purpose undefined)
| slot | The PID slot (0-3) |
| value | The placeholder value |
| std::invalid_argument | if slot is greater than 3 |
| void SparkBase::SetSlot3Placeholder3 | ( | uint8_t | slot, |
| float | value | ||
| ) |
Sets a placeholder value for slot 3 (purpose undefined)
| slot | The PID slot (0-3) |
| value | The placeholder value |
| std::invalid_argument | if slot is greater than 3 |
| void SparkBase::SetSmartCurrentConfig | ( | uint16_t | config | ) |
Sets the smart current configuration.
| config | The configuration value |
| void SparkBase::SetSmartCurrentFreeLimit | ( | uint16_t | limit | ) |
Sets the smart current free limit.
| limit | The free current limit |
| void SparkBase::SetSmartCurrentStallLimit | ( | uint16_t | limit | ) |
Sets the smart current stall limit.
| limit | The stall current limit |
| void SparkBase::SetSmartMotion | ( | float | smartMotion | ) |
Sets the motor's smart motion.
| smartMotion | The desired smart motion value |
| void SparkBase::SetSmartMotionAccelStrategy | ( | uint8_t | slot, |
| float | strategy | ||
| ) |
Sets the acceleration strategy for Smart Motion in the specified slot.
| slot | The Smart Motion slot (0-3) |
| strategy | The acceleration strategy |
| std::invalid_argument | if slot is greater than 3 |
| void SparkBase::SetSmartMotionAllowedClosedLoopError | ( | uint8_t | slot, |
| float | error | ||
| ) |
Sets the allowed closed loop error for Smart Motion in the specified slot.
| slot | The Smart Motion slot (0-3) |
| error | The allowed closed loop error |
| std::invalid_argument | if slot is greater than 3 |
| void SparkBase::SetSmartMotionMaxAccel | ( | uint8_t | slot, |
| float | maxAccel | ||
| ) |
Sets the maximum acceleration for Smart Motion in the specified slot.
| slot | The Smart Motion slot (0-3) |
| maxAccel | The maximum acceleration |
| std::invalid_argument | if slot is greater than 3 |
| void SparkBase::SetSmartMotionMaxVelocity | ( | uint8_t | slot, |
| float | maxVel | ||
| ) |
Sets the maximum velocity for Smart Motion in the specified slot.
| slot | The Smart Motion slot (0-3) |
| maxVel | The maximum velocity |
| std::invalid_argument | if slot is greater than 3 |
| void SparkBase::SetSmartMotionMinVelOutput | ( | uint8_t | slot, |
| float | minVel | ||
| ) |
Sets the minimum velocity output for Smart Motion in the specified slot.
| slot | The Smart Motion slot (0-3) |
| minVel | The minimum velocity |
| std::invalid_argument | if slot is greater than 3 |
| void SparkBase::SetSmartVelocity | ( | float | smartVelocity | ) |
Sets the motor's smart velocity.
| smartVelocity | The desired smart velocity |
| void SparkBase::SetSoftLimitFwd | ( | float | limit | ) |
Sets the forward soft limit.
| limit | The forward soft limit value |
| void SparkBase::SetSoftLimitFwdEn | ( | bool | enable | ) |
Enables or disables the forward soft limit.
| enable | True to enable, false to disable |
| void SparkBase::SetSoftLimitRev | ( | float | limit | ) |
Sets the reverse soft limit.
| limit | The reverse soft limit value |
| void SparkBase::SetSoftLimitRevEn | ( | bool | enable | ) |
Enables or disables the reverse soft limit.
| enable | True to enable, false to disable |
| void SparkBase::SetVelocity | ( | float | velocity | ) |
Sets the motor's velocity.
| velocity | The desired velocity |
| void SparkBase::SetVelocityConversionFactor | ( | float | factor | ) |
Sets the velocity conversion factor.
| factor | The velocity conversion factor |
| void SparkBase::SetVoltage | ( | float | voltage | ) |
Sets the motor's voltage.
| voltage | The desired voltage |