From 4515445795af425fa91920a28ec3f3108f0fa83e Mon Sep 17 00:00:00 2001 From: Jérôme Jutteau Date: Sat, 28 May 2011 18:36:26 +0200 Subject: digital/io-hub: add function to get position from element id This is useful to indicate an angle when we want to approach an element the green zone. --- digital/io-hub/src/robospierre/element.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'digital/io-hub/src/robospierre/element.c') diff --git a/digital/io-hub/src/robospierre/element.c b/digital/io-hub/src/robospierre/element.c index 28c72e4d..ebc5874a 100644 --- a/digital/io-hub/src/robospierre/element.c +++ b/digital/io-hub/src/robospierre/element.c @@ -696,3 +696,26 @@ element_opposed (uint8_t element_id) } return op; } + +position_t +element_get_pos (uint8_t element_id) +{ + element_t e = element_get (element_id); + position_t pos; + pos.v = e.pos; + pos.a = 0; + if (e.attr == (ELEMENT_GREEN |ELEMENT_RIGHT)) + { + /* Set angle to 90° clockwise. */ + pos.a = 0x4000; + /* Remove 400 mm. */ + pos.v.x -= 400; + } + if (e.attr == (ELEMENT_GREEN |ELEMENT_LEFT)) + { + /* Set angle to 270° clockwise. */ + pos.a = 0xc000; + pos.v.x += 400; + } + return pos; +} -- cgit v1.2.3