so_rpy
Second-order fitted RPY dynamics model (no rotor dynamics).
Rotational dynamics are modelled as a fitted second-order linear system driven
by roll, pitch, and yaw commands. Translational dynamics are driven by the
collective thrust command directly, with no motor spin-up lag.
The command interface is [roll_rad, pitch_rad, yaw_rad, thrust_N].
where \(\boldsymbol{\psi} = [\phi,\theta,\psi]^{\top}\) are roll/pitch/yaw angles extracted from \(\mathbf{q}\), \(R = {}^{\mathcal{I}}R_{\mathcal{B}}(\mathbf{q})\) is the rotation from body to world frame, and \({}^{\mathcal{B}}\boldsymbol{\omega}\) is recovered from \(\ddot{\boldsymbol{\psi}}\) via the kinematic Jacobian. The coefficients \(c_{\psi}\), \(c_{\dot{\psi}}\), \(c_u\) are identified from flight data.
dynamics(pos, quat, vel, ang_vel, cmd, rotor_vel=None, dist_f=None, dist_t=None, *, mass, gravity_vec, J, J_inv, acc_coef, cmd_f_coef, rpy_coef, rpy_rates_coef, cmd_rpy_coef)
¶
The fitted model with linear, second order rpy dynamics.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pos
|
Array
|
Position of the drone (m). |
required |
quat
|
Array
|
Quaternion of the drone (xyzw). |
required |
vel
|
Array
|
Velocity of the drone (m/s). |
required |
ang_vel
|
Array
|
Angular velocity of the drone (rad/s). |
required |
cmd
|
Array
|
Roll pitch yaw (rad) and collective thrust (N) command. |
required |
rotor_vel
|
Array | None
|
Speed of the 4 motors (RPMs). Kept for compatibility with the model signature. |
None
|
dist_f
|
Array | None
|
Disturbance force (N) in the world frame acting on the CoM. |
None
|
dist_t
|
Array | None
|
Disturbance torque (Nm) in the world frame acting on the CoM. |
None
|
mass
|
float
|
Mass of the drone (kg). |
required |
gravity_vec
|
Array
|
Gravity vector (m/s^2). We assume the gravity vector points downwards, e.g. [0, 0, -9.81]. |
required |
J
|
Array
|
Inertia matrix (kg m^2). |
required |
J_inv
|
Array
|
Inverse inertia matrix (1/kg m^2). |
required |
acc_coef
|
Array
|
Coefficient for the acceleration (1/s^2). |
required |
cmd_f_coef
|
Array
|
Coefficient for the collective thrust (N/rad^2). |
required |
rpy_coef
|
Array
|
Coefficient for the roll pitch yaw dynamics (1/s). |
required |
rpy_rates_coef
|
Array
|
Coefficient for the roll pitch yaw rates dynamics (1/s^2). |
required |
cmd_rpy_coef
|
Array
|
Coefficient for the roll pitch yaw command dynamics (1/s). |
required |
Returns:
| Type | Description |
|---|---|
tuple[Array, Array, Array, Array, Array | None]
|
The derivatives of all state variables. |
Source code in drone_models/so_rpy/model.py
symbolic_dynamics(model_rotor_vel=False, model_dist_f=False, model_dist_t=False, *, mass, gravity_vec, J, J_inv, acc_coef, cmd_f_coef, rpy_coef, rpy_rates_coef, cmd_rpy_coef)
¶
Return CasADi symbolic expressions for the so_rpy model in quaternion form.
Internally delegates to symbolic_dynamics_euler and converts the Euler-angle state to quaternion + angular-velocity state so that the interface matches that of symbolic_dynamics.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_rotor_vel
|
bool
|
If |
False
|
model_dist_f
|
bool
|
If |
False
|
model_dist_t
|
bool
|
If |
False
|
mass
|
float
|
Drone mass in kg. |
required |
gravity_vec
|
Array
|
Gravity vector, shape |
required |
J
|
Array
|
Inertia matrix, shape |
required |
J_inv
|
Array
|
Inverse inertia matrix, shape |
required |
acc_coef
|
Array
|
Scalar acceleration offset coefficient. |
required |
cmd_f_coef
|
Array
|
Collective-thrust-to-acceleration coefficient. |
required |
rpy_coef
|
Array
|
RPY state feedback coefficient, shape |
required |
rpy_rates_coef
|
Array
|
RPY-rate feedback coefficient, shape |
required |
cmd_rpy_coef
|
Array
|
RPY command feedforward coefficient, shape |
required |
Returns:
| Type | Description |
|---|---|
MX
|
Tuple |
MX
|
|
MX
|
|
MX
|
|
tuple[MX, MX, MX, MX]
|
|
Source code in drone_models/so_rpy/model.py
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 | |
symbolic_dynamics_euler(model_rotor_vel=False, *, mass, gravity_vec, J, J_inv, acc_coef, cmd_f_coef, rpy_coef, rpy_rates_coef, cmd_rpy_coef)
¶
Return CasADi symbolic expressions for the so_rpy model in Euler-angle form.
This is the native representation of the so_rpy model. The state uses
roll/pitch/yaw and their rates rather than quaternion + angular velocity,
which avoids trigonometric overhead inside CasADi-based solvers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_rotor_vel
|
bool
|
If |
False
|
mass
|
float
|
Drone mass in kg. |
required |
gravity_vec
|
Array
|
Gravity vector, shape |
required |
J
|
Array
|
Inertia matrix, shape |
required |
J_inv
|
Array
|
Inverse inertia matrix, shape |
required |
acc_coef
|
Array
|
Scalar acceleration offset coefficient. |
required |
cmd_f_coef
|
Array
|
Collective-thrust-to-acceleration coefficient. |
required |
rpy_coef
|
Array
|
RPY state feedback coefficient, shape |
required |
rpy_rates_coef
|
Array
|
RPY-rate feedback coefficient, shape |
required |
cmd_rpy_coef
|
Array
|
RPY command feedforward coefficient, shape |
required |
Returns:
| Type | Description |
|---|---|
MX
|
Tuple |
MX
|
|
MX
|
|
MX
|
|
tuple[MX, MX, MX, MX]
|
|