Package frc.robot.motors
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
-
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.SparkModel -
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, reverseLimitSwitch, reverseLimitSwitchLockFields inherited from class com.revrobotics.spark.SparkLowLevel
expectedSparkModel, isClosed, kAPIBuildVersion, kAPIMajorVersion, kAPIMinorVersion, kAPIVersion, 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 dcMotor) 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 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.doublea.voidset(double speed) voidupdate()Updates the motors every tick.Methods inherited from class com.revrobotics.spark.SparkMax
configure, getAbsoluteEncoder, getAlternateEncoder, getForwardLimitSwitch, getReverseLimitSwitchMethods 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, stopMotorMethods inherited from class com.revrobotics.spark.SparkLowLevel
close, createSimFaultManager, getDeviceId, getFirmwareString, getFirmwareVersion, getMotorType, getSafeFloat, getSerialNumber, setCANMaxRetries, setControlFramePeriodMs, setPeriodicFrameTimeout, throwIfClosedMethods 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 dcMotor) Constructor for CAN ID, motor type and an instance of DCMotor.- Parameters:
deviceId- the CAN ID of the motortype- the type of motordcMotor- the instance of DCMotor to use for sim calculations
-
-
Method Details
-
update
public void update()Description copied from interface:LoggedMotorUpdates the motors every tick.- Specified by:
updatein 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:LoggedMotora.- Specified by:
getLoggedVoltagein interfaceLoggedMotor- Returns:
- a
-