c4dynamics.states.lib.quatbody.quatbody.I#
- property quatbody.I#
Gets and sets the array of moments of inertia.
\[I = [I_{xx}, I_{yy}, I_{zz}]\]Default: \(I = [0, 0, 0]\)
- Parameters:
I (numpy.array or list) – An array of three moments of inertia about each one of the axes \(([I_{xx}, I_{yy}, I_{zz}])\).
- Returns:
out (numpy.array) – An array of the three moments of inertia \([I_{xx}, I_{yy}, I_{zz}]\).
Example
The moments of inertia determine how much torque is required for a desired angular acceleration about a rotational axis.
In this example, two drones with the same yaw torque and different moments of inertia about the z axis are compared. The drone with the larger moment of inertia accelerates slower:
\[\dot{r} = {M_z \over I_{zz}}\]Import required packages:
>>> import c4dynamics as c4d >>> from matplotlib import pyplot as plt >>> import numpy as np
Settings and initial condtions:
>>> dt = 0.01 >>> torque = [0, 0, 0.01] >>> light = c4d.quatbody() >>> light.I = [0.0082, 0.0082, 0.0149] >>> heavy = c4d.quatbody() >>> heavy.I = [0.0164, 0.0164, 0.0298]
Main loop
>>> for ti in np.arange(0, 2, dt): ... light.inteqm(np.zeros(3), torque, dt) ... light.store(ti) ... heavy.inteqm(np.zeros(3), torque, dt) ... heavy.store(ti)
Plot results:
>>> light.plot('psi') >>> heavy.plot('psi', ax = plt.gca(), color = 'c')