Motion Analysis’ HTR

The Motion Analysis HTR (Hierarchical Translation-Rotation) format was developed as the native skeleton format for the Motion Analysis skeleton generating software. It was created as an alternative to the only existing other format at the time (the BVH format) because of deficiencies in the BVH specification. The Acclaim file format was not yet entered in to the public domain and wasn't available for them to use. A rarely used variant of the HTR format, the GTR format (Global Translation-Rotation) is identical to the HTR format except the hierarchy information is skipped. It is almost never used but it will be noted where the GTR would be different than the HTR

The HTR file format is an excellent all around format. It contains everything necessary for a motion capture file including lots of flexibility in data types and ordering and it has a complete basis pose specification where the starting point for both rotations and translations are given. If it has a drawback it is in a small oddity in the composition of translation data when creating the full transform of a segment (this is described in the interpretation section below).

Parsing the file

The HTR file contains multiple sections: header, segment names & hierarchy, base postion and motion sections. They appear in this order and are denoted by keywords in square brackets "[]". Comment lines can appear in the file and are denoted by a hash mark "#" which can appear at any point in a line (not just at the beginning of a line) the rest of the line is a comment line.

The header section contains global parameter information and starts with the keyword "[HEADER]" on a line by itself. Keywords for parameters in this section appear as the first word of any line, the value for the parameter immediately follows the keyword. When parsing the file simply store the parameter values for later when the motion data is composed into a transformation matrix. The following parameters can appear in this section:

The next section is the segment names and hierarchy section. This is denoted by the keyword "[SegmentNames&Hierarchy]". If this file is an HTR file then each line in this section contains two words. If this is a GTR file then this section has only one word per line (optionally, this section may be skipped since the names of the segments also appear in the motion section of the file). The first word on each line is the name of a segment and the second word is the parent of that segment. If that segment does not have a parent (i.e. is the root object) then the second word is the keyword "GLOBAL". This means that you shouldn't ever have a segment in an HTR file that has the name "global", this would likely confuse most HTR file parsers.

The next section is the base position section and is denoted by the keyword "[BasePosition]". Each line begins with a segment name followed by the translation, rotation and segment length. The translation and rotation values appear in the order X, Y and then Z. It's convenient to create a matrix that is the composition of the base position rotations. The base rotation is used repeatedly so doing the composition now saves time later.

The motion section isn't denoted by the "motion" keyword. Instead, the data for each segment appears in turn and each section begins with the name of the segment in square brackets. In the example motion file "Example1.htr", the first such section starts with the keyword "[LOWERTORSO]". Each line of motion data for a segment starts with the sample number followed by the translation values, then the rotation values and then a scale factor which gets applied to the length of the segment. The translation and rotation values appear in the order X, Y and then Z.

Interpreting the data

Like with the other hierarchical formats the creation of the global transformation of an element is a recursive proces. The childs local transform is generated first then composited with the parents local transform then the grandparents and so on. The creation of the local transform is a little more than just putting the translation and rotation data in a matrix because the base pose of the skeleton must be taken into account. The steps are as follows:

  1. Create a matrix of rotation data from the motion data, call this matrix A.
  2. Take the initial rotatation matrix, call it B, and Multiply A on the right by B.
  3. Sum the translation motion data and the initial motion data to create another matrix C, multiply AB on the right by C.
  4. The resulting transform, ABC, is the local transform for the element. Multiply this on the right by the parents local transform,etc…

When creating a matrix from rotation data be sure to use the value specified by the "EulerRotationOrder" parameter from the header block. If the order is listed as "ZYX" then the order of rotation is X first, followed by Y and then by Z, viz:

vM = vXYZ

The scale value isn't used in these calculations but should be taken into account when drawing segments on the screen. The variations in scale for the length of a segment are typically set up to match the variations in translation by a child segment.