From e0e813dc81eb0d5346ed76724438c94e4ac1e54b Mon Sep 17 00:00:00 2001 From: Nicolas Schodet Date: Mon, 30 May 2011 01:10:13 +0200 Subject: digital/io-hub: change element_get_pos --- digital/io-hub/src/robospierre/bot.h | 10 ++++++++++ digital/io-hub/src/robospierre/element.c | 17 +++++++++-------- digital/io-hub/src/robospierre/element.h | 2 +- 3 files changed, 20 insertions(+), 9 deletions(-) (limited to 'digital/io-hub') diff --git a/digital/io-hub/src/robospierre/bot.h b/digital/io-hub/src/robospierre/bot.h index 661ba584..1c068def 100644 --- a/digital/io-hub/src/robospierre/bot.h +++ b/digital/io-hub/src/robospierre/bot.h @@ -41,6 +41,9 @@ /** Distance from the robot axis to the side. */ #define BOT_SIZE_SIDE 190 +/** Radius of an element. */ +#define BOT_ELEMENT_RADIUS 100 + /** Distance between the front contact point and the robot center. */ #define BOT_FRONT_CONTACT_DIST_MM 150 /** Angle error at the front contact point. */ @@ -53,6 +56,13 @@ /** Distance from robot center to an element near enough to be taken. */ #define BOT_PAWN_TAKING_DISTANCE_MM 150 +/** Distance from border to position in front of a green element. */ +#define BOT_GREEN_ELEMENT_PLACE_DISTANCE_MM 600 +/** Distance to go to capture a green element. */ +#define BOT_GREEN_ELEMENT_MOVE_DISTANCE_MM \ + (BOT_GREEN_ELEMENT_PLACE_DISTANCE_MM - BOT_ELEMENT_RADIUS \ + - BOT_SIZE_FRONT - 20) + /** Speed used for initialisation. */ #ifdef HOST # define BOT_SPEED_INIT 0x20, 0x20, 0x20, 0x20 diff --git a/digital/io-hub/src/robospierre/element.c b/digital/io-hub/src/robospierre/element.c index 0022f09a..bc76a2b0 100644 --- a/digital/io-hub/src/robospierre/element.c +++ b/digital/io-hub/src/robospierre/element.c @@ -31,6 +31,8 @@ #include "chrono.h" #include "logistic.h" +#include "bot.h" +#include "playground.h" /** Elements on table. */ struct element_t element_table[] = @@ -710,19 +712,18 @@ element_get_pos (uint8_t element_id) element_t e = element_get (element_id); position_t pos; pos.v = e.pos; - pos.a = 0; + pos.a = 0xffff; if (e.attr == (ELEMENT_GREEN |ELEMENT_RIGHT)) { - /* Set angle to 90° clockwise. */ - pos.a = 0x4000; - /* Remove 400 mm. */ - pos.v.x -= 400; + /* To the right. */ + pos.a = 0x0000; + pos.v.x = PG_WIDTH - BOT_GREEN_ELEMENT_PLACE_DISTANCE_MM; } if (e.attr == (ELEMENT_GREEN |ELEMENT_LEFT)) { - /* Set angle to 270° clockwise. */ - pos.a = 0xc000; - pos.v.x += 400; + /* To the left. */ + pos.a = 0x8000; + pos.v.x = BOT_GREEN_ELEMENT_PLACE_DISTANCE_MM; } return pos; } diff --git a/digital/io-hub/src/robospierre/element.h b/digital/io-hub/src/robospierre/element.h index 4655c3c1..7ef80e48 100644 --- a/digital/io-hub/src/robospierre/element.h +++ b/digital/io-hub/src/robospierre/element.h @@ -163,7 +163,7 @@ element_nearest_element_id (position_t robot_pos); /** Give the position where the robot need to be placed to get an element. The position correspond to the emplacement of the element with an angle of - zero. If the element is in the green zone, the returned position include + 0xffff. If the element is in the green zone, the returned position include the angle the robot need to set before moving to the element. */ position_t -- cgit v1.2.3