A mobile robot test can record the same relative pose increment several times. Suppose each increment advances one meter along the robot's local x-axis and turns 90 degrees about the local z-axis. If the first pose is aligned with the map, the first translation points along map x. After the first turn, the second translation points along map y. The step is constant in the robot frame while its direction changes in the map frame.

When verifying a pose log, adding the translation vectors directly would place the robot four meters along map x after four increments. Composing the increments instead yields a square path that ends at the initial pose. The difference is visible in both the intermediate positions and the final translation.

Fix the convention in the fixture

Use column vectors and a 4-by-4 matrix that maps body-frame coordinates into the map frame. The upper left block holds the rotation, and the last column holds the position. Applying a local increment means multiplying the current body-to-map pose on the right by the increment matrix. In the example, the step's translation is [1, 0, 0] in the starting body frame for that step.

The fixture uses zeros and ones for the quarter-turn matrix. That makes every intermediate position and the final identity exact for the tested integer inputs.

import numpy as np

step = np.array([

[0, -1, 0, 1],

[1, 0, 0, 0],

[0, 0, 1, 0],

[0, 0, 0, 1],

])

poses = [np.linalg.matrix_power(step, k) for k in range(5)]

positions = np.stack([pose[:3, 3] for pose in poses])

np.testing.assert_array_equal(positions, [

[0, 0, 0],

[1, 0, 0],

[1, 1, 0],

[0, 1, 0],

[0, 0, 0],

])

np.testing.assert_array_equal(poses[-1], np.eye(4, dtype=int))

The second pose is especially useful for diagnosing a frame mix-up. After two increments the translation is [1, 1, 0]. If all translations were accumulated along a fixed map axis, that position would be [2, 0, 0]. Checking only the four-step endpoint can conceal some ordering errors, so compare more than one intermediate result when validating coordinate conventions.

Confirm the assumptions for real logs

Use a power only when the same relative transform applies to every step. A log with a different translation or rotation per row needs an ordered product of those row transforms. Keep the row order and the source and destination frame names with the output. If the starting pose differs from the identity, preserve it and right-multiply it by the repeated local step, or by the ordered product for varying steps.

For measured or numerically estimated rotations, choose a comparison tolerance appropriate to the units and the test goal. The exact integer fixture checks how the transforms are composed. It does not model wheel slip, timing error, sensor noise or other variation in a physical test.

NumPy documents the behavior of matrix_power for integer exponents, including the identity at exponent zero. The Modern Robotics material explains the homogeneous representation and how left and right multiplication correspond to different reference frames. Together they provide a way to test a pose calculation before interpreting field data.

Sources

NumPy matrix_power reference: https://numpy.org/doc/stable/reference/generated/numpy.linalg.matrix_power.html

Modern Robotics homogeneous transformation matrices: https://modernrobotics.northwestern.edu/nu-gm-book-resource/3-3-1-homogeneous-transformation-matrices/