sparkcan Documentation  1.0
SparkBase Class Reference

A base class for controlling REV Robotics SPARK motor controllers via CAN bus. More...

#include <SparkBase.hpp>

Inheritance diagram for SparkBase:

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...
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ SparkBase()

SparkBase::SparkBase ( const std::string &  interfaceName,
uint8_t  deviceId 
)

Initializes SparkBase with the specified CAN interface and ID.

Parameters
interfaceNameThe name of the CAN interface (e.g., "can0")
deviceIdThe CAN ID of the SPARK controller (0-62)
Exceptions
std::out_of_rangeif deviceId is greater than 62
std::system_errorif socket creation fails, with detailed error information
std::runtime_errorif 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:

  • Invalid device ID
  • CAN modules not loaded
  • System resource limitations
  • CAN interface not existing
  • CAN interface not being up
  • CAN bus not initialized
  • Interface already bound to another program

◆ ~SparkBase()

SparkBase::~SparkBase ( )
virtual

Destructor for SparkBase.

Closes the socket connection

Member Function Documentation

◆ BurnFlash()

void SparkBase::BurnFlash ( )

Burns the current configuration to the SPARK controller's flash memory.

◆ ClearStickyFaults()

void SparkBase::ClearStickyFaults ( )

Clears sticky faults on the SPARK controller.

◆ FactoryDefaults()

void SparkBase::FactoryDefaults ( )

Resets the SPARK controller to factory default settings.

◆ FactoryReset()

void SparkBase::FactoryReset ( )

Performs a factory reset on the SPARK controller.

◆ GetAltEncoderAverageDepth()

uint8_t SparkBase::GetAltEncoderAverageDepth ( )

Get the alternate encoder average depth.

Returns
Alternate encoder average depth as uint8_t.

◆ GetAltEncoderCountsPerRev()

uint16_t SparkBase::GetAltEncoderCountsPerRev ( )

Get the alternate encoder counts per revolution.

Returns
Alternate encoder counts per revolution as uint16_t.

◆ GetAltEncoderInverted()

bool SparkBase::GetAltEncoderInverted ( )

Get the alternate encoder inversion state.

Returns
Alternate encoder inversion state as bool.

◆ GetAltEncoderPositionFactor()

float SparkBase::GetAltEncoderPositionFactor ( )

Get the alternate encoder position factor.

Returns
Alternate encoder position factor as float.

◆ GetAltEncoderSampleDelta()

uint8_t SparkBase::GetAltEncoderSampleDelta ( )

Get the alternate encoder sample delta.

Returns
Alternate encoder sample delta as uint8_t.

◆ GetAltEncoderVelocityFactor()

float SparkBase::GetAltEncoderVelocityFactor ( )

Get the alternate encoder velocity factor.

Returns
Alternate encoder velocity factor as float.

◆ GetAlternateEncoderPosition()

float SparkBase::GetAlternateEncoderPosition ( ) const

Gets the position from the alternate encoder.

Returns
float The alternate encoder position in ticks

◆ GetAlternateEncoderVelocity()

float SparkBase::GetAlternateEncoderVelocity ( ) const

Gets the velocity from the alternate encoder.

Returns
float The alternate encoder velocity in RPM

◆ GetAnalogAverageDepth()

uint16_t SparkBase::GetAnalogAverageDepth ( )

Get the analog average depth.

Returns
Analog average depth as uint16_t.

◆ GetAnalogInverted()

bool SparkBase::GetAnalogInverted ( )

Get the analog inversion state.

Returns
Analog inversion state as bool.

◆ GetAnalogPosition()

float SparkBase::GetAnalogPosition ( ) const

Gets the current analog position.

Returns
float The analog position in ticks

◆ GetAnalogPositionConversion()

float SparkBase::GetAnalogPositionConversion ( )

Get the analog position conversion factor.

Returns
Analog position conversion factor as float.

◆ GetAnalogSampleDelta()

uint16_t SparkBase::GetAnalogSampleDelta ( )

Get the analog sample delta.

Returns
Analog sample delta as uint16_t.

◆ GetAnalogSensorMode()

uint8_t SparkBase::GetAnalogSensorMode ( )

Get the analog sensor mode.

Returns
Analog sensor mode as uint8_t.

◆ GetAnalogVelocity()

float SparkBase::GetAnalogVelocity ( ) const

Gets the current analog velocity.

Returns
float The analog velocity in RPM

◆ GetAnalogVelocityConversion()

float SparkBase::GetAnalogVelocityConversion ( )

Get the analog velocity conversion factor.

Returns
Analog velocity conversion factor as float.

◆ GetAnalogVoltage()

float SparkBase::GetAnalogVoltage ( ) const

Gets the current analog voltage.

Returns
float The analog voltage in volts

◆ GetClosedLoopRampRate()

float SparkBase::GetClosedLoopRampRate ( )

Get the closed loop ramp rate.

Returns
Closed loop ramp rate as float.

◆ GetClosedLoopVoltageMode()

uint8_t SparkBase::GetClosedLoopVoltageMode ( )

Get the closed loop voltage mode.

Returns
Closed loop voltage mode as uint8_t.

◆ GetCompensatedNominalVoltage()

float SparkBase::GetCompensatedNominalVoltage ( )

Get the compensated nominal voltage.

Returns
Compensated nominal voltage as float.

◆ GetCtrlType()

uint8_t SparkBase::GetCtrlType ( )

Get the control type.

Returns
Control type as uint8_t. (0 = Duty Cycle, 1 = Velocity, 2 = Voltage, 3 = Position)

◆ GetCurrent()

float SparkBase::GetCurrent ( ) const

Gets the current drawn by the SPARK controller.

Returns
float The current in amperes

◆ GetCurrentChop()

float SparkBase::GetCurrentChop ( )

Get the current chop value.

Returns
Current chop as float.

◆ GetCurrentChopCycles()

uint16_t SparkBase::GetCurrentChopCycles ( )

Get the current chop cycles.

Returns
Current chop cycles as uint16_t.

◆ GetD()

float SparkBase::GetD ( uint8_t  slot)

Get the derivative (D) constant for a given slot.

Parameters
slotThe PID slot (0-3).
Returns
Derivative constant as float.

◆ GetDataPortConfig()

uint8_t SparkBase::GetDataPortConfig ( )

Get the data port configuration.

Returns
Data port config as uint8_t.

◆ GetDFilter()

float SparkBase::GetDFilter ( uint8_t  slot)

Get the DFilter value for a given slot.

Parameters
slotThe PID slot (0-3).
Returns
DFilter value as float.

◆ GetDutyCycle()

float SparkBase::GetDutyCycle ( ) const

Retrieves the current applied output.

Returns
float The applied output, range: [-1.0, 1.0]

◆ GetDutyCycleAverageDepth()

uint8_t SparkBase::GetDutyCycleAverageDepth ( )

Get the duty cycle average depth.

Returns
Duty cycle average depth as uint8_t.

◆ GetDutyCycleInverted()

bool SparkBase::GetDutyCycleInverted ( )

Get the duty cycle inversion state.

Returns
Duty cycle inversion state as bool.

◆ GetDutyCyclePositionFactor()

float SparkBase::GetDutyCyclePositionFactor ( )

Get the duty cycle position factor.

Returns
Duty cycle position factor as float.

◆ GetDutyCyclePrescalar()

uint8_t SparkBase::GetDutyCyclePrescalar ( )

Get the duty cycle prescalar.

Returns
Duty cycle prescalar as uint8_t.

◆ GetDutyCycleVelocityFactor()

float SparkBase::GetDutyCycleVelocityFactor ( )

Get the duty cycle velocity factor.

Returns
Duty cycle velocity factor as float.

◆ GetDutyCycleZeroOffset()

float SparkBase::GetDutyCycleZeroOffset ( )

Get the duty cycle zero offset.

Returns
Duty cycle zero offset as float.

◆ GetEncoderAverageDepth()

uint8_t SparkBase::GetEncoderAverageDepth ( )

Get the encoder average depth.

Returns
Encoder average depth as uint8_t.

◆ GetEncoderCountsPerRev()

uint16_t SparkBase::GetEncoderCountsPerRev ( )

Get the encoder counts per revolution.

Returns
Encoder counts per revolution as uint16_t.

◆ GetEncoderInverted()

bool SparkBase::GetEncoderInverted ( )

Get the encoder inversion state.

Returns
Encoder inversion state as bool.

◆ GetEncoderSampleDelta()

uint8_t SparkBase::GetEncoderSampleDelta ( )

Get the encoder sample delta.

Returns
Encoder sample delta as uint8_t.

◆ GetF()

float SparkBase::GetF ( uint8_t  slot)

Get the feedforward (F) constant for a given slot.

Parameters
slotThe PID slot (0-3).
Returns
Feedforward constant as float.

◆ GetFaults()

uint16_t SparkBase::GetFaults ( ) const

Retrieves the current faults.

Returns
uint16_t A bitfield representing the current faults

◆ GetFeedbackSensorPID0()

uint16_t SparkBase::GetFeedbackSensorPID0 ( )

Get the feedback sensor PID0 value.

Returns
Feedback sensor PID0 as uint16_t.

◆ GetFollowerConfig()

uint32_t SparkBase::GetFollowerConfig ( )

Get the follower configuration.

Returns
Follower configuration as uint32_t.

◆ GetFollowerID()

uint32_t SparkBase::GetFollowerID ( )

Get the follower ID.

Returns
Follower ID as uint32_t.

◆ GetHallSensorAverageDepth()

uint16_t SparkBase::GetHallSensorAverageDepth ( )

Get the Hall sensor average depth.

Returns
Hall sensor average depth as uint16_t.

◆ GetHallSensorSampleRate()

float SparkBase::GetHallSensorSampleRate ( )

Get the Hall sensor sample rate.

Returns
Hall sensor sample rate as float.

◆ GetHardLimitFwdEn()

bool SparkBase::GetHardLimitFwdEn ( )

Get the forward hard limit enable state.

Returns
Forward hard limit enable state as bool.

◆ GetHardLimitRevEn()

bool SparkBase::GetHardLimitRevEn ( )

Get the reverse hard limit enable state.

Returns
Reverse hard limit enable state as bool.

◆ GetI()

float SparkBase::GetI ( uint8_t  slot)

Get the integral (I) constant for a given slot.

Parameters
slotThe PID slot (0-3).
Returns
Integral constant as float.

◆ GetIdleMode() [1/2]

uint8_t SparkBase::GetIdleMode ( )

Get the idle mode.

Returns
Idle mode as uint8_t. (0 = Coast, 1 = Brake)

◆ GetIdleMode() [2/2]

bool SparkBase::GetIdleMode ( ) const

Gets the current idle mode.

Returns
bool True if in brake mode, false if in coast mode

◆ GetIMaxAccum()

float SparkBase::GetIMaxAccum ( uint8_t  slot)

Get the maximum accumulated I term for Smart Motion in a given slot.

Parameters
slotThe Smart Motion slot (0-3).
Returns
Maximum I term accumulation as float.

◆ GetInputDeadband()

float SparkBase::GetInputDeadband ( )

Get the input deadband.

Returns
Input deadband as float.

◆ GetInverted() [1/2]

bool SparkBase::GetInverted ( )

Get whether the motor is inverted.

Returns
Inverted state as bool.

◆ GetInverted() [2/2]

bool SparkBase::GetInverted ( ) const

Checks if the motor is inverted.

Returns
bool True if the motor is inverted, false otherwise

◆ GetIZone()

float SparkBase::GetIZone ( uint8_t  slot)

Get the IZone value for a given slot.

Parameters
slotThe PID slot (0-3).
Returns
IZone value as float.

◆ GetLimitSwitchFwdPolarity()

bool SparkBase::GetLimitSwitchFwdPolarity ( )

Get the forward limit switch polarity.

Returns
Forward limit switch polarity as bool.

◆ GetLimitSwitchRevPolarity()

bool SparkBase::GetLimitSwitchRevPolarity ( )

Get the reverse limit switch polarity.

Returns
Reverse limit switch polarity as bool.

◆ GetMotorKv()

uint16_t SparkBase::GetMotorKv ( )

Get the motor Kv rating.

Returns
Motor Kv as uint16_t.

◆ GetMotorL()

uint16_t SparkBase::GetMotorL ( )

Get the motor inductance.

Returns
Motor inductance as uint16_t.

◆ GetMotorR()

uint16_t SparkBase::GetMotorR ( )

Get the motor resistance.

Returns
Motor resistance as uint16_t.

◆ GetMotorType()

uint8_t SparkBase::GetMotorType ( )

Get the motor type.

Returns
Motor type as uint8_t. (0 = Brushed, 1 = Brushless)

◆ GetOutputMax()

float SparkBase::GetOutputMax ( uint8_t  slot)

Get the output maximum value for a given slot.

Parameters
slotThe PID slot (0-3).
Returns
Output maximum value as float.

◆ GetOutputMin()

float SparkBase::GetOutputMin ( uint8_t  slot)

Get the output minimum value for a given slot.

Parameters
slotThe PID slot (0-3).
Returns
Output minimum value as float.

◆ GetP()

float SparkBase::GetP ( uint8_t  slot)

Get the proportional (P) constant for a given slot.

Parameters
slotThe PID slot (0-3).
Returns
Proportional constant as float.

◆ GetPolePairs()

uint16_t SparkBase::GetPolePairs ( )

Get the number of pole pairs.

Returns
Pole pairs as uint16_t.

◆ GetPosition()

float SparkBase::GetPosition ( ) const

Gets the current position of the motor.

Returns
float The position in ticks

◆ GetPositionConversionFactor()

float SparkBase::GetPositionConversionFactor ( )

Get the position conversion factor.

Returns
Position conversion factor as float.

◆ GetPositionPIDMaxInput()

float SparkBase::GetPositionPIDMaxInput ( )

Get the position PID maximum input.

Returns
Position PID maximum input as float.

◆ GetPositionPIDMinInput()

float SparkBase::GetPositionPIDMinInput ( )

Get the position PID minimum input.

Returns
Position PID minimum input as float.

◆ GetPositionPIDWrapEnable()

bool SparkBase::GetPositionPIDWrapEnable ( )

Get the position PID wrap enable state.

Returns
Position PID wrap enable state as bool.

◆ GetRampRate()

float SparkBase::GetRampRate ( )

Get the ramp rate.

Returns
Ramp rate as float.

◆ GetSensorType()

uint8_t SparkBase::GetSensorType ( )

Get the sensor type.

Returns
Sensor type as uint8_t. (0 = No Sensor, 1 = Hall Sensor, 2 = Encoder)

◆ GetSlot3Placeholder1()

float SparkBase::GetSlot3Placeholder1 ( uint8_t  slot)

Get the value for Slot 3 Placeholder 1 in a given slot.

Parameters
slotThe slot (0-3).
Returns
Placeholder value as float.

◆ GetSlot3Placeholder2()

float SparkBase::GetSlot3Placeholder2 ( uint8_t  slot)

Get the value for Slot 3 Placeholder 2 in a given slot.

Parameters
slotThe slot (0-3).
Returns
Placeholder value as float.

◆ GetSlot3Placeholder3()

float SparkBase::GetSlot3Placeholder3 ( uint8_t  slot)

Get the value for Slot 3 Placeholder 3 in a given slot.

Parameters
slotThe slot (0-3).
Returns
Placeholder value as float.

◆ GetSmartCurrentConfig()

uint16_t SparkBase::GetSmartCurrentConfig ( )

Get the smart current configuration.

Returns
Smart current config as uint16_t.

◆ GetSmartCurrentFreeLimit()

uint16_t SparkBase::GetSmartCurrentFreeLimit ( )

Get the smart current free limit.

Returns
Smart current free limit as uint16_t.

◆ GetSmartCurrentStallLimit()

uint16_t SparkBase::GetSmartCurrentStallLimit ( )

Get the smart current stall limit.

Returns
Smart current stall limit as uint16_t.

◆ GetSmartMotionAccelStrategy()

float SparkBase::GetSmartMotionAccelStrategy ( uint8_t  slot)

Get the acceleration strategy for Smart Motion in a given slot.

Parameters
slotThe Smart Motion slot (0-3).
Returns
Acceleration strategy as float.

◆ GetSmartMotionAllowedClosedLoopError()

float SparkBase::GetSmartMotionAllowedClosedLoopError ( uint8_t  slot)

Get the allowed closed-loop error for Smart Motion in a given slot.

Parameters
slotThe Smart Motion slot (0-3).
Returns
Allowed closed-loop error as float.

◆ GetSmartMotionMaxAccel()

float SparkBase::GetSmartMotionMaxAccel ( uint8_t  slot)

Get the maximum acceleration for Smart Motion in a given slot.

Parameters
slotThe Smart Motion slot (0-3).
Returns
Maximum acceleration as float.

◆ GetSmartMotionMaxVelocity()

float SparkBase::GetSmartMotionMaxVelocity ( uint8_t  slot)

Get the maximum velocity for Smart Motion in a given slot.

Parameters
slotThe Smart Motion slot (0-3).
Returns
Maximum velocity as float.

◆ GetSmartMotionMinVelOutput()

float SparkBase::GetSmartMotionMinVelOutput ( uint8_t  slot)

Get the minimum velocity output for Smart Motion in a given slot.

Parameters
slotThe Smart Motion slot (0-3).
Returns
Minimum velocity output as float.

◆ GetSoftLimitFwd()

float SparkBase::GetSoftLimitFwd ( )

Get the forward soft limit value.

Returns
Forward soft limit as float.

◆ GetSoftLimitFwdEn()

bool SparkBase::GetSoftLimitFwdEn ( )

Get the forward soft limit enable state.

Returns
Forward soft limit enable state as bool.

◆ GetSoftLimitRev()

float SparkBase::GetSoftLimitRev ( )

Get the reverse soft limit value.

Returns
Reverse soft limit as float.

◆ GetSoftLimitRevEn()

bool SparkBase::GetSoftLimitRevEn ( )

Get the reverse soft limit enable state.

Returns
Reverse soft limit enable state as bool.

◆ GetStickyFaults()

uint16_t SparkBase::GetStickyFaults ( ) const

Retrieves the sticky faults.

Returns
uint16_t A bitfield representing the sticky faults

◆ GetTemperature()

float SparkBase::GetTemperature ( ) const

Gets the current temperature of the SPARK controller.

Returns
float The temperature in degrees Celsius

◆ GetVelocity()

float SparkBase::GetVelocity ( ) const

Gets the current velocity.

Returns
float The current velocity in RPM

◆ GetVelocityConversionFactor()

float SparkBase::GetVelocityConversionFactor ( )

Get the velocity conversion factor.

Returns
Velocity conversion factor as float.

◆ GetVoltage()

float SparkBase::GetVoltage ( ) const

Gets the current voltage of the SPARK controller.

Returns
float The voltage in volts

◆ Heartbeat()

void SparkBase::Heartbeat ( )
static

Sends a heartbeat signal to keep all SPARK controllers active.

◆ Identify()

void SparkBase::Identify ( )

Triggers the SPARK controller to identify itself.

◆ IsFollower()

bool SparkBase::IsFollower ( ) const

Checks if the SPARK controller is in follower mode.

Returns
bool True if in follower mode, false otherwise

◆ ResetFaults()

void SparkBase::ResetFaults ( )

Resets all faults on the SPARK controller.

◆ SetAltEncoderAverageDepth()

void SparkBase::SetAltEncoderAverageDepth ( uint8_t  depth)

Sets the average depth for the alternate encoder.

Parameters
depthThe average depth (1-64)

◆ SetAltEncoderCountsPerRev()

void SparkBase::SetAltEncoderCountsPerRev ( uint16_t  counts)

Sets the counts per revolution for the alternate encoder.

Parameters
countsThe number of counts per revolution

◆ SetAltEncoderInverted()

void SparkBase::SetAltEncoderInverted ( bool  inverted)

Sets whether the alternate encoder is inverted.

Parameters
invertedTrue to invert the encoder, false otherwise

◆ SetAltEncoderPositionFactor()

void SparkBase::SetAltEncoderPositionFactor ( float  factor)

Sets the position factor for the alternate encoder.

Parameters
factorThe position factor

◆ SetAltEncoderSampleDelta()

void SparkBase::SetAltEncoderSampleDelta ( uint8_t  delta)

Sets the sample delta for the alternate encoder.

Parameters
deltaThe sample delta (1-255)

◆ SetAltEncoderVelocityFactor()

void SparkBase::SetAltEncoderVelocityFactor ( float  factor)

Sets the velocity factor for the alternate encoder.

Parameters
factorThe velocity factor

◆ SetAnalogAverageDepth()

void SparkBase::SetAnalogAverageDepth ( uint16_t  depth)

Sets the average depth for analog readings.

Parameters
depthThe average depth

◆ SetAnalogInverted()

void SparkBase::SetAnalogInverted ( bool  inverted)

Sets whether the analog sensor is inverted.

Parameters
invertedTrue to invert the sensor, false otherwise

◆ SetAnalogPositionConversion()

void SparkBase::SetAnalogPositionConversion ( float  factor)

Sets the conversion factor for analog position readings.

Parameters
factorThe conversion factor to apply to raw analog readings

◆ SetAnalogSampleDelta()

void SparkBase::SetAnalogSampleDelta ( uint16_t  delta)

Sets the sample delta for analog readings.

Parameters
deltaThe sample delta

◆ SetAnalogSensorMode()

void SparkBase::SetAnalogSensorMode ( uint8_t  mode)

Sets the analog sensor mode.

Parameters
mode0 for Absolute, 1 for Relative

◆ SetAnalogVelocityConversion()

void SparkBase::SetAnalogVelocityConversion ( float  factor)

Sets the conversion factor for analog velocity readings.

Parameters
factorThe conversion factor to apply to raw analog readings

◆ SetClosedLoopRampRate()

void SparkBase::SetClosedLoopRampRate ( float  rampRate)

Sets the closed loop ramp rate.

Parameters
rampRateThe ramp rate in seconds from neutral to full output

◆ SetClosedLoopVoltageMode()

void SparkBase::SetClosedLoopVoltageMode ( uint8_t  mode)

Sets the closed loop voltage mode.

Parameters
mode0 for Disabled, 1 for Control Loop Voltage Output Mode, 2 for Voltage Compensation Mode

◆ SetCompensatedNominalVoltage()

void SparkBase::SetCompensatedNominalVoltage ( float  voltage)

Sets the compensated nominal voltage.

Parameters
voltageThe nominal voltage to compensate for

◆ SetCtrlType()

void SparkBase::SetCtrlType ( CtrlType  type)

Sets the control type.

Parameters
typeCtrlType::kDutyCycle for Duty Cycle, CtrlType::kVelocity for Velocity, CtrlType::kVoltage for Voltage, CtrlType::kPosition for Position

◆ SetCurrent()

void SparkBase::SetCurrent ( float  current)

Sets the motor's current.

Parameters
currentThe desired current

◆ SetCurrentChop()

void SparkBase::SetCurrentChop ( float  chop)

Sets the current chop limit.

Parameters
chopThe current chop limit (0-125 amps)

◆ SetCurrentChopCycles()

void SparkBase::SetCurrentChopCycles ( uint16_t  cycles)

Sets the number of cycles for current chopping.

Parameters
cyclesThe number of cycles

◆ SetD()

void SparkBase::SetD ( uint8_t  slot,
float  d 
)

Sets the derivative gain for the specified PID slot.

Parameters
slotThe PID slot (0-3)
dThe derivative gain value
Exceptions
std::out_of_rangeif slot is greater than 3

◆ SetDataPortConfig()

void SparkBase::SetDataPortConfig ( uint8_t  config)

Configures the data port.

Parameters
config0 for Default, 1 for Alternate Encoder Mode

◆ SetDFilter()

void SparkBase::SetDFilter ( uint8_t  slot,
float  dFilter 
)

Sets the derivative filter for the specified PID slot.

Parameters
slotThe PID slot (0-3)
dFilterThe derivative filter value
Exceptions
std::invalid_argumentif slot is greater than 3

◆ SetDutyCycle()

void SparkBase::SetDutyCycle ( float  dutyCycle)

Sets the motor's applied output.

Parameters
dutyCycleThe desired applied output, range: [-1.0, 1.0]

◆ SetDutyCycleAverageDepth()

void SparkBase::SetDutyCycleAverageDepth ( uint8_t  depth)

Sets the average depth for the duty cycle encoder.

Parameters
depthThe average depth (0-7)

◆ SetDutyCycleInverted()

void SparkBase::SetDutyCycleInverted ( bool  inverted)

Sets whether the duty cycle encoder is inverted.

Parameters
invertedTrue to invert the encoder, false otherwise

◆ SetDutyCyclePositionFactor()

void SparkBase::SetDutyCyclePositionFactor ( float  factor)

Sets the position factor for the duty cycle encoder.

Parameters
factorThe position factor

◆ SetDutyCyclePrescalar()

void SparkBase::SetDutyCyclePrescalar ( uint8_t  prescalar)

Sets the prescalar for the duty cycle encoder.

Parameters
prescalarThe prescalar value (0-71)

◆ SetDutyCycleVelocityFactor()

void SparkBase::SetDutyCycleVelocityFactor ( float  factor)

Sets the velocity factor for the duty cycle encoder.

Parameters
factorThe velocity factor

◆ SetDutyCycleZeroOffset()

void SparkBase::SetDutyCycleZeroOffset ( float  offset)

Sets the zero offset for the duty cycle encoder.

Parameters
offsetThe zero offset (0-1)

◆ SetEncoderAverageDepth()

void SparkBase::SetEncoderAverageDepth ( uint8_t  depth)

Sets the encoder average depth.

Parameters
depthThe average depth (1-64)

◆ SetEncoderCountsPerRev()

void SparkBase::SetEncoderCountsPerRev ( uint16_t  counts)

Sets the encoder counts per revolution.

Parameters
countsThe number of counts per revolution

◆ SetEncoderInverted()

void SparkBase::SetEncoderInverted ( bool  inverted)

Sets whether the encoder is inverted.

Parameters
invertedTrue to invert the encoder, false otherwise

◆ SetEncoderSampleDelta()

void SparkBase::SetEncoderSampleDelta ( uint8_t  delta)

Sets the encoder sample delta.

Parameters
deltaThe sample delta (1-255)

◆ SetF()

void SparkBase::SetF ( uint8_t  slot,
float  f 
)

Sets the feedforward gain for the specified PID slot.

Parameters
slotThe PID slot (0-3)
fThe feedforward gain value
Exceptions
std::out_of_rangeif slot is greater than 3

◆ SetFeedbackSensorPID0()

void SparkBase::SetFeedbackSensorPID0 ( uint16_t  sensor)

Sets the feedback sensor for PID0.

Parameters
sensorThe sensor type

◆ SetFollowerConfig()

void SparkBase::SetFollowerConfig ( uint32_t  config)

Sets the follower configuration.

Parameters
configThe follower configuration value

◆ SetFollowerID()

void SparkBase::SetFollowerID ( uint32_t  id)

Sets the follower ID for this SparkBase.

Parameters
idThe CAN ID of the SPARK controller to follow

◆ SetHallSensorAverageDepth()

void SparkBase::SetHallSensorAverageDepth ( uint16_t  depth)

Sets the hall sensor average depth.

Parameters
depthThe average depth

◆ SetHallSensorSampleRate()

void SparkBase::SetHallSensorSampleRate ( float  rate)

Sets the hall sensor sample rate.

Parameters
rateThe sample rate in Hz

◆ SetHardLimitFwdEn()

void SparkBase::SetHardLimitFwdEn ( bool  enable)

Enables or disables the forward hard limit switch.

Parameters
enableTrue to enable, false to disable

◆ SetHardLimitRevEn()

void SparkBase::SetHardLimitRevEn ( bool  enable)

Enables or disables the reverse hard limit switch.

Parameters
enableTrue to enable, false to disable

◆ SetI()

void SparkBase::SetI ( uint8_t  slot,
float  i 
)

Sets the integral gain for the specified PID slot.

Parameters
slotThe PID slot (0-3)
iThe integral gain value
Exceptions
std::out_of_rangeif slot is greater than 3

◆ SetIdleMode()

void SparkBase::SetIdleMode ( IdleMode  mode)

Sets the idle mode.

Parameters
modeIdleMode::kCoast for Coast, IdleMode::kBrake for Brake

◆ SetIMaxAccum()

void SparkBase::SetIMaxAccum ( uint8_t  slot,
float  maxAccum 
)

Sets the maximum accumulator value for the I term in the specified slot.

Parameters
slotThe PID slot (0-3)
maxAccumThe maximum accumulator value
Exceptions
std::invalid_argumentif slot is greater than 3

◆ SetInputDeadband()

void SparkBase::SetInputDeadband ( float  deadband)

Sets the input deadband.

Parameters
deadbandThe deadband value

◆ SetInputMode()

void SparkBase::SetInputMode ( uint8_t  mode)

Sets the input mode.

Parameters
modeThe input mode

◆ SetInverted()

void SparkBase::SetInverted ( bool  inverted)

Sets whether the motor is inverted.

Parameters
invertedTrue to invert the motor, false otherwise

◆ SetIZone()

void SparkBase::SetIZone ( uint8_t  slot,
float  iZone 
)

Sets the integral zone for the specified PID slot.

Parameters
slotThe PID slot (0-3)
iZoneThe integral zone value
Exceptions
std::invalid_argumentif slot is greater than 3

◆ SetLimitSwitchFwdPolarity()

void SparkBase::SetLimitSwitchFwdPolarity ( bool  polarity)

Sets the polarity of the forward limit switch.

Parameters
polarityTrue for normally open, false for normally closed

◆ SetLimitSwitchRevPolarity()

void SparkBase::SetLimitSwitchRevPolarity ( bool  polarity)

Sets the polarity of the reverse limit switch.

Parameters
polarityTrue for normally open, false for normally closed

◆ SetMotorKv()

void SparkBase::SetMotorKv ( uint16_t  kv)

Sets the motor Kv (velocity constant)

Parameters
kvThe Kv value

◆ SetMotorL()

void SparkBase::SetMotorL ( uint16_t  l)

Sets the motor inductance.

Parameters
lThe inductance value

◆ SetMotorR()

void SparkBase::SetMotorR ( uint16_t  r)

Sets the motor resistance.

Parameters
rThe resistance value

◆ SetMotorType()

void SparkBase::SetMotorType ( MotorType  type)

Sets the motor type.

Parameters
typeMotorType::kBrushed for Brushed, MotorType::kBrushless for Brushless

◆ SetOutputMax()

void SparkBase::SetOutputMax ( uint8_t  slot,
float  max 
)

Sets the output maximum for the specified PID slot.

Parameters
slotThe PID slot (0-3)
maxThe maximum output value
Exceptions
std::invalid_argumentif slot is greater than 3

◆ SetOutputMin()

void SparkBase::SetOutputMin ( uint8_t  slot,
float  min 
)

Sets the output minimum for the specified PID slot.

Parameters
slotThe PID slot (0-3)
minThe minimum output value
Exceptions
std::invalid_argumentif slot is greater than 3

◆ SetP()

void SparkBase::SetP ( uint8_t  slot,
float  p 
)

Sets the proportional gain for the specified PID slot.

Parameters
slotThe PID slot (0-3)
pThe proportional gain value

◆ SetPolePairs()

void SparkBase::SetPolePairs ( uint16_t  pairs)

Sets the number of pole pairs for brushless motors.

Parameters
pairsThe number of pole pairs

◆ SetPosition()

void SparkBase::SetPosition ( float  position)

Sets the motor's position.

Parameters
positionThe desired position

◆ SetPositionConversionFactor()

void SparkBase::SetPositionConversionFactor ( float  factor)

Sets the position conversion factor.

Parameters
factorThe position conversion factor

◆ SetPositionPIDMaxInput()

void SparkBase::SetPositionPIDMaxInput ( float  maxInput)

Sets the maximum input for position PID.

Parameters
maxInputThe maximum input value
Exceptions
std::invalid_argumentif maxInput is not a finite number

◆ SetPositionPIDMinInput()

void SparkBase::SetPositionPIDMinInput ( float  minInput)

Sets the minimum input for position PID.

Parameters
minInputThe minimum input value

◆ SetPositionPIDWrapEnable()

void SparkBase::SetPositionPIDWrapEnable ( bool  enable)

Enables or disables position PID wrap.

Parameters
enableTrue to enable, false to disable

◆ SetRampRate()

void SparkBase::SetRampRate ( float  rate)

Sets the ramp rate.

Parameters
rateThe ramp rate in seconds from neutral to full output

◆ SetSensorType()

void SparkBase::SetSensorType ( SensorType  sensor)

Sets the sensor type.

Parameters
sensorSensorType::kNoSensor for No Sensor, SensorType::kHallSensor for Hall Sensor, SensorType::kEncoder for Encoder

◆ SetSetpoint()

void SparkBase::SetSetpoint ( float  setpoint)

Sets the value for the currently set control type.

Parameters
setpointThe desired value

◆ SetSlot3Placeholder1()

void SparkBase::SetSlot3Placeholder1 ( uint8_t  slot,
float  value 
)

Sets a placeholder value for slot 3 (purpose undefined)

Parameters
slotThe PID slot (0-3)
valueThe placeholder value
Exceptions
std::invalid_argumentif slot is greater than 3

◆ SetSlot3Placeholder2()

void SparkBase::SetSlot3Placeholder2 ( uint8_t  slot,
float  value 
)

Sets a placeholder value for slot 3 (purpose undefined)

Parameters
slotThe PID slot (0-3)
valueThe placeholder value
Exceptions
std::invalid_argumentif slot is greater than 3

◆ SetSlot3Placeholder3()

void SparkBase::SetSlot3Placeholder3 ( uint8_t  slot,
float  value 
)

Sets a placeholder value for slot 3 (purpose undefined)

Parameters
slotThe PID slot (0-3)
valueThe placeholder value
Exceptions
std::invalid_argumentif slot is greater than 3

◆ SetSmartCurrentConfig()

void SparkBase::SetSmartCurrentConfig ( uint16_t  config)

Sets the smart current configuration.

Parameters
configThe configuration value

◆ SetSmartCurrentFreeLimit()

void SparkBase::SetSmartCurrentFreeLimit ( uint16_t  limit)

Sets the smart current free limit.

Parameters
limitThe free current limit

◆ SetSmartCurrentStallLimit()

void SparkBase::SetSmartCurrentStallLimit ( uint16_t  limit)

Sets the smart current stall limit.

Parameters
limitThe stall current limit

◆ SetSmartMotion()

void SparkBase::SetSmartMotion ( float  smartMotion)

Sets the motor's smart motion.

Parameters
smartMotionThe desired smart motion value

◆ SetSmartMotionAccelStrategy()

void SparkBase::SetSmartMotionAccelStrategy ( uint8_t  slot,
float  strategy 
)

Sets the acceleration strategy for Smart Motion in the specified slot.

Parameters
slotThe Smart Motion slot (0-3)
strategyThe acceleration strategy
Exceptions
std::invalid_argumentif slot is greater than 3

◆ SetSmartMotionAllowedClosedLoopError()

void SparkBase::SetSmartMotionAllowedClosedLoopError ( uint8_t  slot,
float  error 
)

Sets the allowed closed loop error for Smart Motion in the specified slot.

Parameters
slotThe Smart Motion slot (0-3)
errorThe allowed closed loop error
Exceptions
std::invalid_argumentif slot is greater than 3

◆ SetSmartMotionMaxAccel()

void SparkBase::SetSmartMotionMaxAccel ( uint8_t  slot,
float  maxAccel 
)

Sets the maximum acceleration for Smart Motion in the specified slot.

Parameters
slotThe Smart Motion slot (0-3)
maxAccelThe maximum acceleration
Exceptions
std::invalid_argumentif slot is greater than 3

◆ SetSmartMotionMaxVelocity()

void SparkBase::SetSmartMotionMaxVelocity ( uint8_t  slot,
float  maxVel 
)

Sets the maximum velocity for Smart Motion in the specified slot.

Parameters
slotThe Smart Motion slot (0-3)
maxVelThe maximum velocity
Exceptions
std::invalid_argumentif slot is greater than 3

◆ SetSmartMotionMinVelOutput()

void SparkBase::SetSmartMotionMinVelOutput ( uint8_t  slot,
float  minVel 
)

Sets the minimum velocity output for Smart Motion in the specified slot.

Parameters
slotThe Smart Motion slot (0-3)
minVelThe minimum velocity
Exceptions
std::invalid_argumentif slot is greater than 3

◆ SetSmartVelocity()

void SparkBase::SetSmartVelocity ( float  smartVelocity)

Sets the motor's smart velocity.

Parameters
smartVelocityThe desired smart velocity

◆ SetSoftLimitFwd()

void SparkBase::SetSoftLimitFwd ( float  limit)

Sets the forward soft limit.

Parameters
limitThe forward soft limit value

◆ SetSoftLimitFwdEn()

void SparkBase::SetSoftLimitFwdEn ( bool  enable)

Enables or disables the forward soft limit.

Parameters
enableTrue to enable, false to disable

◆ SetSoftLimitRev()

void SparkBase::SetSoftLimitRev ( float  limit)

Sets the reverse soft limit.

Parameters
limitThe reverse soft limit value

◆ SetSoftLimitRevEn()

void SparkBase::SetSoftLimitRevEn ( bool  enable)

Enables or disables the reverse soft limit.

Parameters
enableTrue to enable, false to disable

◆ SetVelocity()

void SparkBase::SetVelocity ( float  velocity)

Sets the motor's velocity.

Parameters
velocityThe desired velocity

◆ SetVelocityConversionFactor()

void SparkBase::SetVelocityConversionFactor ( float  factor)

Sets the velocity conversion factor.

Parameters
factorThe velocity conversion factor

◆ SetVoltage()

void SparkBase::SetVoltage ( float  voltage)

Sets the motor's voltage.

Parameters
voltageThe desired voltage

The documentation for this class was generated from the following files: