Class SN_SuperSwerveV2

java.lang.Object
com.ctre.phoenix6.swerve.SwerveDrivetrain<com.ctre.phoenix6.hardware.TalonFX,com.ctre.phoenix6.hardware.TalonFX,com.ctre.phoenix6.hardware.CANcoder>
com.frcteam3255.components.swerve.SN_SuperSwerveV2
All Implemented Interfaces:
edu.wpi.first.wpilibj2.command.Subsystem, AutoCloseable

public class SN_SuperSwerveV2 extends com.ctre.phoenix6.swerve.SwerveDrivetrain<com.ctre.phoenix6.hardware.TalonFX,com.ctre.phoenix6.hardware.TalonFX,com.ctre.phoenix6.hardware.CANcoder> implements edu.wpi.first.wpilibj2.command.Subsystem
Class that extends the Phoenix 6 SwerveDrivetrain class and implements Subsystem so it can easily be used in command-based projects.
  • Nested Class Summary

    Nested classes/interfaces inherited from class com.ctre.phoenix6.swerve.SwerveDrivetrain

    com.ctre.phoenix6.swerve.SwerveDrivetrain.DeviceConstructor<DeviceT extends Object>, com.ctre.phoenix6.swerve.SwerveDrivetrain.OdometryThread, com.ctre.phoenix6.swerve.SwerveDrivetrain.SwerveControlParameters, com.ctre.phoenix6.swerve.SwerveDrivetrain.SwerveDriveState
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    final com.ctre.phoenix6.swerve.SwerveRequest.SysIdSwerveRotation
     
    final com.ctre.phoenix6.swerve.SwerveRequest.SysIdSwerveSteerGains
     
    final edu.wpi.first.wpilibj2.command.sysid.SysIdRoutine
     
    final edu.wpi.first.wpilibj2.command.sysid.SysIdRoutine
     
    edu.wpi.first.wpilibj2.command.sysid.SysIdRoutine
     
    final edu.wpi.first.wpilibj2.command.sysid.SysIdRoutine
     
    final com.ctre.phoenix6.swerve.SwerveRequest.SysIdSwerveTranslation
     

    Fields inherited from class com.ctre.phoenix6.swerve.SwerveDrivetrain

    kNumConfigAttempts, m_drivetrainId, m_jni, m_telemetryJNI
  • Constructor Summary

    Constructors
    Constructor
    Description
    SN_SuperSwerveV2(com.ctre.phoenix6.swerve.SwerveDrivetrainConstants drivetrainConstants, double odometryUpdateFrequency, edu.wpi.first.math.Matrix<edu.wpi.first.math.numbers.N3,edu.wpi.first.math.numbers.N1> odometryStandardDeviation, edu.wpi.first.math.Matrix<edu.wpi.first.math.numbers.N3,edu.wpi.first.math.numbers.N1> visionStandardDeviation, com.ctre.phoenix6.swerve.SwerveModuleConstants<?,?,?>... modules)
    Constructs a CTRE SwerveDrivetrain using the specified constants.
    SN_SuperSwerveV2(com.ctre.phoenix6.swerve.SwerveDrivetrainConstants drivetrainConstants, com.ctre.phoenix6.swerve.SwerveModuleConstants<?,?,?>... modules)
    Constructs a CTRE SwerveDrivetrain using the specified constants.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addVisionMeasurement(edu.wpi.first.math.geometry.Pose2d visionRobotPoseMeters, double timestampSeconds)
    Adds a vision measurement to the Kalman Filter.
    void
    addVisionMeasurement(edu.wpi.first.math.geometry.Pose2d visionRobotPoseMeters, double timestampSeconds, edu.wpi.first.math.Matrix<edu.wpi.first.math.numbers.N3,edu.wpi.first.math.numbers.N1> visionMeasurementStdDevs)
    Adds a vision measurement to the Kalman Filter.
    edu.wpi.first.wpilibj2.command.Command
    applyRequest(Supplier<com.ctre.phoenix6.swerve.SwerveRequest> requestSupplier)
    Returns a command that applies the specified control request to this swerve drivetrain.
    edu.wpi.first.math.kinematics.ChassisSpeeds
    calculateVelocitiesFromInput(DoubleSupplier xAxisSupplier, DoubleSupplier yAxisSupplier, DoubleSupplier rotationAxisSupplier, BooleanSupplier slowMode, boolean isRed, double SLOW_MODE_MULTIPLIER, edu.wpi.first.units.measure.LinearVelocity REAL_DRIVE_SPEED, edu.wpi.first.units.measure.AngularVelocity TURN_SPEED)
    Calculates the chassis velocities based on joystick inputs and other parameters.
    void
    drive(edu.wpi.first.math.kinematics.ChassisSpeeds chassisSpeeds)
     
    void
    drive(edu.wpi.first.math.kinematics.ChassisSpeeds chassisSpeeds, edu.wpi.first.math.geometry.Rotation2d facingAngle, double kP, double kI, double kD)
     
    edu.wpi.first.units.measure.AngularVelocity
     
    boolean
     
    edu.wpi.first.math.geometry.Pose2d
    Return the current estimated pose from the pose estimator.
    double
    getStickRadians(DoubleSupplier rotationXAxis, DoubleSupplier rotationYAxis, double tolerance, double offset)
    Computes the angle of the stick input in radians when the stick is "hit" (i.e.
    boolean
    isAtDesiredPosition(edu.wpi.first.math.geometry.Pose2d target, edu.wpi.first.math.geometry.Pose2d current, edu.wpi.first.units.measure.Distance tolerance)
    Determines whether the robot is at (or sufficiently close to) a desired pose.
    boolean
    isAtDesiredPosition(edu.wpi.first.units.measure.Angle target, edu.wpi.first.units.measure.Angle current, edu.wpi.first.units.measure.Angle tolerance)
    Returns whether the current angle lies strictly within the tolerance window around the target angle.
    boolean
    isAtPosition(edu.wpi.first.math.geometry.Pose2d desiredPose2d, edu.wpi.first.units.measure.Distance tolerance)
    Checks whether the robot's current pose is within a specified translational tolerance of a desired pose.
    boolean
    isAtPosition(edu.wpi.first.math.geometry.Rotation2d desiredRotation, edu.wpi.first.units.measure.Angle tolerance)
    Determines whether the drivetrain's facing is within a given angular tolerance of a desired rotation.
    boolean
    isBehindHorizontalLine(edu.wpi.first.units.measure.Distance blueXValueInMeters, boolean isRed, edu.wpi.first.units.measure.Distance fieldLength)
    Checks whether the robot is "behind" a horizontal field line defined by a distance from the blue alliance wall.
    boolean
    isBehindVerticalLine(edu.wpi.first.units.measure.Distance blueYValueInMeters, boolean isRed, edu.wpi.first.units.measure.Distance fieldWidth)
    Checks whether the robot is "behind" a vertical field line defined by a distance from the blue alliance wall along the Y axis.
    boolean
    isInAutoDriveZone(edu.wpi.first.units.measure.Distance autoDriveMaxDistance, edu.wpi.first.math.geometry.Pose2d target)
    Determines whether the robot is within the specified auto-drive zone based on the distance to a target pose.
    boolean
    isStickHit(DoubleSupplier axis, double tolerance)
    Determines whether a joystick/axis "hit" has occurred by comparing the absolute axis value provided by the given DoubleSupplier against a deadzone tolerance.
    boolean
    isStickHit(DoubleSupplier xAxis, DoubleSupplier yAxis, double tolerance)
    Determines whether a two-dimensional joystick (provided as X and Y axis suppliers) is being "hit" by checking if its magnitude exceeds a given tolerance.
    void
     
    edu.wpi.first.units.measure.Angle
    snapToTarget(edu.wpi.first.math.geometry.Pose2d targetPose)
    Computes the heading (as an Angle) from the robot's current pose to the provided target pose.
    edu.wpi.first.wpilibj2.command.Command
    sysIdDynamic(edu.wpi.first.wpilibj2.command.sysid.SysIdRoutine.Direction direction)
    Runs the SysId Dynamic test in the given direction for the routine specified by m_sysIdRoutineToApply.
    edu.wpi.first.wpilibj2.command.Command
    sysIdQuasistatic(edu.wpi.first.wpilibj2.command.sysid.SysIdRoutine.Direction direction)
    Runs the SysId Quasistatic test in the given direction for the routine specified by m_sysIdRoutineToApply.
    void
     

    Methods inherited from class com.ctre.phoenix6.swerve.SwerveDrivetrain

    close, configNeutralMode, configNeutralMode, getKinematics, getModule, getModuleLocations, getModules, getOdometryFrequency, getOdometryFrequencyMeasure, getOdometryThread, getOperatorForwardDirection, getPigeon2, getRotation3d, getState, getStateCopy, isOdometryValid, isOnCANFD, optimizeBusUtilization, optimizeBusUtilization, optimizeBusUtilization, registerTelemetry, resetPose, resetRotation, resetTranslation, samplePoseAt, seedFieldCentric, seedFieldCentric, setControl, setOperatorPerspectiveForward, setStateStdDevs, setVisionMeasurementStdDevs, tareEverything, updateSimState

    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

    defer, getCurrentCommand, getDefaultCommand, getName, idle, register, removeDefaultCommand, run, runEnd, runOnce, setDefaultCommand, simulationPeriodic, startEnd, startRun
  • Field Details

    • m_translationCharacterization

      public final com.ctre.phoenix6.swerve.SwerveRequest.SysIdSwerveTranslation m_translationCharacterization
    • m_steerCharacterization

      public final com.ctre.phoenix6.swerve.SwerveRequest.SysIdSwerveSteerGains m_steerCharacterization
    • m_rotationCharacterization

      public final com.ctre.phoenix6.swerve.SwerveRequest.SysIdSwerveRotation m_rotationCharacterization
    • m_sysIdRoutineTranslation

      public final edu.wpi.first.wpilibj2.command.sysid.SysIdRoutine m_sysIdRoutineTranslation
    • m_sysIdRoutineSteer

      public final edu.wpi.first.wpilibj2.command.sysid.SysIdRoutine m_sysIdRoutineSteer
    • m_sysIdRoutineRotation

      public final edu.wpi.first.wpilibj2.command.sysid.SysIdRoutine m_sysIdRoutineRotation
    • m_sysIdRoutineToApply

      public edu.wpi.first.wpilibj2.command.sysid.SysIdRoutine m_sysIdRoutineToApply
  • Constructor Details

    • SN_SuperSwerveV2

      public SN_SuperSwerveV2(com.ctre.phoenix6.swerve.SwerveDrivetrainConstants drivetrainConstants, com.ctre.phoenix6.swerve.SwerveModuleConstants<?,?,?>... modules)
      Constructs a CTRE SwerveDrivetrain using the specified constants.

      This constructs the underlying hardware devices, so users should not construct the devices themselves. If they need the devices, they can access them through getters in the classes.

      Parameters:
      drivetrainConstants - Drivetrain-wide constants for the swerve drive
      modules - Constants for each specific module
    • SN_SuperSwerveV2

      public SN_SuperSwerveV2(com.ctre.phoenix6.swerve.SwerveDrivetrainConstants drivetrainConstants, double odometryUpdateFrequency, edu.wpi.first.math.Matrix<edu.wpi.first.math.numbers.N3,edu.wpi.first.math.numbers.N1> odometryStandardDeviation, edu.wpi.first.math.Matrix<edu.wpi.first.math.numbers.N3,edu.wpi.first.math.numbers.N1> visionStandardDeviation, com.ctre.phoenix6.swerve.SwerveModuleConstants<?,?,?>... modules)
      Constructs a CTRE SwerveDrivetrain using the specified constants.

      This constructs the underlying hardware devices, so users should not construct the devices themselves. If they need the devices, they can access them through getters in the classes.

      Parameters:
      drivetrainConstants - Drivetrain-wide constants for the swerve drive
      odometryUpdateFrequency - The frequency to run the odometry loop. If unspecified or set to 0 Hz, this is 250 Hz on CAN FD, and 100 Hz on CAN 2.0.
      odometryStandardDeviation - The standard deviation for odometry calculation in the form [x, y, theta], with units in meters and radians
      visionStandardDeviation - The standard deviation for vision calculation in the form [x, y, theta], with units in meters and radians
      modules - Constants for each specific module
  • Method Details

    • applyRequest

      public edu.wpi.first.wpilibj2.command.Command applyRequest(Supplier<com.ctre.phoenix6.swerve.SwerveRequest> requestSupplier)
      Returns a command that applies the specified control request to this swerve drivetrain.
      Parameters:
      requestSupplier - Function returning the request to apply
      Returns:
      Command to run
    • periodic

      public void periodic()
      Specified by:
      periodic in interface edu.wpi.first.wpilibj2.command.Subsystem
    • addVisionMeasurement

      public void addVisionMeasurement(edu.wpi.first.math.geometry.Pose2d visionRobotPoseMeters, double timestampSeconds)
      Adds a vision measurement to the Kalman Filter. This will correct the odometry pose estimate while still accounting for measurement noise.
      Overrides:
      addVisionMeasurement in class com.ctre.phoenix6.swerve.SwerveDrivetrain<com.ctre.phoenix6.hardware.TalonFX,com.ctre.phoenix6.hardware.TalonFX,com.ctre.phoenix6.hardware.CANcoder>
      Parameters:
      visionRobotPoseMeters - The pose of the robot as measured by the vision camera.
      timestampSeconds - The timestamp of the vision measurement in seconds.
    • addVisionMeasurement

      public void addVisionMeasurement(edu.wpi.first.math.geometry.Pose2d visionRobotPoseMeters, double timestampSeconds, edu.wpi.first.math.Matrix<edu.wpi.first.math.numbers.N3,edu.wpi.first.math.numbers.N1> visionMeasurementStdDevs)
      Adds a vision measurement to the Kalman Filter. This will correct the odometry pose estimate while still accounting for measurement noise.

      Note that the vision measurement standard deviations passed into this method will continue to apply to future measurements until a subsequent call to SwerveDrivetrain.setVisionMeasurementStdDevs(Matrix) or this method.

      Overrides:
      addVisionMeasurement in class com.ctre.phoenix6.swerve.SwerveDrivetrain<com.ctre.phoenix6.hardware.TalonFX,com.ctre.phoenix6.hardware.TalonFX,com.ctre.phoenix6.hardware.CANcoder>
      Parameters:
      visionRobotPoseMeters - The pose of the robot as measured by the vision camera.
      timestampSeconds - The timestamp of the vision measurement in seconds.
      visionMeasurementStdDevs - Standard deviations of the vision pose measurement in the form [x, y, theta], with units in meters and radians.
    • sysIdQuasistatic

      public edu.wpi.first.wpilibj2.command.Command sysIdQuasistatic(edu.wpi.first.wpilibj2.command.sysid.SysIdRoutine.Direction direction)
      Runs the SysId Quasistatic test in the given direction for the routine specified by m_sysIdRoutineToApply.
      Parameters:
      direction - Direction of the SysId Quasistatic test
      Returns:
      Command to run
    • sysIdDynamic

      public edu.wpi.first.wpilibj2.command.Command sysIdDynamic(edu.wpi.first.wpilibj2.command.sysid.SysIdRoutine.Direction direction)
      Runs the SysId Dynamic test in the given direction for the routine specified by m_sysIdRoutineToApply.
      Parameters:
      direction - Direction of the SysId Dynamic test
      Returns:
      Command to run
    • drive

      public void drive(edu.wpi.first.math.kinematics.ChassisSpeeds chassisSpeeds)
    • drive

      public void drive(edu.wpi.first.math.kinematics.ChassisSpeeds chassisSpeeds, edu.wpi.first.math.geometry.Rotation2d facingAngle, double kP, double kI, double kD)
    • xBrake

      public void xBrake()
    • getIsCurrentlyXbraking

      public boolean getIsCurrentlyXbraking()
    • getGyroRate

      public edu.wpi.first.units.measure.AngularVelocity getGyroRate()
      Returns:
      The current rate of rotation for the Pigeon 2. Units: Degrees per Second
    • getPose

      public edu.wpi.first.math.geometry.Pose2d getPose()
      Return the current estimated pose from the pose estimator.
      Returns:
      The current estimated pose
    • calculateVelocitiesFromInput

      public edu.wpi.first.math.kinematics.ChassisSpeeds calculateVelocitiesFromInput(DoubleSupplier xAxisSupplier, DoubleSupplier yAxisSupplier, DoubleSupplier rotationAxisSupplier, BooleanSupplier slowMode, boolean isRed, double SLOW_MODE_MULTIPLIER, edu.wpi.first.units.measure.LinearVelocity REAL_DRIVE_SPEED, edu.wpi.first.units.measure.AngularVelocity TURN_SPEED)
      Calculates the chassis velocities based on joystick inputs and other parameters.
      Parameters:
      xAxisSupplier - A DoubleSupplier providing the x-axis input for forward/backward movement.
      yAxisSupplier - A DoubleSupplier providing the y-axis input for left/right movement.
      rotationAxisSupplier - A DoubleSupplier providing the rotation input for turning.
      slowMode - A BooleanSupplier indicating whether the slow mode is active.
      isRed - A boolean indicating if the robot is on the red alliance (reverses controls if true).
      SLOW_MODE_MULTIPLIER - A multiplier applied to velocities when slow mode is active.
      REAL_DRIVE_SPEED - The maximum linear velocity of the robot in meters per second.
      TURN_SPEED - The maximum angular velocity of the robot in radians per second.
      Returns:
      A ChassisSpeeds object containing the calculated x, y, and rotational velocities.
    • isInAutoDriveZone

      public boolean isInAutoDriveZone(edu.wpi.first.units.measure.Distance autoDriveMaxDistance, edu.wpi.first.math.geometry.Pose2d target)
      Determines whether the robot is within the specified auto-drive zone based on the distance to a target pose.
      Parameters:
      autoDriveMaxDistance - The maximum allowable distance for the auto-drive zone. If null, the method will return false.
      target - The target pose to calculate the distance from the robot's current pose.
      Returns:
      True if the robot's current pose is within the specified maximum distance from the target pose, false otherwise.
    • isAtPosition

      public boolean isAtPosition(edu.wpi.first.math.geometry.Rotation2d desiredRotation, edu.wpi.first.units.measure.Angle tolerance)
      Determines whether the drivetrain's facing is within a given angular tolerance of a desired rotation. The check is performed by comparing the underlying angle measures: it returns true when the current rotation measure is strictly greater than (desiredRotation - tolerance) and strictly less than (desiredRotation + tolerance). In other words, the method tests membership in the open interval (desiredRotation - tolerance, desiredRotation + tolerance). Note: comparisons are done on the raw values returned by Rotation2d.getMeasure(). This method does not perform any additional angle wrapping or normalization beyond what Rotation2d.getMeasure() provides.
      Parameters:
      desiredRotation - the target rotation to compare against (must not be null)
      tolerance - the allowed deviation from the target rotation (must not be null; expected non-negative)
      Returns:
      true if the current rotation is strictly within the specified tolerance of the desired rotation; false otherwise
      Throws:
      NullPointerException - if desiredRotation or tolerance is null
    • isAtPosition

      public boolean isAtPosition(edu.wpi.first.math.geometry.Pose2d desiredPose2d, edu.wpi.first.units.measure.Distance tolerance)
      Checks whether the robot's current pose is within a specified translational tolerance of a desired pose.

      This method compares only the 2D translation (x, y) components of the poses and computes the Euclidean (straight-line) distance between the current pose and the desired pose. The rotational component (heading) of the poses is ignored. The comparison is inclusive: returns true when the distance is less than or equal to the provided tolerance.

      Parameters:
      desiredPose2d - the target Pose2d to compare against (must be in the same coordinate frame as getPose())
      tolerance - a Distance representing the allowable translational error; the method returns true if the straight-line distance to desiredPose2d is less than or equal to this tolerance
      Returns:
      true if the current translation is within the given tolerance of desiredPose2d, false otherwise
    • isAtDesiredPosition

      public boolean isAtDesiredPosition(edu.wpi.first.units.measure.Angle target, edu.wpi.first.units.measure.Angle current, edu.wpi.first.units.measure.Angle tolerance)
      Returns whether the current angle lies strictly within the tolerance window around the target angle. The check performed is: (target - tolerance) LT current LT (target + tolerance) Comparisons are strict: equality with either boundary returns false. This method relies on Angle.minus, Angle.plus and Angle.compareTo. It does not perform any additional normalization or wrap-around handling, so callers should ensure angles are expressed in a consistent range (for example, normalized to [-180,180) or [0,360)) when necessary.
      Parameters:
      target - the desired angle to compare against
      current - the current angle value to test
      tolerance - the allowed deviation from the target (expected to be non-negative)
      Returns:
      true if current is strictly within the tolerance window around target; false otherwise
    • isAtDesiredPosition

      public boolean isAtDesiredPosition(edu.wpi.first.math.geometry.Pose2d target, edu.wpi.first.math.geometry.Pose2d current, edu.wpi.first.units.measure.Distance tolerance)
      Determines whether the robot is at (or sufficiently close to) a desired pose.

      This evaluates the Euclidean distance between the translations (x/y) of the provided target and current poses and returns true when that distance is less than or equal to the supplied tolerance.

      Parameters:
      target - the desired Pose2d to reach (must not be null)
      current - the current Pose2d of the robot (must not be null)
      tolerance - the maximum allowable translational error as a Distance (must not be null)
      Returns:
      true if the translational distance between current and target is within tolerance, false otherwise
    • isStickHit

      public boolean isStickHit(DoubleSupplier xAxis, DoubleSupplier yAxis, double tolerance)
      Determines whether a two-dimensional joystick (provided as X and Y axis suppliers) is being "hit" by checking if its magnitude exceeds a given tolerance. The magnitude is computed using Math.hypot(x, y) where x and y are obtained from the provided DoubleSupplier instances.
      Parameters:
      xAxis - supplier of the joystick X-axis value; must not be null
      yAxis - supplier of the joystick Y-axis value; must not be null
      tolerance - non-negative threshold for considering the stick "hit"; the method returns true when hypot(x, y) > tolerance
      Returns:
      true if the joystick magnitude (sqrt(x^2 + y^2)) is greater than the specified tolerance, false otherwise
    • isStickHit

      public boolean isStickHit(DoubleSupplier axis, double tolerance)
      Determines whether a joystick/axis "hit" has occurred by comparing the absolute axis value provided by the given DoubleSupplier against a deadzone tolerance.
      Parameters:
      axis - a DoubleSupplier that returns the current axis value; must not be null
      tolerance - the deadzone threshold to consider the stick as "hit" (expected non-negative)
      Returns:
      true if Math.abs(axis.getAsDouble()) is strictly greater than tolerance; false otherwise Example: - if axis returns 0.15 and tolerance is 0.1 -> returns true - but if axis returns 0.1 and tolerance is 0.1 -> returns false (strict greater-than)
    • getStickRadians

      public double getStickRadians(DoubleSupplier rotationXAxis, DoubleSupplier rotationYAxis, double tolerance, double offset)
      Computes the angle of the stick input in radians when the stick is "hit" (i.e. when the magnitude of the stick input is within a specified tolerance of 1). The angle is calculated using atan2 of the Y and X stick inputs, and then adjusted by subtracting the provided offset. If the stick input magnitude is outside the tolerance range, this method returns 0.
      Parameters:
      rotationXAxis - supplier for the stick X axis
      rotationYAxis - supplier for the stick Y axis
      tolerance - allowed deviation from unit magnitude to consider the stick "hit"
      offset - an additional angle in radians to subtract from the computed stick angle when the stick is "hit". This allows for adjusting the reference frame or compensating for calibration offsets.
      Returns:
      angle in radians when stick is within tolerance, otherwise 0
    • snapToTarget

      public edu.wpi.first.units.measure.Angle snapToTarget(edu.wpi.first.math.geometry.Pose2d targetPose)
      Computes the heading (as an Angle) from the robot's current pose to the provided target pose. The returned angle points from the robot's current position toward the target, using the field coordinate frame. The computed angle is derived from atan2(dy, dx) where dx = target.x - robot.x and dy = target.y - robot.y and converted from radians to degrees before being wrapped in a Units Angle via Degrees.of(...).
      Parameters:
      targetPose - goal pose to snap toward
      Returns:
      target heading as an Angle (degrees)
    • isBehindHorizontalLine

      public boolean isBehindHorizontalLine(edu.wpi.first.units.measure.Distance blueXValueInMeters, boolean isRed, edu.wpi.first.units.measure.Distance fieldLength)
      Checks whether the robot is "behind" a horizontal field line defined by a distance from the blue alliance wall. For the blue alliance (isRed == false) this returns true when the robot's X position is less than blueXValueInMeters. For the red alliance (isRed == true) the field is mirrored, so the equivalent line is at fieldLength - blueXValueInMeters and we return true when the robot's X is greater than that mirrored value. Coordinates and units: this method uses the drivetrain pose's measured X coordinate (a Distance). The parameters must be supplied in the same units / measurement system (typically meters) and are compared using the Units API (e.g. Distance.lt and Distance.gt).
      Parameters:
      blueXValueInMeters - X offset from the blue alliance wall representing the horizontal line
      isRed - whether the robot is on the red alliance (mirror)
      fieldLength - total field length (used to compute mirrored line)
      Returns:
      true if the robot is behind the specified horizontal line for the current alliance perspective
    • isBehindVerticalLine

      public boolean isBehindVerticalLine(edu.wpi.first.units.measure.Distance blueYValueInMeters, boolean isRed, edu.wpi.first.units.measure.Distance fieldWidth)
      Checks whether the robot is "behind" a vertical field line defined by a distance from the blue alliance wall along the Y axis. For the blue alliance (isRed == false) this returns true when the robot's Y position is less than blueYValueInMeters. For the red alliance (isRed == true) the equivalent line is mirrored at fieldWidth - blueYValueInMeters and we return true when the robot's Y is greater than that mirrored value.
      Parameters:
      blueYValueInMeters - Y offset from the blue alliance wall representing the vertical line
      isRed - whether the robot is on the red alliance
      fieldWidth - total field width (used to compute mirrored line)
      Returns:
      true if the robot is behind the specified vertical line for the current alliance perspective