setPIDgains.m 2.08 KB
Newer Older
1
2
3
4
5
function [vehicle_params] = setPIDgains(vehicle_params)
%SETPIDGAINS 

    %% Position -> Velocity
    % x
6
    vehicle_params.PIDctrl.x.kP = 2;
7
8
    
    % y
9
    vehicle_params.PIDctrl.y.kP = 2;
10
11
    
    % z
12
    vehicle_params.PIDctrl.z.kP = 8;
13
    vehicle_params.PIDctrl.z.kI = 0.1;
14
    vehicle_params.PIDctrl.z.kD = 1;
15
16
17
    
    %% Velocity -> Acceleration
    % x-dot
18
    vehicle_params.PIDctrl.x_dot.kP = 5;
19
    vehicle_params.PIDctrl.x_dot.kI = 0.1;
20
    vehicle_params.PIDctrl.x_dot.kD = 0;
21
22
    
    % y-dot
23
    vehicle_params.PIDctrl.y_dot.kP = 5;
24
    vehicle_params.PIDctrl.y_dot.kI = 0.1;
25
    vehicle_params.PIDctrl.y_dot.kD = 0;
26
27
    
    % z-dot
28
    vehicle_params.PIDctrl.z_dot.kP = 5;
29
    vehicle_params.PIDctrl.z_dot.kI = 0.1;
30
    vehicle_params.PIDctrl.z_dot.kD = 0;
31
32
33
    
    %% Attitude -> Attitude Rate
    % Roll
yean's avatar
yean committed
34
    vehicle_params.PIDctrl.roll.kP = 8;
35
36
37
38
    vehicle_params.PIDctrl.roll.kI = 0;
    vehicle_params.PIDctrl.roll.kD = 0;
    
    % Pitch
yean's avatar
yean committed
39
    vehicle_params.PIDctrl.pitch.kP = 8;
40
41
42
43
    vehicle_params.PIDctrl.pitch.kI = 0;
    vehicle_params.PIDctrl.pitch.kD = 0;
    
    % Yaw
44
    vehicle_params.PIDctrl.yaw.kP = 8;
45
46
47
48
49
    vehicle_params.PIDctrl.yaw.kI = 0;
    vehicle_params.PIDctrl.yaw.kD = 0;
    
    %% Attitude Rate -> Torques
    % Roll Rate
yean's avatar
yean committed
50
51
52
    vehicle_params.PIDctrl.roll_rate.kP = 5;
    vehicle_params.PIDctrl.roll_rate.kI = 0.1;
    vehicle_params.PIDctrl.roll_rate.kD = 0;
53
54
    
    % Pitch Rate
yean's avatar
yean committed
55
56
    vehicle_params.PIDctrl.pitch_rate.kP = 5;
    vehicle_params.PIDctrl.pitch_rate.kI = 0.1;
57
    vehicle_params.PIDctrl.pitch_rate.kD = 0;
58
59
    
    % Yaw Rate
yean's avatar
yean committed
60
61
    vehicle_params.PIDctrl.yaw_rate.kP = 3;
    vehicle_params.PIDctrl.yaw_rate.kI = 0.1;
62
    vehicle_params.PIDctrl.yaw_rate.kD = 0;
63

yean's avatar
yean committed
64
65
66
67
68
69
70
71
72
73
74
75
    
    %% Saturation Values (symmetric upper/lower)
    vehicle_params.max_pitch = deg2rad(45);
    vehicle_params.max_roll = deg2rad(45);
    
    vehicle_params.max_pitch_rate = deg2rad(90);
    vehicle_params.max_roll_rate = deg2rad(90);
    vehicle_params.max_yaw_rate = deg2rad(90);
    
    vehicle_params.max_x_vel = 5;
    vehicle_params.max_y_vel = 5;
    vehicle_params.max_z_vel = 5;
76
77
end