From 6e704c4d23c81fd56b37be9c6280c71331236f97 Mon Sep 17 00:00:00 2001 From: Fredrik Bagge Carlson Date: Thu, 3 Oct 2024 09:05:05 +0200 Subject: [PATCH] add examples to trajectory generation docs --- docs/src/trajectory_planning.md | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/docs/src/trajectory_planning.md b/docs/src/trajectory_planning.md index 5138cf05..114a2e77 100644 --- a/docs/src/trajectory_planning.md +++ b/docs/src/trajectory_planning.md @@ -12,6 +12,35 @@ These both have output connectors of type `RealOutput` called `q, qd, qdd` for p See [Industrial robot](@ref) for an example making use of the [`point_to_point`](@ref) planner. + +## Example + +### Point-to-point trajectory +```@example TRAJ +using Multibody, Plots +Ts = 0.001 +t = -1:Ts:3 + +q1 = [1, 1.2] # Final point (2 DOF) +qd_max = [0.7, 1.2] # Max velocity (2 DOF) +qdd_max = [0.9, 1.1] # Max acceleration (2 DOF) +q, qd, qdd = point_to_point(t; q1, qd_max, qdd_max) + +plot(t, [q qd qdd], ylabel=["\$q\$" "\$\\dot{q}\$" "\$\\ddot{q}\$"], layout=(3,1), l=2, sp=[1 1 2 2 3 3], legend=false) +hline!([qd_max' qdd_max'], l=(2, :dash), sp=[2 2 3 3], c=[1 2 1 2], legend=false) +``` + +### 5:th order polynomial trajectory +```@example TRAJ +t = 0:Ts:3 +q1 = 1 +q, qd, qdd = traj5(t; q1) + +plot(t, [q qd qdd], ylabel=["\$q\$" "\$\\dot{q}\$" "\$\\ddot{q}\$"], layout=(3,1), l=2, legend=false) +``` + + + ## Docstrings ```@index