Skip to content

Commit

Permalink
Call sympy.zeros acording to the docs
Browse files Browse the repository at this point in the history
  • Loading branch information
cdsousa committed Jun 19, 2014
1 parent 86b8ab1 commit 87118a1
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 36 deletions.
4 changes: 2 additions & 2 deletions sympybotics/dynamics/extra_dyn.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion sympybotics/dynamics/regressor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):

Expand Down
28 changes: 14 additions & 14 deletions sympybotics/dynamics/rne.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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
Expand All @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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)

Expand Down
14 changes: 7 additions & 7 deletions sympybotics/dynamics/rne_khalil.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])

Expand Down Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions sympybotics/dynamics/rne_park.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion sympybotics/geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
12 changes: 6 additions & 6 deletions sympybotics/kinematics.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand All @@ -51,18 +51,18 @@ 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])

elif self.rbtdef._dh_convention == 'modified':

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])
Expand All @@ -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])

Expand Down
2 changes: 1 addition & 1 deletion sympybotics/tests/test_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down

0 comments on commit 87118a1

Please sign in to comment.