c4dynamics.eqm.quadcopter.quadforces#
- c4dynamics.eqm.quadcopter.quadforces(X, quad, rotor_speeds, frame='NED')[source]#
Body-frame force and moment acting on a quadcopter.
The force is the rotor thrust plus the linear aerodynamic drag, without gravity. The moment is the rotor thrust and reaction torques, the rotational drag and the rotor gyroscopic coupling.
quadeqmadds gravity and integrates both through the rigid-body equations of motion.- Parameters:
X (array_like) – State vector. 12 entries for an euler-angles body (
rigidbody):[x, y, z, vx, vy, vz, phi, theta, psi, p, q, r], or 13 entries for a quaternion body (quatbody):[x, y, z, vx, vy, vz, qw, qx, qy, qz, p, q, r].quad (object) – The vehicle parameters as attributes:
kTthrust coefficient [N/(rad/s)^2],kQtorque coefficient [N.m/(rad/s)^2],Ax, Ay, Azlinear drag along the body axes [N/(m/s)],Arrotational drag [N.m/(rad/s)],IRrotor inertia [kg.m^2] (optional, default 0),windwind velocity in the inertial frame [m/s] (optional, default still air; the drag acts on the air-relative velocity), and the rotor geometry: eitherrotor_pos(4 x 2, body x, y of each rotor [m], in the body frame of frame) withrotor_dir(4, +1 counterclockwise seen from above, -1 clockwise, default[1, 1, -1, -1]), orl[m] for an x configuration in the motor order front-right, rear-left, front-left, rear-right.rotor_speeds (array_like) – The four rotor speeds [rad/s].
frame ({'NED', 'ENU'}, optional) – Inertial frame convention.
'NED'with a forward-right-down body frame,'ENU'with a forward-left-up body frame. Defaults'NED'.
- Returns:
F_b (numpy.ndarray) – Body-frame force, thrust plus drag [N].
M_b (numpy.ndarray) – Body-frame moment [N.m].
Note
F_b / mis the specific force an accelerometer at the center of mass measures.Examples
>>> import c4dynamics as c4d >>> import numpy as np >>> quad = c4d.struct(kT=3e-6, kQ=1e-7, l=0.2, Ax=0.3, Ay=0.3, Az=0.25, Ar=0.2) >>> X = np.zeros(12) >>> F_b, M_b = c4d.eqm.quadforces(X, quad, [600, 600, 600, 600]) >>> F_b [0 0 -4.32] >>> M_b [0 0 0]