:py:mod:`phoenix6.swerve.utility.linear_path` ============================================= .. py:module:: phoenix6.swerve.utility.linear_path Module Contents --------------- .. py:class:: LinearPath(linear: wpimath.TrapezoidProfile.Constraints, angular: wpimath.TrapezoidProfile.Constraints) A linear path for a holonomic drivetrain (i.e. swerve or mechanum). This generates profiled setpoints for the robot along a straight line based on trapezoidal velocity constraints (using TrapezoidProfile). Initialization:: path = LinearPath( TrapezoidProfile.Constraints(kMaxV, kMaxA), TrapezoidProfile.Constraints(kMaxOmega, kMaxAlpha) ) current = LinearPath.State(initialPose, initialFieldVelocity) Run on update:: current = path.calculate(timeSincePreviousUpdate, current, targetPose) Constructs a linear path. :param linear: The constraints on the profile linear motion :type linear: TrapezoidProfile.Constraints :param angular: The constraints on the profile angular motion :type angular: TrapezoidProfile.Constraints .. py:class:: State(pose: phoenix6.swerve.utility.geometry.Pose2d = Pose2d(), velocity: phoenix6.swerve.utility.kinematics.ChassisVelocities = ChassisVelocities()) Path state. .. py:attribute:: pose The pose at this state. .. py:attribute:: velocity The field-centric velocity at this state. .. py:method:: calculate(t: wpimath.units.seconds, current: State, goal: phoenix6.swerve.utility.geometry.Pose2d) -> State Calculates the pose and velocity of the path at a time t where the current state is at t = 0. :param t: How long to advance from the current state to the desired state :type t: units.seconds :param current: The current state :type current: State :param goal: The desired pose when the path is complete :type goal: Pose2d :returns: The pose and velocity of the profile at time t :rtype: State .. py:method:: total_time() -> wpimath.units.seconds Returns the total time the profile takes to reach the goal. :returns: The total time the profile takes to reach the goal :rtype: units.seconds .. py:method:: is_finished(t: wpimath.units.seconds) -> bool Returns true if the profile has reached the goal. The profile has reached the goal if the time since the profile started has exceeded the profile's total time. :param t: The time since the beginning of the profile :type t: units.seconds :returns: True if the profile has reached the goal :rtype: bool