Skip to content
Snippets Groups Projects
Commit 6694918d authored by Pierre Fernbach's avatar Pierre Fernbach
Browse files

Update the scenario classes to be ran without a viewer

parent 86658f5c
No related branches found
No related tags found
No related merge requests found
......@@ -118,7 +118,10 @@ class AbstractContactGenerator:
"""
Create a Viewer instance
"""
self.v = Viewer(self.ps, viewerClient=self.path_planner.v.client, displayCoM=True)
if self.path_planner.v.client is not None:
self.v = Viewer(self.ps, viewerClient=self.path_planner.v.client, displayCoM=True)
else:
self.v = self.path_planner.v
def compute_configs_from_guide(self, use_acc_init=True, use_acc_end=False, set_ref_height=True):
"""
......@@ -201,15 +204,16 @@ class AbstractContactGenerator:
"""
display the guide path planned
"""
self.v.client.gui.setVisibility(self.robot_node_name, "OFF")
self.path_planner.show_rom()
self.cl.problem.selectProblem("guide_planning")
# this is not the same problem as in the guide_planner. We only added the final path in this problem,
# thus there is only 1 path in this problem
self.path_planner.pp(0)
self.cl.problem.selectProblem("default")
self.path_planner.hide_rom()
self.v.client.gui.setVisibility(self.robot_node_name, "ON")
if self.v.client is not None:
self.v.client.gui.setVisibility(self.robot_node_name, "OFF")
self.path_planner.show_rom()
self.cl.problem.selectProblem("guide_planning")
# this is not the same problem as in the guide_planner. We only added the final path in this problem,
# thus there is only 1 path in this problem
self.path_planner.pp(0)
self.cl.problem.selectProblem("default")
self.path_planner.hide_rom()
self.v.client.gui.setVisibility(self.robot_node_name, "ON")
def run(self):
"""
......
......@@ -112,11 +112,15 @@ class AbstractPathPlanner:
self.afftool.loadObstacleModel(env_package, env_name, "planning", vf, reduceSizes=reduce_sizes)
try:
self.v = vf.createViewer(displayArrows=True)
self.pp = PathPlayer(self.v)
for aff_type in visualize_affordances:
self.afftool.visualiseAffordances(aff_type, self.v, self.v.color.lightBrown)
except Exception:
print("No viewer started !")
class FakeViewer():
def __init__(self):
self.client = None
return
def __call__(self, q):
......@@ -126,12 +130,6 @@ class AbstractPathPlanner:
return
self.v = FakeViewer()
try:
self.pp = PathPlayer(self.v)
except Exception:
pass
for aff_type in visualize_affordances:
self.afftool.visualiseAffordances(aff_type, self.v, self.v.color.lightBrown)
def init_planner(self, kinodynamic=True, optimize=True):
"""
......@@ -196,13 +194,15 @@ class AbstractPathPlanner:
"""
Remove the current robot from the display
"""
self.v.client.gui.setVisibility(self.robot_node_name, "OFF")
if self.v.client is not None:
self.v.client.gui.setVisibility(self.robot_node_name, "OFF")
def show_rom(self):
"""
Add the current robot to the display
"""
self.v.client.gui.setVisibility(self.robot_node_name, "ON")
if self.v.client is not None:
self.v.client.gui.setVisibility(self.robot_node_name, "ON")
@abstractmethod
def run(self):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment