Package frc.team88.swerve.motion
Class SwerveChassis
- java.lang.Object
-
- frc.team88.swerve.motion.SwerveChassis
-
public class SwerveChassis extends java.lang.Object
Represents a complete swerve chassis, with high level operations for controlling it.
-
-
Constructor Summary
Constructors Constructor Description SwerveChassis(Configuration config)
Constructs the SwerveChassis from the config.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description VelocityState
getConstrainedCommandState()
Gets the velocity state commanded after all constraints.double
getMaxRotationSpeed()
Gets the maximum rotation speed if the drive is doing nothing else.double
getMaxTranslationSpeed()
Gets the maximum translation speed if the drive is doing nothing else.OdomState
getOdomState()
Gets the chassis odometry state.VelocityState
getTargetState()
Gets the target velocity state.void
holdAzimuths(boolean hold)
Sets a hold on the current module azimuth targets.boolean
inHoldAzimuthMode()
Gets if the chassis is in hold azimuth mode.void
setBrake()
Sets all motors to brake mode.void
setCoast()
Sets all motors to coast mode.void
setOdomState(double x, double y)
Sets the chassis odometry state.void
setOdomState(double x, double y, double theta)
Sets the chassis odometry state.void
setOdomState(OdomState state)
Sets the chassis odometry state.void
setTargetState(VelocityState target)
Sets the target velocity state.void
update()
Updates all periodic processes in the swerve chassis, such as setting module controls.
-
-
-
Constructor Detail
-
SwerveChassis
public SwerveChassis(Configuration config)
Constructs the SwerveChassis from the config.- Parameters:
config
- The config info for this swerve.
-
-
Method Detail
-
setTargetState
public void setTargetState(VelocityState target)
Sets the target velocity state.- Parameters:
target
- The velocity state to set.
-
getTargetState
public VelocityState getTargetState()
Gets the target velocity state.- Returns:
- The target velocity state.
-
getConstrainedCommandState
public VelocityState getConstrainedCommandState()
Gets the velocity state commanded after all constraints.- Returns:
- The constrained velocity state.
-
holdAzimuths
public void holdAzimuths(boolean hold)
Sets a hold on the current module azimuth targets.- Parameters:
hold
- True if there should be a hold, false otherwise.
-
inHoldAzimuthMode
public boolean inHoldAzimuthMode()
Gets if the chassis is in hold azimuth mode.- Returns:
- True if the chassis is in hold azimuth mode, false otherwise.
-
update
public void update()
Updates all periodic processes in the swerve chassis, such as setting module controls.
-
getOdomState
public OdomState getOdomState()
Gets the chassis odometry state.- Returns:
- The odometry state
-
setOdomState
public void setOdomState(OdomState state)
Sets the chassis odometry state. (for setting chassis initial conditions)- Parameters:
state
- state to set the chassis to
-
setOdomState
public void setOdomState(double x, double y)
Sets the chassis odometry state. (for setting chassis initial conditions)- Parameters:
x
- The x position of the chassis, in feet.y
- The y position of the chassis, in feet.
-
setOdomState
public void setOdomState(double x, double y, double theta)
Sets the chassis odometry state. (for setting chassis initial conditions)- Parameters:
x
- The x position of the chassis, in feet.y
- The y position of the chassis, in feet.theta
- The heading of the chasis, in degrees.
-
setCoast
public void setCoast()
Sets all motors to coast mode.
-
setBrake
public void setBrake()
Sets all motors to brake mode.
-
getMaxTranslationSpeed
public double getMaxTranslationSpeed()
Gets the maximum translation speed if the drive is doing nothing else.- Returns:
- The maximum translation speed, in feet per second.
-
getMaxRotationSpeed
public double getMaxRotationSpeed()
Gets the maximum rotation speed if the drive is doing nothing else.- Returns:
- The maximum rotation speed, in feet per second.
-
-