From 87118a14630f3f38d0efdbf9968938ac97e39cbe Mon Sep 17 00:00:00 2001 From: Cristovao Duarte Sousa Date: Thu, 19 Jun 2014 10:42:18 +0100 Subject: [PATCH] Call sympy.zeros acording to the docs --- sympybotics/dynamics/extra_dyn.py | 4 ++-- sympybotics/dynamics/regressor.py | 2 +- sympybotics/dynamics/rne.py | 28 ++++++++++++++-------------- sympybotics/dynamics/rne_khalil.py | 14 +++++++------- sympybotics/dynamics/rne_park.py | 8 ++++---- sympybotics/geometry.py | 2 +- sympybotics/kinematics.py | 12 ++++++------ sympybotics/tests/test_results.py | 2 +- 8 files changed, 36 insertions(+), 36 deletions(-) diff --git a/sympybotics/dynamics/extra_dyn.py b/sympybotics/dynamics/extra_dyn.py index ef9e165..c490866 100644 --- a/sympybotics/dynamics/extra_dyn.py +++ b/sympybotics/dynamics/extra_dyn.py @@ -13,7 +13,7 @@ def frictionforce(rbtdef, ifunc=None): if not ifunc: ifunc = identity - fric = zeros((rbtdef.dof, 1)) + fric = zeros(rbtdef.dof, 1) if rbtdef.frictionmodel is None or len(rbtdef.frictionmodel) == 0: pass @@ -45,7 +45,7 @@ def driveinertiaterm(rbtdef, ifunc=None): if not ifunc: ifunc = identity - driveinertia = zeros((rbtdef.dof, 1)) + driveinertia = zeros(rbtdef.dof, 1) if rbtdef.driveinertiamodel is None: pass diff --git a/sympybotics/dynamics/regressor.py b/sympybotics/dynamics/regressor.py index 0912187..7003020 100644 --- a/sympybotics/dynamics/regressor.py +++ b/sympybotics/dynamics/regressor.py @@ -16,7 +16,7 @@ def regressor(rbtdef, geom, ifunc=None): dynparms = rbtdef.dynparms() - Y = zeros((rbtdef.dof, len(dynparms))) + Y = zeros(rbtdef.dof, len(dynparms)) for p, parm in enumerate(dynparms): diff --git a/sympybotics/dynamics/rne.py b/sympybotics/dynamics/rne.py index 68c5d98..297f80d 100644 --- a/sympybotics/dynamics/rne.py +++ b/sympybotics/dynamics/rne.py @@ -37,8 +37,8 @@ def gravityterm(rbtdef, geom, ifunc=None): if not ifunc: ifunc = identity rbtdeftmp = deepcopy(rbtdef) - rbtdeftmp.dq = zeros((rbtdeftmp.dof, 1)) - rbtdeftmp.ddq = zeros((rbtdeftmp.dof, 1)) + rbtdeftmp.dq = zeros(rbtdeftmp.dof, 1) + rbtdeftmp.ddq = zeros(rbtdeftmp.dof, 1) rbtdeftmp.frictionmodel = None geomtmp = Geometry(rbtdeftmp) return rne(rbtdeftmp, geomtmp, ifunc) @@ -49,8 +49,8 @@ def coriolisterm(rbtdef, geom, ifunc=None): if not ifunc: ifunc = identity rbtdeftmp = deepcopy(rbtdef) - rbtdeftmp.gravityacc = zeros((3, 1)) - rbtdeftmp.ddq = zeros((rbtdeftmp.dof, 1)) + rbtdeftmp.gravityacc = zeros(3, 1) + rbtdeftmp.ddq = zeros(rbtdeftmp.dof, 1) rbtdeftmp.frictionmodel = None geomtmp = Geometry(rbtdeftmp) return rne(rbtdeftmp, geomtmp, ifunc) @@ -62,11 +62,11 @@ def coriolismatrix(rbtdef, geom, ifunc=None): if not ifunc: ifunc = identity - C = zeros((rbtdef.dof, rbtdef.dof)) + C = zeros(rbtdef.dof, rbtdef.dof) rbtdeftmp = deepcopy(rbtdef) - rbtdeftmp.gravityacc = zeros((3, 1)) - rbtdeftmp.ddq = zeros((rbtdeftmp.dof, 1)) + rbtdeftmp.gravityacc = zeros(3, 1) + rbtdeftmp.ddq = zeros(rbtdeftmp.dof, 1) rbtdeftmp.frictionmodel = None # # Coriolis vector c element k is given by @@ -75,10 +75,10 @@ def coriolismatrix(rbtdef, geom, ifunc=None): # # Find upper triangular A[k]'s - A = [zeros((rbtdef.dof, rbtdef.dof)) for k in range(rbtdef.dof)] + A = [zeros(rbtdef.dof, rbtdef.dof) for k in range(rbtdef.dof)] for i in range(rbtdef.dof): - rbtdeftmp.dq = zeros((rbtdeftmp.dof, 1)) + rbtdeftmp.dq = zeros(rbtdeftmp.dof, 1) rbtdeftmp.dq[i] = 1 geomtmp = Geometry(rbtdeftmp) fw_results = rne_forward(rbtdeftmp, geomtmp, ifunc) @@ -88,7 +88,7 @@ def coriolismatrix(rbtdef, geom, ifunc=None): for i in range(rbtdef.dof): for j in range(i+1, rbtdef.dof): - rbtdeftmp.dq = zeros((rbtdeftmp.dof, 1)) + rbtdeftmp.dq = zeros(rbtdeftmp.dof, 1) rbtdeftmp.dq[i] = rbtdeftmp.dq[j] = 1 geomtmp = Geometry(rbtdeftmp) fw_results = rne_forward(rbtdeftmp, geomtmp, ifunc) @@ -122,15 +122,15 @@ def inertiamatrix(rbtdef, geom, ifunc=None): if not ifunc: ifunc = identity - M = zeros((rbtdef.dof, rbtdef.dof)) + M = zeros(rbtdef.dof, rbtdef.dof) rbtdeftmp = deepcopy(rbtdef) - rbtdeftmp.gravityacc = zeros((3, 1)) + rbtdeftmp.gravityacc = zeros(3, 1) rbtdeftmp.frictionmodel = None - rbtdeftmp.dq = zeros((rbtdeftmp.dof, 1)) + rbtdeftmp.dq = zeros(rbtdeftmp.dof, 1) for i in range(M.rows): - rbtdeftmp.ddq = zeros((rbtdeftmp.dof, 1)) + rbtdeftmp.ddq = zeros(rbtdeftmp.dof, 1) rbtdeftmp.ddq[i] = 1 geomtmp = Geometry(rbtdeftmp) diff --git a/sympybotics/dynamics/rne_khalil.py b/sympybotics/dynamics/rne_khalil.py index 5e4a42b..a9bda3b 100644 --- a/sympybotics/dynamics/rne_khalil.py +++ b/sympybotics/dynamics/rne_khalil.py @@ -15,10 +15,10 @@ def rne_khalil_forward(rbtdef, geom, ifunc=None): dV = list(range(0, rbtdef.dof + 1)) U = list(range(0, rbtdef.dof + 1)) - w[-1] = zeros((3, 1)) - dw[-1] = zeros((3, 1)) + w[-1] = zeros(3, 1) + dw[-1] = zeros(3, 1) dV[-1] = -rbtdef.gravityacc - U[-1] = zeros((3, 3)) + U[-1] = zeros(3, 3) z = Matrix([0, 0, 1]) @@ -58,19 +58,19 @@ def rne_khalil_backward(rbtdef, geom, fw_results, ifunc=None): # extend Rdh so that Rdh[dof] return identity Rdh = geom.Rdh + [eye(3)] # extend pdh so that pRdh[dof] return zero - pdh = geom.pdh + [zeros((3, 1))] + pdh = geom.pdh + [zeros(3, 1)] F = list(range(rbtdef.dof)) M = list(range(rbtdef.dof)) f = list(range(rbtdef.dof + 1)) m = list(range(rbtdef.dof + 1)) - f[rbtdef.dof] = zeros((3, 1)) - m[rbtdef.dof] = zeros((3, 1)) + f[rbtdef.dof] = zeros(3, 1) + m[rbtdef.dof] = zeros(3, 1) z = Matrix([0, 0, 1]) - tau = zeros((rbtdef.dof, 1)) + tau = zeros(rbtdef.dof, 1) fric = frictionforce(rbtdef) Idrive = driveinertiaterm(rbtdef) diff --git a/sympybotics/dynamics/rne_park.py b/sympybotics/dynamics/rne_park.py index 9d78b10..22c084b 100644 --- a/sympybotics/dynamics/rne_park.py +++ b/sympybotics/dynamics/rne_park.py @@ -41,8 +41,8 @@ def rne_park_forward(rbtdef, geom, ifunc=None): V = list(range(0, rbtdef.dof + 1)) dV = list(range(0, rbtdef.dof + 1)) - V[-1] = zeros((6, 1)) - dV[-1] = - zeros((3, 1)).col_join(rbtdef.gravityacc) + V[-1] = zeros(6, 1) + dV[-1] = - zeros(3, 1).col_join(rbtdef.gravityacc) # Forward for i in range(rbtdef.dof): @@ -72,9 +72,9 @@ def rne_park_backward(rbtdef, geom, fw_results, ifunc=None): Tdh_inv = geom.Tdh_inv + [eye(4)] F = list(range(rbtdef.dof + 1)) - F[rbtdef.dof] = zeros((6, 1)) + F[rbtdef.dof] = zeros(6, 1) - tau = zeros((rbtdef.dof, 1)) + tau = zeros(rbtdef.dof, 1) fric = frictionforce(rbtdef) Idrive = driveinertiaterm(rbtdef) diff --git a/sympybotics/geometry.py b/sympybotics/geometry.py index 9d0dbbb..17f608e 100644 --- a/sympybotics/geometry.py +++ b/sympybotics/geometry.py @@ -20,7 +20,7 @@ def __init__(self, robotdef, ifunc=None): def inverse_T(T): return T[0:3, 0:3].transpose().row_join( - T[0:3, 0:3].transpose() * T[0:3, 3]).col_join( - sympy.zeros((1, 3)).row_join(sympy.eye(1))) + sympy.zeros(1, 3).row_join(sympy.eye(1))) (alpha, a, d, theta) = sympy.symbols('alpha,a,d,theta', real=True) diff --git a/sympybotics/kinematics.py b/sympybotics/kinematics.py index 63a3c3d..10ef82d 100644 --- a/sympybotics/kinematics.py +++ b/sympybotics/kinematics.py @@ -41,7 +41,7 @@ def sym_skew(v): self.Jp = list(range(self.rbtdef.dof)) for l in range(self.rbtdef.dof): - self.Jp[l] = sympy.zeros((3, self.rbtdef.dof)) + self.Jp[l] = sympy.zeros(3, self.rbtdef.dof) for j in range(l + 1): if self.rbtdef._links_sigma[j]: self.Jp[l][0:3, j] = ifunc(z_ext[j - 1]) @@ -51,10 +51,10 @@ def sym_skew(v): self.Jo = list(range(self.rbtdef.dof)) for l in range(self.rbtdef.dof): - self.Jo[l] = sympy.zeros((3, self.rbtdef.dof)) + self.Jo[l] = sympy.zeros(3, self.rbtdef.dof) for j in range(l + 1): if self.rbtdef._links_sigma[j]: - self.Jo[l][0:3, j] = sympy.zeros((3, 1)) + self.Jo[l][0:3, j] = sympy.zeros(3, 1) else: self.Jo[l][0:3, j] = ifunc(z_ext[j - 1]) @@ -62,7 +62,7 @@ def sym_skew(v): self.Jp = list(range(self.rbtdef.dof)) for l in range(self.rbtdef.dof): - self.Jp[l] = sympy.zeros((3, self.rbtdef.dof)) + self.Jp[l] = sympy.zeros(3, self.rbtdef.dof) for j in range(l + 1): if self.rbtdef._links_sigma[j]: self.Jp[l][0:3, j] = ifunc(geom.z[j]) @@ -72,10 +72,10 @@ def sym_skew(v): self.Jo = list(range(self.rbtdef.dof)) for l in range(self.rbtdef.dof): - self.Jo[l] = sympy.zeros((3, self.rbtdef.dof)) + self.Jo[l] = sympy.zeros(3, self.rbtdef.dof) for j in range(l + 1): if self.rbtdef._links_sigma[j]: - self.Jo[l][0:3, j] = sympy.zeros((3, 1)) + self.Jo[l][0:3, j] = sympy.zeros(3, 1) else: self.Jo[l][0:3, j] = ifunc(geom.z[j]) diff --git a/sympybotics/tests/test_results.py b/sympybotics/tests/test_results.py index 78809aa..c6eb0d2 100644 --- a/sympybotics/tests/test_results.py +++ b/sympybotics/tests/test_results.py @@ -56,7 +56,7 @@ def test_scara_dh_sym_geo_kin(): [1, 1, 0, -1]]) assert (scara_geo.T[-1] - T_spong).expand() == sympy.zeros(4) - assert (scara_kin.J[-1] - J_spong).expand() == sympy.zeros((6, 4)) + assert (scara_kin.J[-1] - J_spong).expand() == sympy.zeros(6, 4) def test_puma_dh_num_geo_kin_dyn():