drone_models
TODO.
model_features(model)
¶
Get the features of a model.
parametrize(fn, drone_model, xp=None, device=None)
¶
Parametrize a controller function with the default controller parameters for a drone model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fn
|
Callable[P, R]
|
The controller function to parametrize. |
required |
drone_model
|
str
|
The drone model to use. |
required |
xp
|
ModuleType | None
|
The array API module to use. If not provided, numpy is used. |
None
|
device
|
str | None
|
The device to use. If none, the device is inferred from the xp module. |
None
|
Example
Returns:
Type | Description |
---|---|
Callable[P, R]
|
The parametrized controller function with all keyword argument only parameters filled in. |
Source code in drone_models/core.py
core
¶
Core tools for registering and capability checking for the drone models.
ModelParams
¶
named_tuple2xp(params, xp, device=None)
¶
Convert a named tuple to an array API framework.
Source code in drone_models/core.py
parametrize(fn, drone_model, xp=None, device=None)
¶
Parametrize a controller function with the default controller parameters for a drone model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fn
|
Callable[P, R]
|
The controller function to parametrize. |
required |
drone_model
|
str
|
The drone model to use. |
required |
xp
|
ModuleType | None
|
The array API module to use. If not provided, numpy is used. |
None
|
device
|
str | None
|
The device to use. If none, the device is inferred from the xp module. |
None
|
Example
Returns:
Type | Description |
---|---|
Callable[P, R]
|
The parametrized controller function with all keyword argument only parameters filled in. |
Source code in drone_models/core.py
register_model_parameters(params)
¶
Register the default model parameters for this model.
Warning
The model parameters must be a named tuple with a function load
that takes in the
drone model name and returns an instance of itself, or a class that implements the
ModelParams protocol.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
params
|
ModelParams | type[ModelParams]
|
The model parameter type. |
required |
Returns:
Type | Description |
---|---|
Callable[[Callable[P, R]], Callable[P, R]]
|
A decorator function that registers the parameters and returns the function unchanged. |
Source code in drone_models/core.py
supports(rotor_dynamics=True)
¶
Decorator to indicate which features are supported.
Source code in drone_models/core.py
drones
¶
List of available drones.
TODO: Add description.
first_principles
¶
First principles model.
TODO: Add description.
dynamics(pos, quat, vel, ang_vel, cmd, rotor_vel=None, dist_f=None, dist_t=None, *, mass, gravity_vec, J, J_inv, KF, KM, L, mixing_matrix, thrust_tau)
¶
First principles model for a quatrotor.
The input consists of four forces in [N]. TODO more detail.
Based on the quaternion model from https://www.dynsyslab.org/wp-content/papercite-data/pdf/mckinnon-robot20.pdf
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
|
Motor speeds (RPMs). |
required |
rotor_vel
|
Array | None
|
Angular velocity of the 4 motors (RPMs). If None, the commanded thrust is directly applied. If value is given, thrust 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 |
KF
|
float
|
Motor force constant (N/rad^2). |
required |
KM
|
float
|
Motor torque constant (Nm/rad^2). |
required |
L
|
float
|
Distance from the CoM to the motor (m). |
required |
mixing_matrix
|
Array
|
Mixing matrix denoting the turn direction of the motors (4x3). |
required |
thrust_tau
|
float
|
Thrust time constant (s). |
required |
.. math:: \sum_{i=1}^{\infty} x_{i} TODO
Warning
Do not use quat_dot directly for integration! Only usage of ang_vel is mathematically correct. If you still decide to use quat_dot to integrate, ensure unit length! More information https://ahrs.readthedocs.io/en/latest/filters/angular.html
Source code in drone_models/first_principles/model.py
symbolic_dynamics(model_rotor_vel=True, model_dist_f=False, model_dist_t=False, *, mass, gravity_vec, J, J_inv, KF, KM, L, mixing_matrix, thrust_tau)
¶
TODO take from numeric.
Source code in drone_models/first_principles/model.py
model
¶
TODO.
dynamics(pos, quat, vel, ang_vel, cmd, rotor_vel=None, dist_f=None, dist_t=None, *, mass, gravity_vec, J, J_inv, KF, KM, L, mixing_matrix, thrust_tau)
¶
First principles model for a quatrotor.
The input consists of four forces in [N]. TODO more detail.
Based on the quaternion model from https://www.dynsyslab.org/wp-content/papercite-data/pdf/mckinnon-robot20.pdf
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
|
Motor speeds (RPMs). |
required |
rotor_vel
|
Array | None
|
Angular velocity of the 4 motors (RPMs). If None, the commanded thrust is directly applied. If value is given, thrust 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 |
KF
|
float
|
Motor force constant (N/rad^2). |
required |
KM
|
float
|
Motor torque constant (Nm/rad^2). |
required |
L
|
float
|
Distance from the CoM to the motor (m). |
required |
mixing_matrix
|
Array
|
Mixing matrix denoting the turn direction of the motors (4x3). |
required |
thrust_tau
|
float
|
Thrust time constant (s). |
required |
.. math:: \sum_{i=1}^{\infty} x_{i} TODO
Warning
Do not use quat_dot directly for integration! Only usage of ang_vel is mathematically correct. If you still decide to use quat_dot to integrate, ensure unit length! More information https://ahrs.readthedocs.io/en/latest/filters/angular.html
Source code in drone_models/first_principles/model.py
symbolic_dynamics(model_rotor_vel=True, model_dist_f=False, model_dist_t=False, *, mass, gravity_vec, J, J_inv, KF, KM, L, mixing_matrix, thrust_tau)
¶
TODO take from numeric.
Source code in drone_models/first_principles/model.py
params
¶
First principles model parameters.
FirstPrinciplesParams
¶
Bases: NamedTuple
Parameters for the FirstPrinciples model.
load(drone_model)
staticmethod
¶
Load the parameters for the drone model from the params.toml file.
Source code in drone_models/first_principles/params.py
so_rpy
¶
SoRpy model.
TODO: Add description.
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 double integrator (DI) model with optional motor delay (D).
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)
¶
The fitted double integrator (DI) model with optional motor delay (D).
TODO.
Source code in drone_models/so_rpy/model.py
model
¶
TODO.
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 double integrator (DI) model with optional motor delay (D).
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)
¶
The fitted double integrator (DI) model with optional motor delay (D).
TODO.
Source code in drone_models/so_rpy/model.py
params
¶
TODO.
SoRpyParams
¶
Bases: NamedTuple
Parameters for the SoRpy model.
load(drone_model)
staticmethod
¶
Load the parameters for the drone model from the params.toml file.
Source code in drone_models/so_rpy/params.py
so_rpy_rotor
¶
SoRpyRotor model.
TODO: Add description.
dynamics(pos, quat, vel, ang_vel, cmd, rotor_vel=None, dist_f=None, dist_t=None, *, mass, gravity_vec, J, J_inv, KF, KM, rotor_coef, acc_coef, cmd_f_coef, rpy_coef, rpy_rates_coef, cmd_rpy_coef)
¶
The fitted double integrator (DI) model with optional motor delay (D).
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 |
KF
|
Array
|
Motor force constant (N/rad^2). |
required |
KM
|
Array
|
Motor torque constant (Nm/rad^2). |
required |
rotor_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
22 23 24 25 26 27 28 29 30 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 |
|
symbolic_dynamics(model_rotor_vel=False, model_dist_f=False, model_dist_t=False, *, mass, gravity_vec, J, J_inv, KF, KM, rotor_coef, acc_coef, cmd_f_coef, rpy_coef, rpy_rates_coef, cmd_rpy_coef)
¶
The fitted double integrator (DI) model with optional motor delay (D).
TODO.
Source code in drone_models/so_rpy_rotor/model.py
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 |
|
model
¶
TODO.
dynamics(pos, quat, vel, ang_vel, cmd, rotor_vel=None, dist_f=None, dist_t=None, *, mass, gravity_vec, J, J_inv, KF, KM, rotor_coef, acc_coef, cmd_f_coef, rpy_coef, rpy_rates_coef, cmd_rpy_coef)
¶
The fitted double integrator (DI) model with optional motor delay (D).
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 |
KF
|
Array
|
Motor force constant (N/rad^2). |
required |
KM
|
Array
|
Motor torque constant (Nm/rad^2). |
required |
rotor_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
22 23 24 25 26 27 28 29 30 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 |
|
symbolic_dynamics(model_rotor_vel=False, model_dist_f=False, model_dist_t=False, *, mass, gravity_vec, J, J_inv, KF, KM, rotor_coef, acc_coef, cmd_f_coef, rpy_coef, rpy_rates_coef, cmd_rpy_coef)
¶
The fitted double integrator (DI) model with optional motor delay (D).
TODO.
Source code in drone_models/so_rpy_rotor/model.py
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 |
|
params
¶
TODO.
SoRpyRotorParams
¶
Bases: NamedTuple
Parameters for the SoRpyRotor model.
load(drone_model)
staticmethod
¶
Load the parameters for the drone model from the params.toml file.
Source code in drone_models/so_rpy_rotor/params.py
so_rpy_rotor_drag
¶
SoRpyRotorDrag model.
TODO: Add description.
dynamics(pos, quat, vel, ang_vel, cmd, rotor_vel=None, dist_f=None, dist_t=None, *, mass, gravity_vec, J, J_inv, KF, KM, thrust_time_coef, acc_coef, cmd_f_coef, rpy_coef, rpy_rates_coef, cmd_rpy_coef, drag_linear_coef, drag_square_coef)
¶
The fitted double integrator (DI) model with optional motor delay (D).
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 |
KF
|
Array
|
Motor force constant (N/rad^2). |
required |
KM
|
Array
|
Motor torque constant (Nm/rad^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 |
drag_linear_coef
|
Array
|
Coefficient for the linear drag (1/s). |
required |
drag_square_coef
|
Array
|
Coefficient for the square drag (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_rotor_drag/model.py
21 22 23 24 25 26 27 28 29 30 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 133 134 135 136 137 138 139 140 141 142 |
|
symbolic_dynamics(model_rotor_vel=True, model_dist_f=False, model_dist_t=False, *, mass, gravity_vec, J, J_inv, KF, KM, thrust_time_coef, acc_coef, cmd_f_coef, rpy_coef, rpy_rates_coef, cmd_rpy_coef, drag_linear_coef, drag_square_coef)
¶
The fitted double integrator (DI) model with optional motor delay (D).
TODO.
Source code in drone_models/so_rpy_rotor_drag/model.py
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 |
|
model
¶
TODO.
dynamics(pos, quat, vel, ang_vel, cmd, rotor_vel=None, dist_f=None, dist_t=None, *, mass, gravity_vec, J, J_inv, KF, KM, thrust_time_coef, acc_coef, cmd_f_coef, rpy_coef, rpy_rates_coef, cmd_rpy_coef, drag_linear_coef, drag_square_coef)
¶
The fitted double integrator (DI) model with optional motor delay (D).
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 |
KF
|
Array
|
Motor force constant (N/rad^2). |
required |
KM
|
Array
|
Motor torque constant (Nm/rad^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 |
drag_linear_coef
|
Array
|
Coefficient for the linear drag (1/s). |
required |
drag_square_coef
|
Array
|
Coefficient for the square drag (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_rotor_drag/model.py
21 22 23 24 25 26 27 28 29 30 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 133 134 135 136 137 138 139 140 141 142 |
|
symbolic_dynamics(model_rotor_vel=True, model_dist_f=False, model_dist_t=False, *, mass, gravity_vec, J, J_inv, KF, KM, thrust_time_coef, acc_coef, cmd_f_coef, rpy_coef, rpy_rates_coef, cmd_rpy_coef, drag_linear_coef, drag_square_coef)
¶
The fitted double integrator (DI) model with optional motor delay (D).
TODO.
Source code in drone_models/so_rpy_rotor_drag/model.py
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 |
|
params
¶
SoRpyRotorDrag model parameters.
SoRpyRotorDragParams
¶
Bases: NamedTuple
Parameters for the SoRpyRotorDrag model.
load(drone_model)
staticmethod
¶
Load the parameters for the drone model from the params.toml file.
Source code in drone_models/so_rpy_rotor_drag/params.py
symbols
¶
Symbols used in the symbolic drone models.
pos = cs.vertcat(px, py, pz)
module-attribute
¶
Symbolic drone position.
Can be used to define symbolic CasADi expressions that are passed to model-based optimizers such as Acados.
:meta hide-value:
transform
¶
Transformations between physical parameters of the quadrotors.
Conversions such as from motor forces to rotor speeds, or from thrust to PWM, are bundled in this module.
force2pwm(thrust, thrust_max, pwm_max)
¶
Convert thrust in N to thrust in PWM.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
thrust
|
Array | float
|
Array or float of the thrust in [N] |
required |
thrust_max
|
Array | float
|
Maximum thrust in [N] |
required |
pwm_max
|
Array | float
|
Maximum PWM value |
required |
Returns:
Type | Description |
---|---|
Array
|
Thrust converted in PWM. |
Source code in drone_models/transform.py
motor_force2rotor_vel(motor_forces, kf)
¶
Convert motor forces to rotor velocities.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
motor_forces
|
Array
|
Motor forces in SI units with shape (..., N). |
required |
kf
|
float | Array
|
Thrust coefficient. |
required |
Returns:
Type | Description |
---|---|
Array
|
Array of rotor velocities in rad/s with shape (..., N). |
Source code in drone_models/transform.py
pwm2force(pwm, thrust_max, pwm_max)
¶
Convert pwm thrust command to actual thrust.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pwm
|
Array | float
|
Array or float of the pwm value |
required |
thrust_max
|
Array | float
|
Maximum thrust in [N] |
required |
pwm_max
|
Array | float
|
Maximum PWM value |
required |
Returns:
Name | Type | Description |
---|---|---|
thrust |
Array | float
|
Array or float thrust in [N] |
Source code in drone_models/transform.py
rotor_vel2body_force(rotor_vel, kf)
¶
Convert rotor velocities to motor forces.
Source code in drone_models/transform.py
rotor_vel2body_torque(rotor_vel, kf, km, L, mixing_matrix)
¶
Convert rotor velocities to motor torques.
Source code in drone_models/transform.py
utils
¶
Utility functions for the drone models and controllers.
to_xp(*args, xp, device)
¶
Convert all arrays in the argument list to the given xp framework and device.
Source code in drone_models/utils/__init__.py
rotation
¶
In this file, some important rotations from scipy.spatial.transform.rotation are reimplemented in the Array API to be useable with jax, numpy, etc.
https://github.com/scipy/scipy/blob/main/scipy/spatial/transform/_rotation.pyx https://github.com/jax-ml/jax/blob/main/jax/_src/scipy/spatial/transform.py
ang_vel2quat_dot(quat, ang_vel)
¶
Calculates the quaternion derivative based on an angular velocity.
Source code in drone_models/utils/rotation.py
ang_vel2rpy_rates(quat, ang_vel)
¶
Convert angular velocity to rpy rates with batch support.
Source code in drone_models/utils/rotation.py
ang_vel_deriv2rpy_rates_deriv(quat, ang_vel, ang_vel_deriv)
¶
Convert rpy rates derivatives to angular velocity derivatives.
.. math:: \dot{\psi} = \mathbf{\dot{W}}\mathbf{\omega} + \mathbf{W} \dot{\mathbf{\omega}}
Source code in drone_models/utils/rotation.py
create_cs_ang_vel2rpy_rates()
¶
TODO.
Source code in drone_models/utils/rotation.py
create_cs_ang_vel_deriv2rpy_rates_deriv()
¶
TODO.
Source code in drone_models/utils/rotation.py
create_cs_rpy_rates2ang_vel()
¶
TODO.
Source code in drone_models/utils/rotation.py
create_cs_rpy_rates_deriv2ang_vel_deriv()
¶
TODO.
Source code in drone_models/utils/rotation.py
cs_quat2euler(quat, seq='xyz', degrees=False)
¶
TODO.
Source code in drone_models/utils/rotation.py
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 |
|
cs_quat2matrix(quat)
¶
Creates a symbolic rotation matrix based on a symbolic quaternion.
From https://github.com/cmower/spatial-casadi/blob/master/spatial_casadi/spatial.py
Source code in drone_models/utils/rotation.py
rpy_rates2ang_vel(quat, rpy_rates)
¶
Convert rpy rates to angular velocity with batch support.
Source code in drone_models/utils/rotation.py
rpy_rates_deriv2ang_vel_deriv(quat, rpy_rates, rpy_rates_deriv)
¶
Convert rpy rates derivatives to angular velocity derivatives.
.. math:: \dot{\omega} = \mathbf{\dot{W}}\dot{\mathbf{\psi}} + \mathbf{W} \ddot{\mathbf{\psi}}