Master Thesis Code
by Simon Moser
Loading...
Searching...
No Matches
trajectoryExample.m
Go to the documentation of this file.
1% =========================================================================== %
2%> @example trajectoryExample.m
3%>
4%> This example shows how to use the Trajectory class to create a trajectory
5%> with waypoints and visualize it.
6% =========================================================================== %
7
8% Create a set start times and stay times for each waypoint
9t_start = seconds(0:10:120);
10t_stay = repmat(seconds(0), size(t_start));
11
12% Create a set of waypoint positions
13pos = [...
14 0 0 0; ...
15 1 0 0; ...
16 1 1 0; ...
17 0 1 0; ...
18 0 0 1; ...
19 1 0 1; ...
20 1 1 1; ...
21 0 1 1; ...
22 0 0 2; ...
23 1 0 2; ...
24 1 1 2; ...
25 0 1 2; ...
26 0 0 0; ...
27 ];
28
29% Create a set of waypoint orientations
30% this is only a yaw-rotation of 90 ° per row and after 360° the pitch also
31% changes by 90°.
32ori = quaternion([...
33 0 1 0 0; ...
34 0 -0.71 -0.71 0; ...
35 0 0 1 0; ...
36 0 0.71 -0.71 0; ...
37 0 -0.71 0 0.71; ...
38 -0.5 -0.5 -0.5 0.5; ...
39 -0.71 0 -0.71 0; ...
40 -0.5 0.5 -0.5 -0.5; ...
41 0 0 0 1; ...
42 -0.71 0 0 0.71; ...
43 1 0 0 0; ...
44 -0.71 0 0 -0.71; ...
45 0 1 0 0; ...
46 ]);
47
48% Create a trajectory object
49traj = Trajectory();
50
51% Add the waypoints to the trajectory
52traj.addWaypoints(t_start, t_stay, pos, ori);
53
54% display the waypoints
55traj.plotWaypoints;
56
57% generate the Trajectory
58traj.generateTrajectory(pos="minSnap", ori="makima");
59
60% visualize the trajectory
Trajectory Class for generating and manipulating trajectories from waypoints.
Definition Trajectory.m:37
function generateTrajectory(in obj, in options)
Generate the trajectory from the waypoints table.
app that can be used to visualize a Trajectory object