Class FollowTrajectory

  • All Implemented Interfaces:
    edu.wpi.first.util.sendable.Sendable, edu.wpi.first.wpilibj2.command.Command

    public class FollowTrajectory
    extends edu.wpi.first.wpilibj2.command.CommandBase
    A command that uses a RAMSETE controller (DiffDriveController) to follow a trajectory Trajectory with a differential drive.

    The command handles trajectory-following, PID calculations, and feedforwards internally. This is intended to be a more-or-less "complete solution" that can be used by teams without a great deal of controls expertise.

    Advanced teams seeking more flexibility (for example, those who wish to use the onboard PID functionality of a "smart" motor controller) may use the secondary constructor that omits the PID and feedforward functionality, returning only the raw wheel speeds from the RAMSETE controller.

    This class is provided by the NewCommands VendorDep

    • Field Summary

      • Fields inherited from class edu.wpi.first.wpilibj2.command.CommandBase

        m_requirements
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void end​(boolean interrupted)  
      void execute()  
      void initialize()  
      boolean isFinished()  
      • Methods inherited from class edu.wpi.first.wpilibj2.command.CommandBase

        addRequirements, getName, getRequirements, getSubsystem, initSendable, setName, setSubsystem, withName
      • 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.Command

        alongWith, andThen, andThen, asProxy, beforeStarting, beforeStarting, cancel, deadlineWith, hasRequirement, isScheduled, perpetually, raceWith, runsWhenDisabled, schedule, schedule, until, withInterrupt, withTimeout
    • Constructor Detail

      • FollowTrajectory

        public FollowTrajectory​(Trajectory trajectory,
                                java.util.function.Supplier<edu.wpi.first.math.geometry.Pose2d> pose,
                                DiffDriveController controller,
                                FeedForwardController feedforward,
                                DifferentialKinematics kinematics,
                                java.util.function.Supplier<DifferentialDrivetrainState> wheelSpeeds,
                                PIDFController leftController,
                                PIDFController rightController,
                                java.util.function.BiConsumer<java.lang.Double,​java.lang.Double> outputVolts,
                                edu.wpi.first.wpilibj2.command.Subsystem... requirements)
        Constructs a new FollowTrajectory that, when executed, will follow the provided trajectory. PID control and feedforward are handled internally, and outputs are scaled -12 to 12 representing units of volts.

        Note: The controller will *not* set the outputVolts to zero upon completion of the path - this is left to the user, since it is not appropriate for paths with nonstationary endstates.

        Parameters:
        trajectory - The trajectory to follow.
        pose - A function that supplies the robot pose - use one of the odometry classes to provide this.
        controller - The RAMSETE controller used to follow the trajectory.
        feedforward - The feedforward to use for the drive.
        kinematics - The kinematics for the robot drivetrain.
        wheelSpeeds - A function that supplies the speeds of the left and right sides of the robot drive.
        leftController - The PIDFController for the left side of the robot drive.
        rightController - The PIDFController for the right side of the robot drive.
        outputVolts - A function that consumes the computed left and right outputs (in volts) for the robot drive.
        requirements - The subsystems to require.
    • Method Detail

      • initialize

        public void initialize()
      • execute

        public void execute()
      • end

        public void end​(boolean interrupted)
      • isFinished

        public boolean isFinished()