Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update on-the-fly docs for waypointsFromPoses #855

Merged
merged 1 commit into from
Oct 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 14 additions & 13 deletions Writerside/topics/pplib-Create-a-Path-On-the-fly.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ and a helper method available that makes doing so a lot easier.

> **Warning**
>
> The `bezierFromPoses` method required that the rotation component of each pose is the **direction of travel**, not the
> The `waypointsFromPoses` method required that the rotation component of each pose is the **direction of travel**, not
> the
> rotation of a swerve chassis.
>
> To set the rotation the path should end with, use the `GoalEndState`.
Expand All @@ -23,17 +24,17 @@ and a helper method available that makes doing so a lot easier.
<tab title="Java" group-key="java">

```Java
// Create a list of bezier points from poses. Each pose represents one waypoint.
// Create a list of waypoints from poses. Each pose represents one waypoint.
// The rotation component of the pose should be the direction of travel. Do not use holonomic rotation.
List<Translation2d> bezierPoints = PathPlannerPath.bezierFromPoses(
List<Waypoint> waypoints = PathPlannerPath.waypointsFromPoses(
new Pose2d(1.0, 1.0, Rotation2d.fromDegrees(0)),
new Pose2d(3.0, 1.0, Rotation2d.fromDegrees(0)),
new Pose2d(5.0, 3.0, Rotation2d.fromDegrees(90))
);

// Create the path using the bezier points created above
// Create the path using the waypoints created above
PathPlannerPath path = new PathPlannerPath(
bezierPoints,
waypoints,
new PathConstraints(3.0, 3.0, 2 * Math.PI, 4 * Math.PI), // The constraints for this path. If using a differential drivetrain, the angular constraints have no effect.
null, // The ideal starting state, this is only relevant for pre-planned paths, so can be null for on-the-fly paths.
new GoalEndState(0.0, Rotation2d.fromDegrees(-90)) // Goal end state. You can set a holonomic rotation here. If using a differential drivetrain, the rotation will have no effect.
Expand All @@ -52,19 +53,19 @@ path.preventFlipping = true;
using namespace pathplanner;


// Create a vector of bezier points from poses. Each pose represents one waypoint.
// Create a vector of waypoints from poses. Each pose represents one waypoint.
// The rotation component of the pose should be the direction of travel. Do not use holonomic rotation.
std::vector<frc::Pose2d> poses{
frc::Pose2d(1.0_m, 1.0_m, frc::Rotation2d(0_deg)),
frc::Pose2d(3.0_m, 1.0_m, frc::Rotation2d(0_deg)),
frc::Pose2d(5.0_m, 3.0_m, frc::Rotation2d(90_deg))
};
std::vector<frc::Translation2d> bezierPoints = PathPlannerPath::bezierFromPoses(poses);
std::vector<Waypoint> waypoints = PathPlannerPath::waypointsFromPoses(poses);

// Create the path using the bezier points created above
// Create the path using the waypoints created above
// We make a shared pointer here since the path following commands require a shared pointer
auto path = std::make_shared<PathPlannerPath>(
bezierPoints,
waypoints,
PathConstraints(3.0_mps, 3.0_mps_sq, 360_deg_per_s, 720_deg_per_s_sq), // The constraints for this path. If using a differential drivetrain, the angular constraints have no effect.
std::nullopt, // The ideal starting state, this is only relevant for pre-planned paths, so can be nullopt for on-the-fly paths.
GoalEndState(0.0_mps, frc::Rotation2d(-90_deg)) // Goal end state. You can set a holonomic rotation here. If using a differential drivetrain, the rotation will have no effect.
Expand All @@ -82,17 +83,17 @@ from pathplannerlib.path import PathPlannerPath, PathConstraints, GoalEndState
from wpimath.geometry import Pose2d, Rotation2d
import math

# Create a list of bezier points from poses. Each pose represents one waypoint.
# Create a list of waypoints from poses. Each pose represents one waypoint.
# The rotation component of the pose should be the direction of travel. Do not use holonomic rotation.
bezierPoints = PathPlannerPath.bezierFromPoses(
waypoints = PathPlannerPath.waypointsFromPoses(
Pose2d(1.0, 1.0, Rotation2d.fromDegrees(0)),
Pose2d(3.0, 1.0, Rotation2d.fromDegrees(0)),
Pose2d(5.0, 3.0, Rotation2d.fromDegrees(90))
)

# Create the path using the bezier points created above
# Create the path using the waypoints created above
path = new PathPlannerPath(
bezierPoints,
waypoints,
PathConstraints(3.0, 3.0, 2 * math.pi, 4 * math.pi), # The constraints for this path. If using a differential drivetrain, the angular constraints have no effect.
None, # The ideal starting state, this is only relevant for pre-planned paths, so can be None for on-the-fly paths.
GoalEndState(0.0, Rotation2d.fromDegrees(-90)) # Goal end state. You can set a holonomic rotation here. If using a differential drivetrain, the rotation will have no effect.
Expand Down
Loading