#include <string.h>
#include <robodim.h>
#include <error.h>
+#include "corns_configs.h"
+#include <trgen.h>
/************************************************************************
* Trajectory constraints used, are initialized in the init state
struct TrajectoryConstraints tcFast, tcSlow, tcVerySlow;
+/************************************************************************
+ * Functions to manipulate map etc.
+ ************************************************************************/
+
+static const Point containerPosition(PLAYGROUND_WIDTH_M - 0.25, 0.02); // blue container Position
+
+// returns pointer to next real (non-fake) corn which was not yet collected
+struct corn * choose_next_corn()
+{
+ Point cornPosition;
+
+ double minDistance = 2 * PLAYGROUND_HEIGHT_M; // "infinity"
+ struct corn *minCorn = NULL, *corn;
+ // robot.corns->corns[NUM_OF_FAKE_CORNS] is first non-fake corn in the robot.corns structure
+ for(corn = &robot.corns->corns[NUM_OF_FAKE_CORNS]; corn < &robot.corns->corns[robot.corns->corns_count]; corn++) {
+ cornPosition.x = corn->position.x;
+ cornPosition.y = corn->position.y;
+ double distance = cornPosition.distanceTo(containerPosition);
+
+ if (distance < minDistance && corn->was_collected == false) {
+ minDistance = distance;
+ minCorn = corn;
+ }
+ }
+
+ if (minCorn) printf("\tmin distance was: %.3f ", minDistance);
+ return minCorn;
+}
+
+Pos * get_corn_approach_position(struct corn *corn)
+{
+
+}
+
+
/************************************************************************
* FSM STATES DECLARATION
************************************************************************/
DBG_PRINT_EVENT("unhandled event");
break;
case EV_EXIT:
+ robot.corns = get_all_corns(robot.corns_conf_side, robot.corns_conf_center);
break;
}
}