so_rpy_rotor
Second-order fitted RPY dynamics model with first-order thrust dynamics.
Extends so_rpy by adding a scalar thrust state \(F\) that captures motor
spin-up and spin-down with a first-order lag. Rotational dynamics remain a
fitted second-order linear system driven by RPY commands.
The command interface is [roll_rad, pitch_rad, yaw_rad, thrust_N].
The rotor_vel state is the current thrust in Newtons (not motor RPMs).
where \(\tau\) is the thrust time constant, \(\boldsymbol{\psi} = [\phi,\theta,\psi]^{\top}\) are roll/pitch/yaw angles extracted from \(\mathbf{q}\), and \(R = {}^{\mathcal{I}}R_{\mathcal{B}}(\mathbf{q})\) is the rotation from body to world frame.
dynamics(pos, quat, vel, ang_vel, cmd, rotor_vel=None, dist_f=None, dist_t=None, *, mass, gravity_vec, J, J_inv, thrust_time_coef, acc_coef, cmd_f_coef, rpy_coef, rpy_rates_coef, cmd_rpy_coef)
¶
Fitted model with linear, second order rpy dynamics with thrust 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). If None, the commanded thrust is directly applied (not recommended). If value is given, rotor dynamics are calculated. |
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 |
thrust_time_coef
|
Array
|
Coefficient for the rotor dynamics (1/s). |
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]
|
tuple[Array, Array, Array, Array, Array | None]: description |
Source code in drone_models/so_rpy_rotor/model.py
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 | |
symbolic_dynamics(model_rotor_vel=False, model_dist_f=False, model_dist_t=False, *, mass, gravity_vec, J, J_inv, thrust_time_coef, acc_coef, cmd_f_coef, rpy_coef, rpy_rates_coef, cmd_rpy_coef)
¶
Return CasADi symbolic expressions for the so_rpy_rotor 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 |
thrust_time_coef
|
Array
|
First-order thrust lag time constant coefficient (1/s). |
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_rotor/model.py
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 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 | |
symbolic_dynamics_euler(model_rotor_vel=True, *, mass, gravity_vec, J, J_inv, thrust_time_coef, acc_coef, cmd_f_coef, rpy_coef, rpy_rates_coef, cmd_rpy_coef)
¶
Return CasADi symbolic expressions for the so_rpy_rotor model in Euler-angle form.
This is the native representation of the so_rpy_rotor 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 |
True
|
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 |
thrust_time_coef
|
Array
|
First-order thrust lag time constant coefficient (1/s). |
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_rotor/model.py
252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 | |