Class SparkBaseConfig

java.lang.Object
com.revrobotics.spark.config.BaseConfig
com.revrobotics.spark.config.SparkBaseConfig
Direct Known Subclasses:
SparkFlexConfig, SparkMaxConfig

public abstract class SparkBaseConfig extends BaseConfig
  • Field Details

  • Constructor Details

    • SparkBaseConfig

      public SparkBaseConfig()
  • Method Details

    • apply

      public SparkBaseConfig apply(SparkBaseConfig config)
      Applies settings from another SparkBaseConfig to this one, including all of its nested configurations.

      Settings in the provided config will overwrite existing values in this object. Settings not specified in the provided config remain unchanged.

      Parameters:
      config - The SparkBaseConfig to copy settings from
      Returns:
      The updated SparkBaseConfig for method chaining
    • apply

      public SparkBaseConfig apply(AbsoluteEncoderConfig config)
      Applies settings from an AbsoluteEncoderConfig to this SparkBaseConfig.

      Settings in the provided config will overwrite existing values in this object. Settings not specified in the provided config remain unchanged.

      Parameters:
      config - The AbsoluteEncoderConfig to copy settings from
      Returns:
      The updated SparkBaseConfig for method chaining
    • apply

      public SparkBaseConfig apply(AnalogSensorConfig config)
      Applies settings from an AnalogSensorConfig to this SparkBaseConfig.

      Settings in the provided config will overwrite existing values in this object. Settings not specified in the provided config remain unchanged.

      Parameters:
      config - The AnalogSensorConfig to copy settings from
      Returns:
      The updated SparkBaseConfig for method chaining
    • apply

      public SparkBaseConfig apply(EncoderConfig config)
      Applies settings from an EncoderConfig to this SparkBaseConfig.

      Settings in the provided config will overwrite existing values in this object. Settings not specified in the provided config remain unchanged.

      Parameters:
      config - The EncoderConfig to copy settings from
      Returns:
      The updated SparkBaseConfig for method chaining
    • apply

      public SparkBaseConfig apply(LimitSwitchConfig config)
      Applies settings from a LimitSwitchConfig to this SparkBaseConfig.

      Settings in the provided config will overwrite existing values in this object. Settings not specified in the provided config remain unchanged.

      Parameters:
      config - The LimitSwitchConfig to copy settings from
      Returns:
      The updated SparkBaseConfig for method chaining
    • apply

      public SparkBaseConfig apply(SoftLimitConfig config)
      Applies settings from a SoftLimitConfig to this SparkBaseConfig.

      Settings in the provided config will overwrite existing values in this object. Settings not specified in the provided config remain unchanged.

      Parameters:
      config - The SoftLimitConfig to copy settings from
      Returns:
      The updated SparkBaseConfig for method chaining
    • apply

      public SparkBaseConfig apply(ClosedLoopConfig config)
      Applies settings from a ClosedLoopConfig to this SparkBaseConfig.

      Settings in the provided config will overwrite existing values in this object. Settings not specified in the provided config remain unchanged.

      Parameters:
      config - The ClosedLoopConfig to copy settings from
      Returns:
      The updated SparkBaseConfig for method chaining
    • apply

      public SparkBaseConfig apply(SignalsConfig config)
      Applies settings from a SignalsConfig to this SparkBaseConfig.

      Settings in the provided config will overwrite existing values in this object. Settings not specified in the provided config remain unchanged.

      Parameters:
      config - The SignalsConfig to copy settings from
      Returns:
      The updated SparkBaseConfig for method chaining
    • idleMode

      public SparkBaseConfig idleMode(SparkBaseConfig.IdleMode idleMode)
      Sets the idle mode setting for the SPARK.
      Parameters:
      idleMode - Coast or brake
      Returns:
      The modified SparkBaseConfig object for method chaining
    • inverted

      public SparkBaseConfig inverted(boolean inverted)
      Common interface for inverting direction of a speed controller.

      This call has no effect if the controller is a follower. To invert a follower, see the follow() method.

      Parameters:
      inverted - True for inverted
      Returns:
      The modified SparkBaseConfig object for method chaining
    • smartCurrentLimit

      public SparkBaseConfig smartCurrentLimit(int stallLimit)
      Sets the current limit in Amps.

      The motor controller will reduce the controller voltage output to avoid surpassing this limit. This limit is enabled by default and used for brushless only. This limit is highly recommended when using the NEO brushless motor.

      The NEO Brushless Motor has a low internal resistance, which can mean large current spikes that could be enough to cause damage to the motor and controller. This current limit provides a smarter strategy to deal with high current draws and keep the motor and controller operating in a safe region.

      Parameters:
      stallLimit - The current limit in Amps.
      Returns:
      The modified SparkBaseConfig object for method chaining
    • smartCurrentLimit

      public SparkBaseConfig smartCurrentLimit(int stallLimit, int freeLimit)
      Sets the current limit in Amps.

      The motor controller will reduce the controller voltage output to avoid surpassing this limit. This limit is enabled by default and used for brushless only. This limit is highly recommended when using the NEO brushless motor.

      The NEO Brushless Motor has a low internal resistance, which can mean large current spikes that could be enough to cause damage to the motor and controller. This current limit provides a smarter strategy to deal with high current draws and keep the motor and controller operating in a safe region.

      The controller can also limit the current based on the RPM of the motor in a linear fashion to help with controllability in closed loop control. For a response that is linear the entire RPM range leave limit RPM at 0.

      Parameters:
      stallLimit - The current limit in Amps at 0 RPM.
      freeLimit - The current limit at free speed (5700RPM for NEO).
      Returns:
      The modified SparkBaseConfig object for method chaining
    • smartCurrentLimit

      public SparkBaseConfig smartCurrentLimit(int stallLimit, int freeLimit, int limitRpm)
      Sets the current limit in Amps.

      The motor controller will reduce the controller voltage output to avoid surpassing this limit. This limit is enabled by default and used for brushless only. This limit is highly recommended when using the NEO brushless motor.

      The NEO Brushless Motor has a low internal resistance, which can mean large current spikes that could be enough to cause damage to the motor and controller. This current limit provides a smarter strategy to deal with high current draws and keep the motor and controller operating in a safe region.

      The controller can also limit the current based on the RPM of the motor in a linear fashion to help with controllability in closed loop control. For a response that is linear the entire RPM range leave limit RPM at 0.

      Parameters:
      stallLimit - The current limit in Amps at 0 RPM.
      freeLimit - The current limit at free speed (5700RPM for NEO).
      limitRpm - RPM less than this value will be set to the stallLimit, RPM values greater than limitRpm will scale linearly to freeLimit
      Returns:
      The modified SparkBaseConfig object for method chaining
    • secondaryCurrentLimit

      public SparkBaseConfig secondaryCurrentLimit(double limit)
      Sets the secondary current limit in Amps.

      The motor controller will disable the output of the controller briefly if the current limit is exceeded to reduce the current. This limit is a simplified 'on/off' controller. This limit is enabled by default but is set higher than the default Smart Current Limit.

      The time the controller is off after the current limit is reached is determined by the parameter limitCycles, which is the number of PWM cycles (20kHz). The recommended value is the default of 0 which is the minimum time and is part of a PWM cycle from when the over current is detected. This allows the controller to regulate the current close to the limit value.

      The total time is set by the equation t = (50us - t0) + 50us * limitCycles t = total off time after over current t0 = time from the start of the PWM cycle until over current is detected

      Parameters:
      limit - The current limit in Amps.
      Returns:
      The modified SparkBaseConfig object for method chaining
    • secondaryCurrentLimit

      public SparkBaseConfig secondaryCurrentLimit(double limit, int chopCycles)
      Sets the secondary current limit in Amps.

      The motor controller will disable the output of the controller briefly if the current limit is exceeded to reduce the current. This limit is a simplified 'on/off' controller. This limit is enabled by default but is set higher than the default Smart Current Limit.

      The time the controller is off after the current limit is reached is determined by the parameter limitCycles, which is the number of PWM cycles (20kHz). The recommended value is the default of 0 which is the minimum time and is part of a PWM cycle from when the over current is detected. This allows the controller to regulate the current close to the limit value.

      The total time is set by the equation t = (50us - t0) + 50us * limitCycles t = total off time after over current t0 = time from the start of the PWM cycle until over current is detected

      Parameters:
      limit - The current limit in Amps.
      chopCycles - The number of additional PWM cycles to turn the driver off after overcurrent is detected.
      Returns:
      The modified SparkBaseConfig object for method chaining
    • openLoopRampRate

      public SparkBaseConfig openLoopRampRate(double rate)
      Sets the ramp rate for open loop control modes.

      This is the maximum rate at which the motor controller's output is allowed to change.

      Parameters:
      rate - Time in seconds to go from 0 to full throttle.
      Returns:
      The modified SparkBaseConfig object for method chaining
    • closedLoopRampRate

      public SparkBaseConfig closedLoopRampRate(double rate)
      Sets the ramp rate for closed loop control modes.

      This is the maximum rate at which the motor controller's output is allowed to change.

      Parameters:
      rate - Time in seconds to go from 0 to full throttle.
      Returns:
      The modified SparkBaseConfig object for method chaining
    • voltageCompensation

      public SparkBaseConfig voltageCompensation(double nominalVoltage)
      Sets the voltage compensation setting for all modes on the SPARK and enables voltage compensation.
      Parameters:
      nominalVoltage - Nominal voltage to compensate output to
      Returns:
      The modified SparkBaseConfig object for method chaining
    • disableVoltageCompensation

      public SparkBaseConfig disableVoltageCompensation()
      Disables the voltage compensation setting for all modes on the SPARK.
      Returns:
      The modified SparkBaseConfig object for method chaining
    • follow

      public SparkBaseConfig follow(SparkBase leader)
      Causes this controller's output to mirror the provided leader.

      Only voltage output is mirrored. Settings changed on the leader do not affect the follower.

      The motor will spin in the same direction as the leader. This can be changed by passing a true constant after the leader parameter.

      Following anything other than a CAN-enabled SPARK is not officially supported.

      Parameters:
      leader - The motor controller to follow.
      Returns:
      The modified SparkBaseConfig object for method chaining
    • follow

      public SparkBaseConfig follow(SparkBase leader, boolean invert)
      Causes this controller's output to mirror the provided leader.

      Only voltage output is mirrored. Settings changed on the leader do not affect the follower.

      Following anything other than a CAN-enabled SPARK is not officially supported.

      Parameters:
      leader - The motor controller to follow.
      invert - Set the follower to output opposite of the leader
      Returns:
      The modified SparkBaseConfig object for method chaining
    • follow

      public SparkBaseConfig follow(int leaderCanId)
      Causes this controller's output to mirror the provided leader.

      Only voltage output is mirrored. Settings changed on the leader do not affect the follower.

      The motor will spin in the same direction as the leader. This can be changed by passing a true constant after the deviceID parameter.

      Following anything other than a CAN-enabled SPARK is not officially supported.

      Parameters:
      leaderCanId - The CAN ID of the device to follow.
      Returns:
      The modified SparkBaseConfig object for method chaining
    • follow

      public SparkBaseConfig follow(int leaderCanId, boolean invert)
      Causes this controller's output to mirror the provided leader.

      Only voltage output is mirrored. Settings changed on the leader do not affect the follower.

      Following anything other than a CAN-enabled SPARK is not officially supported.

      Parameters:
      leaderCanId - The CAN ID of the device to follow.
      invert - Set the follower to output opposite of the leader
      Returns:
      The modified SparkBaseConfig object for method chaining
    • disableFollowerMode

      public SparkBaseConfig disableFollowerMode()
      Disables follower mode on the controller.
      Returns:
      The modified SparkBaseConfig object for method chaining
    • flatten

      public String flatten()
      Overrides:
      flatten in class BaseConfig