Commit 9ff4cfb6 authored by Pierre Fernbach's avatar Pierre Fernbach
Browse files

[Python] change python script to be compliant with python3

parent 0bfb5ce4
......@@ -103,7 +103,7 @@ def genPlan(stepsize=0.06):
start = time.time()
configs = fullBody.interpolate(stepsize, 5, 0., filterStates = True,testReachability = False)
end = time.time()
print("Contact plan generated in " + str(end-start) + "seconds")
print(("Contact plan generated in " + str(end-start) + "seconds"))
def contactPlan(step = 0.5):
v.client.gui.setVisibility("hyq", "ON")
......@@ -115,6 +115,6 @@ def contactPlan(step = 0.5):
time.sleep(step)
print("Root path generated in " + str(tp.t) + " ms.")
print(("Root path generated in " + str(tp.t) + " ms."))
genPlan(0.01);contactPlan(0.01)
......@@ -105,7 +105,7 @@ def genPlan(stepsize=0.06):
start = time.time()
configs = fullBody.interpolate(stepsize, 5, 0., filterStates = True,testReachability = False)
end = time.time()
print "Contact plan generated in " + str(end-start) + "seconds"
print("Contact plan generated in " + str(end-start) + "seconds")
def contactPlan(step = 0.5):
v.client.gui.setVisibility("hyq", "ON")
......@@ -117,6 +117,6 @@ def contactPlan(step = 0.5):
time.sleep(step)
print "Root path generated in " + str(tp.t) + " ms."
print("Root path generated in " + str(tp.t) + " ms.")
genPlan(0.01);contactPlan(0.01)
......@@ -57,7 +57,7 @@ t = ps.solve ()
if isinstance(t, list):
t = t[0]* 3600000 + t[1] * 60000 + t[2] * 1000 + t[3]
print("computation time for root path ", t)
print(("computation time for root path ", t))
# Playing the computed path
from hpp.gepetto import PathPlayer
......
......@@ -2,9 +2,9 @@ from hpp.corbaserver.rbprm.hrp2 import Robot
from hpp.gepetto import Viewer
from hpp.corbaserver.rbprm.tools.display_tools import *
import time
print "Plan guide trajectory ..."
print("Plan guide trajectory ...")
import hrp2_flatGround_path as tp
print "Done."
print("Done.")
import time
pId = tp.ps.numberPaths() -1
......@@ -31,7 +31,7 @@ fullBody.setReferenceConfig(q_ref)
fullBody.setPostureWeights(fullBody.postureWeights[::]+[0]*6)
fullBody.setCurrentConfig (q_init)
v(q_ref)
print "Generate limb DB ..."
print("Generate limb DB ...")
tStart = time.time()
# generate databases :
......@@ -49,8 +49,8 @@ fullBody.runLimbSampleAnalysis(fullBody.lArmId, "ReferenceConfiguration", True)
tGenerate = time.time() - tStart
print "Done."
print "Databases generated in : "+str(tGenerate)+" s"
print("Done.")
print("Databases generated in : "+str(tGenerate)+" s")
#define initial and final configurations :
configSize = fullBody.getConfigSize() -fullBody.client.robot.getDimensionExtraConfigSpace()
......@@ -89,13 +89,13 @@ fullBody.setStartState(q_init,[fullBody.rLegId,fullBody.lLegId])
fullBody.setEndState(q_goal,[fullBody.rLegId,fullBody.lLegId])
print "Generate contact plan ..."
print("Generate contact plan ...")
tStart = time.time()
configs = fullBody.interpolate(0.01,pathId=pId,robustnessTreshold = 1., filterStates = True,testReachability = False, quasiStatic = False)
tInterpolateConfigs = time.time() - tStart
print "Done."
print "Contact plan generated in : "+str(tInterpolateConfigs)+" s"
print "number of configs :", len(configs)
print("Done.")
print("Contact plan generated in : "+str(tInterpolateConfigs)+" s")
print("number of configs :", len(configs))
#raw_input("Press Enter to display the contact sequence ...")
#displayContactSequence(v,configs)
......@@ -76,7 +76,7 @@ ps.selectPathPlanner("DynamicPlanner")
# Solve the planning problem :
t = ps.solve ()
print "Guide planning time : ",t
print("Guide planning time : ",t)
# display solution :
......
......@@ -2,9 +2,9 @@ from hpp.corbaserver.rbprm.hrp2 import Robot
from hpp.gepetto import Viewer
from hpp.corbaserver.rbprm.tools.display_tools import *
import time
print "Plan guide trajectory ..."
print("Plan guide trajectory ...")
import hrp2_plateformes_path as tp
print "Done."
print("Done.")
import time
pId = tp.ps.numberPaths() -1
......@@ -32,7 +32,7 @@ fullBody.setCurrentConfig (q_init)
fullBody.setPostureWeights(fullBody.postureWeights[::]+[0]*6)
#fullBody.usePosturalTaskContactCreation(True)
print "Generate limb DB ..."
print("Generate limb DB ...")
tStart = time.time()
# generate databases :
......@@ -44,8 +44,8 @@ fullBody.runLimbSampleAnalysis(fullBody.lLegId, "ReferenceConfiguration", True)
tGenerate = time.time() - tStart
print "Done."
print "Databases generated in : "+str(tGenerate)+" s"
print("Done.")
print("Databases generated in : "+str(tGenerate)+" s")
#define initial and final configurations :
configSize = fullBody.getConfigSize() -fullBody.client.robot.getDimensionExtraConfigSpace()
......@@ -84,13 +84,13 @@ fullBody.setStartState(q_init,[fullBody.rLegId,fullBody.lLegId])
fullBody.setEndState(q_goal,[fullBody.rLegId,fullBody.lLegId])
print "Generate contact plan ..."
print("Generate contact plan ...")
tStart = time.time()
configs = fullBody.interpolate(0.01,pathId=pId,robustnessTreshold = robTreshold, filterStates = True,testReachability=False)
tInterpolateConfigs = time.time() - tStart
print "Done."
print "Contact plan generated in : "+str(tInterpolateConfigs)+" s"
print "number of configs :", len(configs)
print("Done.")
print("Contact plan generated in : "+str(tInterpolateConfigs)+" s")
print("number of configs :", len(configs))
#raw_input("Press Enter to display the contact sequence ...")
#displayContactSequence(v,configs)
......
......@@ -2,9 +2,9 @@ from hpp.corbaserver.rbprm.hyq_contact6D import Robot
from hpp.gepetto import Viewer
from hpp.corbaserver.rbprm.tools.display_tools import *
import time
print "Plan guide trajectory ..."
print("Plan guide trajectory ...")
import hyq_slalom_debris_path as tp
print "Done."
print("Done.")
import time
pId = tp.ps.numberPaths() -1
......@@ -30,7 +30,7 @@ q_init = q_ref[::]
fullBody.setReferenceConfig(q_ref)
fullBody.setCurrentConfig (q_init)
print "Generate limb DB ..."
print("Generate limb DB ...")
tStart = time.time()
# generate databases :
......@@ -46,8 +46,8 @@ for limbId in fullBody.limbNames :
tGenerate = time.time() - tStart
print "Done."
print "Databases generated in : "+str(tGenerate)+" s"
print("Done.")
print("Databases generated in : "+str(tGenerate)+" s")
#define initial and final configurations :
configSize = fullBody.getConfigSize() -fullBody.client.robot.getDimensionExtraConfigSpace()
......@@ -86,13 +86,13 @@ fullBody.setStartState(q_init,[fullBody.rLegId,fullBody.lArmId,fullBody.rArmId,f
fullBody.setEndState(q_goal,[fullBody.rLegId,fullBody.lArmId,fullBody.rArmId,fullBody.lLegId])
print "Generate contact plan ..."
print("Generate contact plan ...")
tStart = time.time()
configs = fullBody.interpolate(0.01,pathId=pId,robustnessTreshold = 2, filterStates = True,testReachability = False)
tInterpolateConfigs = time.time() - tStart
print "Done."
print "Contact plan generated in : "+str(tInterpolateConfigs)+" s"
print "number of configs :", len(configs)
print("Done.")
print("Contact plan generated in : "+str(tInterpolateConfigs)+" s")
print("number of configs :", len(configs))
#raw_input("Press Enter to display the contact sequence ...")
#displayContactSequence(v,configs)
......
......@@ -81,7 +81,7 @@ ps.selectPathPlanner("DynamicPlanner")
# Solve the planning problem :
t = ps.solve ()
print "Guide planning time : ",t
print("Guide planning time : ",t)
ps.optimizePath(1)
pid = ps.numberPaths()-1
......
......@@ -2,9 +2,9 @@ from talos_rbprm.talos import Robot
from hpp.gepetto import Viewer
from hpp.corbaserver.rbprm.tools.display_tools import *
import time
print "Plan guide trajectory ..."
print("Plan guide trajectory ...")
import talos_flatGround_path as tp
print "Done."
print("Done.")
import time
pId = tp.ps.numberPaths() -1
......@@ -29,7 +29,7 @@ fullBody.setCurrentConfig (q_init)
fullBody.setPostureWeights(fullBody.postureWeights[::]+[0]*6)
#fullBody.usePosturalTaskContactCreation(True)
print "Generate limb DB ..."
print("Generate limb DB ...")
tStart = time.time()
# generate databases :
......@@ -41,8 +41,8 @@ fullBody.addLimb(fullBody.lLegId,fullBody.lleg,fullBody.lfoot,fullBody.lLegOffse
tGenerate = time.time() - tStart
print "Done."
print "Databases generated in : "+str(tGenerate)+" s"
print("Done.")
print("Databases generated in : "+str(tGenerate)+" s")
#define initial and final configurations :
configSize = fullBody.getConfigSize() -fullBody.client.robot.getDimensionExtraConfigSpace()
......@@ -81,13 +81,13 @@ fullBody.setStartState(q_init,[fullBody.rLegId,fullBody.lLegId])
fullBody.setEndState(q_goal,[fullBody.rLegId,fullBody.lLegId])
print "Generate contact plan ..."
print("Generate contact plan ...")
tStart = time.time()
configs = fullBody.interpolate(0.01,pathId=pId,robustnessTreshold = 2, filterStates = True,quasiStatic=True)
tInterpolateConfigs = time.time() - tStart
print "Done."
print "Contact plan generated in : "+str(tInterpolateConfigs)+" s"
print "number of configs :", len(configs)
print("Done.")
print("Contact plan generated in : "+str(tInterpolateConfigs)+" s")
print("number of configs :", len(configs))
#raw_input("Press Enter to display the contact sequence ...")
#displayContactSequence(v,configs)
......
......@@ -49,7 +49,7 @@ afftool.loadObstacleModel ("hpp_environments", "multicontact/ground", "planning"
try :
v = vf.createViewer(displayArrows = True)
except Exception:
print "No viewer started !"
print("No viewer started !")
class FakeViewer():
def __init__(self):
return
......@@ -86,7 +86,7 @@ ps.selectPathPlanner("DynamicPlanner")
# Solve the planning problem :
t = ps.solve ()
print "Guide planning time : ",t
print("Guide planning time : ",t)
pathId = 0
......
......@@ -2,9 +2,9 @@ from talos_rbprm.talos import Robot # select the robot
from hpp.gepetto import Viewer
from hpp.corbaserver.rbprm.tools.display_tools import *
import time
print "Plan guide trajectory ..."
print("Plan guide trajectory ...")
import talos_navBauzil_path as tp # load the guide planning script
print "Done."
print("Done.")
import time
Robot.urdfSuffix += "_safeFeet"
......@@ -37,7 +37,7 @@ fullBody.setCurrentConfig (q_init)
fullBody.setPostureWeights(fullBody.postureWeights[::]+[0]*6)
fullBody.usePosturalTaskContactCreation(True)
print "Generate limb DB ..."
print("Generate limb DB ...")
tStart = time.time()
# generate databases :
nbSamples = 100000
......@@ -50,8 +50,8 @@ fullBody.addLimb(fullBody.lLegId,fullBody.lleg,fullBody.lfoot,fullBody.lLegOffse
#fullBody.saveLimbDatabase(rLegId, "./db/talos_lLeg_walk.db")
tGenerate = time.time() - tStart
print "Done."
print "Databases generated in : "+str(tGenerate)+" s"
print("Done.")
print("Databases generated in : "+str(tGenerate)+" s")
#define initial and final configurations :
......@@ -89,13 +89,13 @@ fullBody.setStartState(q_init,[fullBody.lLegId,fullBody.rLegId])
fullBody.setEndState(q_goal,[fullBody.lLegId,fullBody.rLegId])
print "Generate contact plan ..."
print("Generate contact plan ...")
tStart = time.time()
configs = fullBody.interpolate(0.01,pathId=pId,robustnessTreshold = 2, filterStates = True,testReachability=True,quasiStatic=True)
tInterpolateConfigs = time.time() - tStart
print "Done."
print "number of configs :", len(configs)
raw_input("Press Enter to display the contact sequence ...")
print("Done.")
print("number of configs :", len(configs))
input("Press Enter to display the contact sequence ...")
displayContactSequence(v,configs)
......
......@@ -2,9 +2,9 @@ from talos_rbprm.talos import Robot
from hpp.gepetto import Viewer
from hpp.corbaserver.rbprm.tools.display_tools import *
import time
print "Plan guide trajectory ..."
print("Plan guide trajectory ...")
import talos_navBauzil_hard_path as tp
print "Done."
print("Done.")
import time
Robot.urdfSuffix += "_safeFeet"
......@@ -37,7 +37,7 @@ fullBody.setCurrentConfig (q_init)
fullBody.setPostureWeights(fullBody.postureWeights[::]+[0]*6)
fullBody.usePosturalTaskContactCreation(True)
print "Generate limb DB ..."
print("Generate limb DB ...")
tStart = time.time()
# generate databases :
nbSamples = 10000
......@@ -52,8 +52,8 @@ fullBody.addNonContactingLimb(fullBody.rArmId,fullBody.rarm,fullBody.rhand,5000)
fullBody.runLimbSampleAnalysis(fullBody.rArmId, "ReferenceConfiguration", True)
tGenerate = time.time() - tStart
print "Done."
print "Databases generated in : "+str(tGenerate)+" s"
print("Done.")
print("Databases generated in : "+str(tGenerate)+" s")
#define initial and final configurations :
configSize = fullBody.getConfigSize() -fullBody.client.robot.getDimensionExtraConfigSpace()
......@@ -91,13 +91,13 @@ fullBody.setStartState(q_init,[fullBody.lLegId,fullBody.rLegId])
fullBody.setEndState(q_goal,[fullBody.lLegId,fullBody.rLegId])
print "Generate contact plan ..."
print("Generate contact plan ...")
tStart = time.time()
configs = fullBody.interpolate(0.01,pathId=pId,robustnessTreshold = 2, filterStates = True,testReachability=True,quasiStatic=True)
tInterpolateConfigs = time.time() - tStart
print "Done."
print "number of configs :", len(configs)
raw_input("Press Enter to display the contact sequence ...")
print("Done.")
print("number of configs :", len(configs))
input("Press Enter to display the contact sequence ...")
displayContactSequence(v,configs)
......
......@@ -84,7 +84,7 @@ ps.selectPathPlanner("DynamicPlanner")
# Solve the planning problem :
t = ps.solve ()
print "Guide planning time : ",t
print("Guide planning time : ",t)
# display solution :
......
......@@ -90,7 +90,7 @@ ps.selectPathPlanner("DynamicPlanner")
# Solve the planning problem :
t = ps.solve ()
print "Guide planning time : ",t
print("Guide planning time : ",t)
# display solution :
......
......@@ -2,9 +2,9 @@ from talos_rbprm.talos import Robot
from hpp.gepetto import Viewer
from hpp.corbaserver.rbprm.tools.display_tools import *
import time
print "Plan guide trajectory ..."
print("Plan guide trajectory ...")
import talos_plateformes_path as tp
print "Done."
print("Done.")
import time
Robot.urdfSuffix+="_safeFeet"
pId = tp.ps.numberPaths() -1
......@@ -32,7 +32,7 @@ fullBody.setCurrentConfig (q_init)
fullBody.setPostureWeights(fullBody.postureWeights[::]+[0]*6)
#fullBody.usePosturalTaskContactCreation(True)
print "Generate limb DB ..."
print("Generate limb DB ...")
tStart = time.time()
# generate databases :
......@@ -44,8 +44,8 @@ fullBody.runLimbSampleAnalysis(fullBody.lLegId, "ReferenceConfiguration", True)
tGenerate = time.time() - tStart
print "Done."
print "Databases generated in : "+str(tGenerate)+" s"
print("Done.")
print("Databases generated in : "+str(tGenerate)+" s")
#define initial and final configurations :
configSize = fullBody.getConfigSize() -fullBody.client.robot.getDimensionExtraConfigSpace()
......@@ -84,13 +84,13 @@ fullBody.setStartState(q_init,[fullBody.rLegId,fullBody.lLegId])
fullBody.setEndState(q_goal,[fullBody.rLegId,fullBody.lLegId])
print "Generate contact plan ..."
print("Generate contact plan ...")
tStart = time.time()
configs = fullBody.interpolate(0.01,pathId=pId,robustnessTreshold = robTreshold, filterStates = True,quasiStatic=True)
tInterpolateConfigs = time.time() - tStart
print "Done."
print "Contact plan generated in : "+str(tInterpolateConfigs)+" s"
print "number of configs :", len(configs)
print("Done.")
print("Contact plan generated in : "+str(tInterpolateConfigs)+" s")
print("number of configs :", len(configs))
#raw_input("Press Enter to display the contact sequence ...")
#displayContactSequence(v,configs)
......
......@@ -2,9 +2,9 @@ from talos_rbprm.talos import Robot
from hpp.gepetto import Viewer
from hpp.corbaserver.rbprm.tools.display_tools import *
import time
print "Plan guide trajectory ..."
print("Plan guide trajectory ...")
import talos_stairs10_path as tp
print "Done."
print("Done.")
import time
......@@ -36,7 +36,7 @@ fullBody.setReferenceConfig(q_ref)
fullBody.setCurrentConfig (q_init)
fullBody.setPostureWeights(fullBody.postureWeights[::]+[0]*6)
fullBody.usePosturalTaskContactCreation(True)
print "Generate limb DB ..."
print("Generate limb DB ...")
tStart = time.time()
# generate databases :
nbSamples = 50000
......@@ -48,8 +48,8 @@ fullBody.addLimb(fullBody.lLegId,fullBody.lleg,fullBody.lfoot,fullBody.lLegOffse
tGenerate = time.time() - tStart
print "Done."
print "Databases generated in : "+str(tGenerate)+" s"
print("Done.")
print("Databases generated in : "+str(tGenerate)+" s")
#define initial and final configurations :
......@@ -87,12 +87,12 @@ fullBody.setStartState(q_init,[fullBody.lLegId,fullBody.rLegId])
fullBody.setEndState(q_goal,[fullBody.lLegId,fullBody.rLegId])
print "Generate contact plan ..."
print("Generate contact plan ...")
tStart = time.time()
configs = fullBody.interpolate(0.01,pathId=pId,robustnessTreshold = 2, filterStates = True,testReachability=True,quasiStatic=True)
tInterpolateConfigs = time.time() - tStart
print "Done."
print "number of configs :", len(configs)
print("Done.")
print("number of configs :", len(configs))
#raw_input("Press Enter to display the contact sequence ...")
#displayContactSequence(v,configs)
......
......@@ -2,19 +2,19 @@ from hpp.corbaserver.rbprm.anymal import Robot
from hpp.gepetto import Viewer
from hpp.corbaserver.rbprm.tools.display_tools import *
import time
print "Plan guide trajectory ..."
print("Plan guide trajectory ...")
import anymal_circle_path as tp
print "Done."
print("Done.")
import time
statusFilename = tp.statusFilename
pId = 0
f = open(statusFilename,"a")
if tp.ps.numberPaths() > 0 :
print "Path planning OK."
print("Path planning OK.")
f.write("Planning_success: True"+"\n")
f.close()
else :
print "Error during path planning"
print("Error during path planning")
f.write("Planning_success: False"+"\n")
f.close()
import sys
......@@ -39,7 +39,7 @@ ps.setParameter("Kinodynamic/accelerationBound",tp.aMax)
try :
v = tp.Viewer (ps,viewerClient=tp.v.client, displayCoM = True)
except Exception:
print "No viewer started !"
print("No viewer started !")
class FakeViewer():
def __init__(self):
return
......@@ -78,7 +78,7 @@ else :
fullBody.setCurrentConfig (q_init)
print "Generate limb DB ..."
print("Generate limb DB ...")
tStart = time.time()
# generate databases :
"""
......@@ -91,8 +91,8 @@ fullBody.runLimbSampleAnalysis(fullBody.lLegId, "ReferenceConfiguration", True)
fullBody.loadAllLimbs("fixedStep04","ReferenceConfiguration")
tGenerate = time.time() - tStart
print "Done."
print "Databases generated in : "+str(tGenerate)+" s"
print("Done.")
print("Databases generated in : "+str(tGenerate)+" s")
#define initial and final configurations :
configSize = fullBody.getConfigSize() -fullBody.client.robot.getDimensionExtraConfigSpace()
......@@ -138,33 +138,33 @@ else :
fullBody.setStartState(q_init,[fullBody.lArmId,fullBody.lLegId,fullBody.rArmId,fullBody.rLegId],normals)
fullBody.setEndState(q_goal,[fullBody.lArmId,fullBody.lLegId,fullBody.rArmId,fullBody.rLegId],normals)
print "Generate contact plan ..."
print("Generate contact plan ...")
tStart = time.time()
configs = fullBody.interpolate(0.002,pathId=pId,robustnessTreshold = 1, filterStates = True,quasiStatic=True)
tInterpolateConfigs = time.time() - tStart
print "Done."
print "Contact plan generated in : "+str(tInterpolateConfigs)+" s"
print "number of configs :", len(configs)
print("Done.")
print("Contact plan generated in : "+str(tInterpolateConfigs)+" s")
print("number of configs :", len(configs))
#raw_input("Press Enter to display the contact sequence ...")
#displayContactSequence(v,configs)
if len(configs) < 2 :
cg_success = False
print "Error during contact generation."
print("Error during contact generation.")
else:
cg_success = True
print "Contact generation Done."
print("Contact generation Done.")
if abs(configs[-1][0] - tp.q_goal[0]) < 0.01 and abs(configs[-1][1]- tp.q_goal[1]) < 0.01 and (len(fullBody.getContactsVariations(len(configs)-2,len(configs)-1))==1):
print "Contact generation successful."
print("Contact generation successful.")
cg_reach_goal = True
else:
print "Contact generation failed to reach the goal."
print("Contact generation failed to reach the goal.")
cg_reach_goal = False
if len(configs) > 10 :
cg_too_many_states = True
cg_success = False
print "Discarded contact sequence because it was too long."
print("Discarded contact sequence because it was too long.")
else:
cg_too_many_states = False
......
......@@ -2,19 +2,19 @@ from hpp.corbaserver.rbprm.anymal import Robot
from hpp.gepetto import Viewer
from hpp.corbaserver.rbprm.tools.display_tools import *
import time
print "Plan guide trajectory ..."
print("Plan guide trajectory ...")
import anymal_circle_oriented_path as tp
print "Done."
print("Done.")
import time
statusFilename = tp.statusFilename
pId