dynamics.so_rpy_rotor
crazyflow.dynamics.so_rpy_rotor
¶
Second-order fitted RPY dynamics with first-order thrust dynamics.
Extends so_rpy by adding a scalar thrust state \(f_\Sigma\) 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), carried as four entries of
which only the first enters the dynamics.
where \(\mathbf{f}_\mathrm{g} = m\mathbf{g}\).
This is the native Euler-angle form. For how the simulation integrates this state in quaternion + angular velocity coordinates, see so_rpy.
| Variable | Name | Description |
|---|---|---|
| \(\mathbf{p}\) | pos |
Position in m |
| \(\mathbf{v}\) | vel |
Velocity in m/s |
| \(\boldsymbol{\Psi} = [\phi,\theta,\psi]^{\top}\) | Roll, pitch, and yaw in rad, from quat |
|
| \(\dot{\boldsymbol{\Psi}}\) | Roll, pitch, and yaw rates in rad/s, from ang_vel |
|
| \(f_\Sigma\) | rotor_vel[0] |
Collective thrust in N |
| \(\boldsymbol{\Psi}_\mathrm{cmd}\) | cmd[:3] |
Commanded roll, pitch, and yaw in rad |
| \(f_{\Sigma,\mathrm{cmd}}\) | cmd[3] |
Commanded collective thrust in N |
| \(\mathbf{f}_\mathrm{g}\) | Gravitational force | |
| \(\mathbf{R}\) | Rotation from body to world frame | |
| \(\mathbf{e}_\mathrm{z}\) | Unit vector in z direction |
| Parameter | Name | Description |
|---|---|---|
| \(m\) | mass |
Mass in kg |
| \(\mathbf{g}\) | gravity_vec |
Gravity vector in m/s² |
| \(c_\tau\) | thrust_dyn_coef |
Thrust dynamics coefficient in 1/s |
| \(c_\mathrm{acc}\) | acc_coef |
Thrust offset |
| \(c_\mathrm{f}\) | cmd_f_coef |
Thrust scaling coefficient |
| \(\boldsymbol{c}_{\boldsymbol{\Psi},1}\) | rpy_coef |
Rotational dynamics coefficients |
| \(\boldsymbol{c}_{\boldsymbol{\Psi},2}\) | rpy_rates_coef |
Rotational dynamics coefficients |
| \(\boldsymbol{c}_{\boldsymbol{\Psi},3}\) | cmd_rpy_coef |
Rotational dynamics coefficients |
Classes¶
Params
¶
Attributes¶
J = field(metadata={CORE_NDIM_KEY: 2})
class-attribute
instance-attribute
¶
Inertia matrix of the drone.
J_inv = field(metadata={CORE_NDIM_KEY: 2})
class-attribute
instance-attribute
¶
Inverse of the inertia matrix of the drone.
acc_coef = field(metadata={CORE_NDIM_KEY: 1})
class-attribute
instance-attribute
¶
Thrust offset.
cmd_f_coef = field(metadata={CORE_NDIM_KEY: 1})
class-attribute
instance-attribute
¶
Thrust scaling coefficient.
cmd_rpy_coef = field(metadata={CORE_NDIM_KEY: 1})
class-attribute
instance-attribute
¶
Rotational dynamics coefficients of the commanded roll, pitch, and yaw.
gravity_vec = field(metadata={CORE_NDIM_KEY: 1})
class-attribute
instance-attribute
¶
Gravity vector of the drone.
mass = field(metadata={CORE_NDIM_KEY: 1})
class-attribute
instance-attribute
¶
Mass of the drone.
rpy_coef = field(metadata={CORE_NDIM_KEY: 1})
class-attribute
instance-attribute
¶
Rotational dynamics coefficients of the roll, pitch, and yaw angles.
rpy_rates_coef = field(metadata={CORE_NDIM_KEY: 1})
class-attribute
instance-attribute
¶
Rotational dynamics coefficients of the roll, pitch, and yaw rates.
thrust_dyn_coef = field(metadata={CORE_NDIM_KEY: 1})
class-attribute
instance-attribute
¶
Thrust dynamics coefficient.
Methods:¶
create(drone, device)
staticmethod
¶
Create the default parameters for the simulation.
Source code in crazyflow/dynamics/so_rpy_rotor/dynamics.py
Functions:¶
symbolic_dynamics(model_rotor_vel=True, model_dist_f=False, model_dist_t=False, *, mass, gravity_vec, J, J_inv, thrust_dyn_coef, acc_coef, cmd_f_coef, rpy_coef, rpy_rates_coef, cmd_rpy_coef)
¶
Return CasADi symbolic expressions for the so_rpy_rotor dynamics 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 |
True
|
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_dyn_coef
|
Array
|
Thrust dynamics coefficient in 1/s. |
required |
acc_coef
|
Array
|
Thrust offset in N. |
required |
cmd_f_coef
|
Array
|
Thrust scaling coefficient. |
required |
rpy_coef
|
Array
|
Rotational dynamics coefficients of the roll, pitch, and yaw angles in 1/s², shape
|
required |
rpy_rates_coef
|
Array
|
Rotational dynamics coefficients of the roll, pitch, and yaw rates in 1/s,
shape |
required |
cmd_rpy_coef
|
Array
|
Rotational dynamics coefficients of the commanded roll, pitch, and yaw in
1/s², shape |
required |
Returns:
| Type | Description |
|---|---|
MX
|
Tuple |
MX
|
|
MX
|
|
MX
|
|
tuple[MX, MX, MX, MX]
|
|
Source code in crazyflow/dynamics/so_rpy_rotor/dynamics.py
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 250 251 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 | |
symbolic_dynamics_euler(model_rotor_vel=True, *, mass, gravity_vec, J, J_inv, thrust_dyn_coef, acc_coef, cmd_f_coef, rpy_coef, rpy_rates_coef, cmd_rpy_coef)
¶
Return CasADi symbolic expressions for the so_rpy_rotor dynamics in Euler-angle form.
This is the native representation of the so_rpy_rotor dynamics. 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_dyn_coef
|
Array
|
Thrust dynamics coefficient in 1/s. |
required |
acc_coef
|
Array
|
Thrust offset in N. |
required |
cmd_f_coef
|
Array
|
Thrust scaling coefficient. |
required |
rpy_coef
|
Array
|
Rotational dynamics coefficients of the roll, pitch, and yaw angles in 1/s², shape
|
required |
rpy_rates_coef
|
Array
|
Rotational dynamics coefficients of the roll, pitch, and yaw rates in 1/s,
shape |
required |
cmd_rpy_coef
|
Array
|
Rotational dynamics coefficients of the commanded roll, pitch, and yaw in
1/s², shape |
required |
Returns:
| Type | Description |
|---|---|
MX
|
Tuple |
MX
|
|
MX
|
|
MX
|
|
tuple[MX, MX, MX, MX]
|
|
Source code in crazyflow/dynamics/so_rpy_rotor/dynamics.py
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 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 | |