Skip to content
Peter Corke edited this page May 30, 2021 · 2 revisions

Convert pose object to NumPy array

All pose objects have a .A property which is the underlying NumPy array

>>> T = SE3.Tx(2)
>>> T.A
Out[16]: 
array([[       1,        0,        0,        2],
       [       0,        1,        0,        0],
       [       0,        0,        1,        0],
       [       0,        0,        0,        1]])

If the object has multiple values the result will be a list of NumPy arrays

>>> T=SE3.Tx([2,3,4])
>>> T.A
[array([[       1,        0,        0,        2],
        [       0,        1,        0,        0],
        [       0,        0,        1,        0],
        [       0,        0,        0,        1]]),
 array([[       1,        0,        0,        3],
        [       0,        1,        0,        0],
        [       0,        0,        1,        0],
        [       0,        0,        0,        1]]),
 array([[       1,        0,        0,        4],
        [       0,        1,        0,        0],
        [       0,        0,        1,        0],
        [       0,        0,        0,        1]])]

Plotting with Jupyter notebook

Plots will appear within the notebook if use the

%matplotlib notebook

magic command. However this is incapable of showing animations, for that to work you need the graphics window to "pop out" so choose a different backend.

Convert between SE3 and SO3

It is frequently necessary to convert between these types. The constructors handle a variety of types so the easiest way to do this is

>>> R = SO3.Rx(0.3)
>>> T = SE3(R)
>>> T
   1         0         0         0         
   0         0.9553   -0.2955    0         
   0         0.2955    0.9553    0         
   0         0         0         1  

The opposite operation is

>>> SO3(T)
   1         0         0         
   0         0.9553   -0.2955    
   0         0.2955    0.9553    

Note that the .R property gives an SO(3) NumPy array not an SO3 object

>>> T.R
array([[       1,        0,        0],
       [       0,   0.9553,  -0.2955],
       [       0,   0.2955,   0.9553]])