Skip to content

Commit 2859136

Browse files
committed
Update attitude controller
1 parent bece6f8 commit 2859136

2 files changed

Lines changed: 9 additions & 13 deletions

File tree

drone_controllers/mellinger/control.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ def attitude2force_torque(
139139
vel: Array,
140140
ang_vel: Array,
141141
cmd: Array,
142+
prev_ang_vel: Array | None = None,
142143
ctrl_errors: tuple[Array, ...] | None = None,
143144
ctrl_info: tuple[Array, ...] | None = None,
144145
ctrl_freq: int = 500,
@@ -209,18 +210,13 @@ def attitude2force_torque(
209210
# Warning: We assume zero desired angular velocity
210211
ang_vel_des = xp.zeros_like(ang_vel)
211212
prev_ang_vel_des = xp.zeros_like(ang_vel)
212-
ew = ang_vel_des - ang_vel # if the setpoint is ever != 0 => change sign of setpoint[1]
213+
ew = ang_vel_des - ang_vel
213214
# WARNING: if the setpoint is ever != 0 => change sign of ew.y!
214215

215-
# ang_vel_d_err likely dampens the system because of measurement noise. This term needs to be
216-
# tuned to the sensors of the drone. Since we don't have similar noise properties in the sim, we
217-
# set this term to zero. We still keep the calculation in here for completeness.
218-
# prev_ang_vel = ang_vel if ctrl_info is None else ctrl_info[0]
219-
# Disable the ang_vel_d_err term by setting prev_ang_vel to ang_vel. The other two terms are
220-
# already zero.
221-
prev_ang_vel = ang_vel
216+
# l.259 ff [err_d_rpy]
217+
prev_ang_vel = xp.zeros_like(ang_vel) if prev_ang_vel is None else prev_ang_vel
222218
ang_vel_d_err = ((ang_vel_des - prev_ang_vel_des) - (ang_vel - prev_ang_vel)) / dt
223-
# # l.281: No err_d_yaw
219+
# l.281: No err_d_yaw
224220
ang_vel_d_err = xpx.at(ang_vel_d_err)[..., 2].set(0)
225221

226222
# l. 268 ff Integral Error

drone_controllers/mellinger/params.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[cf2x_L250]
22
[cf2x_L250.core]
3-
mass = 0.033
3+
mass = 0.029 # The controller is using the wrong mass by default
44
mass_thrust = 132000
55
pwm_min = 7000
66
pwm_max = 65535
@@ -33,7 +33,7 @@ int_err_max = [1.0, 1.0, 1500.0]
3333

3434
[cf2x_P250]
3535
[cf2x_P250.core]
36-
mass = 0.033
36+
mass = 0.029 # The controller is using the wrong mass by default
3737
mass_thrust = 132000
3838
pwm_min = 7000
3939
pwm_max = 65535
@@ -66,7 +66,7 @@ int_err_max = [1.0, 1.0, 1500.0]
6666

6767
[cf2x_T350]
6868
[cf2x_T350.core]
69-
mass = 0.03454 # TODO
69+
mass = 0.0325 # The controller is using the wrong mass by default
7070
mass_thrust = 132000
7171
pwm_min = 7000
7272
pwm_max = 65535
@@ -100,7 +100,7 @@ int_err_max = [1.0, 1.0, 1500.0]
100100
[cf21B_500]
101101
[cf21B_500.core]
102102
gravity_vec = [0.0, 0.0, -9.81]
103-
mass = 0.04338
103+
mass = 0.0393 # The controller is using the wrong mass by default
104104
L = 0.035355
105105
rpm2thrust = [0.0, -3.133427287299859e-7, 4.407354891648379e-10]
106106
rpm2torque = [0.0, 1.65886356219615e-9, 2.4693477924534137e-12]

0 commit comments

Comments
 (0)