Skip to content
Snippets Groups Projects
Commit 1872dcc5 authored by Gabriele Buondonno's avatar Gabriele Buondonno
Browse files

[python] Move np and rotate to utils

parent 7d39ac95
No related branches found
No related tags found
No related merge requests found
......@@ -9,31 +9,4 @@ from . import libpinocchio_pywrap as pin
from .libpinocchio_pywrap import _rpyToMatrix as rpyToMatrix
from .libpinocchio_pywrap import _matrixToRpy as matrixToRpy
def npToTTuple(M):
L = M.tolist()
for i in range(len(L)):
L[i] = tuple(L[i])
return tuple(L)
def npToTuple(M):
if len(M.shape) == 1:
return tuple(M.tolist())
if M.shape[0] == 1:
return tuple(M.tolist()[0])
if M.shape[1] == 1:
return tuple(M.T.tolist()[0])
return npToTTuple(M)
def rotate(axis, ang):
'''
# Transformation Matrix corresponding to a rotation about x,y or z
eg. T = rot('x', pi / 4): rotate pi/4 rad about x axis
'''
cood = {'x': 0, 'y': 1, 'z': 2}
u = np.zeros(3)
u[cood[axis]] = 1.0
return pin.AngleAxis(ang, u).matrix()
__all__ = ['npToTTuple', 'npToTuple', 'rotate', 'rpyToMatrix', 'matrixToRpy']
__all__ = ['rpyToMatrix', 'matrixToRpy']
......@@ -10,10 +10,37 @@ import numpy as np
import numpy.linalg as npl
from . import libpinocchio_pywrap as pin
from .rpy import matrixToRpy, npToTTuple, npToTuple, rotate, rpyToMatrix
from .rpy import matrixToRpy, rpyToMatrix
from .deprecation import deprecated
def npToTTuple(M):
L = M.tolist()
for i in range(len(L)):
L[i] = tuple(L[i])
return tuple(L)
def npToTuple(M):
if len(M.shape) == 1:
return tuple(M.tolist())
if M.shape[0] == 1:
return tuple(M.tolist()[0])
if M.shape[1] == 1:
return tuple(M.T.tolist()[0])
return npToTTuple(M)
def rotate(axis, ang):
'''
# Transformation Matrix corresponding to a rotation about x,y or z
eg. T = rot('x', pi / 4): rotate pi/4 rad about x axis
'''
cood = {'x': 0, 'y': 1, 'z': 2}
u = np.zeros(3)
u[cood[axis]] = 1.0
return pin.AngleAxis(ang, u).matrix()
def eye(n):
res = np.eye(n)
if pin.getNumpyType()==np.matrix:
......
from .. import libpinocchio_pywrap as pin
from ..shortcuts import buildModelsFromUrdf, createDatas
from ..rpy import npToTuple
from ..utils import npToTuple
from . import BaseVisualizer
......
from .. import libpinocchio_pywrap as pin
from ..shortcuts import buildModelsFromUrdf, createDatas
from ..rpy import npToTuple
from ..utils import npToTuple
from . import BaseVisualizer
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment