Class SwerveSteeringSubsystem
java.lang.Object
edu.wpi.first.wpilibj2.command.SubsystemBase
xbot.common.command.BaseSubsystem
xbot.common.command.BaseSetpointSubsystem<Double>
xbot.common.subsystems.drive.swerve.SwerveSteeringSubsystem
- All Implemented Interfaces:
Sendable
,Subsystem
,DataFrameRefreshable
,SupportsSetpointLock
,IPropertySupport
-
Field Summary
Fields inherited from class xbot.common.command.BaseSetpointSubsystem
atGoal, lastTargetValueUsedforAtGoal
Fields inherited from class xbot.common.command.BaseSubsystem
aKitLog, dataFrameRefreshables
-
Constructor Summary
ConstructorsConstructorDescriptionSwerveSteeringSubsystem
(SwerveInstance swerveInstance, XCANMotorController.XCANMotorControllerFactory mcFactory, XCANCoder.XCANCoderFactory canCoderFactory, PropertyFactory pf, PIDManager.PIDManagerFactory pidf, XSwerveDriveElectricalContract electricalContract) -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
areTwoTargetsEquivalent
(Double target1, Double target2) Gets the reported position of the CANCoder.Gets the current position of the mechanism using the best available encoder.Gets current angle as a Rotation2dGets current angle in degreesGets the CANCoder for this steering module.getLabel()
Gets the motor controller for this steering module.Gets target angle in degreesboolean
void
periodic()
This method is called on eachCommandScheduler
loop.void
Consumes and processes inputs from the device or subsystem.void
Calculates the nearest position on the motor encoder to targetDegrees and sets the controller's PID target.void
setPower
(double power) Sets the output power of the motor.void
setTargetValue
(Double value) Sets target angle in degreessysIdDynamic
(SysIdRoutine.Direction direction) Gets a command to run the SysId routine in the dynamic mode.sysIdQuasistatic
(SysIdRoutine.Direction direction) Gets a command to run the SysId routine in the quasistatic mode.Methods inherited from class xbot.common.command.BaseSetpointSubsystem
areTwoDoublesEquivalent, areTwoDoublesEquivalent, createSetTargetCommand, createSetTargetCommand, getSetpointLock, isMaintainerAtGoal, setMaintainerIsAtGoal
Methods inherited from class xbot.common.command.BaseSubsystem
registerDataFrameRefreshable
Methods inherited from class edu.wpi.first.wpilibj2.command.SubsystemBase
addChild, getName, getSubsystem, initSendable, setName, setSubsystem
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface edu.wpi.first.wpilibj2.command.Subsystem
defer, getCurrentCommand, getDefaultCommand, register, removeDefaultCommand, run, runEnd, runOnce, setDefaultCommand, simulationPeriodic, startEnd, startRun
-
Constructor Details
-
SwerveSteeringSubsystem
@Inject public SwerveSteeringSubsystem(SwerveInstance swerveInstance, XCANMotorController.XCANMotorControllerFactory mcFactory, XCANCoder.XCANCoderFactory canCoderFactory, PropertyFactory pf, PIDManager.PIDManagerFactory pidf, XSwerveDriveElectricalContract electricalContract)
-
-
Method Details
-
getLabel
-
getPrefix
- Specified by:
getPrefix
in interfaceIPropertySupport
- Overrides:
getPrefix
in classBaseSubsystem
-
getCurrentValue
Gets current angle in degrees- Specified by:
getCurrentValue
in classBaseSetpointSubsystem<Double>
-
getCurrentRotation
Gets current angle as a Rotation2d -
getTargetValue
Gets target angle in degrees- Specified by:
getTargetValue
in classBaseSetpointSubsystem<Double>
-
setTargetValue
Sets target angle in degrees- Specified by:
setTargetValue
in classBaseSetpointSubsystem<Double>
-
setPower
public void setPower(double power) Sets the output power of the motor.- Specified by:
setPower
in classBaseSetpointSubsystem<Double>
- Parameters:
power
- The power value, between -1 and 1.
-
isCalibrated
public boolean isCalibrated()- Specified by:
isCalibrated
in classBaseSetpointSubsystem<Double>
-
sysIdQuasistatic
Gets a command to run the SysId routine in the quasistatic mode.- Parameters:
direction
- The direction to run the SysId routine.- Returns:
- The command to run the SysId routine.
-
sysIdDynamic
Gets a command to run the SysId routine in the dynamic mode.- Parameters:
direction
- The direction to run the SysId routine.- Returns:
- The command to run the SysId routine.
-
getVelocity
-
getMotorController
Gets the motor controller for this steering module.- Returns:
- The motor controller for this steering module.
-
getEncoder
Gets the CANCoder for this steering module.- Returns:
- The CANCoder for this steering module.
-
getBestEncoderPosition
Gets the current position of the mechanism using the best available encoder.- Returns:
- The position in degrees.
-
getAbsoluteEncoderPosition
Gets the reported position of the CANCoder.- Returns:
- The position of the CANCoder.
-
setMotorControllerPidTarget
public void setMotorControllerPidTarget()Calculates the nearest position on the motor encoder to targetDegrees and sets the controller's PID target. -
areTwoTargetsEquivalent
- Specified by:
areTwoTargetsEquivalent
in classBaseSetpointSubsystem<Double>
-
periodic
public void periodic()Description copied from class:BaseSubsystem
This method is called on eachCommandScheduler
loop.- Specified by:
periodic
in interfaceSubsystem
- Overrides:
periodic
in classBaseSubsystem
-
refreshDataFrame
public void refreshDataFrame()Description copied from interface:DataFrameRefreshable
Consumes and processes inputs from the device or subsystem.- Specified by:
refreshDataFrame
in interfaceDataFrameRefreshable
- Overrides:
refreshDataFrame
in classBaseSubsystem
-