RobotPy 2020 Trajectory Support

RobotPy 2020.2.2.5 now has support for all the new trajectory generation stuff in WPILib 2020. Of course, it’s only barely tested – but that’s where you come in!

Here’s some code that I copied from the frc docs, seems to generate a trajectory and doesn’t crash:

from wpilib.geometry import Pose2d, Rotation2d, Translation2d
from wpilib.trajectory import TrajectoryGenerator, TrajectoryConfig

# TODO: units are wrong

sideStart = Pose2d(1.54, 23.23, Rotation2d.fromDegrees(180))
crossScale = Pose2d(23.7, 6.8, Rotation2d.fromDegrees(-160))

# 2018 cross scale auto waypoints
#   const frc::Pose2d sideStart{1.54_ft, 23.23_ft, frc::Rotation2d(180_deg)};
#   const frc::Pose2d crossScale{23.7_ft, 6.8_ft, frc::Rotation2d(-160_deg)};

interiorWaypoints = [
    Translation2d(14.54, 23.23),
    Translation2d(21.04, 18.23),
]

#   std::vector<frc::Translation2d> interiorWaypoints{
#       frc::Translation2d{14.54_ft, 23.23_ft},
#       frc::Translation2d{21.04_ft, 18.23_ft}};

config = TrajectoryConfig(12, 12)
config.setReversed(True)

trajectory = TrajectoryGenerator.generateTrajectory(
    sideStart, interiorWaypoints, crossScale, config
)

Also, if you care about things being in feet, be sure to comment on #626

4 Likes

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.