Skip to content

Commit 920e20c

Browse files
authored
Merge pull request #170 from JuliaComputing/trajdocs
add examples to trajectory generation docs
2 parents a33400b + 6e704c4 commit 920e20c

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

docs/src/trajectory_planning.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,35 @@ These both have output connectors of type `RealOutput` called `q, qd, qdd` for p
1212

1313
See [Industrial robot](@ref) for an example making use of the [`point_to_point`](@ref) planner.
1414

15+
16+
## Example
17+
18+
### Point-to-point trajectory
19+
```@example TRAJ
20+
using Multibody, Plots
21+
Ts = 0.001
22+
t = -1:Ts:3
23+
24+
q1 = [1, 1.2] # Final point (2 DOF)
25+
qd_max = [0.7, 1.2] # Max velocity (2 DOF)
26+
qdd_max = [0.9, 1.1] # Max acceleration (2 DOF)
27+
q, qd, qdd = point_to_point(t; q1, qd_max, qdd_max)
28+
29+
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)
30+
hline!([qd_max' qdd_max'], l=(2, :dash), sp=[2 2 3 3], c=[1 2 1 2], legend=false)
31+
```
32+
33+
### 5:th order polynomial trajectory
34+
```@example TRAJ
35+
t = 0:Ts:3
36+
q1 = 1
37+
q, qd, qdd = traj5(t; q1)
38+
39+
plot(t, [q qd qdd], ylabel=["\$q\$" "\$\\dot{q}\$" "\$\\ddot{q}\$"], layout=(3,1), l=2, legend=false)
40+
```
41+
42+
43+
1544
## Docstrings
1645

1746
```@index

0 commit comments

Comments
 (0)