Tracking animation

From FlightGear wiki
Jump to: navigation, search

The new (in 2.11) locked-track animation can do exactly the same thing as the Locked Track constraint available in Blender. However it can also be used to simulate simple inverse kinematic systems consisting of two bones connected with a revolute joint (aka hinge).

If you get used to Blender its a really powerful tool (I have problems if trying to work with other modelling programs :P) and with using the right scripts it gets a very neat tool for creating models for FlightGear. For example for a gear scissor just add an armature with two bones, add an IK constraint to the second bone and attach an element of the scissor to each bone, and you are done. You can watch the animation in Blender and using an exporter script now it is possible to watch exactly the same animation inside FlightGear. You don't need to guess any coordinates/axes/etc. and if you modify and object you just have to export it again, without manually modifying the animation xml.

There are (currently) only two axes required. The lock-axis and the track-axis. They should be orthogonal, as the rotation is only possible round the lock-axis. Internally the track-axis is always orthonormalized to the lock-axis, as calculations always are performed in the plane normal to the lock-axis.

For example, you can use the normal rotate animation to rotate the main strut. Every attached hydraulic cylinder, link, etc. is then animated using the locked-track animation. For a hydraulic cylinder the piston and the cylinder housing each are animated using a locked-track animation tracking each other. For a gear scissor, a locked-track animation tracks from a point attached to the strut to a point on the axis. Two objects can be attached to the animation, allowing to animate a scissor. (The object and the slave object, are rotated such that the exactly fill the space between the two attachment points of the scissor).

For the animation a center point and an orientation (axis) are required to calculate the location and orientation of the rotation. Think of the center as the location of the hinge somewhere in space and of the axis as the actual orientation of the hinge. You can now either specify the position of the hinge and the orientation of its axis or (the alternate form) two points on the axis of the hinge, which are then used to calculate the center and orientation of the hinge. (If you use the alternate form the center and axis are automatically calculated from the two given points).

There is no rotation that you can not describe with a single axis given by its xyz coordinates.


Slave center/object

The slave-center specifies the location of the revolute joint. Optionally an object can be specified using slave-name, which will be attached to the animated object and also tracks to the target object.

Examples

Basic usage (Same behaviour as Locked Track constraint in Blender):

<?xml version="1.0" encoding="utf8"?>
<PropertyList>
  <animation>
    <type>locked-track</type>

    <object-name>ADS Arm - Fuselage.r</object-name>
    <center>
      <x-m>4.9</x-m>
      <y-m>1.47</y-m>
      <z-m>3.82</z-m>
    </center>
    <lock-axis>
      <x>0</x>
      <y>1</y>
      <z>0</z>
    </lock-axis>
    <track-axis>
      <x>0.75</x>
      <y>0</y>
      <z>-0.662</z>
    </track-axis>

    <target-name>ADS Arm - Ramp.r</target-name>
    <target-center>
      <x-m>7.969</x-m>
      <y-m>1.475</y-m>
      <z-m>1.11</z-m>
    </target-center>

  </animation>
</PropertyList>

Gear scissor/Link with joint (In Blender the same animation can be achieved using an armature with two bones and an IK constraint applied to the second bone, tracking the target object. The animated object is attached to the first bone and the slave object to the second bone.):

<?xml version="1.0" encoding="utf8"?>
<PropertyList>
  <animation>
    <type>locked-track</type>

    <object-name>NLG Front Door</object-name>
    <center>
      <x-m>-11.52</x-m>
      <y-m>0</y-m>
      <z-m>1.13</z-m>
    </center>
    <lock-axis>
      <x>0</x>
      <y>1</y>
      <z>0</z>
    </lock-axis>
    <track-axis>
      <x>1</x>
      <y>0</y>
      <z>0</z>
    </track-axis>

    <target-name>NLG-Strut</target-name>
    <target-center>
      <x-m>-9.9</x-m>
      <y-m>0</y-m>
      <z-m>1.13</z-m>
    </target-center>

    <slave-name>NLG Front Door Arm</slave-name>
    <slave-center>
      <x-m>-11.335</x-m>
      <y-m>0</y-m>
      <z-m>1.076</z-m>
    </slave-center>
  </animation>
</PropertyList>

Use a condition to disable tracking (and optionally apply specify a rotation beeing applied while disabled):

<?xml version="1.0" encoding="utf8"?>
<PropertyList>
  <animation>
    <type>locked-track</type>

    <condition>
      <property>/controls/gear/nose-wheel-steering</property>
    </condition>
    <disabled-rotation-deg>-90</disabled-rotation-deg>

    <object-name>Torque Link Upper Arm</object-name>
    <center>
      <x-m>-9.785</x-m>
      <y-m>0</y-m>
      <z-m>1.04</z-m>
    </center>
    <lock-axis>
      <x>0</x>
      <y>1</y>
      <z>0</z>
    </lock-axis>
    <track-axis>
      <x>0.022</x>
      <y>0</y>
      <z>-1</z>
    </track-axis>

    <target-name>Torque Link Lower Arm</target-name>
    <target-center>
      <x-m>-9.789</x-m>
      <y-m>0</y-m>
      <z-m>0.454</z-m>
    </target-center>

    <slave-center>
      <x-m>-10.033</x-m>
      <y-m>0</y-m>
      <z-m>1.035</z-m>
    </slave-center>
  </animation>
</PropertyList>

3 axis locked-track animation

Sometime is necessary realize the animation to an object with ball joint, is the typical case of a hydraulic jack actuate the opening the landing gear, it is necessary to proceed in two stages, as locked-track animation always needs at least a locked axis.

First locks, for example, the Y axis and directs the object to a target object, in this example BOX_GEAR_GREEN.000 with coordinates: target-center . The track-axis is the axis that should point the target:

<?xml version="1.0" encoding="utf8"?>
    <animation>
        <type>locked-track</type>
        <object-name>gear-front-jack-02</object-name>
        <center>
            <x-m>-2.91953</x-m>
            <y-m>-0.06230</y-m>
            <z-m>-1.30829</z-m>
        </center>
        <lock-axis>
            <x>0</x>
            <y>1</y>
            <z>0</z>
        </lock-axis>
        <track-axis>
            <x>1</x>
            <y>-0.23</y>
            <z>0.630</z> 
        </track-axis>
        <target-name>BOX_GEAR_GREEN.000</target-name>
        <target-center>
            <x-m>-2.04543</x-m>
            <y-m>-0.23232</y-m>
            <z-m>-0.82533</z-m>
        </target-center>
    </animation>

Then write a second locked-track, which should be put immediately under the first, which locks the axis X. Everything else is equal, as all other references are unchanged.

<?xml version="1.0" encoding="utf8"?>
    <animation>
        <type>locked-track</type>
        <object-name>gear-front-jack-02</object-name>
        <center>
            <x-m>-2.91953</x-m>
            <y-m>-0.06230</y-m>
            <z-m>-1.30829</z-m>
        </center>
        <lock-axis>
            <x>1</x>
            <y>0</y>
            <z>0</z>
        </lock-axis>
        <track-axis>
            <x>1</x>
            <y>-0.23</y>
            <z>0.630</z> 
        </track-axis>
        <target-name>BOX_GEAR_GREEN.000</target-name>
        <target-center>
            <x-m>-2.04543</x-m>
            <y-m>-0.23232</y-m>
            <z-m>-0.82533</z-m>
        </target-center>
    </animation>

Tips

Graphic graph of coordinates of vertices of a line in angular coordinates according to the linear XYZ form

Strangely, the coordinates of the <track-axis> section do not seem to work on the coordinates given in the form: <x1-m> .. </ x1-m> ... <z2-m> .. </ z2-m >. We must give the coordinates in the form <x> ... </ x> ... <z> .. </ z>. To easily convert vertices, you can use the 3D CAD application FreeCad. You create a line by inserting the two vertices (V1 and V2) and then activating the Bounding Box display, as shown in the figure. The 3 coordinates X, Y, Z can be used directly as X, Y, Z coordinates. But be careful with the signs.