diff --git a/script/scenarios/sandbox/ANYmal/__init__.py b/script/scenarios/sandbox/ANYmal/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/script/scenarios/sandbox/ANYmal/anymal_flatGround.py b/script/scenarios/sandbox/ANYmal/anymal_flatGround.py new file mode 100644 index 0000000000000000000000000000000000000000..60ad7078930c1cef15fd0b15845e358dab03b4ac --- /dev/null +++ b/script/scenarios/sandbox/ANYmal/anymal_flatGround.py @@ -0,0 +1,93 @@ +from hpp.corbaserver.rbprm.anymal_contact6D import Robot +from hpp.gepetto import Viewer +from tools.display_tools import * +import time +print "Plan guide trajectory ..." +import anymal_flatGround_path as tp +print "Done." +import time + + + +pId = tp.ps.numberPaths() -1 +fullBody = Robot () +# Set the bounds for the root, take slightly larger bounding box than during root planning +root_bounds = tp.root_bounds[::] +root_bounds[0] -= 0.2 +root_bounds[1] += 0.2 +root_bounds[2] -= 0.2 +root_bounds[3] += 0.2 +root_bounds[-1] = 0.5 +root_bounds[-2] = 0.4 +fullBody.setJointBounds ("root_joint", root_bounds) +# add the 6 extraDof for velocity and acceleration (see *_path.py script) +fullBody.client.robot.setDimensionExtraConfigSpace(tp.extraDof) +fullBody.client.robot.setExtraConfigSpaceBounds([-tp.vMax,tp.vMax,-tp.vMax,tp.vMax,0,0,-tp.aMax,tp.aMax,-tp.aMax,tp.aMax,0,0]) +ps = tp.ProblemSolver( fullBody ) +ps.setParameter("Kinodynamic/velocityBound",tp.vMax) +ps.setParameter("Kinodynamic/accelerationBound",tp.aMax) +#load the viewer +v = tp.Viewer (ps,viewerClient=tp.v.client, displayCoM = True) + +# load a reference configuration +q_ref = fullBody.referenceConfig[::]+[0,0,0,0,0,0] +q_init = q_ref[::] +fullBody.setReferenceConfig(q_ref) +fullBody.setCurrentConfig (q_init) + + +print "Generate limb DB ..." +tStart = time.time() +fullBody.loadAllLimbs("static","ReferenceConfigurationCustom") +tGenerate = time.time() - tStart +print "Done." +print "Databases generated in : "+str(tGenerate)+" s" +fullBody.setReferenceConfig(q_ref) + +#define initial and final configurations : +configSize = fullBody.getConfigSize() -fullBody.client.robot.getDimensionExtraConfigSpace() + +q_init[0:7] = tp.ps.configAtParam(pId,0.01)[0:7] # use this to get the correct orientation +q_goal = q_init[::]; q_goal[0:7] = tp.ps.configAtParam(pId,tp.ps.pathLength(pId))[0:7] +dir_init = tp.ps.configAtParam(pId,0.01)[tp.indexECS:tp.indexECS+3] +acc_init = tp.ps.configAtParam(pId,0.01)[tp.indexECS+3:tp.indexECS+6] +dir_goal = tp.ps.configAtParam(pId,tp.ps.pathLength(pId)-0.01)[tp.indexECS:tp.indexECS+3] +acc_goal = [0,0,0] + +robTreshold = 3 +# copy extraconfig for start and init configurations +q_init[configSize:configSize+3] = dir_init[::] +q_init[configSize+3:configSize+6] = acc_init[::] +q_goal[configSize:configSize+3] = dir_goal[::] +q_goal[configSize+3:configSize+6] = [0,0,0] + +q_init[2] = q_ref[2] +q_goal[2] = q_ref[2] + +fullBody.setStaticStability(True) +fullBody.setCurrentConfig (q_init) +v(q_init) + +fullBody.setCurrentConfig (q_goal) +v(q_goal) + +v.addLandmark('anymal_reachability/base',0.3) +v(q_init) + +# specify the full body configurations as start and goal state of the problem +fullBody.setStartState(q_init,fullBody.limbs_names) +fullBody.setEndState(q_goal,fullBody.limbs_names) + + +print "Generate contact plan ..." +tStart = time.time() +configs = fullBody.interpolate(0.01,pathId=pId,robustnessTreshold = robTreshold, filterStates = True,testReachability=True,quasiStatic=True) +tInterpolateConfigs = time.time() - tStart +print "Done. " +print "Contact sequence computed in "+str(tInterpolateConfigs)+" s." +print "number of configs :", len(configs) +#raw_input("Press Enter to display the contact sequence ...") +#displayContactSequence(v,configs) + + + diff --git a/script/scenarios/sandbox/ANYmal/anymal_flatGround_path.py b/script/scenarios/sandbox/ANYmal/anymal_flatGround_path.py new file mode 100644 index 0000000000000000000000000000000000000000..86be5ac9a43d5ed939547c9e1b6aca371aee6c1f --- /dev/null +++ b/script/scenarios/sandbox/ANYmal/anymal_flatGround_path.py @@ -0,0 +1,103 @@ +from hpp.corbaserver.rbprm.anymal_abstract import Robot +from hpp.gepetto import Viewer +from hpp.corbaserver import Client +from hpp.corbaserver import ProblemSolver +import time + + + +vMax = 0.3# linear velocity bound for the root +aMax = 1. # linear acceleration bound for the root +extraDof = 6 +mu=0.5# coefficient of friction +# Creating an instance of the helper class, and loading the robot +rbprmBuilder = Robot() +# Define bounds for the root : bounding box of the scenario +root_bounds = [-3,3,-3,3, 0.4, 0.5] +rbprmBuilder.setJointBounds ("root_joint", root_bounds) + +# The following lines set constraint on the valid configurations: +# a configuration is valid only if all limbs can create a contact with the corresponding afforcances type +rbprmBuilder.setFilter(rbprmBuilder.urdfNameRom) +for rom in rbprmBuilder.urdfNameRom : + rbprmBuilder.setAffordanceFilter(rom, ['Support']) + +# We also bound the rotations of the torso. (z, y, x) +rbprmBuilder.boundSO3([-4.,4.,-0.1,0.1,-0.1,0.1]) +# Add 6 extraDOF to the problem, used to store the linear velocity and acceleration of the root +rbprmBuilder.client.robot.setDimensionExtraConfigSpace(extraDof) +# We set the bounds of this extraDof with velocity and acceleration bounds (expect on z axis) +rbprmBuilder.client.robot.setExtraConfigSpaceBounds([-vMax,vMax,-vMax,vMax,0,0,-aMax,aMax,-aMax,aMax,0,0]) +indexECS = rbprmBuilder.getConfigSize() - rbprmBuilder.client.robot.getDimensionExtraConfigSpace() + +# Creating an instance of HPP problem solver +ps = ProblemSolver( rbprmBuilder ) +# define parameters used by various methods : +ps.setParameter("Kinodynamic/velocityBound",vMax) +ps.setParameter("Kinodynamic/accelerationBound",aMax) +# force the orientation of the trunk to match the direction of the motion +ps.setParameter("Kinodynamic/forceOrientation",True) +ps.setParameter("DynamicPlanner/sizeFootX",0.01) +ps.setParameter("DynamicPlanner/sizeFootY",0.01) +ps.setParameter("DynamicPlanner/friction",mu) +# sample only configuration with null velocity and acceleration : +ps.setParameter("ConfigurationShooter/sampleExtraDOF",False) +ps.setParameter("PathOptimization/RandomShortcut/NumberOfLoops",100) + +# initialize the viewer : +from hpp.gepetto import ViewerFactory +vf = ViewerFactory (ps) + +# load the module to analyse the environnement and compute the possible contact surfaces +from hpp.corbaserver.affordance.affordance import AffordanceTool +afftool = AffordanceTool () +afftool.setAffordanceConfig('Support', [0.5, 0.03, 0.00005]) +afftool.loadObstacleModel ("hpp_environments", "multicontact/ground", "planning", vf) +v = vf.createViewer(displayArrows = True) +#afftool.visualiseAffordances('Support', v, v.color.lightBrown) +#v.addLandmark(v.sceneName,1) + +# Setting initial configuration +q_init = rbprmBuilder.getCurrentConfig (); +q_init [0:3] = [0,0,0.444] +q_init[-6:-3] = [0,0,0] +v (q_init) +ps.setInitialConfig (q_init) +# set goal config +rbprmBuilder.setCurrentConfig (q_init) +q_goal = q_init [::] +q_goal[0:3] = [1.5,0,0.444] +q_goal[-6:-3] = [0,0,0] +v(q_goal) + + +ps.addGoalConfig (q_goal) + +# Choosing RBPRM shooter and path validation methods. +ps.selectConfigurationShooter("RbprmShooter") +ps.addPathOptimizer ("RandomShortcutDynamic") +ps.selectPathValidation("RbprmPathValidation",0.05) +# Choosing kinodynamic methods : +ps.selectSteeringMethod("RBPRMKinodynamic") +ps.selectDistance("Kinodynamic") +ps.selectPathPlanner("DynamicPlanner") + +# Solve the planning problem : +t = ps.solve () +print "Guide planning time : ",t + + +# display solution : +from hpp.gepetto import PathPlayer +pp = PathPlayer (v) +pp.dt=0.1 +#pp.displayVelocityPath(1) +#v.client.gui.setVisibility("path_1_root","ALWAYS_ON_TOP") +pp.dt = 0.01 +#pp(1) + +# move the robot out of the view before computing the contacts +q_far = q_init[::] +q_far[2] = -2 +v(q_far) + diff --git a/script/scenarios/sandbox/ANYmal/anymal_slalom_debris.py b/script/scenarios/sandbox/ANYmal/anymal_slalom_debris.py new file mode 100644 index 0000000000000000000000000000000000000000..2c2cce5c4fce25a5fd93ac28d6fafdefd6cf8ec5 --- /dev/null +++ b/script/scenarios/sandbox/ANYmal/anymal_slalom_debris.py @@ -0,0 +1,96 @@ +from hpp.corbaserver.rbprm.anymal_contact6D import Robot +from hpp.gepetto import Viewer +from tools.display_tools import * +import time +print "Plan guide trajectory ..." +import anymal_slalom_debris_path as tp +print "Done." +import time + + + +pId = tp.ps.numberPaths() -1 +fullBody = Robot () +# Set the bounds for the root, take slightly larger bounding box than during root planning +root_bounds = tp.root_bounds[::] +root_bounds[0] -= 0.2 +root_bounds[1] += 0.2 +root_bounds[2] -= 0.2 +root_bounds[3] += 0.2 +root_bounds[-1] = 0.8 +root_bounds[-2] = 0.4 +fullBody.setJointBounds ("root_joint", root_bounds) +# add the 6 extraDof for velocity and acceleration (see *_path.py script) +fullBody.client.robot.setDimensionExtraConfigSpace(tp.extraDof) +fullBody.client.robot.setExtraConfigSpaceBounds([-tp.vMax,tp.vMax,-tp.vMax,tp.vMax,0,0,-tp.aMax,tp.aMax,-tp.aMax,tp.aMax,-0,0]) +ps = tp.ProblemSolver( fullBody ) +ps.setParameter("Kinodynamic/velocityBound",tp.vMax) +ps.setParameter("Kinodynamic/accelerationBound",tp.aMax) +#load the viewer +v = tp.Viewer (ps,viewerClient=tp.v.client, displayCoM = True) + +# load a reference configuration +q_ref = fullBody.referenceConfig[::]+[0,0,0,0,0,0] +q_init = q_ref[::] +fullBody.setReferenceConfig(q_ref) +fullBody.setCurrentConfig (q_init) + + +print "Generate limb DB ..." +tStart = time.time() +fullBody.loadAllLimbs("static","ReferenceConfigurationCustom",nbSamples=100000) +tGenerate = time.time() - tStart +print "Done." +print "Databases generated in : "+str(tGenerate)+" s" +fullBody.setReferenceConfig(q_ref) + +#define initial and final configurations : +configSize = fullBody.getConfigSize() -fullBody.client.robot.getDimensionExtraConfigSpace() + +q_init[0:7] = tp.ps.configAtParam(pId,0.01)[0:7] # use this to get the correct orientation +q_goal = q_init[::]; q_goal[0:7] = tp.ps.configAtParam(pId,tp.ps.pathLength(pId))[0:7] +dir_init = tp.ps.configAtParam(pId,0.01)[tp.indexECS:tp.indexECS+3] +acc_init = tp.ps.configAtParam(pId,0.01)[tp.indexECS+3:tp.indexECS+6] +dir_goal = tp.ps.configAtParam(pId,tp.ps.pathLength(pId)-0.01)[tp.indexECS:tp.indexECS+3] +acc_goal = [0,0,0] + +robTreshold = 5 +# copy extraconfig for start and init configurations +q_init[configSize:configSize+3] = dir_init[::] +q_init[configSize+3:configSize+6] = acc_init[::] +q_goal[configSize:configSize+3] = dir_goal[::] +q_goal[configSize+3:configSize+6] = [0,0,0] + +q_init[2] = q_ref[2] +q_goal[2] = q_ref[2] + +fullBody.setStaticStability(True) +fullBody.setCurrentConfig (q_init) +v(q_init) + +fullBody.setCurrentConfig (q_goal) +v(q_goal) + +v.addLandmark('anymal_reachability/base',0.3) +v(q_init) + +# specify the full body configurations as start and goal state of the problem +fullBody.setStartState(q_init,fullBody.limbs_names) +fullBody.setEndState(q_goal,fullBody.limbs_names) + + +print "Generate contact plan ..." +tStart = time.time() +configs = fullBody.interpolate(0.01,pathId=pId,robustnessTreshold = robTreshold, filterStates = True,testReachability=True,quasiStatic=True) +tInterpolateConfigs = time.time() - tStart +print "Done. " +print "Contact sequence computed in "+str(tInterpolateConfigs)+" s." +print "number of configs :", len(configs) +#raw_input("Press Enter to display the contact sequence ...") +#v.startCapture("capture_cs/capture","png") +#displayContactSequence(v,configs) +#v.stopCapture() + + + + diff --git a/script/scenarios/sandbox/ANYmal/anymal_slalom_debris_path.py b/script/scenarios/sandbox/ANYmal/anymal_slalom_debris_path.py new file mode 100644 index 0000000000000000000000000000000000000000..ae5f535444d1ee8f5883080f5ff669d1e7a82544 --- /dev/null +++ b/script/scenarios/sandbox/ANYmal/anymal_slalom_debris_path.py @@ -0,0 +1,105 @@ +from hpp.corbaserver.rbprm.anymal_abstract import Robot +from hpp.gepetto import Viewer +from hpp.corbaserver import Client +from hpp.corbaserver import ProblemSolver +import time + + + +vMax = 0.2# linear velocity bound for the root +aMax = 0.1 # linear acceleration bound for the root +extraDof = 6 +mu=0.5# coefficient of friction +# Creating an instance of the helper class, and loading the robot +rbprmBuilder = Robot() +# Define bounds for the root : bounding box of the scenario +root_bounds = [-1.7,2.5, -0.2, 2, 0.444, 0.444] +rbprmBuilder.setJointBounds ("root_joint", root_bounds) + +# The following lines set constraint on the valid configurations: +# a configuration is valid only if all limbs can create a contact with the corresponding afforcances type +rbprmBuilder.setFilter(rbprmBuilder.urdfNameRom) +for rom in rbprmBuilder.urdfNameRom : + rbprmBuilder.setAffordanceFilter(rom, ['Support']) + +# We also bound the rotations of the torso. (z, y, x) +rbprmBuilder.boundSO3([-4,4,-0.1,0.1,-0.1,0.1]) +# Add 6 extraDOF to the problem, used to store the linear velocity and acceleration of the root +rbprmBuilder.client.robot.setDimensionExtraConfigSpace(extraDof) +# We set the bounds of this extraDof with velocity and acceleration bounds (expect on z axis) +rbprmBuilder.client.robot.setExtraConfigSpaceBounds([-vMax,vMax,-vMax,vMax,0,0,-aMax,aMax,-aMax,aMax,0,0]) +indexECS = rbprmBuilder.getConfigSize() - rbprmBuilder.client.robot.getDimensionExtraConfigSpace() + +# Creating an instance of HPP problem solver +ps = ProblemSolver( rbprmBuilder ) +# define parameters used by various methods : +ps.setParameter("Kinodynamic/velocityBound",vMax) +ps.setParameter("Kinodynamic/accelerationBound",aMax) +# force the orientation of the trunk to match the direction of the motion +ps.setParameter("Kinodynamic/forceOrientation",True) +ps.setParameter("DynamicPlanner/sizeFootX",0.01) +ps.setParameter("DynamicPlanner/sizeFootY",0.01) +ps.setParameter("DynamicPlanner/friction",mu) +# sample only configuration with null velocity and acceleration : +ps.setParameter("ConfigurationShooter/sampleExtraDOF",False) +ps.setParameter("PathOptimization/RandomShortcut/NumberOfLoops",100) + +# initialize the viewer : +from hpp.gepetto import ViewerFactory +vf = ViewerFactory (ps) + +# load the module to analyse the environnement and compute the possible contact surfaces +from hpp.corbaserver.affordance.affordance import AffordanceTool +afftool = AffordanceTool () +afftool.setAffordanceConfig('Support', [0.5, 0.03, 0.00005]) +afftool.loadObstacleModel ("hpp_environments", "multicontact/slalom_debris", "planning", vf,reduceSizes=[0.05,0,0]) +v = vf.createViewer(displayArrows = True) +#afftool.visualiseAffordances('Support', v, v.color.lightBrown) +#v.addLandmark(v.sceneName,1) + +# Setting initial configuration +q_init = rbprmBuilder.getCurrentConfig (); +q_init [0:3] = [-1.5,0,0.444] +q_init[-6:-3] = [0.05,0,0] +v (q_init) +ps.setInitialConfig (q_init) +# set goal config +rbprmBuilder.setCurrentConfig (q_init) +q_goal = q_init [::] +q_goal[0:3] = [2.2,0,0.444] +q_goal[-6:-3] = [0.05,0,0] +v(q_goal) + + +ps.addGoalConfig (q_goal) + +# Choosing RBPRM shooter and path validation methods. +ps.selectConfigurationShooter("RbprmShooter") +ps.addPathOptimizer ("RandomShortcutDynamic") +ps.selectPathValidation("RbprmPathValidation",0.05) +# Choosing kinodynamic methods : +ps.selectSteeringMethod("RBPRMKinodynamic") +ps.selectDistance("Kinodynamic") +ps.selectPathPlanner("DynamicPlanner") + +# Solve the planning problem : +t = ps.solve () +#v.solveAndDisplay('rm',2,radiusSphere=0.01) +print "Guide planning time : ",t + + +# display solution : +from hpp.gepetto import PathPlayer +pp = PathPlayer (v) +pp.dt=0.1 +#pp.displayVelocityPath(1) +#v.client.gui.setVisibility("path_1_root","ALWAYS_ON_TOP") +pp.dt = 0.01 +#v.startCapture("capture_root/capture","png") +#pp(1) +#v.stopCapture() + +# move the robot out of the view before computing the contacts +q_far = q_init[::] +q_far[2] = -2 +v(q_far) diff --git a/script/scenarios/sandbox/ANYmal/darpa.py b/script/scenarios/sandbox/ANYmal/darpa.py new file mode 100644 index 0000000000000000000000000000000000000000..b97b9dd142d1e57fb10f5472169cba38e49a42ae --- /dev/null +++ b/script/scenarios/sandbox/ANYmal/darpa.py @@ -0,0 +1,104 @@ +from hpp.corbaserver.rbprm.anymal_contact6D import Robot +from hpp.gepetto import Viewer +from tools.display_tools import * +import time +print "Plan guide trajectory ..." +import darpa_path as tp +print "Done." +import time + + + +pId = tp.ps.numberPaths() -1 +fullBody = Robot () +# Set the bounds for the root, take slightly larger bounding box than during root planning +root_bounds = tp.root_bounds[::] +root_bounds[0] -= 0.2 +root_bounds[1] += 0.2 +root_bounds[2] -= 0.2 +root_bounds[3] += 0.2 +root_bounds[-1] = 0.9 +root_bounds[-2] = 0.4 +fullBody.setJointBounds ("root_joint", root_bounds) +# constraint the joints limits in a conservative manner. +# This is a 'hack' to help produce contact sequence requiring less torque +fullBody.setJointBounds("LF_KFE",[-1.5,0.]) +fullBody.setJointBounds("RF_KFE",[-1.5,0.]) +fullBody.setJointBounds("LH_KFE",[0.,1.5]) +fullBody.setJointBounds("RH_KFE",[0.,1.5]) +fullBody.setJointBounds("LH_HFE",[-2.35,0.]) +fullBody.setJointBounds("RH_HFE",[-2.3,-0.1]) +fullBody.setJointBounds("LF_HFE",[0.15,2.35]) +fullBody.setJointBounds("RF_HFE",[0.3,2.35]) +# add the 6 extraDof for velocity and acceleration (see *_path.py script) +fullBody.client.robot.setDimensionExtraConfigSpace(tp.extraDof) +fullBody.client.robot.setExtraConfigSpaceBounds([-tp.vMax,tp.vMax,-tp.vMax,tp.vMax,-tp.vMax,tp.vMax,-tp.aMax,tp.aMax,-tp.aMax,tp.aMax,-tp.aMaxZ,tp.aMaxZ]) +ps = tp.ProblemSolver( fullBody ) +ps.setParameter("Kinodynamic/velocityBound",tp.vMax) +ps.setParameter("Kinodynamic/accelerationBound",tp.aMax) +#load the viewer +v = tp.Viewer (ps,viewerClient=tp.v.client, displayCoM = True) + +# load a reference configuration +q_ref = fullBody.referenceConfig[::]+[0,0,0,0,0,0] +q_init = q_ref[::] +fullBody.setReferenceConfig(q_ref) +fullBody.setCurrentConfig (q_init) + +dict_heuristic = {fullBody.rLegId:"static", fullBody.lLegId:"static", fullBody.rArmId:"fixedStep04", fullBody.lArmId:"fixedStep04"} +print "Generate limb DB ..." +tStart = time.time() +fullBody.loadAllLimbs(dict_heuristic,"ReferenceConfigurationCustom",nbSamples=50000) +tGenerate = time.time() - tStart +print "Done." +print "Databases generated in : "+str(tGenerate)+" s" +fullBody.setReferenceConfig(q_ref) + +#define initial and final configurations : +configSize = fullBody.getConfigSize() -fullBody.client.robot.getDimensionExtraConfigSpace() + +q_init[0:7] = tp.ps.configAtParam(pId,0.01)[0:7] # use this to get the correct orientation +q_goal = q_init[::]; q_goal[0:7] = tp.ps.configAtParam(pId,tp.ps.pathLength(pId))[0:7] +dir_init = tp.ps.configAtParam(pId,0.01)[tp.indexECS:tp.indexECS+3] +acc_init = tp.ps.configAtParam(pId,0.01)[tp.indexECS+3:tp.indexECS+6] +dir_goal = tp.ps.configAtParam(pId,tp.ps.pathLength(pId)-0.01)[tp.indexECS:tp.indexECS+3] +acc_goal = [0,0,0] + +robTreshold = 0 +# copy extraconfig for start and init configurations +q_init[configSize:configSize+3] = dir_init[::] +q_init[configSize+3:configSize+6] = acc_init[::] +q_goal[configSize:configSize+3] = dir_goal[::] +q_goal[configSize+3:configSize+6] = [0,0,0] + +q_init[2] = q_ref[2] +q_goal[2] = q_ref[2] + +fullBody.setStaticStability(True) +fullBody.setCurrentConfig (q_init) +v(q_init) + +fullBody.setCurrentConfig (q_goal) +v(q_goal) + +v.addLandmark('anymal_reachability/base',0.3) +v(q_init) + +# specify the full body configurations as start and goal state of the problem +fullBody.setStartState(q_init,fullBody.limbs_names) +fullBody.setEndState(q_goal,fullBody.limbs_names) + + +print "Generate contact plan ..." +tStart = time.time() +configs = fullBody.interpolate(0.01,pathId=pId,robustnessTreshold = robTreshold, filterStates = True,testReachability=True,quasiStatic=True) +tInterpolateConfigs = time.time() - tStart +print "Done. " +print "Contact sequence computed in "+str(tInterpolateConfigs)+" s." +print "number of configs :", len(configs) +raw_input("Press Enter to display the contact sequence ...") +displayContactSequence(v,configs) + +import tools.createActionDRP as exp + + diff --git a/script/scenarios/sandbox/ANYmal/darpa_path.py b/script/scenarios/sandbox/ANYmal/darpa_path.py new file mode 100644 index 0000000000000000000000000000000000000000..fb73c175efa269faa81f94c240628ba39d460f7f --- /dev/null +++ b/script/scenarios/sandbox/ANYmal/darpa_path.py @@ -0,0 +1,107 @@ +from hpp.corbaserver.rbprm.anymal_abstract import Robot +from hpp.gepetto import Viewer +from hpp.corbaserver import Client +from hpp.corbaserver import ProblemSolver +import time + + + +vMax = 0.3# linear velocity bound for the root +aMax = 1. # linear acceleration bound for the root +aMaxZ=5. +extraDof = 6 +mu=0.5# coefficient of friction +# Creating an instance of the helper class, and loading the robot +rbprmBuilder = Robot() +# Define bounds for the root : bounding box of the scenario +root_bounds = [-1.5,2.,-0.01,0.01, 0.4, 1.] +rbprmBuilder.setJointBounds ("root_joint", root_bounds) + +# The following lines set constraint on the valid configurations: +# a configuration is valid only if all limbs can create a contact with the corresponding afforcances type +rbprmBuilder.setFilter(rbprmBuilder.urdfNameRom) +for rom in rbprmBuilder.urdfNameRom : + rbprmBuilder.setAffordanceFilter(rom, ['Support']) + +# We also bound the rotations of the torso. (z, y, x) +rbprmBuilder.boundSO3([-0.01,0.01,-0.3,0.3,-0.01,0.01]) +# Add 6 extraDOF to the problem, used to store the linear velocity and acceleration of the root +rbprmBuilder.client.robot.setDimensionExtraConfigSpace(extraDof) +# We set the bounds of this extraDof with velocity and acceleration bounds (expect on z axis) +rbprmBuilder.client.robot.setExtraConfigSpaceBounds([-vMax,vMax,-vMax,vMax,-vMax,vMax,-aMax,aMax,-aMax,aMax,-aMaxZ,aMaxZ]) +indexECS = rbprmBuilder.getConfigSize() - rbprmBuilder.client.robot.getDimensionExtraConfigSpace() + +# Creating an instance of HPP problem solver +ps = ProblemSolver( rbprmBuilder ) +# define parameters used by various methods : +ps.setParameter("Kinodynamic/velocityBound",vMax) +ps.setParameter("Kinodynamic/accelerationBound",aMax) +ps.setParameter("Kinodynamic/verticalAccelerationBound",aMaxZ) +# force the orientation of the trunk to match the direction of the motion +ps.setParameter("Kinodynamic/forceOrientation",False) +ps.setParameter("DynamicPlanner/sizeFootX",0.01) +ps.setParameter("DynamicPlanner/sizeFootY",0.01) +ps.setParameter("DynamicPlanner/friction",mu) +# sample only configuration with null velocity and acceleration : +ps.setParameter("ConfigurationShooter/sampleExtraDOF",False) +ps.setParameter("PathOptimization/RandomShortcut/NumberOfLoops",100) + +# initialize the viewer : +from hpp.gepetto import ViewerFactory +vf = ViewerFactory (ps) + +# load the module to analyse the environnement and compute the possible contact surfaces +from hpp.corbaserver.affordance.affordance import AffordanceTool +afftool = AffordanceTool () +afftool.setAffordanceConfig('Support', [0.5, 0.03, 0.00005]) +afftool.loadObstacleModel ("hpp_environments", "multicontact/darpa", "planning", vf,reduceSizes=[0.08,0,0]) +v = vf.createViewer(displayArrows = True) +#afftool.visualiseAffordances('Support', v, v.color.lightBrown) +#v.addLandmark(1550243518,1) + +# Setting initial configuration +q_init = rbprmBuilder.getCurrentConfig (); +q_init [0:3] = [-1.2,0,0.444] +q_init[-6:-3] = [0.02,0,0] +v (q_init) +ps.setInitialConfig (q_init) +# set goal config +rbprmBuilder.setCurrentConfig (q_init) +q_goal = q_init [::] +q_goal[0:3] = [1.7,0,0.444] +q_goal[-6:-3] = [0.02,0,0] +v(q_goal) + + +ps.addGoalConfig (q_goal) + +# Choosing RBPRM shooter and path validation methods. +ps.selectConfigurationShooter("RbprmShooter") +ps.addPathOptimizer ("RandomShortcutDynamic") +ps.selectPathValidation("RbprmPathValidation",0.05) +# Choosing kinodynamic methods : +ps.selectSteeringMethod("RBPRMKinodynamic") +ps.selectDistance("Kinodynamic") +ps.selectPathPlanner("DynamicPlanner") + +# Solve the planning problem : +t = ps.solve () +print "Guide planning time : ",t +#v.solveAndDisplay('rm',2,radiusSphere=0.01) + + + +# display solution : +from hpp.gepetto import PathPlayer +pp = PathPlayer (v) +pp.dt=0.1 +pp.displayVelocityPath(1) +v.client.gui.setVisibility("path_1_root","ALWAYS_ON_TOP") +pp.dt = 0.01 +pp(1) + +# move the robot out of the view before computing the contacts +q_far = q_init[::] +q_far[2] = -2 +v(q_far) + diff --git a/script/scenarios/sandbox/ANYmal/plinth.py b/script/scenarios/sandbox/ANYmal/plinth.py new file mode 100644 index 0000000000000000000000000000000000000000..b8a4cef8bf23f70363bcaa5f9c6a6a7351a0682e --- /dev/null +++ b/script/scenarios/sandbox/ANYmal/plinth.py @@ -0,0 +1,98 @@ +from hpp.corbaserver.rbprm.anymal_contact6D import Robot +from hpp.gepetto import Viewer +from tools.display_tools import * +import time +print "Plan guide trajectory ..." +import plinth_path as tp +print "Done." +import time + + + +pId = tp.ps.numberPaths() -1 +fullBody = Robot () +# Set the bounds for the root, take slightly larger bounding box than during root planning +root_bounds = tp.root_bounds[::] +root_bounds[0] -= 0.2 +root_bounds[1] += 0.2 +root_bounds[2] -= 0.2 +root_bounds[3] += 0.2 +root_bounds[-1] = 0.9 +root_bounds[-2] = 0.4 +fullBody.setJointBounds ("root_joint", root_bounds) +fullBody.setJointBounds("LF_KFE",[-1.4,0.]) +fullBody.setJointBounds("RF_KFE",[-1.4,0.]) +fullBody.setJointBounds("LH_KFE",[0.,1.4]) +fullBody.setJointBounds("RH_KFE",[0.,1.4]) +# add the 6 extraDof for velocity and acceleration (see *_path.py script) +fullBody.client.robot.setDimensionExtraConfigSpace(tp.extraDof) +fullBody.client.robot.setExtraConfigSpaceBounds([-tp.vMax,tp.vMax,-tp.vMax,tp.vMax,-tp.vMax,tp.vMax,-tp.aMax,tp.aMax,-tp.aMax,tp.aMax,-tp.aMaxZ,tp.aMaxZ]) +ps = tp.ProblemSolver( fullBody ) +ps.setParameter("Kinodynamic/velocityBound",tp.vMax) +ps.setParameter("Kinodynamic/accelerationBound",tp.aMax) +#load the viewer +v = tp.Viewer (ps,viewerClient=tp.v.client, displayCoM = True) + +# load a reference configuration +q_ref = fullBody.referenceConfig[::]+[0,0,0,0,0,0] +q_init = q_ref[::] +fullBody.setReferenceConfig(q_ref) +fullBody.setCurrentConfig (q_init) + +dict_heuristic = {fullBody.rLegId:"static", fullBody.lLegId:"static", fullBody.rArmId:"fixedStep04", fullBody.lArmId:"fixedStep04"} +print "Generate limb DB ..." +tStart = time.time() +fullBody.loadAllLimbs(dict_heuristic,"ReferenceConfigurationCustom",nbSamples=50000) +tGenerate = time.time() - tStart +print "Done." +print "Databases generated in : "+str(tGenerate)+" s" +fullBody.setReferenceConfig(q_ref) + +#define initial and final configurations : +configSize = fullBody.getConfigSize() -fullBody.client.robot.getDimensionExtraConfigSpace() + +q_init[0:7] = tp.ps.configAtParam(pId,0.01)[0:7] # use this to get the correct orientation +q_goal = q_init[::]; q_goal[0:7] = tp.ps.configAtParam(pId,tp.ps.pathLength(pId))[0:7] +dir_init = tp.ps.configAtParam(pId,0.01)[tp.indexECS:tp.indexECS+3] +acc_init = tp.ps.configAtParam(pId,0.01)[tp.indexECS+3:tp.indexECS+6] +dir_goal = tp.ps.configAtParam(pId,tp.ps.pathLength(pId)-0.01)[tp.indexECS:tp.indexECS+3] +acc_goal = [0,0,0] + +robTreshold = 2 +# copy extraconfig for start and init configurations +q_init[configSize:configSize+3] = dir_init[::] +q_init[configSize+3:configSize+6] = acc_init[::] +q_goal[configSize:configSize+3] = dir_goal[::] +q_goal[configSize+3:configSize+6] = [0,0,0] + +q_init[2] = q_ref[2] +q_goal[2] = q_ref[2] + +fullBody.setStaticStability(True) +fullBody.setCurrentConfig (q_init) +v(q_init) + +fullBody.setCurrentConfig (q_goal) +v(q_goal) + +v.addLandmark('anymal_reachability/base',0.3) +v(q_init) + +# specify the full body configurations as start and goal state of the problem +fullBody.setStartState(q_init,fullBody.limbs_names) +fullBody.setEndState(q_goal,fullBody.limbs_names) + + +print "Generate contact plan ..." +tStart = time.time() +configs = fullBody.interpolate(0.01,pathId=pId,robustnessTreshold = robTreshold, filterStates = True,testReachability=True,quasiStatic=True) +tInterpolateConfigs = time.time() - tStart +print "Done. " +print "Contact sequence computed in "+str(tInterpolateConfigs)+" s." +print "number of configs :", len(configs) +raw_input("Press Enter to display the contact sequence ...") +displayContactSequence(v,configs) + +import tools.createActionDRP as exp + + diff --git a/script/scenarios/sandbox/ANYmal/plinth_path.py b/script/scenarios/sandbox/ANYmal/plinth_path.py new file mode 100644 index 0000000000000000000000000000000000000000..b844b185c3e71a2d829a48500fb3d2578c9fe83a --- /dev/null +++ b/script/scenarios/sandbox/ANYmal/plinth_path.py @@ -0,0 +1,108 @@ +from hpp.corbaserver.rbprm.anymal_abstract import Robot +from hpp.gepetto import Viewer +from hpp.corbaserver import Client +from hpp.corbaserver import ProblemSolver +import time + + + +vMax = 0.3# linear velocity bound for the root +aMax = 1. # linear acceleration bound for the root +aMaxZ=5. +extraDof = 6 +mu=0.5# coefficient of friction +# Creating an instance of the helper class, and loading the robot +Robot.urdfName += '_large' +rbprmBuilder = Robot() +# Define bounds for the root : bounding box of the scenario +root_bounds = [-2,2,-0.01,0.01, 0.4, 1.2] +rbprmBuilder.setJointBounds ("root_joint", root_bounds) + +# The following lines set constraint on the valid configurations: +# a configuration is valid only if all limbs can create a contact with the corresponding afforcances type +rbprmBuilder.setFilter(rbprmBuilder.urdfNameRom) +for rom in rbprmBuilder.urdfNameRom : + rbprmBuilder.setAffordanceFilter(rom, ['Support']) + +# We also bound the rotations of the torso. (z, y, x) +rbprmBuilder.boundSO3([-0.1,0.1,-0.5,0.5,-0.1,0.1]) +# Add 6 extraDOF to the problem, used to store the linear velocity and acceleration of the root +rbprmBuilder.client.robot.setDimensionExtraConfigSpace(extraDof) +# We set the bounds of this extraDof with velocity and acceleration bounds (expect on z axis) +rbprmBuilder.client.robot.setExtraConfigSpaceBounds([-vMax,vMax,-vMax,vMax,-vMax,vMax,-aMax,aMax,-aMax,aMax,-aMaxZ,aMaxZ]) +indexECS = rbprmBuilder.getConfigSize() - rbprmBuilder.client.robot.getDimensionExtraConfigSpace() + +# Creating an instance of HPP problem solver +ps = ProblemSolver( rbprmBuilder ) +# define parameters used by various methods : +ps.setParameter("Kinodynamic/velocityBound",vMax) +ps.setParameter("Kinodynamic/accelerationBound",aMax) +ps.setParameter("Kinodynamic/verticalAccelerationBound",aMaxZ) +# force the orientation of the trunk to match the direction of the motion +ps.setParameter("Kinodynamic/forceOrientation",True) +ps.setParameter("DynamicPlanner/sizeFootX",0.1) +ps.setParameter("DynamicPlanner/sizeFootY",0.1) +ps.setParameter("DynamicPlanner/friction",mu) +# sample only configuration with null velocity and acceleration : +ps.setParameter("ConfigurationShooter/sampleExtraDOF",False) +ps.setParameter("PathOptimization/RandomShortcut/NumberOfLoops",100) + +# initialize the viewer : +from hpp.gepetto import ViewerFactory +vf = ViewerFactory (ps) + +# load the module to analyse the environnement and compute the possible contact surfaces +from hpp.corbaserver.affordance.affordance import AffordanceTool +afftool = AffordanceTool () +afftool.setAffordanceConfig('Support', [0.5, 0.03, 0.00005]) +afftool.loadObstacleModel ("hpp_environments", "multicontact/ori_plinth", "planning", vf,reduceSizes=[0.05,0,0]) +v = vf.createViewer(displayArrows = True) +afftool.visualiseAffordances('Support', v, v.color.lightBrown) +v.addLandmark(v.sceneName,1) + +# Setting initial configuration +q_init = rbprmBuilder.getCurrentConfig (); +q_init [0:3] = [-1.7,0,0.444] +q_init[-6:-3] = [0.02,0,0] +v (q_init) +ps.setInitialConfig (q_init) +# set goal config +rbprmBuilder.setCurrentConfig (q_init) +q_goal = q_init [::] +q_goal[0:3] = [1.7,0,0.444] +q_goal[-6:-3] = [0.02,0,0] +v(q_goal) + + +ps.addGoalConfig (q_goal) + +# Choosing RBPRM shooter and path validation methods. +ps.selectConfigurationShooter("RbprmShooter") +ps.addPathOptimizer ("RandomShortcutDynamic") +ps.selectPathValidation("RbprmPathValidation",0.05) +# Choosing kinodynamic methods : +ps.selectSteeringMethod("RBPRMKinodynamic") +ps.selectDistance("Kinodynamic") +ps.selectPathPlanner("DynamicPlanner") + +# Solve the planning problem : +t = ps.solve () +print "Guide planning time : ",t +#v.solveAndDisplay('rm',2,radiusSphere=0.01) + + + +# display solution : +from hpp.gepetto import PathPlayer +pp = PathPlayer (v) +pp.dt=0.1 +pp.displayVelocityPath(1) +v.client.gui.setVisibility("path_1_root","ALWAYS_ON_TOP") +pp.dt = 0.01 +pp(1) + +# move the robot out of the view before computing the contacts +q_far = q_init[::] +q_far[2] = -2 +v(q_far) +