Skip to content

Commit ee11010

Browse files
authored
increase gain, fix error for se23 control (#33)
Signed-off-by: Li-Yu Lin <liyu8561501@gmail.com>
1 parent aa7679e commit ee11010

File tree

6 files changed

+587
-305
lines changed

6 files changed

+587
-305
lines changed

cyecca/models/rdd2.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,18 @@
2424
Jx = 0.02166666666666667
2525
Jy = 0.02166666666666667
2626
Jz = 0.04000000000000001
27-
Jxz = 0.0
2827

2928
# position loop
3029
kp_pos = 2.0 # position proportional gain
31-
kp_vel = 4.0 # velocity proportional gain
30+
kp_vel = 6.0 # velocity proportional gain
3231
# pos_sp_dist_max = 2 # position setpoint max distance
3332
# vel_max = 2.0 # max velocity command
34-
x_integral_max = 0.25 # 10% trim throttle
35-
y_integral_max = 0.25 # 10% trim throttle
36-
z_integral_max = 0.25 # 10% trim throttle
37-
ki_x = 0.1 # 1/ integrator time constant in 1/seconds
38-
ki_y = 0.1 # 1/ integrator time constant in 1/seconds
39-
ki_z = 0.1 # 1/ integrator time constant in 1/seconds
33+
x_integral_max = 0.10 # 25% throttle
34+
y_integral_max = 0.10 # 25% throttle
35+
z_integral_max = 0.10 # 25% throttle
36+
ki_x = 0.1 # time constant in second
37+
ki_y = 0.1
38+
ki_z = 0.1 # velocity z integral gain
4039

4140

4241
def angle_wrap(angle):

cyecca/models/rdd2_loglinear.py

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from cyecca.models.bezier import derive_dcm_to_quat
99
from cyecca.lie.group_se23 import SE23Quat, se23
1010
from cyecca.symbolic import SERIES
11+
from cyecca.models.rdd2 import saturatem
1112

1213
# print("python: ", sys.executable)
1314

@@ -36,12 +37,14 @@
3637
# kp_yaw = 1
3738

3839
# position loop
39-
kp_pos = 0.5 # position proportional gain
40-
kp_vel = 2.0 # velocity proportional gain
4140
# pos_sp_dist_max = 2 # position setpoint max distance
4241
# vel_max = 2.0 # max velocity command
43-
z_integral_max = 0 # 5.0
44-
ki_z = 0.05 # velocity z integral gain
42+
x_integral_max = 0.25 # 10% trim throttle
43+
y_integral_max = 0.25 # 10% trim throttle
44+
z_integral_max = 0.25 # 10% trim throttle
45+
ki_x = 0.1 # 1/ integrator time constant in 1/seconds
46+
ki_y = 0.1 # 1/ integrator time constant in 1/seconds
47+
ki_z = 0.1 # 1/ integrator time constant in 1/seconds
4548

4649

4750
def saturate(x, x_min, x_max):
@@ -175,8 +178,8 @@ def se23_solve_control():
175178
# ]
176179
# ) # omega3 # control omega1,2,3, and az
177180
# Q = 100*ca.diag(ca.vertcat(10, 10, 10, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5)) # penalize state
178-
Q = 8 * np.eye(9) # penalize state
179-
R = 1 * ca.DM.eye(9) # penalize input
181+
Q = 100 * np.eye(9) # penalize state
182+
R = 2e-1 * ca.DM.eye(9) # penalize input
180183
K, _, _ = lqr(A, B, Q, R)
181184
K = -K
182185
BK = B @ K
@@ -203,7 +206,7 @@ def derive_outerloop_control():
203206
zeta = ca.SX.sym("zeta", 9)
204207
at_w = ca.SX.sym("at_w", 3)
205208
q_wb = SO3Quat.elem(ca.SX.sym("q_wb", 4)) # orientation
206-
z_i = ca.SX.sym("z_i") # z velocity error integral
209+
z_i = ca.SX.sym("z_i", 3) # z velocity error integral
207210
dt = ca.SX.sym("dt") # time step
208211

209212
# CALC
@@ -239,8 +242,18 @@ def derive_outerloop_control():
239242
p_term = ca.if_else(p_norm > p_norm_max, p_norm_max * p_term / p_norm, p_term)
240243

241244
# throttle integral
242-
z_i_2 = z_i + zeta[2] * dt
243-
z_i_2 = saturate(z_i_2, -ca.vertcat(z_integral_max), ca.vertcat(z_integral_max))
245+
z_i_2 = z_i + zeta[0:3] * dt
246+
z_i_2 = saturatem(
247+
z_i_2,
248+
-thrust_trim
249+
* ca.vertcat(
250+
x_integral_max / ki_x, y_integral_max / ki_y, z_integral_max / ki_z
251+
),
252+
thrust_trim
253+
* ca.vertcat(
254+
x_integral_max / ki_x, y_integral_max / ki_y, z_integral_max / ki_z
255+
),
256+
)
244257

245258
# trim throttle
246259
T = p_term + thrust_trim * zW + ki_z * z_i * zW

0 commit comments

Comments
 (0)