Master Thesis Code
by Simon Moser
Loading...
Searching...
No Matches
waypointsToMeasurementsExample.m
Go to the documentation of this file.
1% =========================================================================== %
2%> @example waypointsToMeasurementsExample.m
3%>
4%> This example shows how to use the @ref Trajectory and @ref JumpSensor
5%> classes to create a trajectory and generate realistic sensor data from 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% generate the Trajectory
55traj.generateTrajectory(pos="minSnap", ori="makima");
56
57% visualize the trajectory
59
60% Create a JumpSensor object
61sensor = JumpSensor();
62
63data = sensor.generateFromTrajectory(traj);
64
65% visualize the sensor data
66figure;
67subplot(211); % acceleration
68plot(data.tt.t, data.tt.acc);
69title('Acceleration');
70xlabel('Time [s]');
71ylabel('Acceleration [m/s^2]');
72grid on;
73
74subplot(212); % angular velocity
75plot(data.tt.t, data.tt.gyr);
76title('Angular Velocity');
77xlabel('Time [s]');
78ylabel('Angular Velocity [°/s]');
79grid on;
JumpSensor is a simulation of the JUMP sensor of the ZurichMove Project.
Definition JumpSensor.m:41
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