In Pinocchio Robotics, when calculating the error between two transformations (target_tform and cur_tform), it's essential to understand that transformations in robotics typically involve both rotation and translation components. The discrepancy you're observing between error = target_tform.actInv(cur_tform) and the simple vector difference target_tform.translation - cur_tform.translation arises from how rotations influence the translation error.
Understanding actInv
The method actInv is generally used to compute the inverse action of one transformation on another. Specifically, target_tform.actInv(cur_tform) can be interpreted as:
[
\text{error} = \text{target_tform}^{-1} \cdot \text{cur_tform}
]
This operation involves both the inverse of the rotation and the inverse of the translation components of target_tform.
Why It's Not Just a Simple Translation Difference
-
Rotation Affects Translation:
- When you compute the error using
actInv, the translation component of the resulting transformation isn't just the difference between the two translation vectors. Instead, it accounts for the rotation of the target_tform.
- Mathematically, the translation part of the error is computed as:
[
\text{error.translation} = \text{target_tform.rotation}^{-1} \times (\text{cur_tform.translation} - \text{target_tform.translation})
]
- This means that the difference in translations is first rotated by the inverse of the target's rotation before being assigned to the error's translation component.
-
Frame of Reference:
- The simple difference
target_tform.translation - cur_tform.translation assumes that both translations are in the same frame of reference without considering the orientation of target_tform.
- However,
actInv changes the frame of reference, effectively rotating the translation difference to align with the target frame's orientation.
Practical Implications
-
Error Representation: The error computed using actInv provides a more accurate representation of the positional and orientational difference between the target_tform and cur_tform. It reflects how much and in which direction you need to move and rotate to align cur_tform with target_tform.
-
Control and Optimization: In control algorithms or optimization routines, using the transformation-based error ensures that both rotational and translational discrepancies are appropriately accounted for, leading to more precise and efficient convergence.
Example
Suppose:
target_tform has a rotation of 90 degrees about the Z-axis and a translation of (1, 0, 0).
cur_tform has no rotation and a translation of (2, 0, 0).
Using actInv:
[
\text{error.translation} = \text{Rotation}^{-90^\circ} \times (2 - 1, 0 - 0, 0 - 0) = \text{Rotation}^{-90^\circ} \times (1, 0, 0) = (0, -1, 0)
]
Simple difference:
[
\text{target_tform.translation} - \text{cur_tform.translation} = (1 - 2, 0 - 0, 0 - 0) = (-1, 0, 0)
]
As seen, the two results differ because actInv accounts for rotation, providing the translation error in the rotated frame.
Conclusion
The key reason error = target_tform.actInv(cur_tform) differs from target_tform.translation - cur_tform.translation is that actInv incorporates both rotational and translational differences by transforming the translation error into the target frame's orientation. This ensures a comprehensive and accurate representation of the transformation error, which is crucial for precise robotic control and manipulation tasks.
Because actInv computes the relative transform by rotating the translation difference, the translation part of target_tform.actInv(cur_tform) accounts for target_tform’s orientation. Thus, it isn’t simply target_tform.translation minus cur_tform.translation but includes rotation, making the error’s translation different from the straightforward vector difference.