From 21ca265b3b58d1a1dff0fe97c6a401b7203c4528 Mon Sep 17 00:00:00 2001 From: Nicolas Schodet Date: Fri, 6 Apr 2012 23:25:36 +0200 Subject: digital/ai/tools: set robot position in control scripts --- digital/ai/tools/test_simu.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'digital/ai/tools/test_simu.py') diff --git a/digital/ai/tools/test_simu.py b/digital/ai/tools/test_simu.py index d55417a5..11ea1b17 100644 --- a/digital/ai/tools/test_simu.py +++ b/digital/ai/tools/test_simu.py @@ -49,7 +49,8 @@ class ObstacleWithBeacon (obstacle_view.RoundObstacle): class TestSimu (InterNode): """Interface, with simulated programs.""" - def __init__ (self, robot_class, robot_nb = 1, color_switch = True): + def __init__ (self, robot_class, robot_nb = 1, + color_switch_set_pos = False): # Hub. self.hub = mex.hub.Hub (min_clients = 1 + robot_class.client_nb * robot_nb) @@ -86,11 +87,12 @@ class TestSimu (InterNode): r.view = r.robot_view.Bag (self.table, self.actuator_view, self.sensor_frame, r.model) # Color switch. - if color_switch: - def change_color (r = r): - i = r.model.color_switch.state - r.asserv.set_simu_pos (*r.robot_start_pos[i]) - r.model.color_switch.register (change_color) + def change_color (r = r): + i = r.model.color_switch.state + r.asserv.set_simu_pos (*r.robot_start_pos[i]) + if color_switch_set_pos: + r.asserv.set_pos (*r.robot_start_pos[i]) + r.model.color_switch.register (change_color) def close (self): self.forked_hub.kill () -- cgit v1.2.3