Is there an equivalent function to assertQuaternionValid()
in tf2? I suppose I could just re-implement the source code for the function using tf2 equivalents? http://docs.ros.org/en/diamondback/api/tf/html/c++/tf_8h_source.html#l00486
Originally posted by jn42 on ROS Answers with karma: 43 on 2021-09-18
Post score: 1
Original comments
Comment by osilva on 2021-09-19:
There is a thread that may be interesting to you:
https://github.com/ros/geometry2/pull/196
Comment by Mike Scheutzow on 2021-09-19:
I'm having trouble understanding this idea that a calculation should be refused because the quaternion is slightly un-normalized. It seems reasonable to log a warning if you think that characteristic is important, but by my thinking you should proceed with the calculation anyway.
Comment by lucasw on 2023-05-13:
Re-implementing that source code in python:
q = transform_stamped.transform.rotation
q_norm_error = abs(q.x * q.x + q.y * q.y + q.z * q.z + q.w * q.w - 1.0)
text = f"quaternion norm error {q_norm_error:0.6f}, {q}".replace("\n", ", ")
if q_norm_error > 0.01:
...
Probably converting the quaternion to the transformations.py array representation and doing a dot with itself is better