Package xbot.common.subsystems.drive
Class BaseSwerveDriveSubsystem
java.lang.Object
edu.wpi.first.wpilibj2.command.SubsystemBase
xbot.common.command.BaseSubsystem
xbot.common.subsystems.drive.BaseDriveSubsystem
xbot.common.subsystems.drive.BaseSwerveDriveSubsystem
- All Implemented Interfaces:
Sendable
,Subsystem
,DataFrameRefreshable
,IPropertySupport
,ISwerveAdvisorDriveSupport
public abstract class BaseSwerveDriveSubsystem
extends BaseDriveSubsystem
implements DataFrameRefreshable, ISwerveAdvisorDriveSupport
-
Nested Class Summary
-
Field Summary
Fields inherited from class xbot.common.subsystems.drive.BaseDriveSubsystem
kThrottleDeadband, lastRawCommandedDirection, lastRawCommandedRotation
Fields inherited from class xbot.common.command.BaseSubsystem
aKitLog, dataFrameRefreshables
-
Constructor Summary
ConstructorDescriptionBaseSwerveDriveSubsystem
(PIDManager.PIDManagerFactory pidFactory, PropertyFactory pf, SwerveComponent frontLeftSwerve, SwerveComponent frontRightSwerve, SwerveComponent rearLeftSwerve, SwerveComponent rearRightSwerve) -
Method Summary
Modifier and TypeMethodDescriptionvoid
controlOnlyActiveSwerveModuleSubsystem
(double drivePower, double steeringPower) Controls the drive power and steering power of the active module.void
crabDrive
(double drivePower, double steeringPower) Give the same power to all steering modules, and the another power to all the drive wheels.void
fieldOrientedDrive
(XYPair translation, double rotation, double currentHeading, XYPair centerOfRotationInches) double
protected PIDDefaults
Returns the default PID values for the heading PID.double
Returns the total distance tracked by the encoder - On the LEFT side of the robot - Pointing in the direction of +Y traveldouble
double
protected PIDDefaults
Returns the default PID values for the positional PID.double
double
Returns the total distance tracked by the encoder - On the RIGHT side of the robot - Pointing in the direction of +Y traveldouble
Returns the total distance tracked by the encoder - In the center of the robot - Pointing in the direction of +X traveldouble
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
void
Set the target movement speed and rotation, rotating around the center of the robot.void
Set the target movement speed and rotation, with an arbitrary center of rotation.void
periodic()
This method is called on eachCommandScheduler
loop.void
Consumes and processes inputs from the device or subsystem.void
setActivateBrakeOverride
(boolean activateBrakeOverride) void
setActiveModule
(BaseSwerveDriveSubsystem.SwerveModuleLocation activeModule) Meant to be used alongside debugging methods.void
setCollectorOrientedTurningActive
(boolean isActive) void
setDesiredHeading
(double heading) void
void
setExtremePrecisionTranslationActive
(boolean isActive) void
setGamePieceOrientatedRotationActive
(boolean isActive) void
setIsRobotOrientedDrive
(boolean isActive) void
setManualBalanceMode
(boolean isActive) void
Meant to be used alongside debugging methods.void
setNoviceMode
(boolean enabled) void
setPositionMaintainerXTarget
(double positionMaintainerXTarget) void
setPrecisionRotationActive
(boolean isActive) void
setPrecisionTranslationActive
(boolean isActive) void
setQuickAlignActive
(boolean isActive) void
setRotateToHubActive
(boolean isActive) void
setUnlockFullDrivePower
(boolean value) void
setVelocityMaintainerXTarget
(double velocityMaintainerXTarget) void
Methods inherited from class xbot.common.subsystems.drive.BaseDriveSubsystem
arcadeDrive, cheesyDrive, drive, drive, drive, fieldOrientedDrive, getMaxOutput, setQuickTurn, stop, tankDrive
Methods inherited from class xbot.common.command.BaseSubsystem
getPrefix, 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 xbot.common.subsystems.drive.swerve.ISwerveAdvisorDriveSupport
getLookAtPointActive, getLookAtPointTarget, getStaticHeadingActive, getStaticHeadingTarget
Methods inherited from interface edu.wpi.first.wpilibj2.command.Subsystem
defer, getCurrentCommand, getDefaultCommand, register, removeDefaultCommand, run, runEnd, runOnce, setDefaultCommand, simulationPeriodic, startEnd, startRun
-
Constructor Details
-
BaseSwerveDriveSubsystem
public BaseSwerveDriveSubsystem(PIDManager.PIDManagerFactory pidFactory, PropertyFactory pf, SwerveComponent frontLeftSwerve, SwerveComponent frontRightSwerve, SwerveComponent rearLeftSwerve, SwerveComponent rearRightSwerve)
-
-
Method Details
-
getPositionalPIDDefaults
Returns the default PID values for the positional PID. Override this method to change the default values.- Returns:
- The default PID values.
-
getHeadingPIDDefaults
Returns the default PID values for the heading PID. Override this method to change the default values.- Returns:
- The default PID values.
-
getSwerveDriveKinematics
-
getMaxTargetSpeedMetersPerSecond
public double getMaxTargetSpeedMetersPerSecond() -
getMaxTargetTurnRate
public double getMaxTargetTurnRate() -
getPositionalPid
- Specified by:
getPositionalPid
in classBaseDriveSubsystem
-
getRotateToHeadingPid
- Specified by:
getRotateToHeadingPid
in classBaseDriveSubsystem
-
getRotateDecayPid
- Specified by:
getRotateDecayPid
in classBaseDriveSubsystem
-
fieldOrientedDrive
-
setManualBalanceMode
public void setManualBalanceMode(boolean isActive) -
isManualBalanceModeActive
public boolean isManualBalanceModeActive() -
isGamePieceRotationActive
public boolean isGamePieceRotationActive() -
setGamePieceOrientatedRotationActive
public void setGamePieceOrientatedRotationActive(boolean isActive) -
isCollectorRotationActive
public boolean isCollectorRotationActive() -
setCollectorOrientedTurningActive
public void setCollectorOrientedTurningActive(boolean isActive) -
isUnlockFullDrivePowerActive
public boolean isUnlockFullDrivePowerActive() -
setUnlockFullDrivePower
public void setUnlockFullDrivePower(boolean value) -
createUnlockFullDrivePowerCommand
-
isPrecisionTranslationActive
public boolean isPrecisionTranslationActive() -
isExtremePrecisionTranslationActive
public boolean isExtremePrecisionTranslationActive() -
setPrecisionTranslationActive
public void setPrecisionTranslationActive(boolean isActive) -
setExtremePrecisionTranslationActive
public void setExtremePrecisionTranslationActive(boolean isActive) -
isPrecisionRotationActive
public boolean isPrecisionRotationActive() -
setPrecisionRotationActive
public void setPrecisionRotationActive(boolean isActive) -
isRobotOrientedDriveActive
public boolean isRobotOrientedDriveActive() -
setIsRobotOrientedDrive
public void setIsRobotOrientedDrive(boolean isActive) -
setQuickAlignActive
public void setQuickAlignActive(boolean isActive) -
isQuickAlignActive
public boolean isQuickAlignActive() -
isRotateToHubActive
public boolean isRotateToHubActive() -
setRotateToHubActive
public void setRotateToHubActive(boolean isActive) -
move
Set the target movement speed and rotation, rotating around the center of the robot.- Specified by:
move
in classBaseDriveSubsystem
- Parameters:
translate
- The translation velocity.rotate
- The rotation velocity.
-
move
Set the target movement speed and rotation, with an arbitrary center of rotation.- Parameters:
translate
- The translation velocity.rotate
- The rotation velocity.centerOfRotationInches
- The center of rotation.
-
setActivateBrakeOverride
public void setActivateBrakeOverride(boolean activateBrakeOverride) -
setWheelsToXMode
public void setWheelsToXMode() -
crabDrive
public void crabDrive(double drivePower, double steeringPower) Give the same power to all steering modules, and the another power to all the drive wheels. Does not currently use PID! As a result, wheel positions will vary wildly!- Parameters:
drivePower
- -1 to 1 power to apply to the drive wheels.steeringPower
- -1 to 1 power to apply to the steering modules.
-
getLeftTotalDistance
public double getLeftTotalDistance()Description copied from class:BaseDriveSubsystem
Returns the total distance tracked by the encoder - On the LEFT side of the robot - Pointing in the direction of +Y travel- Specified by:
getLeftTotalDistance
in classBaseDriveSubsystem
-
getRightTotalDistance
public double getRightTotalDistance()Description copied from class:BaseDriveSubsystem
Returns the total distance tracked by the encoder - On the RIGHT side of the robot - Pointing in the direction of +Y travel- Specified by:
getRightTotalDistance
in classBaseDriveSubsystem
-
getTransverseDistance
public double getTransverseDistance()Description copied from class:BaseDriveSubsystem
Returns the total distance tracked by the encoder - In the center of the robot - Pointing in the direction of +X travel- Specified by:
getTransverseDistance
in classBaseDriveSubsystem
-
getFrontLeftSwerveModuleSubsystem
-
getFrontRightSwerveModuleSubsystem
-
getRearLeftSwerveModuleSubsystem
-
getRearRightSwerveModuleSubsystem
-
setActiveModule
Meant to be used alongside debugging methods. Has no effect when the robot is in normal, "Maintainer" operation.- Parameters:
activeModule
- Which module to set as the active module.
-
setNextModuleAsActiveModule
public void setNextModuleAsActiveModule()Meant to be used alongside debugging methods. Has no effect when the robot is in normal, "Maintainer" operation. Moves the active module to the next module, according to the pattern FrontLeft, FrontRight, RearLeft, RearRight. -
setDesiredHeading
public void setDesiredHeading(double heading) - Specified by:
setDesiredHeading
in interfaceISwerveAdvisorDriveSupport
-
getDesiredHeading
public double getDesiredHeading()- Specified by:
getDesiredHeading
in interfaceISwerveAdvisorDriveSupport
-
controlOnlyActiveSwerveModuleSubsystem
public void controlOnlyActiveSwerveModuleSubsystem(double drivePower, double steeringPower) Controls the drive power and steering power of the active module. Stops all other modules. Intended for use when you want to investigate a single module without moving all the others.- Parameters:
drivePower
- -1 to 1 power to apply to the drive component.steeringPower
- -1 to 1 power to apply to the steering component.
-
getVelocityMaintainerXTarget
public double getVelocityMaintainerXTarget() -
setVelocityMaintainerXTarget
public void setVelocityMaintainerXTarget(double velocityMaintainerXTarget) -
getPositionMaintainerXTarget
public double getPositionMaintainerXTarget() -
setPositionMaintainerXTarget
public void setPositionMaintainerXTarget(double positionMaintainerXTarget) -
createEnableDisableQuickAlignActive
-
getSwerveModuleStates
-
setNoviceMode
public void setNoviceMode(boolean enabled) -
setDriveModuleCurrentLimits
-
createChangeDriveCurrentLimitsCommand
-
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
-