Skip to content

Commit cf574bd

Browse files
committed
yapf
1 parent cae456d commit cf574bd

10 files changed

+49
-105
lines changed

src/dynamic_graph/sot/core/feature_position.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,7 @@ class FeaturePosition(Entity):
2828

2929
signalMap = dict()
3030

31-
def __init__(self,
32-
name,
33-
signalPosition=None,
34-
signalJacobian=None,
35-
referencePosition=None):
31+
def __init__(self, name, signalPosition=None, signalJacobian=None, referencePosition=None):
3632
self._feature = FeaturePoint6d(name)
3733
self.obj = self._feature.obj
3834
self._reference = FeaturePoint6d(name + '_ref')

src/dynamic_graph/sot/core/math_small_entities.py

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,17 @@
66
# from operator import WeightDir
77
# from operator import Nullificator
88
from .operator import (
9-
Add_of_double, Add_of_matrix, Add_of_vector, Component_of_vector,
10-
Compose_R_and_T, ConvolutionTemporal, HomoToMatrix, HomoToRotation,
11-
HomoToTwist, Inverse_of_matrix, Inverse_of_matrixHomo,
12-
Inverse_of_matrixrotation, Inverse_of_matrixtwist, Inverse_of_unitquat,
13-
MatrixDiagonal, MatrixHomoToPose, MatrixHomoToPoseQuaternion,
14-
PoseQuaternionToMatrixHomo, MatrixHomoToPoseRollPitchYaw,
15-
MatrixHomoToPoseUTheta, MatrixToHomo, MatrixToQuaternion, MatrixToRPY,
16-
MatrixToUTheta, MatrixHomoToSE3Vector, SE3VectorToMatrixHomo,
17-
MatrixTranspose, Multiply_double_vector, Multiply_matrix_vector,
18-
Multiply_matrixTwist_vector, Multiply_matrixHomo_vector,
19-
Multiply_of_double, Multiply_of_matrix, Multiply_of_matrixHomo,
20-
Multiply_of_matrixrotation, Multiply_of_matrixtwist,
21-
Multiply_of_quaternion, Multiply_of_vector, PoseRollPitchYawToMatrixHomo,
22-
PoseRollPitchYawToPoseUTheta, PoseUThetaToMatrixHomo, QuaternionToMatrix,
23-
RPYToMatrix, Selec_column_of_matrix, Selec_of_matrix, Selec_of_vector,
24-
SkewSymToVector, Stack_of_vector, Substract_of_double, Substract_of_matrix,
25-
Substract_of_vector, UThetaToQuaternion)
9+
Add_of_double, Add_of_matrix, Add_of_vector, Component_of_vector, Compose_R_and_T, ConvolutionTemporal,
10+
HomoToMatrix, HomoToRotation, HomoToTwist, Inverse_of_matrix, Inverse_of_matrixHomo, Inverse_of_matrixrotation,
11+
Inverse_of_matrixtwist, Inverse_of_unitquat, MatrixDiagonal, MatrixHomoToPose, MatrixHomoToPoseQuaternion,
12+
PoseQuaternionToMatrixHomo, MatrixHomoToPoseRollPitchYaw, MatrixHomoToPoseUTheta, MatrixToHomo, MatrixToQuaternion,
13+
MatrixToRPY, MatrixToUTheta, MatrixHomoToSE3Vector, SE3VectorToMatrixHomo, MatrixTranspose, Multiply_double_vector,
14+
Multiply_matrix_vector, Multiply_matrixTwist_vector, Multiply_matrixHomo_vector, Multiply_of_double,
15+
Multiply_of_matrix, Multiply_of_matrixHomo, Multiply_of_matrixrotation, Multiply_of_matrixtwist,
16+
Multiply_of_quaternion, Multiply_of_vector, PoseRollPitchYawToMatrixHomo, PoseRollPitchYawToPoseUTheta,
17+
PoseUThetaToMatrixHomo, QuaternionToMatrix, RPYToMatrix, Selec_column_of_matrix, Selec_of_matrix, Selec_of_vector,
18+
SkewSymToVector, Stack_of_vector, Substract_of_double, Substract_of_matrix, Substract_of_vector,
19+
UThetaToQuaternion)
2620

2721
from .derivator import Derivator_of_Matrix, Derivator_of_Vector
2822
from .matrix_constant import MatrixConstant

src/dynamic_graph/sot/core/matrix_util.py

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ def vectorToTuple(M):
2929

3030
# Convert from Roll, Pitch, Yaw to transformation Matrix
3131
def rpy2tr(r, p, y):
32-
mat = matrix(rotate('z', y)) * matrix(rotate('y', p)) * matrix(
33-
rotate('x', r))
32+
mat = matrix(rotate('z', y)) * matrix(rotate('y', p)) * matrix(rotate('x', r))
3433
return matrixToTuple(mat)
3534

3635

@@ -64,8 +63,7 @@ def generateOrthonormalM(v1):
6463
e1 = e1.tolist()
6564
e2 = e2.tolist()
6665
e3 = e3.tolist()
67-
M = ((e1[0][0], e2[0][0], e3[0][0]), (e1[0][1], e2[0][1], e3[0][1]),
68-
(e1[0][2], e2[0][2], e3[0][2]))
66+
M = ((e1[0][0], e2[0][0], e3[0][0]), (e1[0][1], e2[0][1], e3[0][1]), (e1[0][2], e2[0][2], e3[0][2]))
6967
return M
7068

7169

@@ -123,14 +121,7 @@ def rotate(axis, ang):
123121

124122
def quaternionToMatrix(q):
125123
[qx, qy, qz, qw] = q
126-
R = [[
127-
1 - 2 * qy**2 - 2 * qz**2, 2 * qx * qy - 2 * qz * qw,
128-
2 * qx * qz + 2 * qy * qw
129-
], [
130-
2 * qx * qy + 2 * qz * qw, 1 - 2 * qx**2 - 2 * qz**2,
131-
2 * qy * qz - 2 * qx * qw
132-
], [
133-
2 * qx * qz - 2 * qy * qw, 2 * qy * qz + 2 * qx * qw,
134-
1 - 2 * qx**2 - 2 * qy**2
135-
]]
124+
R = [[1 - 2 * qy**2 - 2 * qz**2, 2 * qx * qy - 2 * qz * qw, 2 * qx * qz + 2 * qy * qw],
125+
[2 * qx * qy + 2 * qz * qw, 1 - 2 * qx**2 - 2 * qz**2, 2 * qy * qz - 2 * qx * qw],
126+
[2 * qx * qz - 2 * qy * qw, 2 * qy * qz + 2 * qx * qw, 1 - 2 * qx**2 - 2 * qy**2]]
136127
return R

src/dynamic_graph/sot/core/meta_task_visual_point.py

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,8 @@ class MetaTaskVisualPoint(object):
1717
proj = 0
1818

1919
def opPointExist(self, opPoint):
20-
sigsP = filter(lambda x: x.getName().split(':')[-1] == opPoint,
21-
self.dyn.signals())
22-
sigsJ = filter(lambda x: x.getName().split(':')[-1] == 'J' + opPoint,
23-
self.dyn.signals())
20+
sigsP = filter(lambda x: x.getName().split(':')[-1] == opPoint, self.dyn.signals())
21+
sigsJ = filter(lambda x: x.getName().split(':')[-1] == 'J' + opPoint, self.dyn.signals())
2422
return len(sigsP) == 1 & len(sigsJ) == 1
2523

2624
def defineDynEntities(self, dyn):
@@ -34,12 +32,8 @@ def createOpPoint(self, opPoint, opPointRef='right-wrist'):
3432

3533
def createOpPointModif(self):
3634
self.opPointModif = OpPointModifier('opmodif' + self.name)
37-
plug(
38-
self.dyn.signal(self.opPoint),
39-
self.opPointModif.signal('positionIN'))
40-
plug(
41-
self.dyn.signal('J' + self.opPoint),
42-
self.opPointModif.signal('jacobianIN'))
35+
plug(self.dyn.signal(self.opPoint), self.opPointModif.signal('positionIN'))
36+
plug(self.dyn.signal('J' + self.opPoint), self.opPointModif.signal('jacobianIN'))
4337
self.opPointModif.activ = False
4438

4539
def createFeatures(self):
@@ -105,17 +99,12 @@ def opmodif(self):
10599
def opmodif(self, m):
106100
if isinstance(m, bool) and not m:
107101
plug(self.dyn.signal(self.opPoint), self.proj.signal('transfo'))
108-
plug(
109-
self.dyn.signal('J' + self.opPoint), self.feature.signal('Jq'))
102+
plug(self.dyn.signal('J' + self.opPoint), self.feature.signal('Jq'))
110103
self.opPointModif.activ = False
111104
else:
112105
if not self.opPointModif.activ:
113-
plug(
114-
self.opPointModif.signal('position'),
115-
self.proj.signal('transfo'))
116-
plug(
117-
self.opPointModif.signal('jacobian'),
118-
self.feature.signal('Jq'))
106+
plug(self.opPointModif.signal('position'), self.proj.signal('transfo'))
107+
plug(self.opPointModif.signal('jacobian'), self.feature.signal('Jq'))
119108
self.opPointModif.setTransformation(m)
120109
self.opPointModif.activ = True
121110

src/dynamic_graph/sot/core/utils/attime.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,7 @@ def registerEvents(self, iter, *funs):
6969
self.registerEvent(iter, fun)
7070
else: # assert iscallable(fun)
7171
if 'functor' in fun.__dict__:
72-
self.registerEvent(iter,
73-
(fun.functor, fun.functor.__doc__))
72+
self.registerEvent(iter, (fun.functor, fun.functor.__doc__))
7473
else:
7574
self.registerEvent(iter, (fun, fun.__doc__))
7675

@@ -109,7 +108,6 @@ def generatorDecorator(self, iterarg):
109108
This next calling pattern is a little bit strange. Use it to decorate
110109
a function definition: @attime(30) def run30(): ...
111110
"""
112-
113111
class calendarDeco:
114112
iterRef = iterarg
115113
calendarRef = self
@@ -120,11 +118,9 @@ def __init__(selfdeco, functer):
120118
functer.__doc__ = "No doc fun"
121119
if len(functer.__doc__) > 0:
122120
selfdeco.__doc__ = functer.__doc__
123-
selfdeco.__doc__ += " (will be run at time " + str(
124-
selfdeco.iterRef) + ")"
121+
selfdeco.__doc__ += " (will be run at time " + str(selfdeco.iterRef) + ")"
125122
selfdeco.fun = functer
126-
selfdeco.calendarRef.registerEvents(selfdeco.iterRef, functer,
127-
functer.__doc__)
123+
selfdeco.calendarRef.registerEvents(selfdeco.iterRef, functer, functer.__doc__)
128124

129125
def __call__(selfdeco, *args):
130126
selfdeco.fun(*args)

src/dynamic_graph/sot/core/utils/history.py

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ def __init__(self, dynEnt, freq=100, zmpSig=None):
1313
self.freq = freq
1414
self.zmpSig = zmpSig
1515
self.dynEnt = dynEnt
16-
self.withZmp = (self.zmpSig is not None) and ("waist" in map(
17-
lambda x: x.name, self.dynEnt.signals()))
16+
self.withZmp = (self.zmpSig is not None) and ("waist" in map(lambda x: x.name, self.dynEnt.signals()))
1817

1918
def record(self):
2019
i = self.dynEnt.position.time
@@ -41,23 +40,18 @@ def dumpToOpenHRP(self, baseName="dyninv", sample=1):
4140
fileWaist = open(baseName + '.waist', 'w')
4241
sampleT = 0.005
4342
for nT, q in enumerate(self.q):
44-
fileRPY.write(
45-
str(sampleT * nT) + ' ' + str(q[3]) + ' ' + str(q[4]) + ' ' +
46-
str(q[5]) + '\n')
43+
fileRPY.write(str(sampleT * nT) + ' ' + str(q[3]) + ' ' + str(q[4]) + ' ' + str(q[5]) + '\n')
4744
fileWaist.write(
48-
str(sampleT * nT) + ' ' + str(q[0]) + ' ' + str(q[1]) + ' ' +
49-
str(q[2]) + ' ' + str(q[3]) + ' ' + str(q[4]) + ' ' +
50-
str(q[5]) + '\n')
45+
str(sampleT * nT) + ' ' + str(q[0]) + ' ' + str(q[1]) + ' ' + str(q[2]) + ' ' + str(q[3]) + ' ' +
46+
str(q[4]) + ' ' + str(q[5]) + '\n')
5147
filePos.write(str(sampleT * nT) + ' ')
5248
for j in range(6, 36):
5349
filePos.write(str(q[j]) + ' ')
5450
filePos.write(10 * ' 0' + '\n')
5551
if self.withZmp:
5652
fileZMP = open(baseName + '.zmp', 'w')
5753
for nT, z in enumerate(self.zmp):
58-
fileZMP.write(
59-
str(sampleT * nT) + ' ' + str(z[0]) + ' ' + str(z[1]) +
60-
' ' + str(z[2]) + '\n')
54+
fileZMP.write(str(sampleT * nT) + ' ' + str(z[0]) + ' ' + str(z[1]) + ' ' + str(z[2]) + '\n')
6155

6256
filePos0 = open(baseName + '_pos0.py', 'w')
6357
filePos0.write("dyninv_posinit = '")

src/dynamic_graph/sot/core/utils/viewer_helper.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,7 @@ def __init__(self, viewer):
9191
self.refresh()
9292

9393
def refresh(self):
94-
self.viewer.updateElementConfig('pong',
95-
[0, 0.9, self.pos * 0.1, 0, 0, 0])
94+
self.viewer.updateElementConfig('pong', [0, 0.9, self.pos * 0.1, 0, 0, 0])
9695

9796
def __call__(self):
9897
self.pos += 1
@@ -101,5 +100,4 @@ def __call__(self):
101100

102101
def updateComDisplay(robot, comsig, objname='com'):
103102
if comsig.time > 0:
104-
robot.viewer.updateElementConfig(
105-
objname, [comsig.value[0], comsig.value[1], 0, 0, 0, 0])
103+
robot.viewer.updateElementConfig(objname, [comsig.value[0], comsig.value[1], 0, 0, 0, 0])

src/dynamic_graph/sot/core/utils/viewer_loger.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ class ViewerLoger:
1212
robot.viewer = ViewerLoger(robot)
1313
1414
'''
15-
1615
def __init__(self, robot):
1716
self.robot = robot
1817
self.viewer = robot.viewer
@@ -24,8 +23,7 @@ def updateElementConfig(self, name, state):
2423
t = self.robot.state.time
2524
if name not in self.fileMap:
2625
self.fileMap[name] = open('/tmp/view_' + name + '.dat', 'w')
27-
self.fileMap[name].write(
28-
"\t".join([str(f) for f in [
29-
t,
30-
] + list(state)]) + '\n')
26+
self.fileMap[name].write("\t".join([str(f) for f in [
27+
t,
28+
] + list(state)]) + '\n')
3129
self.viewer.updateElementConfig(name, state)

tests/python/matrix-util.py

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,9 @@ def test_vector_to_tuple(self):
2323
def test_rpy_tr(self):
2424
for rpy, tr in [
2525
((0, 0, 0), mod.matrixToTuple(np.identity(4))),
26-
((np.pi, 0, 0), ((1, 0, 0, 0), (0, -1, 0, 0), (0, 0, -1, 0),
27-
(0, 0, 0, 1))),
28-
((0, np.pi, 0), ((-1, 0, 0, 0), (0, 1, 0, 0), (0, 0, -1, 0),
29-
(0, 0, 0, 1))),
30-
((0, 0, np.pi), ((-1, 0, 0, 0), (0, -1, 0, 0), (0, 0, 1, 0),
31-
(0, 0, 0, 1))),
26+
((np.pi, 0, 0), ((1, 0, 0, 0), (0, -1, 0, 0), (0, 0, -1, 0), (0, 0, 0, 1))),
27+
((0, np.pi, 0), ((-1, 0, 0, 0), (0, 1, 0, 0), (0, 0, -1, 0), (0, 0, 0, 1))),
28+
((0, 0, np.pi), ((-1, 0, 0, 0), (0, -1, 0, 0), (0, 0, 1, 0), (0, 0, 0, 1))),
3229
]:
3330
np.testing.assert_allclose(tr, mod.rpy2tr(*rpy), atol=1e-15)
3431

@@ -39,26 +36,21 @@ def test_matrix_rpy(self):
3936
]:
4037
np.testing.assert_allclose(rpy, mod.matrixToRPY(mat))
4138
# np.testing.assert_allclose(mat, mod.RPYToMatrix(rpy))
42-
np.testing.assert_allclose(rpy,
43-
mod.matrixToRPY(mod.RPYToMatrix(rpy)))
39+
np.testing.assert_allclose(rpy, mod.matrixToRPY(mod.RPYToMatrix(rpy)))
4440

4541
def test_rotate(self):
4642
for axis, angle, mat in [
47-
('x', np.pi, ((1, 0, 0, 0), (0, -1, 0, 0), (0, 0, -1, 0),
48-
(0, 0, 0, 1))),
49-
('y', np.pi, ((-1, 0, 0, 0), (0, 1, 0, 0), (0, 0, -1, 0),
50-
(0, 0, 0, 1))),
51-
('z', np.pi, ((-1, 0, 0, 0), (0, -1, 0, 0), (0, 0, 1, 0),
52-
(0, 0, 0, 1))),
43+
('x', np.pi, ((1, 0, 0, 0), (0, -1, 0, 0), (0, 0, -1, 0), (0, 0, 0, 1))),
44+
('y', np.pi, ((-1, 0, 0, 0), (0, 1, 0, 0), (0, 0, -1, 0), (0, 0, 0, 1))),
45+
('z', np.pi, ((-1, 0, 0, 0), (0, -1, 0, 0), (0, 0, 1, 0), (0, 0, 0, 1))),
5346
]:
5447
self.assertEqual(mat, mod.rotate(axis, angle))
5548

5649
def test_quat_mat(self):
5750
for quat, mat in [
5851
((0, 0, 0, 1), np.identity(3)),
5952
((0, 0, 1, 0), ((-1, 0, 0), (0, -1, 0), (0, 0, 1))),
60-
((0, -0.5, 0, 0.5), ((0.5, 0, -0.5), (0, 1, 0), (0.5, 0,
61-
0.5))),
53+
((0, -0.5, 0, 0.5), ((0.5, 0, -0.5), (0, 1, 0), (0.5, 0, 0.5))),
6254
]:
6355
self.assertEqual(mat, mod.quaternionToMatrix(quat))
6456

tests/python/test-parameter-server.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@
2222
class TestParameterServer(unittest.TestCase):
2323
def test_set_parameter(self):
2424
# Read talos model
25-
path = join(
26-
dirname(dirname(abspath(__file__))), 'models', 'others', 'python')
25+
path = join(dirname(dirname(abspath(__file__))), 'models', 'others', 'python')
2726
sys.path.append(path)
2827

2928
from example_robot_data.path import EXAMPLE_ROBOT_DATA_MODEL_DIR
@@ -35,17 +34,14 @@ def test_set_parameter(self):
3534
urdf_rrbot_model_string = fs.read()
3635
fs.close()
3736

38-
param_server.setParameter("/robot_description",
39-
urdf_rrbot_model_string)
37+
param_server.setParameter("/robot_description", urdf_rrbot_model_string)
4038
model2_string = param_server.getParameter("/robot_description")
4139

4240
self.assertEqual(urdf_rrbot_model_string, model2_string)
4341

4442
aValue = 0.122
45-
param_server.setParameterDbl("/specificities/feet/right/size/height",
46-
aValue)
47-
a2Value = param_server.getParameterDbl(
48-
"/specificities/feet/right/size/height")
43+
param_server.setParameterDbl("/specificities/feet/right/size/height", aValue)
44+
a2Value = param_server.getParameterDbl("/specificities/feet/right/size/height")
4945
self.assertEqual(aValue, a2Value)
5046

5147

0 commit comments

Comments
 (0)