From 970f09bfb720e8624e63e9c9eafdbeca92c0de16 Mon Sep 17 00:00:00 2001 From: Mansard <nmansard@laas.fr> Date: Thu, 6 Oct 2011 11:56:47 +0200 Subject: [PATCH] Added some cases for matrix2vector convertion + corrected a probable bug in rpy. --- python/matrix_util.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/python/matrix_util.py b/python/matrix_util.py index 2aaf588..ab43f0c 100644 --- a/python/matrix_util.py +++ b/python/matrix_util.py @@ -19,12 +19,13 @@ def matrixToTuple(M): return tuple(res) def vectorToTuple(M): - if M.shape[0]==1: return tuple(M.tolist()[0]) + if len(M.shape)==1: return tuple(M.tolist()) + elif M.shape[0]==1: return tuple(M.tolist()[0]) else: return tuple(M.transpose().tolist()[0]) # Convert from Roll, Pitch, Yaw to transformation Matrix def rpy2tr(r,p,y): - mat = matrix(rotate('z',r))*matrix(rotate('y',p))*matrix(rotate('x',y)) + mat = matrix(rotate('z',y))*matrix(rotate('y',p))*matrix(rotate('x',r)) return matrixToTuple(mat) # Get the distance btw the position components of 2 transf matrices -- GitLab