Class SparkMaxWrapper

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

public class SparkMaxWrapper extends com.revrobotics.spark.SparkMax implements LoggedMotor
  • 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.SparkModel
  • 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, reverseLimitSwitch, reverseLimitSwitchLock

    Fields inherited from class com.revrobotics.spark.SparkLowLevel

    expectedSparkModel, isClosed, kAPIBuildVersion, kAPIMajorVersion, kAPIMinorVersion, kAPIVersion, 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 dcMotor)
    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 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
    a.
    void
    set(double speed)
     
    void
    Updates the motors every tick.

    Methods inherited from class com.revrobotics.spark.SparkMax

    configure, getAbsoluteEncoder, getAlternateEncoder, getForwardLimitSwitch, getReverseLimitSwitch

    Methods inherited from class com.revrobotics.spark.SparkBase

    clearFaults, configureAsync, disable, get, getAnalog, getAppliedOutput, getBusVoltage, getClosedLoopController, getEncoder, getFaults, getInverted, getLastError, getMotorTemperature, getOutputCurrent, 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, getDeviceId, getFirmwareString, getFirmwareVersion, getMotorType, getSafeFloat, getSerialNumber, setCANMaxRetries, setControlFramePeriodMs, setPeriodicFrameTimeout, throwIfClosed

    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 dcMotor)
      Constructor for CAN ID, motor type and an instance of DCMotor.
      Parameters:
      deviceId - the CAN ID of the motor
      type - the type of motor
      dcMotor - the instance of DCMotor to use for sim calculations
  • Method Details

    • update

      public void update()
      Description copied from interface: LoggedMotor
      Updates the motors every tick.
      Specified by:
      update 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
      a.
      Specified by:
      getLoggedVoltage in interface LoggedMotor
      Returns:
      a