-
Notifications
You must be signed in to change notification settings - Fork 7
Trajectory Planning with Trapezoidal Velocity Interpolator
In this task, you will implement a trajectory planning algorithm between a series of cartesian points such that each trajectories between points follow a three-segment path of acceleration, constant velocity, and deceleration. This leads to a trapezoidal velocity profile, and a “linear segment with parabolic blend” (LSPB) position profile, as shown in the lecture:

-
▶️ 🧑💻 Open the scriptweek9/trapezoidal_trajectory.pyand go to the functionplan_cartesian_trajectory(self)which contains a template for solving the task. -
▶️ 🔎 explore how the function is already implemented. It defines the cartesian pointswaypoint, a maximum velocitypdmaxand the time for completing each segment of the trajectorytime. It then calls the functiongenerate_trapezoidal_segmentfor each dimension (X, Y and Z) and each pair of points in order to generate the wanted trajectories. Finally, it plots all the generated position and velocity profiles. -
▶️ 🧑💻 Go to the functiongenerate_trapezoidal_segmentand complete the missing parts of the code (i.e. the parts with## TODO).-
ℹ️ To make debugging easier, you can start with only two points (i.e. temporarily removing the third waypoint).
-
ℹ️ Remember that if
$\dot{p}_{max} \geq 2\cdot \frac{p_f-p_0}{t_f}$ you need to use a triangular profile. -
ℹ️ Remember the trajectory is split into 3 segments as follows:
-
-
▶️ 🧑💻 Now let's add a fourth waypoint at the end of ourwaypointslist equal to[0.1, 0.1, 0.0], i.e. equal to the first point, so that we generate a circular motion and our robot's end-effector returns back to the original position. NOTE: that in this case$\dot{p}_{max} < \frac{p_f - p_0}{t_f}$ which means that we cannot reach the goal in the given time within the velocity limits, therefore we need to adjusting the time for computing the last segment.a.
▶️ Can you come up with an equation that computes the time needed to reach the final position with trapezoidal velocity and the given$\dot{p}_{max}$ ?b.
▶️ Modify thegenerate_trapezoidal_segmentfunction to correctly handle this case updating$t_f$ when needed.▶️ If you have done everything correctly, at the end you will be generating a plot like the following:
-
▶️ 🧑💻 Modify the code to also compute and plot the acceleration for each segment of the trajectories.
Parts for the workshops are extracted, edited from and/or inspired by the following sources.
- Official ROS humble tutorials: https://docs.ros.org/en/humble/Tutorials.html
- Elephant Robotics docs: https://docs.elephantrobotics.com/docs/gitbook-en/