Skip to content

Commit 888593e

Browse files
committed
[Python] fix python 3 & format
1 parent 4b6d1e1 commit 888593e

File tree

6 files changed

+214
-215
lines changed

6 files changed

+214
-215
lines changed

src/hpp/corbaserver/affordance/affordance.py

Lines changed: 159 additions & 158 deletions
Large diffs are not rendered by default.

src/hpp/corbaserver/affordance/client.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,22 @@
1818
from hpp.corbaserver.client import Client as _Parent
1919
from hpp_idl.hpp.corbaserver.affordance import Afford
2020

21-
class Client (_Parent):
22-
"""
21+
22+
class Client(_Parent):
23+
"""
2324
Connect and create clients for hpp-affordance library.
2425
"""
2526

26-
defaultClients = {
27-
'affordance': Afford,
28-
}
27+
defaultClients = {
28+
'affordance': Afford,
29+
}
2930

30-
def __init__(self, url = None, context = "corbaserver"):
31-
"""
31+
def __init__(self, url=None, context="corbaserver"):
32+
"""
3233
Initialize CORBA and create default clients.
3334
:param url: URL in the IOR, corbaloc, corbalocs, and corbanames formats.
3435
For a remote corba server, use
3536
url = "corbaloc:iiop:<host>:<port>/NameService"
3637
"""
37-
self._initOrb (url)
38-
self._makeClients ("affordanceCorba", self.defaultClients, context)
38+
self._initOrb(url)
39+
self._makeClients("affordanceCorba", self.defaultClients, context)
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
from .client import Client
2-
from .robot import Robot
1+
from .client import Client # noqa
2+
from .robot import Robot # noqa

src/hpp/corbaserver/affordance/robot.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@
1717

1818
from hpp.corbaserver.robot import Robot as Parent
1919

20-
class Robot (Parent):
20+
21+
class Robot(Parent):
2122
packageName = "hpp-affordance-corba"
2223
urdfName = "hyq_trunk_large"
2324
urdfSuffix = ""
2425
srdfSuffix = ""
2526

26-
def __init__ (self, robotName, load = True):
27-
Parent.__init__ (self, robotName, "freeflyer", load)
27+
def __init__(self, robotName, load=True):
28+
Parent.__init__(self, robotName, "freeflyer", load)
2829
self.rightWrist = ""
29-
self.leftWrist = ""
30-
30+
self.leftWrist = ""

tests/test-affordance-config.py

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
11
# Import Gepetto viewer helpwer class
2-
from hpp.gepetto import Viewer
3-
# Import Problem solver (holds most of the generated data)
4-
from hpp.corbaserver.problem_solver import ProblemSolver
52
# Import robot. Needed to create a robot instance for the viewer application
63
from hpp.corbaserver.affordance import Robot
4+
# Import the affordance helper class to extract useful surface
5+
# objects from the environment, and create an instance of affordanceTool
6+
from hpp.corbaserver.affordance.affordance import AffordanceTool
7+
# Import Problem solver (holds most of the generated data)
8+
from hpp.corbaserver.problem_solver import ProblemSolver
9+
from hpp.gepetto import Viewer
710

811
# Create instance of the hyq robot, the problem solver and the viewer
912
robot = Robot('hyq')
10-
ps = ProblemSolver (robot)
11-
r = Viewer (ps)
13+
ps = ProblemSolver(robot)
14+
r = Viewer(ps)
1215

1316
# Setting initial configuration to show on the viewer
14-
q_init = robot.getCurrentConfig ()
15-
q_init [0:3] = [-2, 0, 0.63]
16-
robot.setCurrentConfig (q_init)
17-
r (q_init)
17+
q_init = robot.getCurrentConfig()
18+
q_init[0:3] = [-2, 0, 0.63]
19+
robot.setCurrentConfig(q_init)
20+
r(q_init)
1821

1922
# Set coulour variables for different affordance types
2023
SupportColour = [0.0, 0.95, 0.80]
2124
LeanColour = [0.9, 0.5, 0]
2225

23-
# Import the affordance helper class to extract useful surface
24-
# objects from the environment, and create an instance of affordanceTool
25-
from hpp.corbaserver.affordance.affordance import AffordanceTool
26-
afftool = AffordanceTool ()
26+
afftool = AffordanceTool()
2727

28-
# Set the affordance configuration. The configuration vector has size 3
28+
# Set the affordance configuration. The configuration vector has size 3
2929
# and comprises the error margin, the angle margin for neighbouring triangles
3030
# and the minimum area, in that order.
3131
# If no configuration is set, a default configuration is used.
@@ -34,7 +34,7 @@
3434

3535
# Load obstacle models and visualise affordances. When loading an obstacle,
3636
# the affordance analysis is done automatically.
37-
afftool.loadObstacleModel ("hpp-affordance-corba", "darpa", "planning", r)
37+
afftool.loadObstacleModel("hpp-affordance-corba", "darpa", "planning", r)
3838
afftool.visualiseAffordances('Support', r, SupportColour)
3939

4040
# If affordance configuration is changed, the affordance analysis must
@@ -65,5 +65,3 @@
6565
afftool.setMargin('Support', 0.0681487)
6666
afftool.analyseAll()
6767
afftool.visualiseAffordances('Support', r, SupportColour)
68-
69-

tests/test-oriented-box.py

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,46 @@
11
# Import Gepetto viewer helpwer class
2-
from hpp.gepetto import Viewer
3-
# Import Problem solver (holds most of the generated data)
4-
from hpp.corbaserver.problem_solver import ProblemSolver
52
# Import robot. Needed to create a robot instance for the viewer application
63
from hpp.corbaserver.affordance import Robot
4+
# Import the affordance helper class to extract useful surface
5+
# objects from the environment, and create an instance of affordanceTool
6+
from hpp.corbaserver.affordance.affordance import AffordanceTool
7+
# Import Problem solver (holds most of the generated data)
8+
from hpp.corbaserver.problem_solver import ProblemSolver
9+
from hpp.gepetto import Viewer
710

811
# Create instance of the hyq robot, the problem solver and the viewer
912
robot = Robot('hyq')
10-
ps = ProblemSolver (robot)
11-
r = Viewer (ps)
13+
ps = ProblemSolver(robot)
14+
r = Viewer(ps)
1215

1316
# Setting initial configuration to show on the viewer
14-
q_init = robot.getCurrentConfig ()
15-
q_init [0:3] = [-2, 0, 0.63]
16-
robot.setCurrentConfig (q_init)
17-
r (q_init)
17+
q_init = robot.getCurrentConfig()
18+
q_init[0:3] = [-2, 0, 0.63]
19+
robot.setCurrentConfig(q_init)
20+
r(q_init)
1821

1922
# Set coulour variables for different affordance types
2023
SupportColour = [0.0, 0.95, 0.80]
2124
LeanColour = [0.9, 0.5, 0]
2225

23-
# Import the affordance helper class to extract useful surface
24-
# objects from the environment, and create an instance of affordanceTool
25-
from hpp.corbaserver.affordance.affordance import AffordanceTool
26-
afftool = AffordanceTool ()
26+
afftool = AffordanceTool()
2727

2828
afftool.setAffordanceConfig('Support', [0.3, 0.3, 0.05])
2929
afftool.setAffordanceConfig('Lean', [0.1, 0.3, 0.05])
3030

3131
# Load obstacle models and visualise affordances. When loading an obstacle,
3232
# the affordance analysis is done automatically.
33-
afftool.loadObstacleModel ("hpp-affordance-corba", "darpa", "planning", r)
34-
afftool.loadObstacleModel ("hpp-affordance-corba", "box", "box1", r)
33+
afftool.loadObstacleModel("hpp-affordance-corba", "darpa", "planning", r)
34+
afftool.loadObstacleModel("hpp-affordance-corba", "box", "box1", r)
3535
afftool.visualiseAffordances('Support', r, SupportColour)
3636

3737
# If an object is translated or rotated, the affordance analysis must
3838
# be relaunched.
3939
# First, delete the already created affordance objects (this function also
4040
# deletes them from viewer)
41-
afftool.deleteAffordances(r,'box1/base_link_0')
41+
afftool.deleteAffordances(r, 'box1/base_link_0')
4242
# Next, move the obstacle and recompute its position (updates viewer)
43-
ps.moveObstacle('box1/base_link_0', [0,1,0.25, 1,0,0,0])
43+
ps.moveObstacle('box1/base_link_0', [0, 1, 0.25, 1, 0, 0, 0])
4444
r.computeObjectPosition()
4545
# Now, reanalyse the object that was moved
4646
afftool.analyseObject('box1/base_link_0')
@@ -53,20 +53,19 @@
5353

5454
# Some Lean affordances are no more valid due to the orientation of
5555
# the obstacle
56-
afftool.loadObstacleModel ("hpp-affordance-corba", "box", "box2", r)
57-
afftool.deleteAffordances(r,'box2/base_link_0')
58-
ps.moveObstacle('box2/base_link_0', [0,1.5,0.5, 0.985,0.174,0,0])
56+
afftool.loadObstacleModel("hpp-affordance-corba", "box", "box2", r)
57+
afftool.deleteAffordances(r, 'box2/base_link_0')
58+
ps.moveObstacle('box2/base_link_0', [0, 1.5, 0.5, 0.985, 0.174, 0, 0])
5959
r.computeObjectPosition()
6060
afftool.analyseObject('box2/base_link_0')
6161
afftool.visualiseAffordances('Support', r, SupportColour, 'box2/base_link_0')
6262
afftool.visualiseAffordances('Lean', r, LeanColour, 'box2/base_link_0')
6363

6464
# No support affordances are found due to the orientation of the obstacle
65-
afftool.loadObstacleModel ("hpp-affordance-corba", "box", "box3", r)
66-
afftool.deleteAffordances(r,'box3/base_link_0')
67-
ps.moveObstacle('box3/base_link_0', [0,2,0.75, 0.940,0.342,0,0])
65+
afftool.loadObstacleModel("hpp-affordance-corba", "box", "box3", r)
66+
afftool.deleteAffordances(r, 'box3/base_link_0')
67+
ps.moveObstacle('box3/base_link_0', [0, 2, 0.75, 0.940, 0.342, 0, 0])
6868
r.computeObjectPosition()
6969
afftool.analyseObject('box3/base_link_0')
7070
afftool.visualiseAffordances('Support', r, SupportColour, 'box3/base_link_0')
7171
afftool.visualiseAffordances('Lean', r, LeanColour, 'box3/base_link_0')
72-

0 commit comments

Comments
 (0)