Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
MicroCART
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Distributed Autonomous Networked Control Lab
MicroCART
Commits
a1c0e10a
Commit
a1c0e10a
authored
7 years ago
by
bapries
Browse files
Options
Downloads
Patches
Plain Diff
Added necesarry files from andy for the simulink model to work
parent
8164fb57
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
controls/model/Quadcopter_Model_R2016_B.slx
+0
-0
0 additions, 0 deletions
controls/model/Quadcopter_Model_R2016_B.slx
controls/model/modelParameters.m
+84
-65
84 additions, 65 deletions
controls/model/modelParameters.m
with
84 additions
and
65 deletions
controls/model/Quadcopter_Model_R2016_B.slx
+
0
−
0
View file @
a1c0e10a
No preview for this file type
This diff is collapsed.
Click to expand it.
controls/model/modelParameters.m
+
84
−
65
View file @
a1c0e10a
% Add Library Blocks to Path
path
=
genpath
(
'Library_blocks'
);
addpath
(
path
);
% Add Library Blocks and 3D animation to Path
path_1
=
genpath
(
'Library_blocks'
);
path_2
=
genpath
(
'3D_Animation'
);
addpath
(
path_1
,
path_2
);
% Log Analysis Toggle
logAnalysisToggle
=
1
;
% 1 for log analysis, 0 for normal operation
logAnalysisToggle
=
0
;
% 1 for log analysis, 0 for normal operation
% Physics Verification Toggle
physicsVerificationToggle
=
1
;
% Define Simulink Runtime (if logAnalysisToggle is selected, this will be
% automatically set based on the log files time)
runtime
=
55
;
runtime
=
40
;
%max(time)
;
% Model Parameters
m
=
1.216
;
% Quadrotor + battery mass
g
=
9.81
;
% Acceleration of gravity
Jxx
=
0.01
30
;
% Quadrotor and battery motor of inertia around bx (pitch)
Jyy
=
0.01
40
;
% Quadrotor and battery motor of inertia around by (roll)
Jzz
=
0.02
85
;
% Quadrotor and battery motor of inertia around bz (yaw)
Jreq
=
4.2012e-05
;
% Rotor and motor moment of inertia around axis of rotation
Kt
=
1.2007e-05
;
% Rotor thrust constant
Kh
=
3.4574e-04
;
% Rotor in-plane drag constant
K
d
=
1
.4
852e-07
;
% Rotor drag constant
rhx
=
0.16
;
%
X-axis distance from center of mass to a rotor hub
rh
y
=
0.16
;
%
Y
-axis distance from center of mass to a rotor hub
rh
z
=
0.
03
;
%
Z
-axis distance from center of mass to a rotor hub
r
_oc
=
[
0
;
0
;
0
];
% Vector from origin to center of mass
Rm
=
0.235
;
%
Mo
tor
resistance
Kq
=
96.3422
;
% Motor
torque con
stan
t
K
v
=
96.3422
;
% Motor
back emf
constant
If
=
0.3836
;
% Motor
internal friction curre
nt
Pmin
=
0
;
% M
inimum zybo output duty cycle command
Pm
ax
=
1
;
% M
ax
imum zybo output duty cycle command
Tc
=
0.04
;
%
Camera system sampling perio
d
T
q
=
0.0
05
;
%
Quad
sampling period
tau_c
=
0
;
%
Camera system total latency
Vb
=
12.3
;
%
Nominal battery voltage (V)
x_controlled_o
=
0
;
%
Equilibrium l
ater
al controller output
y
_controlled_o
=
0
;
% Equilibrium l
ongitudin
al controller output
y
aw
_controlled_o
=
0
;
% Equilibrium
yaw
controller output
Kp_mahony
=
0.4
;
% Proportional term for mahony filter
K
i
_mahony
=
0.
001
;
% Integr
al term for mahony filter
delta_T
=
4
*
[
0
,
0
,
2.351e-4
];
m
=
1.216
;
% Quadrotor + battery mass
g
=
9.81
;
% Acceleration of gravity
Jxx
=
0.01
10
;
%0.0130;
% Quadrotor and battery motor of inertia around bx (pitch)
Jyy
=
0.01
16
;
%0.0140;
% Quadrotor and battery motor of inertia around by (roll)
Jzz
=
0.02
23
;
%0.0285;
% Quadrotor and battery motor of inertia around bz (yaw)
Jreq
=
4.2012e-05
;
% Rotor and motor moment of inertia around axis of rotation
Kt
=
1.2007e-05
;
% Rotor thrust constant
delta_T
=
[
0
,
0
,
9.404e-04
];
% Thrust constant adjustment factor
K
h
=
3
.4
574e-04
;
% Rotor
in-plane
drag constant
Kd
=
1.4852e-07
;
%
Rotor drag constant
rh
x
=
0.16
;
%
X
-axis distance from center of mass to a rotor hub
rh
y
=
0.
16
;
%
Y
-axis distance from center of mass to a rotor hub
r
hz
=
0.03
;
% Z-axis distance from center of mass to a rotor hub
r_oc
=
[
0
;
0
;
0
];
%
Vec
tor
from origin to center of mass
Rm
=
0.235
;
% Motor
resi
stan
ce
K
q
=
96.3422
;
% Motor
torque
constant
Kv
=
96.3422
;
% Motor
back emf consta
nt
If
=
0.3836
;
% M
otor internal friction current
Pm
in
=
0
;
% M
in
imum zybo output duty cycle command
Pmax
=
1
;
%
Maximum zybo output duty cycle comman
d
T
c
=
0.0
1
;
%0.04;
%
Camera system
sampling period
Tq
=
0.005
;
%
Quad sampling period
tau_c
=
0
;
%
Camera system total latency
Vb
=
12.3
;
%
Nominal b
at
t
er
y voltage (V)
x
_controlled_o
=
0
;
% Equilibrium l
ater
al controller output
y_controlled_o
=
0
;
% Equilibrium
longitudinal
controller output
yaw_controlled_o
=
0
;
% Equilibrium yaw controller output
K
p
_mahony
=
0.
4
;
% Proportion
al term for mahony filter
Ki_mahony
=
0.001
;
% Integral term for mahony filter
% Define Biquad Filter Parameters
b0
=
0.020083
;
b1
=
0.040167
;
b2
=
0.020083
;
a0
=
1
;
a1
=
-
1.561
;
a2
=
0.6414
;
SOS_Matrix
=
[
b0
,
b1
,
b2
,
a0
,
a1
,
a2
];
accel_Fc
=
10
;
Fs
=
1
/
Tq
;
accel_K
=
tan
(
pi
*
accel_Fc
/
Fs
);
Q
=
0.707
;
accel_norm
=
1.0
/
(
1.0
+
accel_K
/
Q
+
accel_K
*
accel_K
);
% Determine Initial Conditions
accel_b0
=
accel_K
*
accel_K
*
accel_norm
;
accel_b1
=
2.0
*
accel_b0
;
accel_b2
=
accel_b0
;
accel_a0
=
1
;
accel_a1
=
2.0
*
(
accel_K
*
accel_K
-
1
)
*
accel_norm
;
accel_a2
=
(
1.0
-
accel_K
/
Q
+
accel_K
*
accel_K
)
*
accel_norm
;
% Equilibrium rotor speeds
omega0_o
=
sqrt
((
m
*
g
)/(
4
*
Kt
));
omega1_o
=
sqrt
((
m
*
g
)/(
4
*
Kt
));
omega2_o
=
sqrt
((
m
*
g
)/(
4
*
Kt
));
omega3_o
=
sqrt
((
m
*
g
)/(
4
*
Kt
));
accel_SOS_Matrix
=
[
accel_b0
,
accel_b1
,
accel_b2
,
accel_a0
,
accel_a1
,
accel_a2
];
% Equilibrium height controller output
height_controlled_o
=
(((
Rm
*
If
...
+
(((
omega0_o
*
2
*
Rm
*
Kv
*
Kq
...
*
Kd
+
1
)
^
2
)
-
1
)/(
4
*
Rm
*
Kv
^
2
*
Kq
...
*
Kd
))/
Vb
)
*
(
Pmax
-
Pmin
)
+
Pmin
);
OF_Fc
=
7
;
OF_K
=
tan
(
pi
*
OF_Fc
/
Fs
);
OF_norm
=
1.0
/
(
1.0
+
OF_K
/
Q
+
OF_K
*
OF_K
);
OF_b0
=
OF_K
*
OF_K
*
OF_norm
;
OF_b1
=
2.0
*
OF_b0
;
OF_b2
=
OF_b0
;
OF_a0
=
1
;
OF_a1
=
2.0
*
(
OF_K
*
OF_K
-
1
)
*
OF_norm
;
OF_a2
=
(
1.0
-
OF_K
/
Q
+
OF_K
*
OF_K
)
*
OF_norm
;
OF_SOS_Matrix
=
[
OF_b0
,
OF_b1
,
OF_b2
,
OF_a0
,
OF_a1
,
OF_a2
];
% Determine Initial Conditions
%
Equilibrium pos
itions
%
Position Initial Cond
itions
x_o
=
0
;
y_o
=
0
;
z_o
=
0
;
%
Equilibrium veloc
iti
e
s
%
Velocity Initial Cond
iti
on
s
x_vel_o
=
0
;
y_vel_o
=
0
;
z_vel_o
=
0
;
% E
quilibrium angle
s
% E
uler Angle Initial Condition
s
roll_o
=
0
;
pitch_o
=
0
;
yaw_o
=
0
;
% E
quilibrium angular rate
s
% E
uler Rate Initial Condition
s
rollrate_o
=
0
;
pitchrate_o
=
0
;
yawrate_o
=
0
;
% Equilibrium rotor speeds
omega0_o
=
sqrt
((
m
*
g
)/(
4
*
Kt
));
omega1_o
=
sqrt
((
m
*
g
)/(
4
*
Kt
));
omega2_o
=
sqrt
((
m
*
g
)/(
4
*
Kt
));
omega3_o
=
sqrt
((
m
*
g
)/(
4
*
Kt
));
% Equilibrium height controller output
height_controlled_o
=
(((
Rm
*
If
...
+
(((
omega0_o
*
2
*
Rm
*
Kv
*
Kq
...
*
Kd
+
1
)
^
2
)
-
1
)/(
4
*
Rm
*
Kv
^
2
*
Kq
...
*
Kd
))/
Vb
)
*
(
Pmax
-
Pmin
)
+
Pmin
);
if
logAnalysisToggle
==
1
%%%%%% Commented out section until logging is .txt file based %%%%%%
% FNAME
...
...
@@ -96,10 +118,10 @@ if logAnalysisToggle == 1
%
%fname = 'sampleLogFile.txt';
fname
=
''
;
fpath
=
''
;
fpath
=
'
C:\Users\Andy\Documents\School\MicroCART\GitRepo\MicroCART_17-18\controls\model\logFiles\
'
;
if
(
isempty
(
fname
))
[
fname
,
fpath
]
=
uigetfile
(
'.txt'
,
'Select log file'
);
[
fname
]
=
uigetfile
(
'.txt'
,
'Select log file'
,
fpath
);
end
params
.
file
.
name
=
fname
;
% file name only
...
...
@@ -210,10 +232,7 @@ if logAnalysisToggle == 1
raw_gyro_data_arr
=
...
[
raw_gyro_data_x
,
raw_gyro_data_y
,
raw_gyro_data_z
];
raw_gyro_data
=
timeseries
(
raw_gyro_data_arr
,
time
);
% Create time series object for z command
throttle_command
=
timeseries
(
dataStruct
.
RC_Throttle_Constant
.
data
,
time
);
% Pull the measurements from the complimentary filter
pitch_measured_IMU
=
dataStruct
.
Pitch_trim_add_Sum
.
data
;
roll_measured_IMU
=
dataStruct
.
Roll_Constant
.
data
;
...
...
@@ -222,9 +241,9 @@ if logAnalysisToggle == 1
IMU_angle_data
=
timeseries
(
IMU_angle_arr
,
time
);
% Pull VRPN pitch and roll
pitch_measured_VRPN
=
dataStruct
.
VRPN_Pitch_Constant
.
data
;
roll_measured_VRPN
=
dataStruct
.
VRPN_Roll_Constant
.
data
;
pitch_measured_VRPN
=
dataStruct
.
Pitch_trim_add_Sum
.
data
;
% Define setpoint timeseries
x_setpoint_model
=
timeseries
(
x_setpoint
,
time
);
y_setpoint_model
=
timeseries
(
y_setpoint
,
time
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment