Class SwerveSteeringSubsystem
java.lang.Object
org.wpilib.command2.SubsystemBase
xbot.common.command.BaseSubsystem
xbot.common.command.BaseSetpointSubsystem<Double,Double>
xbot.common.command.BaseSimpleSetpointSubsystem
xbot.common.subsystems.drive.swerve.SwerveSteeringSubsystem
- All Implemented Interfaces:
org.wpilib.command2.Subsystem, org.wpilib.telemetry.TelemetryLoggable, DataFrameRefreshable, SupportsSetpointLock, TunablePrefixProvider
public class SwerveSteeringSubsystem
extends BaseSimpleSetpointSubsystem
implements DataFrameRefreshable
-
Field Summary
Fields inherited from class BaseSetpointSubsystem
atGoal, lastTargetValueUsedforAtGoalFields inherited from class BaseSubsystem
aKitLog -
Constructor Summary
ConstructorsConstructorDescriptionSwerveSteeringSubsystem(SwerveInstance swerveInstance, XCANMotorController.XCANMotorControllerFactory mcFactory, XCANCoder.XCANCoderFactory canCoderFactory, TunableFactory tunableFactory, PIDManager.PIDManagerFactory pidf, XSwerveDriveElectricalContract electricalContract) -
Method Summary
Modifier and TypeMethodDescriptionorg.wpilib.units.measure.AngleGets the reported position of the CANCoder.org.wpilib.units.measure.AngleGets the current position of the mechanism using the best available encoder.org.wpilib.math.geometry.Rotation2dGets 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 degreesorg.wpilib.units.measure.AngularVelocitybooleanvoidperiodic()This method is called on eachCommandSchedulerloop.voidConsumes and processes inputs from the device or subsystem.voidCalculates the nearest position on the motor encoder to targetDegrees and sets the controller's PID target.voidSets the output power of the motor.voidsetTargetValue(Double value) Sets target angle in degreesorg.wpilib.command2.CommandsysIdDynamic(org.wpilib.command2.sysid.SysIdRoutine.Direction direction) Gets a command to run the SysId routine in the dynamic mode.org.wpilib.command2.CommandsysIdQuasistatic(org.wpilib.command2.sysid.SysIdRoutine.Direction direction) Gets a command to run the SysId routine in the quasistatic mode.Methods inherited from class BaseSimpleSetpointSubsystem
areTwoTargetsEquivalentMethods inherited from class BaseSetpointSubsystem
areTwoDoublesEquivalent, areTwoDoublesEquivalent, createSetTargetCommand, createSetTargetCommand, getSetpointLock, isMaintainerAtGoal, setMaintainerIsAtGoalMethods inherited from class org.wpilib.command2.SubsystemBase
getName, getTelemetryType, logTo, setNameMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.wpilib.command2.Subsystem
defer, getCurrentCommand, getDefaultCommand, idle, register, removeDefaultCommand, run, runEnd, runOnce, setDefaultCommand, simulationPeriodic, startEnd, startRun
-
Constructor Details
-
SwerveSteeringSubsystem
@Inject public SwerveSteeringSubsystem(SwerveInstance swerveInstance, XCANMotorController.XCANMotorControllerFactory mcFactory, XCANCoder.XCANCoderFactory canCoderFactory, TunableFactory tunableFactory, PIDManager.PIDManagerFactory pidf, XSwerveDriveElectricalContract electricalContract)
-
-
Method Details
-
getLabel
-
getPrefix
- Specified by:
getPrefixin interfaceTunablePrefixProvider- Overrides:
getPrefixin classBaseSubsystem
-
getCurrentValue
Gets current angle in degrees- Specified by:
getCurrentValuein classBaseSetpointSubsystem<Double,Double>
-
getCurrentRotation
public org.wpilib.math.geometry.Rotation2d getCurrentRotation()Gets current angle as a Rotation2d -
getTargetValue
Gets target angle in degrees- Specified by:
getTargetValuein classBaseSetpointSubsystem<Double,Double>
-
setTargetValue
Sets target angle in degrees- Specified by:
setTargetValuein classBaseSetpointSubsystem<Double,Double>
-
setPower
Sets the output power of the motor.- Specified by:
setPowerin classBaseSetpointSubsystem<Double,Double> - Parameters:
power- The power value, between -1 and 1.
-
isCalibrated
public boolean isCalibrated()- Specified by:
isCalibratedin classBaseSetpointSubsystem<Double,Double>
-
sysIdQuasistatic
public org.wpilib.command2.Command sysIdQuasistatic(org.wpilib.command2.sysid.SysIdRoutine.Direction direction) 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
public org.wpilib.command2.Command sysIdDynamic(org.wpilib.command2.sysid.SysIdRoutine.Direction direction) 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
public org.wpilib.units.measure.AngularVelocity getVelocity() -
getMotorController
Gets the motor controller for this steering module.- Returns:
- The motor controller for this steering module.
-
getEncoder
-
getBestEncoderPosition
public org.wpilib.units.measure.Angle getBestEncoderPosition()Gets the current position of the mechanism using the best available encoder.- Returns:
- The position in degrees.
-
getAbsoluteEncoderPosition
public org.wpilib.units.measure.Angle 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. -
periodic
public void periodic()Description copied from class:BaseSubsystemThis method is called on eachCommandSchedulerloop.- Specified by:
periodicin interfaceorg.wpilib.command2.Subsystem- Overrides:
periodicin classBaseSubsystem
-
refreshDataFrame
public void refreshDataFrame()Description copied from interface:DataFrameRefreshableConsumes and processes inputs from the device or subsystem.- Specified by:
refreshDataFramein interfaceDataFrameRefreshable
-