c4dynamics.eqm.quadcopter.quadforces

Contents

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. quadeqm adds 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: kT thrust coefficient [N/(rad/s)^2], kQ torque coefficient [N.m/(rad/s)^2], Ax, Ay, Az linear drag along the body axes [N/(m/s)], Ar rotational drag [N.m/(rad/s)], IR rotor inertia [kg.m^2] (optional, default 0), wind wind velocity in the inertial frame [m/s] (optional, default still air; the drag acts on the air-relative velocity), and the rotor geometry: either rotor_pos (4 x 2, body x, y of each rotor [m], in the body frame of frame) with rotor_dir (4, +1 counterclockwise seen from above, -1 clockwise, default [1, 1, -1, -1]), or l [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 / m is 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]