From 94ed449899985636256b5228d5e0f6bba5af2971 Mon Sep 17 00:00:00 2001 From: Jérémy Dufour Date: Thu, 1 May 2008 00:57:16 +0200 Subject: * digital/io/src - add a function to the sharp module to know if there is a obstacle in front of us (by taking in account the current moving direction of the bot). --- digital/io/src/main.c | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) (limited to 'digital/io/src/main.c') diff --git a/digital/io/src/main.c b/digital/io/src/main.c index 2e7dafcd..e5d25cf3 100644 --- a/digital/io/src/main.c +++ b/digital/io/src/main.c @@ -274,25 +274,11 @@ main_loop (void) /* If we are moving */ if (moving_direction) { - /* If we are moving forward */ - if (moving_direction == 1) + if (sharp_path_obstrued (moving_direction)) { - /* Use only front sharps */ - if (sharp_get_interpreted (SHARP_FRONT_LEFT) || - sharp_get_interpreted (SHARP_FRONT_MIDDLE) || - sharp_get_interpreted (SHARP_FRONT_RIGHT)) - /* Generate an event for move FSM */ - FSM_HANDLE_EVENT (&move_fsm, - MOVE_EVENT_bot_move_obstacle); - } - /* If we are moving backward */ - else if (moving_direction == 2) - { - /* Use only back sharps */ - if (sharp_get_interpreted (SHARP_BACK_LEFT) || - sharp_get_interpreted (SHARP_BACK_RIGHT)) - /* Generate an event for move FSM */ - FSM_HANDLE_EVENT (&move_fsm, MOVE_EVENT_bot_move_obstacle); + /* Generate an event for move FSM */ + FSM_HANDLE_EVENT (&move_fsm, + MOVE_EVENT_bot_move_obstacle); } } } -- cgit v1.2.3