-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathquadsim_run.m
59 lines (46 loc) · 1.27 KB
/
quadsim_run.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
% StarryPilot MatSim
% Author: Jiachi Zou
% 06/15/2018
clear all;
clc;
global Var;
%% initialization
init_var;
init_disp;
% ADRC_ENABLE = 0;
%% execute simulator
while 1
start_val = get(Var.start_hd, 'value');
if ~start_val
drawnow limitrate;
continue;
end
k = k + 1;
%% read sensor data
Sensor = get_sensor(QuadrotorState);
% ESO
eso;
%% Quadrotor Control
% altitude control
altitude_control;
% attitude control
attitude_control;
% disturbance compensation
disturb_comp;
% test example
test;
%% mix throttle according to airframe configuration
QuadrotorControl.throttle = throttle_mix(base_throttle, QuadrotorControl.u, QuadrotorModel.airframe);
% compensate throttle due to the delay of motor
throttle_compensate;
%% update quadrotor model states
QuadrotorState = update_quadmodel( Var.h, QuadrotorControl.throttle, motor_sysd, QuadrotorModel, QuadrotorState );
QuadrotorState.att.q = euler2quaternion(QuadrotorState.att.euler);
%% update 3D model
Quadrotor3D = update_quadrotor_3D( Quadrotor3D, QuadrotorState );
draw_quadrotor_3D( Quadrotor3D, QuadrotorState );
%% record and update UI
record;
updateUI;
draw_adrc;
end