Package frc.robot.motors
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
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.WarningsNested 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.SparkModelNested classes/interfaces inherited from class com.revrobotics.NativeResourceCleaner
com.revrobotics.NativeResourceCleaner.OnClean -
Field Summary
FieldsFields inherited from class com.revrobotics.spark.SparkMax
configAccessorFields inherited from class com.revrobotics.spark.SparkBase
absoluteEncoder, absoluteEncoderLock, analogSensor, analogSensorLock, closedLoopController, closedLoopControllerLock, encoder, encoderLock, forwardLimitSwitch, forwardLimitSwitchLock, forwardSoftLimit, forwardSoftLimitLock, reverseLimitSwitch, reverseLimitSwitchLock, reverseSoftLimit, reverseSoftLimitLockFields inherited from class com.revrobotics.spark.SparkLowLevel
expectedSparkModel, isClosed, kAPIBuildVersion, kAPIMajorVersion, kAPIMinorVersion, kAPIVersion, motorType, sparkHandle -
Constructor Summary
ConstructorsConstructorDescriptionSparkMaxWrapper(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 TypeMethodDescriptionGets the unique identifier of a motor for logging purposes.doubleGets the current of the motor in amperes.doubleGets the position of the motor in rotations.doubleGets the setpoint of the motor in range [-1, 1].doubleGets the angular velocity of the motor in rotations per minute.doubleGets the voltage of the motor in volts.voidset(double speed) voidUpdates the motors every tick.Methods inherited from class com.revrobotics.spark.SparkMax
configure, configure, getAbsoluteEncoder, getAlternateEncoder, getForwardLimitSwitch, getReverseLimitSwitchMethods 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, stopMotorMethods 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, throwIfClosedMethods inherited from class com.revrobotics.NativeResourceCleaner
registerCleanerMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface frc.robot.motors.LoggedMotor
initMethods inherited from interface edu.wpi.first.wpilibj.motorcontrol.MotorController
setVoltage
-
Field Details
-
LOOP_PERIOD_MS
public static final double LOOP_PERIOD_MS- See Also:
-
-
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 motortype- 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 motortype- the type of motormotorConfigs- the instance of DCMotor to use for sim calculations
-
-
Method Details
-
updateSimState
public void updateSimState()Description copied from interface:LoggedMotorUpdates the motors every tick.- Specified by:
updateSimStatein interfaceLoggedMotor
-
set
public void set(double speed) - Specified by:
setin interfaceedu.wpi.first.wpilibj.motorcontrol.MotorController- Overrides:
setin classcom.revrobotics.spark.SparkBase
-
getIdentifier
Description copied from interface:LoggedMotorGets the unique identifier of a motor for logging purposes. This value is intended to be the CAN ID.- Specified by:
getIdentifierin interfaceLoggedMotor- Returns:
- the unique identifier for the motor
-
getLoggedPosition
public double getLoggedPosition()Description copied from interface:LoggedMotorGets the position of the motor in rotations.- Specified by:
getLoggedPositionin interfaceLoggedMotor- Returns:
- the position of the motor in rotations
-
getLoggedVelocity
public double getLoggedVelocity()Description copied from interface:LoggedMotorGets the angular velocity of the motor in rotations per minute.- Specified by:
getLoggedVelocityin interfaceLoggedMotor- Returns:
- the angular velocity of the motor in rotations per minute
-
getLoggedSetpoint
public double getLoggedSetpoint()Description copied from interface:LoggedMotorGets the setpoint of the motor in range [-1, 1].- Specified by:
getLoggedSetpointin interfaceLoggedMotor- Returns:
- the setpoint in range [-1, 1]
-
getLoggedVoltage
public double getLoggedVoltage()Description copied from interface:LoggedMotorGets the voltage of the motor in volts.- Specified by:
getLoggedVoltagein interfaceLoggedMotor- Returns:
- the voltage of the motor
-
getLoggedCurrent
public double getLoggedCurrent()Description copied from interface:LoggedMotorGets the current of the motor in amperes.- Specified by:
getLoggedCurrentin interfaceLoggedMotor- Returns:
- the current of the motor
-