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.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
FieldsFields 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
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.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
update()
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
-
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:LoggedMotor
Updates the motors every tick.- Specified by:
update
in interfaceLoggedMotor
-
set
public void set(double speed) - Specified by:
set
in interfaceedu.wpi.first.wpilibj.motorcontrol.MotorController
- Overrides:
set
in classcom.revrobotics.spark.SparkBase
-
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 interfaceLoggedMotor
- 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 interfaceLoggedMotor
- 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 interfaceLoggedMotor
- 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 interfaceLoggedMotor
- Returns:
- the setpoint in range [-1, 1]
-
getLoggedVoltage
public double getLoggedVoltage()Description copied from interface:LoggedMotor
a.- Specified by:
getLoggedVoltage
in interfaceLoggedMotor
- Returns:
- a
-