4 * Finite state machine of the localization part.
6 * Copyright : (c) 2008 CTU Dragons
7 * CTU FEE - Department of Control Engineering
8 * License : GNU GPL v.2
14 #include <laser-nav.h>
21 struct mcl_model *mcl;
22 //struct mcl_laser_measurement meas_angles;
26 FSM_STATE_DECL(ignore_laser);
29 * FSM state: first state. Initilization.
37 * FSM state: main state. Every state will return back to this one.
41 struct mcl_model *mcl = robot.mcl;
44 printf("MCL reset\n");
49 FSM_SIGNAL(MOTION, EV_FOUND_AFTER_RESET, NULL);
51 case EV_ODO_RECEIVED: {
52 struct mcl_robot_odo *odo = FSM_EVENT_PTR;
53 struct mcl_robot_pos *est = robot.mcl->estimated;
54 mcl->predict(mcl, odo);
57 robot.est_pos.x = est->x;
58 robot.est_pos.y = est->y;
59 robot.est_pos.phi = est->angle;
60 ROBOT_UNLOCK(est_pos);
63 case EV_LASER_RECEIVED: {
64 struct mcl_laser_measurement *meas = FSM_EVENT_PTR;
65 if (robot.laser_enabled) {
66 struct mcl_robot_pos *est = robot.mcl->estimated;
67 mcl->update(mcl, meas);
70 robot.est_pos.x = est->x;
71 robot.est_pos.y = est->y;
72 robot.est_pos.phi = est->angle;
73 ROBOT_UNLOCK(est_pos);
77 /* DBG("est_pos=[%f,%f,%f]\n", robot.est_pos.x, robot.est_pos.y, robot.est_pos.phi); */
79 robot.mcl->resample(robot.mcl);
82 case EV_SET_ESTIMATED: {
83 struct mcl_robot_pos *pos = FSM_EVENT_PTR;
84 mcl->set_estimated(mcl, pos);
92 DBG_PRINT_EVENT("unhandled event");