Conversion of orientation quaternion from ROS / Quaternions.online to Blender

I have an issue using quaternions that are coming from ROS. I have already seen this post (How to use quaternions coming from ros?) but I am unable to comment since I do not have enough reputation yet.

The quaternion represents the orientation of a camera to take an image from a certain position. In this case it points to the origin of the reference frame so it is simpler to see if it is correct in Blender. The quaternion from ROS can be visualized in RVIZ and looks like this: I am also certain that this quaternion is correct since it can be visualized as well in quaternions.online.

Just as in the other post, when using this quaternion directly in Blender, the camera points in a different direction. As was told in the other post, the camera looks in the direction of the negative z-axis. However I am unsure how I should perform this transformation.

I have tried the solution where I map the blender settings of z = backwards, y = up and x = right to the ROS settings where x = forwards, y=left and z=up. This makes the transformation: X_blender = - Y_ros Y_blender = Z_ros Z_blender = - X_ros W_blender = W_ros

This did not solve the issue, the camera now points to a different incorrect position: What is the transformation that I should perform to use quaternions from quaternions.online or ROS in Blender?

• I was able to solve this by rotating the orientation quaternion by 90 degrees around the y-axis. This corresponded to making the orientation align with the x-axis instead of the negative z-axis. So the ros-quaternion was multiplied by the following rotation quaternion: quat_rot = mathutils.Quaternion((math.sqrt(2)/2, 0, -math.sqrt(2)/2, 0)) – Toon Jan 6 at 18:43