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 ++++++++------ digital/ai/tools/test_simu_control_guybrush.py | 6 ++---- digital/ai/tools/test_simu_control_marcel.py | 6 ++---- digital/ai/tools/test_simu_control_robospierre.py | 6 ++---- 4 files changed, 14 insertions(+), 18 deletions(-) (limited to 'digital/ai/tools') 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 () diff --git a/digital/ai/tools/test_simu_control_guybrush.py b/digital/ai/tools/test_simu_control_guybrush.py index 321b0d86..6d742e90 100644 --- a/digital/ai/tools/test_simu_control_guybrush.py +++ b/digital/ai/tools/test_simu_control_guybrush.py @@ -33,7 +33,8 @@ class TestSimuControl (TestSimu): LOWER_CLAMP_ROTATION_STROKE = int (16 * 250) def __init__ (self, robot_class, *args): - TestSimu.__init__ (self, robot_class, *args, color_switch = False) + TestSimu.__init__ (self, robot_class, *args, + color_switch_set_pos = True) self.io = self.robots[0].io self.asserv = self.robots[0].asserv self.mimot = self.robots[0].mimot @@ -90,8 +91,5 @@ class TestSimuControl (TestSimu): def lower_clamp_rotate_command (self): self.mimot.speed_pos ('a0', self.LOWER_CLAMP_ROTATION_STROKE / 2) - def change_color (self, *dummy): - pass - if __name__ == '__main__': run ('guybrush', TestSimuControl) diff --git a/digital/ai/tools/test_simu_control_marcel.py b/digital/ai/tools/test_simu_control_marcel.py index 3d25592c..b2832479 100644 --- a/digital/ai/tools/test_simu_control_marcel.py +++ b/digital/ai/tools/test_simu_control_marcel.py @@ -29,7 +29,8 @@ class TestSimuControl (TestSimu): """Interface with extra control.""" def __init__ (self, robot_class, *args): - TestSimu.__init__ (self, robot_class, *args, color_switch = False) + TestSimu.__init__ (self, robot_class, *args, + color_switch_set_pos = True) self.io = self.robots[0].io self.asserv = self.robots[0].asserv self.mimot = self.robots[0].mimot @@ -105,8 +106,5 @@ class TestSimuControl (TestSimu): def loader_down_command (self): self.io.loader ('d') - def change_color (self, *dummy): - pass - if __name__ == '__main__': run ('marcel', TestSimuControl) diff --git a/digital/ai/tools/test_simu_control_robospierre.py b/digital/ai/tools/test_simu_control_robospierre.py index afe60f74..a75ba9c7 100644 --- a/digital/ai/tools/test_simu_control_robospierre.py +++ b/digital/ai/tools/test_simu_control_robospierre.py @@ -33,7 +33,8 @@ class TestSimuControl (TestSimu): ROTATION_STROKE = 0x233e def __init__ (self, robot_class, *args): - TestSimu.__init__ (self, robot_class, *args, color_switch = False) + TestSimu.__init__ (self, robot_class, *args, + color_switch_set_pos = True) self.io = self.robots[0].io self.asserv = self.robots[0].asserv self.mimot = self.robots[0].mimot @@ -152,8 +153,5 @@ class TestSimuControl (TestSimu): order = 'drop_clear' self.io.drop (order) - def change_color (self, *dummy): - pass - if __name__ == '__main__': run ('robospierre', TestSimuControl) -- cgit v1.2.3