# Calculate Transformation Matrix between two sensors

My question is if I can calculate the transformation matrix between two sensors.

Each sensor provides a $$4\times 4$$ matrix for every timestep recorded. The sensors are moving and have some noise in the data. I would like to calculate the best fitting transformation matrix between the two sensors with the given data because I cant measure the position of the sensors to each other.

At the moment I am trying to get the transformation matrix with an algorithm from this paper. I want to ask if this IS a solution, or I missed something.

The paper you linked to describes an algorithm similar to the Kabsch algorithm from what I see. It's used to find the least squares rotation between two sets of points. For your case you need something else entirely.

Suppose sensor 1 has matrix $$M_1$$ at time t and sensor 2 has matrix $$M_2$$ at time t. That means that a vector, whose coordinates in the local coordinate system of sensor 1 are $$v^1_i$$, would have, in the local coordinate system of sensor 2, coordinates equal to $$v^2_i = M_2^{-1}M_1v^1_i$$ So the transformation matrix 'between' those two sesors is $$M_2^{-1}M_1$$. If you take the rotation part of that matrix (basically the 3x3 part) it would give you a rotation matrix between sensor 2 and sensor 1. If you want their relative position, take the translation part of $$M_1$$ and subtract from it the translation part of $$M_2$$. That would be the position of sensor 1 relative to sensor 2 in the 'world' coordinate system.

If your sensors are moving relative to each other and your data is noisy, a simple average is not going to be enough. I suggest you use a Kalman filter. A Kalman filter incorporates a model (for example constant acceleration model), and a continuous evaluation of how accurate the model is and adjusts the model parameters in response to the input.

If, however, the relative rotation is the same at every time point and you're trying to find a 'mean' rotation to denoise the input, I found a whole paper on the subject: http://users.cecs.anu.edu.au/~hongdong/rotationaveraging.pdf I also found a discussion on averaging quaternions which seems to suggest a simple solution: https://stackoverflow.com/questions/12374087/average-of-multiple-quaternions

• Thanks for the answer. I was thinking something like this, the problem is that the transformation matrix is valid only for M1 and M2 at the time t, for M1 and M2 at the time t+1 the transformation matrix would be a different one. I was thinking if there is something like a general transformation matrix i could calculate or compute that fits allways. Is something like this possible? – user33278 Nov 11 '19 at 16:50
• I edited my answer, found some discussions on this. So I understand that your two sensors have the same relative rotation to each other at all times and you're trying to find it? – iliar Nov 11 '19 at 17:56
• Thank you for your answer again, I think you got it right. After reading my post I understand that it's not clear what i meant. So yes the sensores are fixed and have always the same position to each other, they differ in their measurement, because of the motion. Let's say they are fixed on a car, one at the front, the otherone at the back, if the measurement was recorded on a flat and straight road it would be just the avarage of the transformation matrix at all times, but driving up a hill will break my transformation matrix. – user33278 Nov 11 '19 at 19:15
• The paper you linked looks like the answer to my question. "By solving the conjugate rotation problem, one can compute the relationship between the robot and camera frames." – user33278 Nov 11 '19 at 19:21
• Sorry, forgot about that. Thank you. :) – user33278 Nov 11 '19 at 20:26