Class SwerveModuleSubsystem
java.lang.Object
org.wpilib.command2.SubsystemBase
xbot.common.command.BaseSubsystem
xbot.common.subsystems.drive.swerve.SwerveModuleSubsystem
- All Implemented Interfaces:
org.wpilib.command2.Subsystem, org.wpilib.telemetry.TelemetryLoggable, DataFrameRefreshable, TunablePrefixProvider
-
Field Summary
Fields inherited from class BaseSubsystem
aKitLog -
Constructor Summary
ConstructorsConstructorDescriptionSwerveModuleSubsystem(SwerveInstance swerveInstance, SwerveDriveSubsystem driveSubsystem, SwerveSteeringSubsystem steeringSubsystem, XSwerveDriveElectricalContract contract, TunableFactory tunableFactory) -
Method Summary
Modifier and TypeMethodDescriptionorg.wpilib.math.kinematics.SwerveModulePositionorg.wpilib.math.kinematics.SwerveModuleVelocityGets the current state of the module, in METRIC UNITS.org.wpilib.math.geometry.Translation2dorg.wpilib.math.kinematics.SwerveModuleVelocityvoidperiodic()This method is called on eachCommandSchedulerloop.voidConsumes and processes inputs from the device or subsystem.voidvoidsetNoviceMode(boolean enabled) voidsetPowers(double drivePower, double steeringPower) Very basic drive method - bypasses all PID to directly control the motors.voidsetTargetState(org.wpilib.math.kinematics.SwerveModuleVelocity swerveModuleState) Sets the target steering angle and drive power for this module, in METRIC UNITS.voidsetTargetState(org.wpilib.math.kinematics.SwerveModuleVelocity swerveModuleState, boolean optimize) Methods 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
-
SwerveModuleSubsystem
@Inject public SwerveModuleSubsystem(SwerveInstance swerveInstance, SwerveDriveSubsystem driveSubsystem, SwerveSteeringSubsystem steeringSubsystem, XSwerveDriveElectricalContract contract, TunableFactory tunableFactory)
-
-
Method Details
-
setTargetState
public void setTargetState(org.wpilib.math.kinematics.SwerveModuleVelocity swerveModuleState) Sets the target steering angle and drive power for this module, in METRIC UNITS.- Parameters:
swerveModuleState- Metric swerve module state
-
setTargetState
public void setTargetState(org.wpilib.math.kinematics.SwerveModuleVelocity swerveModuleState, boolean optimize) -
getCurrentState
public org.wpilib.math.kinematics.SwerveModuleVelocity getCurrentState()Gets the current state of the module, in METRIC UNITS.- Returns:
- Metric swerve module state
-
getCurrentPosition
public org.wpilib.math.kinematics.SwerveModulePosition getCurrentPosition() -
getTargetState
public org.wpilib.math.kinematics.SwerveModuleVelocity getTargetState() -
getPrefix
- Specified by:
getPrefixin interfaceTunablePrefixProvider- Overrides:
getPrefixin classBaseSubsystem
-
getModuleTranslation
public org.wpilib.math.geometry.Translation2d getModuleTranslation() -
getDriveSubsystem
-
getSteeringSubsystem
-
setNoviceMode
public void setNoviceMode(boolean enabled) -
setPowers
public void setPowers(double drivePower, double steeringPower) Very basic drive method - bypasses all PID to directly control the motors. Ensure that your command has required control of all relevant subsystems before doing this, or you will be fighting the maintainers.- Parameters:
drivePower- -1 to 1 value for nodule wheel powersteeringPower- -1 to 1 value for module rotation power
-
setDriveCurrentLimits
-
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
-