Commit 87071cd6 authored by Pierre Fernbach's avatar Pierre Fernbach
Browse files

[Scripts] abstractContactGenerator now implement run()

parent b18ad165
......@@ -43,6 +43,7 @@ class AbstractContactGenerator:
self.end_contacts = self.used_limbs # limbs in contact in the final configuration
self.configs = [] # will contains the whole body configuration computed after calling 'interpolate'
@abstractmethod
def load_fullbody(self):
"""
......@@ -172,20 +173,16 @@ class AbstractContactGenerator:
"""
displayContactSequence(self.v, self.configs)
@abstractmethod
def run(self):
"""
Must be defined in the child class to run all the methods with the correct arguments.
"""
# example of definition:
"""
self.load_fullbody()
self.set_joints_bounds()
self.set_reference(True)
self.load_limbs("fixedStep06")
self.set_reference()
self.load_limbs()
self.init_problem()
self.init_viewer()
self.compute_configs_from_guide()
self.interpolate()
"""
pass
......@@ -6,17 +6,6 @@ class ContactGenerator(HRP2ContactGenerator):
def __init__(self):
super().__init__(PathPlanner())
def run(self):
self.load_fullbody()
self.set_joints_bounds()
self.set_reference(True)
self.load_limbs("fixedStep06")
self.init_problem()
self.init_viewer()
self.compute_configs_from_guide()
self.interpolate()
if __name__ == "__main__":
cg = ContactGenerator()
cg.run()
......
......@@ -5,25 +5,17 @@ class ContactGenerator(HRP2ContactGenerator):
def __init__(self):
super().__init__(PathPlanner())
def run(self):
self.root_translation_bounds = [-5, 5, -1.5, 1.5, 0.65, 0.9]
self.robustness = 0.
self.quasi_static = False
self.load_fullbody()
self.set_joints_bounds()
self.set_reference(True)
def load_limbs(self):
super().load_limbs("fixedStep1")
self.fullbody.minDist = 0.3
self.load_limbs("fixedStep1")
self.init_problem()
self.init_viewer()
self.compute_configs_from_guide()
# force root height to be at exactly on the first platform
def compute_configs_from_guide(self):
super().compute_configs_from_guide()
self.q_init[2] = self.q_ref[2] + 0.16
self.q_goal[2] = self.q_ref[2] + 0.16
self.interpolate()
if __name__ == "__main__":
......
......@@ -2,13 +2,19 @@ from scenarios.hrp2_path_planner import HRP2PathPlanner
class PathPlanner(HRP2PathPlanner):
def set_rom_filters(self):
super().set_rom_filters()
# TEMP fix, because of issue https://github.com/humanoid-path-planner/hpp-fcl/issues/134 in hpp-fcl
# we need to disable ROM checks in this scenario with really small contact surfaces
self.rbprmBuilder.setFilter([])
def run(self):
self.v_max = 0.3
self.root_translation_bounds = [-5,5, -1.5, 1.5, 0.70, 0.8]
self.init_problem()
self.q_init[0:3] = [0.12, 0.25, 0.75]
self.q_goal[0:3] = [1.08, 0.25, 0.75]
self.init_viewer("multicontact/plateforme_surfaces",reduce_sizes=[0.12,0,0], visualize_affordances=["Support"])
self.init_viewer("multicontact/plateforme_surfaces",reduce_sizes=[0.1,0,0], visualize_affordances=["Support"])
self.init_planner()
self.solve()
self.display_path()
......
......@@ -6,17 +6,6 @@ class ContactGenerator(TalosContactGenerator):
def __init__(self):
super().__init__(PathPlanner())
def run(self):
self.load_fullbody()
self.set_joints_bounds()
self.set_reference(True)
self.load_limbs("fixedStep06")
self.init_problem()
self.init_viewer()
self.compute_configs_from_guide()
self.interpolate()
if __name__ == "__main__":
cg = ContactGenerator()
cg.run()
......
......@@ -6,18 +6,9 @@ class ContactGenerator(TalosContactGenerator):
def __init__(self):
super().__init__(PathPlanner())
def run(self):
self.load_fullbody()
# set reference configuration with the arms bended to avoid collisions with the plateform
def set_reference(self):
super().set_reference()
self.q_ref = self.fullbody.referenceConfig_elbowsUp[::] + [0] * self.path_planner.extra_dof
self.set_joints_bounds()
self.set_reference(True)
self.load_limbs("fixedStep06")
self.init_problem()
self.init_viewer()
self.compute_configs_from_guide()
self.interpolate()
if __name__ == "__main__":
......
......@@ -6,6 +6,11 @@ class ContactGenerator(TalosContactGenerator):
def __init__(self):
super().__init__(PathPlanner())
def set_reference(self):
super().set_reference()
self.q_ref = self.fullbody.referenceConfig_elbowsUp[::] + [0] * self.path_planner.extra_dof
def load_limbs(self, heuristic):
super().load_limbs(heuristic)
# In this scenario, the arms are not used to create contact, but they may move to avoid collision.
......@@ -15,17 +20,6 @@ class ContactGenerator(TalosContactGenerator):
self.fullbody.runLimbSampleAnalysis(self.fullbody.rArmId, "ReferenceConfiguration", True)
def run(self):
self.load_fullbody()
self.set_joints_bounds()
self.set_reference(True)
self.load_limbs("fixedStep06")
self.init_problem()
self.init_viewer()
self.compute_configs_from_guide()
self.interpolate()
if __name__ == "__main__":
cg = ContactGenerator()
cg.run()
......
......@@ -20,6 +20,7 @@ class ContactGenerator(TalosContactGenerator):
self.fullbody.setJointBounds('leg_left_1_joint', [-0.1, 0.2])
self.fullbody.setJointBounds('leg_right_1_joint', [-0.2, 0.1])
def run(self):
self.load_fullbody()
self.set_joints_bounds()
......
......@@ -6,24 +6,23 @@ class ContactGenerator(TalosContactGenerator):
def __init__(self):
super().__init__(PathPlanner())
def set_joints_bounds(self):
super().set_joints_bounds()
self.fullbody.setConstrainedJointsBounds()
def run(self):
self.load_fullbody()
def load_fullbody(self):
super().load_fullbody()
# path planning use different limbs, reset it to right/left feet
self.used_limbs = [self.fullbody.lLegId, self.fullbody.rLegId]
self.init_contacts = self.used_limbs
self.end_contacts = self.used_limbs
self.set_joints_bounds()
self.set_reference(True)
self.load_limbs("fixedStep06", nb_samples=100000)
self.init_problem()
self.init_viewer()
self.compute_configs_from_guide()
def set_joints_bounds(self):
super().set_joints_bounds()
self.fullbody.setConstrainedJointsBounds()
def load_limbs(self):
super().load_limbs("fixedStep06", nb_samples=100000)
def compute_configs_from_guide(self):
super().compute_configs_from_guide()
self.q_goal[2] = self.q_ref[2] + 0.6 # set height to the top of the stairs
self.interpolate()
if __name__ == "__main__":
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment