From 38aa82a1a03efd53933957fece2e19567afbe6bd Mon Sep 17 00:00:00 2001 From: Nicolas Schodet Date: Sat, 12 May 2012 14:43:44 +0200 Subject: digital/asserv, digital/mimot: add blocking simulation --- digital/ai/tools/test_simu_control_guybrush.py | 10 ++++++++++ digital/asserv/src/asserv/main.c | 15 +++++++++++++++ digital/asserv/tools/asserv/asserv.py | 7 +++++++ digital/mimot/src/dirty/main.c | 7 +++++++ digital/mimot/tools/mimot/mimot.py | 4 ++++ 5 files changed, 43 insertions(+) (limited to 'digital') diff --git a/digital/ai/tools/test_simu_control_guybrush.py b/digital/ai/tools/test_simu_control_guybrush.py index 146ad04a..e895bf39 100644 --- a/digital/ai/tools/test_simu_control_guybrush.py +++ b/digital/ai/tools/test_simu_control_guybrush.py @@ -52,6 +52,10 @@ class TestSimuControl (TestSimu): fill = 'y') Button (self.control_frame, text = 'FSM step', padx = 0, pady = 0, command = self.fsm_debug).pack () + Button (self.control_frame, text = 'Asserv block', padx = 0, pady = 0, + command = self.asserv_block).pack () + Button (self.control_frame, text = 'Clamp block', padx = 0, pady = 0, + command = self.clamp_block).pack () def out_button (name, toggle): def command (): self.io.output (toggle, 'toggle') @@ -107,6 +111,12 @@ class TestSimuControl (TestSimu): def fsm_debug (self): self.io.fsm_debug () + def asserv_block (self): + self.asserv.block () + + def clamp_block (self): + self.mimot.block ('a0') + def move (self, ev): pos = self.table_view.screen_coord ((ev.x, ev.y)) if self.goto_var.get (): diff --git a/digital/asserv/src/asserv/main.c b/digital/asserv/src/asserv/main.c index 4170288b..e8355fbd 100644 --- a/digital/asserv/src/asserv/main.c +++ b/digital/asserv/src/asserv/main.c @@ -302,6 +302,21 @@ proto_callback (uint8_t cmd, uint8_t size, uint8_t *args) output_set (output, v8_to_v16 (args[1], args[2])); control_state_set_mode (state, CS_MODE_NONE, 0); break; +#endif + case c ('b', 0): + /* Simulate a blocked state. */ + output_set (&output_left, 0); + output_set (&output_right, 0); + control_state_blocked (&cs_main.state); + break; +#if AC_ASSERV_AUX_NB + case c ('B', 1): + /* Simulate a blocked state on auxiliary motor. + * - b: aux index. */ + if (!auxp) { proto_send0 ('?'); return; } + output_set (output, 0); + control_state_blocked (state); + break; #endif case c ('c', 4): /* Add to position consign. diff --git a/digital/asserv/tools/asserv/asserv.py b/digital/asserv/tools/asserv/asserv.py index fb45c633..387bbbb4 100644 --- a/digital/asserv/tools/asserv/asserv.py +++ b/digital/asserv/tools/asserv/asserv.py @@ -177,6 +177,13 @@ class Proto: del self.stats_line return array + def block (self, w = None): + """Simulate blocking.""" + if w is None: + self.proto.send ('b') + else: + self.proto.send ('B', 'B', self._index[w]) + def consign (self, w, c): """Consign offset.""" if w == 't': diff --git a/digital/mimot/src/dirty/main.c b/digital/mimot/src/dirty/main.c index e294c8bf..f6b7fd6a 100644 --- a/digital/mimot/src/dirty/main.c +++ b/digital/mimot/src/dirty/main.c @@ -224,6 +224,13 @@ proto_callback (uint8_t cmd, uint8_t size, uint8_t *args) output_set (output, v8_to_v16 (args[1], args[2])); control_state_set_mode (state, CS_MODE_NONE, 0); break; + case c ('b', 1): + /* Simulate a blocked state on auxiliary motor. + * - b: aux index. */ + if (!auxp) { proto_send0 ('?'); return; } + output_set (output, 0); + control_state_blocked (state); + break; case c ('b', 2): /* Set brake and set zero auxiliary pwm. * - b: aux index. diff --git a/digital/mimot/tools/mimot/mimot.py b/digital/mimot/tools/mimot/mimot.py index cb4caace..01d2b74a 100644 --- a/digital/mimot/tools/mimot/mimot.py +++ b/digital/mimot/tools/mimot/mimot.py @@ -134,6 +134,10 @@ class Proto: del self.stats_line return array + def block (self, w): + """Simulate blocking.""" + self.proto.send ('b', 'B', self._index[w]) + def consign (self, w, c): """Consign offset.""" self.proto.send ('c', 'Bh', self._index[w], c) -- cgit v1.2.3