Class TurretBase
- java.lang.Object
-
- edu.wpi.first.wpilibj2.command.SubsystemBase
-
- ca.retrylife.frc.templates.turrets.TurretBase
-
- Direct Known Subclasses:
ProfiledTurret
public abstract class TurretBase extends SubsystemBase
TurretBase is the base class for all turret templates. It contains common methods, and utilities
-
-
Field Summary
Fields Modifier and Type Field Description protected Rotation2d[]
deadzone
-
Constructor Summary
Constructors Constructor Description TurretBase(Rotation2d minDeadzoneAngle, Rotation2d maxDeadzoneAngle)
Create a TurretBase with a deadzone
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected double
findDistanceFromAToB(Rotation2d a, Rotation2d b)
Find the fastest and safest way to get from A to B.abstract boolean
isAligned()
Get if the turret is aligned with its goalabstract void
lookAt(Rotation2d angle)
Tell the turret to look at a robot-relative anglevoid
lookAt(Translation2d point)
Tell the turret to look at a robot-relative point in space, where (1,1) is 45 degreesabstract void
periodic()
abstract void
stop()
Stop the turret-
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
getCurrentCommand, getDefaultCommand, register, setDefaultCommand, simulationPeriodic
-
-
-
-
Field Detail
-
deadzone
protected Rotation2d[] deadzone
-
-
Constructor Detail
-
TurretBase
public TurretBase(Rotation2d minDeadzoneAngle, Rotation2d maxDeadzoneAngle)
Create a TurretBase with a deadzone- Parameters:
minDeadzoneAngle
- Robot-relative angle where the turret deadzone startsmaxDeadzoneAngle
- Robot-relative angle where the turret deadzone ends
-
-
Method Detail
-
periodic
public abstract void periodic()
-
lookAt
public abstract void lookAt(Rotation2d angle)
Tell the turret to look at a robot-relative angle- Parameters:
angle
- Robot-relative angle
-
lookAt
public void lookAt(Translation2d point)
Tell the turret to look at a robot-relative point in space, where (1,1) is 45 degrees- Parameters:
point
- Robot-relative point in space
-
isAligned
public abstract boolean isAligned()
Get if the turret is aligned with its goal- Returns:
- Is the turret aligned?
-
stop
public abstract void stop()
Stop the turret
-
findDistanceFromAToB
protected double findDistanceFromAToB(Rotation2d a, Rotation2d b)
Find the fastest and safest way to get from A to B. Treat this function as "if I am at A, and I want to go to B, I must turn X degrees to the right"- Parameters:
a
- Current positionb
- Goal position- Returns:
- Best offset to use
-
-