ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
1

Problem using superimposition_matrix from transformations.py in the tf package

asked 2013-02-12 17:34:55 -0600

davidcw gravatar image

updated 2014-01-28 17:15:13 -0600

ngrennan gravatar image

I am trying to find the transformation matrix from one set of points to another, and tried to use the function "superimposition_matrix" (from transformations.py), but am getting unexpected results. I don't know if this is a bug or if I'm just missing something, but I was hoping someone could shed some light on my problem.

The function is defined/described as follows:

def superimposition_matrix(v0, v1, scaling=False, usesvd=True):
    "Return matrix to transform given vector set into second vector set ..."

I've provided a simplified example below to illustrate my confusion. In this example, I am trying to find the transformation matrix from a unit-box centered at the origin, to a 100 side-length box with a corner at the origin. Having calculated the transformation matrix using the function superimposition_matrix(), I do a sanity check by transforming one of the corners of the unit-box, but do not get the expected result.

v0 = numpy.array(((0.5,-0.5,0),(0.5,0.5,0),(-0.5,0.5,0),(-0.5,-0.5,0)))
v1 = numpy.array(((100,0,0),(100,100,0),(0,100,0),(0,0,0)))
tfmatrix = superimposition_matrix(v0, v1, scaling=True, usesvd=True)
pos_orig = numpy.array((0.5,-0.5,0,1))
pos_new = numpy.dot(tfmatrix,pos_orig)
print(pos_new)

The array printed is "[ 48.24860074 -49.14653816 -17.21676633 1. ]" But I would expect the answer to be close to "[100 0 0 1.]"

  • ROS version: Fuerte (Full-Desktop install)
  • OS: Ubuntu 12.04 (Precise)
  • Package: TF (Python)

Any insights would be appreciated. Thanks!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2014-04-30 13:18:29 -0600

ssafarik gravatar image

Your v0 and v1 are transposed. It will work as you expect if you run the code as above, but with tfmatrix = superimposition_matrix(v0.T, v1.T, scaling=True, usesvd=True)

Steve.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2013-02-12 17:34:55 -0600

Seen: 406 times

Last updated: Apr 30 '14