summaryrefslogtreecommitdiff
path: root/digital/io-hub/src/robospierre/element.c
diff options
context:
space:
mode:
authorJérôme Jutteau2011-05-28 18:36:26 +0200
committerJérôme Jutteau2011-05-28 19:04:47 +0200
commit4515445795af425fa91920a28ec3f3108f0fa83e (patch)
tree97bcc5af3cd53971ef29ad222c40748454a7f7f1 /digital/io-hub/src/robospierre/element.c
parent4b2e09a630c2242197d39920173b27d1968e4f85 (diff)
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.
Diffstat (limited to 'digital/io-hub/src/robospierre/element.c')
-rw-r--r--digital/io-hub/src/robospierre/element.c23
1 files changed, 23 insertions, 0 deletions
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;
+}