summaryrefslogtreecommitdiffhomepage
path: root/digital/io-hub/src
diff options
context:
space:
mode:
authorNicolas Schodet2013-04-27 23:51:54 +0200
committerNicolas Schodet2013-04-28 00:49:58 +0200
commit068fac5ec55588187a242f3b7ae7033e1f6a39f1 (patch)
tree322d9ba13181b23a22cc337e63e093bf856c7fdd /digital/io-hub/src
parentcab5c7e032771ec19e384436b1bfbd1b89793c7e (diff)
digital/io-hub/src/apbirthday: fix conversion from float to integer angle
Diffstat (limited to 'digital/io-hub/src')
-rw-r--r--digital/io-hub/src/apbirthday/top.cc3
-rw-r--r--digital/io-hub/src/common-cc/move.cc2
2 files changed, 3 insertions, 2 deletions
diff --git a/digital/io-hub/src/apbirthday/top.cc b/digital/io-hub/src/apbirthday/top.cc
index 0fb37ca1..3f7bf2a5 100644
--- a/digital/io-hub/src/apbirthday/top.cc
+++ b/digital/io-hub/src/apbirthday/top.cc
@@ -47,7 +47,8 @@ top_cake_angle (const vect_t &pos)
float dx = pos.x - pg_cake_pos.x;
float dy = pos.y - pg_cake_pos.y;
float angle_rad = std::atan2 (dy, dx);
- uint16_t angle = angle_rad * ((1 << 16) / (2 * M_PI));
+ // Be careful not to lose sign during conversion.
+ int16_t angle = angle_rad * ((1 << 16) / (2 * M_PI));
return angle;
}
diff --git a/digital/io-hub/src/common-cc/move.cc b/digital/io-hub/src/common-cc/move.cc
index 75613584..5c7d3708 100644
--- a/digital/io-hub/src/common-cc/move.cc
+++ b/digital/io-hub/src/common-cc/move.cc
@@ -150,7 +150,7 @@ Move::go_or_rotate (const vect_t &dst, uint16_t angle, bool with_angle,
// Compute angle to destination, if destination is really near, angle is
// almost meaningless.
vect_t v = dst; vect_sub (&v, &robot_position.v);
- uint16_t dst_angle = 0;
+ int16_t dst_angle = 0;
int16_t diff = 0;
if (vect_dot_product (&v, &v) > eps * eps)
{