Class SparkMaxWrapper

java.lang.Object
com.revrobotics.NativeResourceCleaner
com.revrobotics.spark.SparkLowLevel
com.revrobotics.spark.SparkBase
com.revrobotics.spark.SparkMax
frc.robot.motors.SparkMaxWrapper
All Implemented Interfaces:
com.revrobotics.REVDevice, edu.wpi.first.wpilibj.motorcontrol.MotorController, LoggedMotor, AutoCloseable

public class SparkMaxWrapper extends com.revrobotics.spark.SparkMax implements LoggedMotor
Spark max wrapper class, using SparkMaxSim.
  • Nested Class Summary

    Nested classes/interfaces inherited from class com.revrobotics.spark.SparkBase

    com.revrobotics.spark.SparkBase.ControlType, com.revrobotics.spark.SparkBase.Faults, com.revrobotics.spark.SparkBase.PersistMode, com.revrobotics.spark.SparkBase.ResetMode, com.revrobotics.spark.SparkBase.Warnings

    Nested classes/interfaces inherited from class com.revrobotics.spark.SparkLowLevel

    com.revrobotics.spark.SparkLowLevel.MotorType, com.revrobotics.spark.SparkLowLevel.PeriodicFrame, com.revrobotics.spark.SparkLowLevel.PeriodicStatus0, com.revrobotics.spark.SparkLowLevel.PeriodicStatus1, com.revrobotics.spark.SparkLowLevel.PeriodicStatus2, com.revrobotics.spark.SparkLowLevel.PeriodicStatus3, com.revrobotics.spark.SparkLowLevel.PeriodicStatus4, com.revrobotics.spark.SparkLowLevel.PeriodicStatus5, com.revrobotics.spark.SparkLowLevel.PeriodicStatus6, com.revrobotics.spark.SparkLowLevel.PeriodicStatus7, com.revrobotics.spark.SparkLowLevel.PeriodicStatus8, com.revrobotics.spark.SparkLowLevel.PeriodicStatus9, com.revrobotics.spark.SparkLowLevel.SparkModel

    Nested classes/interfaces inherited from class com.revrobotics.NativeResourceCleaner

    com.revrobotics.NativeResourceCleaner.OnClean
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final double
     

    Fields inherited from class com.revrobotics.spark.SparkMax

    configAccessor

    Fields inherited from class com.revrobotics.spark.SparkBase

    absoluteEncoder, absoluteEncoderLock, analogSensor, analogSensorLock, closedLoopController, closedLoopControllerLock, encoder, encoderLock, forwardLimitSwitch, forwardLimitSwitchLock, forwardSoftLimit, forwardSoftLimitLock, reverseLimitSwitch, reverseLimitSwitchLock, reverseSoftLimit, reverseSoftLimitLock

    Fields inherited from class com.revrobotics.spark.SparkLowLevel

    expectedSparkModel, isClosed, kAPIBuildVersion, kAPIMajorVersion, kAPIMinorVersion, kAPIVersion, motorType, sparkHandle
  • Constructor Summary

    Constructors
    Constructor
    Description
    SparkMaxWrapper(int deviceId, com.revrobotics.spark.SparkLowLevel.MotorType type)
    Constructor for CAN ID and motor type.
    SparkMaxWrapper(int deviceId, com.revrobotics.spark.SparkLowLevel.MotorType type, edu.wpi.first.math.system.plant.DCMotor motorConfigs)
    Constructor for CAN ID, motor type and an instance of DCMotor.
  • Method Summary

    Modifier and Type
    Method
    Description
    Gets the unique identifier of a motor for logging purposes.
    double
    Gets the current of the motor in amperes.
    double
    Gets the position of the motor in rotations.
    double
    Gets the setpoint of the motor in range [-1, 1].
    double
    Gets the angular velocity of the motor in rotations per minute.
    double
    Gets the voltage of the motor in volts.
    void
    set(double speed)
     
    void
    Updates the motors every tick.

    Methods inherited from class com.revrobotics.spark.SparkMax

    configure, configure, getAbsoluteEncoder, getAlternateEncoder, getForwardLimitSwitch, getReverseLimitSwitch

    Methods inherited from class com.revrobotics.spark.SparkBase

    clearFaults, configureAsync, configureAsync, disable, get, getAnalog, getAppliedOutput, getBusVoltage, getClosedLoopController, getEncoder, getFaults, getForwardSoftLimit, getInverted, getLastError, getMotorTemperature, getOutputCurrent, getReverseSoftLimit, getStickyFaults, getStickyWarnings, getWarnings, hasActiveFault, hasActiveWarning, hasStickyFault, hasStickyWarning, isFollower, pauseFollowerMode, pauseFollowerModeAsync, resumeFollowerMode, resumeFollowerModeAsync, setCANTimeout, setInverted, setVoltage, stopMotor

    Methods inherited from class com.revrobotics.spark.SparkLowLevel

    close, createSimFaultManager, getCleanAction, getDeviceId, getFirmwareString, getFirmwareVersion, getMotorType, getPeriodicStatus0, getPeriodicStatus1, getPeriodicStatus2, getPeriodicStatus3, getPeriodicStatus4, getPeriodicStatus5, getPeriodicStatus6, getPeriodicStatus7, getPeriodicStatus8, getPeriodicStatus9, getSafeFloat, getSerialNumber, setCANMaxRetries, setControlFramePeriodMs, setPeriodicFrameTimeout, throwIfClosed

    Methods inherited from class com.revrobotics.NativeResourceCleaner

    registerCleaner

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface frc.robot.motors.LoggedMotor

    init

    Methods inherited from interface edu.wpi.first.wpilibj.motorcontrol.MotorController

    setVoltage
  • Field Details

  • Constructor Details

    • SparkMaxWrapper

      public SparkMaxWrapper(int deviceId, com.revrobotics.spark.SparkLowLevel.MotorType type)
      Constructor for CAN ID and motor type.
      Parameters:
      deviceId - the CAN ID of the motor
      type - the type of motor
    • SparkMaxWrapper

      public SparkMaxWrapper(int deviceId, com.revrobotics.spark.SparkLowLevel.MotorType type, edu.wpi.first.math.system.plant.DCMotor motorConfigs)
      Constructor for CAN ID, motor type and an instance of DCMotor.
      Parameters:
      deviceId - the CAN ID of the motor
      type - the type of motor
      motorConfigs - the instance of DCMotor to use for sim calculations
  • Method Details

    • updateSimState

      public void updateSimState()
      Description copied from interface: LoggedMotor
      Updates the motors every tick.
      Specified by:
      updateSimState in interface LoggedMotor
    • set

      public void set(double speed)
      Specified by:
      set in interface edu.wpi.first.wpilibj.motorcontrol.MotorController
      Overrides:
      set in class com.revrobotics.spark.SparkBase
    • getIdentifier

      public String getIdentifier()
      Description copied from interface: LoggedMotor
      Gets the unique identifier of a motor for logging purposes. This value is intended to be the CAN ID.
      Specified by:
      getIdentifier in interface LoggedMotor
      Returns:
      the unique identifier for the motor
    • getLoggedPosition

      public double getLoggedPosition()
      Description copied from interface: LoggedMotor
      Gets the position of the motor in rotations.
      Specified by:
      getLoggedPosition in interface LoggedMotor
      Returns:
      the position of the motor in rotations
    • getLoggedVelocity

      public double getLoggedVelocity()
      Description copied from interface: LoggedMotor
      Gets the angular velocity of the motor in rotations per minute.
      Specified by:
      getLoggedVelocity in interface LoggedMotor
      Returns:
      the angular velocity of the motor in rotations per minute
    • getLoggedSetpoint

      public double getLoggedSetpoint()
      Description copied from interface: LoggedMotor
      Gets the setpoint of the motor in range [-1, 1].
      Specified by:
      getLoggedSetpoint in interface LoggedMotor
      Returns:
      the setpoint in range [-1, 1]
    • getLoggedVoltage

      public double getLoggedVoltage()
      Description copied from interface: LoggedMotor
      Gets the voltage of the motor in volts.
      Specified by:
      getLoggedVoltage in interface LoggedMotor
      Returns:
      the voltage of the motor
    • getLoggedCurrent

      public double getLoggedCurrent()
      Description copied from interface: LoggedMotor
      Gets the current of the motor in amperes.
      Specified by:
      getLoggedCurrent in interface LoggedMotor
      Returns:
      the current of the motor