Transformation matrices to geometry_msgs/Pose
Hello everyone,
I am trying to calculate the pose of an object in the format for geometry_msgs/pose, therefore position in (x,y,z) and orientation in quaternion (x, z, z, w). I already got the pose in a different format, that is to say a 3 * 4 matrix (Edit: I found out later on they actually add a (0,0,0,1) to make the matrix in homogenous coordinates). Somebody told me the matrix represents the pose as follows:
- first 3 columns: 3x3 rotation matrix
- 4th column: translation vector
How can I transform between these two formats in both direction? Is there maybe some function already available? Thanks in advance!
EDIT: In the original question I forgot to answer that I was looking for a solution using Python. The accepted answer is using c++. Please refer to the additional answer I posted for the python version.