*******************************************************************************/
struct movement;
-struct close_to_target;
+//struct close_to_target;
struct wait_for_command;
struct lost;
struct wait_and_try_again;
struct MotionBase;
struct FSMMotion : boost::statechart::asynchronous_state_machine<FSMMotion, MotionBase, Scheduler> {
- FSMMotion(my_context ctx) : my_base(ctx) {
- printf("%s\n", __FUNCTION__);
- }
+ FSMMotion(my_context ctx) : my_base(ctx) {}
};
struct MotionBase : sc::simple_state<MotionBase, FSMMotion, wait_for_command> {
{
enum target_status ret;
wait_for_command() {
- printf("%s\n", __FUNCTION__);
stop();
}
sc::result react(const EV_NEW_TARGET &event) {
- printf("%s EV_NEW_TARGET\n", __FUNCTION__);
ret = new_target((struct move_target*)event.ev_ptr);
free (event.ev_ptr);
switch (ret) {
case TARGET_OK: return transit<movement>();
case TARGET_INACC: return transit<wait_and_try_again>();
case TARGET_ERROR:
- /*FSM_SIGNAL(MAIN, EV_MOTION_DONE, NULL)*/;
+ robot.sched.queue_event(robot.MAIN, new EV_MOTION_DONE());
ul_logerr("Target error\n");
}
return discard_event();
// Skip close to target because sometimes it turn the robot to much
// FSM_TRANSITION(close_to_target);
robot.sched.queue_event(robot.MAIN, new EV_MOTION_DONE());
- /*TODO FSM_SIGNAL(MAIN, EV_MOTION_DONE, NULL);*/
return transit<wait_for_command>();
}
sc::result react(const EV_TRAJECTORY_DONE_AND_CLOSE &) {
-
robot.sched.queue_event(robot.MAIN, new EV_MOTION_DONE());
- /*TODO FSM_SIGNAL(MAIN, EV_MOTION_DONE, NULL);*/
return transit<wait_for_command>();
}
sc::result react(const EV_OBSTACLE &) {
case TARGET_INACC: return transit<wait_and_try_again>();
// Fatal error during planning
case TARGET_ERROR:
- /*TODO FSM_SIGNAL(MAIN, EV_MOTION_DONE, NULL);*/
+ robot.sched.queue_event(robot.MAIN, new EV_MOTION_DONE());
ul_logerr("Target error\n");
/* FIXME (Filip): shouldn't transition to wait_for_command be here?
No, probably not, if an error occurs, robot won't move any more
sc::custom_reaction<EV_TRAJECTORY_DONE>,
sc::custom_reaction<EV_TRAJECTORY_DONE_AND_CLOSE> > reactions;
};
-
+/*
struct close_to_target : TimedState<close_to_target, MotionBase>{
Timer timeout_for_close;
close_to_target(my_context ctx) : base_state(ctx) {
stop();
}
sc::result react(const EV_TRAJECTORY_DONE_AND_CLOSE &) {
- /*TODO FSM_SIGNAL(MAIN, EV_MOTION_DONE, NULL);*/
+ robot.sched.queue_event(robot.MAIN, new EV_MOTION_DONE());
return transit<wait_for_command>();
}
sc::result react(const EV_OBSTACLE_BEHIND &) {
sc::transition<EV_TIMER, lost>,
sc::transition<EV_MOVE_STOP, wait_for_command> > reactions;
};
-
+*/
struct lost : TimedState<lost, MotionBase>{
Timer lost_tout;
lost(my_context ctx) : base_state(ctx) {
case TARGET_OK: return transit<movement>();
case TARGET_INACC: return transit<wait_and_try_again>();
case TARGET_ERROR:
- /*TODO FSM_SIGNAL(MAIN, EV_MOTION_DONE, NULL);*/
+ robot.sched.queue_event(robot.MAIN, new EV_MOTION_DONE());
ul_logerr("Target error\n");
}
return discard_event();
/* FIXME (Filip): this could happen forever */
// Fatal error during planning
case TARGET_ERROR:
- /*TODO FSM_SIGNAL(MAIN, EV_MOTION_DONE, NULL);*/
+ robot.sched.queue_event(robot.MAIN, new EV_MOTION_DONE());
ul_logerr("Target error\n");
}
return discard_event();
}
sc::result react(const EV_TRAJECTORY_DONE &) {
- /* TODO FSM_SIGNAL(MAIN, EV_MOTION_DONE, NULL);*/
+ robot.sched.queue_event(robot.MAIN, new EV_MOTION_DONE());
return transit<wait_for_command>();
}
sc::result react(const EV_TRAJECTORY_DONE_AND_CLOSE &) {
- /* TODO FSM_SIGNAL(MAIN, EV_MOTION_DONE, NULL);*/
+ robot.sched.queue_event(robot.MAIN, new EV_MOTION_DONE());
return transit<wait_for_command>();
}
typedef mpl::list<