Skip to content

Commit a85e854

Browse files
committed
Update B500 params and rename thrust to rotor tau
1 parent 3604440 commit a85e854

2 files changed

Lines changed: 23 additions & 19 deletions

File tree

drone_models/data/params.toml

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ rpm2thrust = [0.0, 0.0, 3.16e-10] # TODO, Index is order
1313
rpm2torque = [0.0, 0.0, 7.94e-12] # TODO, Index is order
1414
# TODO: This is an arbitrary number that leads to a working simulation. It MUST be fitted and
1515
# updated as soon as possible.
16-
thrust_tau = 0.03 # TODO value? TODO rename to rotor_tau
16+
thrust_tau = 0.03 # TODO value?
17+
rotor_tau = 0.03 # TODO value?
1718
mixing_matrix = [
1819
[-1.0, -1.0, 1.0, 1.0],
1920
[-1.0, 1.0, 1.0, -1.0],
@@ -46,7 +47,8 @@ J = [ # TODO
4647
]
4748
rpm2thrust = [0.0, 0.0, 5.792654323957372e-10] # TODO, Index is order
4849
rpm2torque = [0.0, 0.0, 7.94e-12] # TODO, Index is order
49-
thrust_tau = 0.138 # TODO value? TODO rename to rotor_tau
50+
thrust_tau = 0.138 # TODO value?
51+
rotor_tau = 0.138 # TODO value?
5052
mixing_matrix = [
5153
[-1.0, -1.0, 1.0, 1.0],
5254
[-1.0, 1.0, 1.0, -1.0],
@@ -78,7 +80,8 @@ J = [ # TODO
7880
]
7981
rpm2thrust = [0.0, 0.0, 1.068340683985525e-09] # TODO, Index is order
8082
rpm2torque = [0.0, 0.0, 7.94e-12] # TODO, Index is order
81-
thrust_tau = 0.115 # TODO value? TODO rename to rotor_tau
83+
thrust_tau = 0.115 # TODO value?
84+
rotor_tau = 0.115 # TODO value?
8285
mixing_matrix = [
8386
[-1.0, -1.0, 1.0, 1.0],
8487
[-1.0, 1.0, 1.0, -1.0],
@@ -108,10 +111,11 @@ J = [
108111
[0.0, 28e-6, 0.0],
109112
[0.0, 0.0, 49e-6]
110113
]
111-
rpm2thrust = [0.0, 2.6713375766104237e-06, 2.9910560258944037e-10] # TODO , Index is order
112-
rpm2torque = [0.0, 2.435151264350409e-09, 2.424629050055297e-12] # TODO , Index is order
114+
rpm2thrust = [0.0, -3.133427287299859e-7, 4.407354891648379e-10] # TODO , Index is order
115+
rpm2torque = [0.0, 1.65886356219615e-9, 2.4693477924534137e-12] # TODO , Index is order
113116
thrust2torque = 0.00593893393599368
114-
thrust_tau = 0.08 # TODO value? TODO rename to rotor_tau
117+
thrust_tau = 0.06286705869479182
118+
rotor_tau = 0.06082197967926632
115119
mixing_matrix = [
116120
[-1.0, -1.0, 1.0, 1.0],
117121
[-1.0, 1.0, 1.0, -1.0],
@@ -121,12 +125,12 @@ mixing_matrix = [
121125
# we still keep them here in one place, since some other things (sim, estimator, firmware) might need them.
122126
pwm_min = 7000
123127
pwm_max = 65535
124-
thrust_min = 0.03 # in N per motor
125-
thrust_max = 0.18 # in N per motor
126-
vmotor_min = 0.983691398141343 # in V
127-
vmotor_max = 2.643523702759344 # in V
128-
vmotor2thrust = [-0.023218159473266192, 0.057892237383960946, -0.005372315709548128, 0.003180315209941464] # Index is order
129-
vmotor2torque = [-0.023218159473266192, 0.057892237383960946, -0.005372315709548128, 0.003180315209941464] # TODO, Index is order
130-
vmotor2rpm = [4304.90684659941, 3948.957007115487] # Index is order
128+
thrust_min = 0.02136263065537499 # in N per motor
129+
thrust_max = 0.2 # in N per motor
130+
vmotor_min = 0.8298950452630223 # in V
131+
vmotor_max = 3.084359953389033 # in V
132+
vmotor2thrust = [-0.014058926705279723, 0.04265273261724981, 0.0018327760144017432, 0.0020576974784587178] # Index is order
133+
vmotor2torque = [-0.00016088354909542246, 0.0003960426420309137, -4.6274122414327404e-5, 1.8490661674309596e-5] # TODO, Index is order
134+
vmotor2rpm = [2938.3995608848436, 6001.834195381014] # Index is order
131135
prop_radius = 27.5e-3 # TODO check
132136
prop_inertia = 38.93e-9

drone_models/first_principles/model.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def dynamics(
3535
rpm2torque: Array,
3636
L: float,
3737
mixing_matrix: Array,
38-
thrust_tau: float,
38+
rotor_tau: float,
3939
) -> tuple[Array, Array, Array, Array, Array | None]:
4040
r"""First principles model for a quatrotor.
4141
@@ -74,7 +74,7 @@ def dynamics(
7474
More information https://ahrs.readthedocs.io/en/latest/filters/angular.html
7575
"""
7676
xp = array_namespace(pos)
77-
mass, gravity_vec, J, J_inv, rpm2thrust, rpm2torque, L, mixing_matrix, thrust_tau = to_xp(
77+
mass, gravity_vec, J, J_inv, rpm2thrust, rpm2torque, L, mixing_matrix, rotor_tau = to_xp(
7878
mass,
7979
gravity_vec,
8080
J,
@@ -83,7 +83,7 @@ def dynamics(
8383
rpm2torque,
8484
L,
8585
mixing_matrix,
86-
thrust_tau,
86+
rotor_tau,
8787
xp=xp,
8888
device=device(pos),
8989
)
@@ -92,7 +92,7 @@ def dynamics(
9292
if rotor_vel is None:
9393
rotor_vel, rotor_vel_dot = cmd, None
9494
else:
95-
rotor_vel_dot = 1 / thrust_tau * (cmd - rotor_vel) # - 1 / KM * rotor_vel**2
95+
rotor_vel_dot = 1 / rotor_tau * (cmd - rotor_vel) # - 1 / KM * rotor_vel**2
9696
# Creating force and torque vector
9797
forces_motor = rpm2thrust[0] + rpm2thrust[1] * rotor_vel + rpm2thrust[2] * rotor_vel**2
9898
torques_motor = rpm2torque[0] + rpm2torque[1] * rotor_vel + rpm2torque[2] * rotor_vel**2
@@ -137,7 +137,7 @@ def symbolic_dynamics(
137137
rpm2torque: Array,
138138
L: float,
139139
mixing_matrix: Array,
140-
thrust_tau: float,
140+
rotor_tau: float,
141141
) -> tuple[cs.MX, cs.MX, cs.MX, cs.MX]:
142142
"""TODO take from numeric."""
143143
# States and Inputs
@@ -153,7 +153,7 @@ def symbolic_dynamics(
153153
# Defining the dynamics function
154154
if model_rotor_vel:
155155
# Thrust dynamics
156-
rotor_vel_dot = 1 / thrust_tau * (U - symbols.rotor_vel) # - 1 / KM * symbols.rotor_vel**2
156+
rotor_vel_dot = 1 / rotor_tau * (U - symbols.rotor_vel) # - 1 / KM * symbols.rotor_vel**2
157157
forces_motor = (
158158
rpm2thrust[0] + rpm2thrust[1] * symbols.rotor_vel + rpm2thrust[2] * symbols.rotor_vel**2
159159
)

0 commit comments

Comments
 (0)