+
+ /* basic collision detection */
+ a2 = atan2(ROBOT_WIDTH/2, ROBOT_LENGTH/2);
+ d = norm(ROBOT_WIDTH/2, ROBOT_LENGTH/2);
+
+ xfl = x + cos(a+a2) * d;
+ yfl = y + sin(a+a2) * d;
+ if (!is_in_area(xfl, yfl, 0) && l_speed > 0)
+ l_speed = 0;
+
+ xrl = x + cos(a+M_PI-a2) * d;
+ yrl = y + sin(a+M_PI-a2) * d;
+ if (!is_in_area(xrl, yrl, 0) && l_speed < 0)
+ l_speed = 0;
+
+ xrr = x + cos(a+M_PI+a2) * d;
+ yrr = y + sin(a+M_PI+a2) * d;
+ if (!is_in_area(xrr, yrr, 0) && r_speed < 0)
+ r_speed = 0;
+
+ xfr = x + cos(a-a2) * d;
+ yfr = y + sin(a-a2) * d;
+ if (!is_in_area(xfr, yfr, 0) && r_speed > 0)
+ r_speed = 0;
+
+ /* XXX should lock */
+ l_enc += (l_speed / 1000);