-
Notifications
You must be signed in to change notification settings - Fork 0
/
student_control_multi_waypt.m
29 lines (22 loc) · 1.11 KB
/
student_control_multi_waypt.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
% MEAM 620 Student Multi Waypoint code
if (setitM(qn)~=903) %The variable setitM(qn) tracks what type of sequence each quad is in.
%If the quad switches sequences, this if statement will be active.
setitM(qn)=903; %This changes setitM(qn) to the current sequence type so that this code only runs once.
%PUT ANY INITIALIZATION HERE
t0 = GetUnixTime;
pos0 = qd{qn}.pos;
load('/home/meam620group11/matlab/test_waypoints/test_waypts_3.mat');
path = [pos0'; waypts];
[times, pos_des, vel_des, acc_des] = trajectory_generator(path, SIMPLE_TRAJ, TARGET_ACC, MAX_WAYPT_DIST);
%END INTITIALIZATION
end %everything beyond this point runs every control loop iteration
%COMPUTE CONTROL HERE
t = GetUnixTime - t0;
% get desired state
qd{qn}.pos_des = interp1(times, pos_des, t, 'linear', 'extrap')';
qd{qn}.vel_des = interp1(times, vel_des, t, 'linear', 'extrap')';
qd{qn}.acc_des = interp1(times, acc_des, t, 'linear', 'extrap')';
qd{qn}.yaw_des = 0;
qd{qn}.yawdot_des = 0;
[F, M, trpy, drpy] = controller(qd, t, qn, struct('mass', MASS));
qd{qn}.euler_des = trpy(2:end);