]> rtime.felk.cvut.cz Git - eurobot/public.git/commitdiff
Events
authorPetr Silhavik <silhavik.p@gmail.com>
Fri, 4 Jan 2013 11:54:18 +0000 (12:54 +0100)
committerPetr Silhavik <silhavik.p@gmail.com>
Fri, 4 Jan 2013 11:54:18 +0000 (12:54 +0100)
Change events names

src/robofsm/events.h
src/robofsm/fsmhead.hpp
src/robofsm/fsmmove.cc
src/robofsm/homologation2012.cc
src/robofsm/motion-control.cc
src/robofsm/movehelper.cc
src/robofsm/robot.cc
src/robofsm/robot_orte.cc
src/robofsm/test/camera_onoff.cc
src/robofsm/test/rectangle.cc

index 158e1501d3e674c6349e30820d5290c3105fb135..6294770be84527e2af6ccd61be1d5e57bb9a2a59 100644 (file)
 namespace sc = boost::statechart;
 
 /**
- * EV_TIMER - Timeout.
+ * evTimer - Basic event for timeout.
  */
-struct EV_TIMER : sc::event< EV_TIMER >{
+struct evTimer : sc::event< evTimer > {
        void *ev_ptr;
-       EV_TIMER(void *par = NULL) : ev_ptr(par) {};
+       evTimer(void *par = NULL) : ev_ptr(par) {};
 };
 
 /**
- * EV_RETURN - Return from submachine.
+ * evReturn - Return from submachine.
  */
-struct EV_RETURN : sc::event< EV_RETURN >{
+struct evReturn : sc::event< evReturn > {
        void *ev_ptr;
-       EV_RETURN(void *par = NULL) : ev_ptr(par) {};
+       evReturn(void *par = NULL) : ev_ptr(par) {};
 };
 
 /**
- * EV_START - Changed state of start connector.
+ * evStart - Changed state of start connector.
  */
-struct EV_START : sc::event< EV_START >{
+struct evStart : sc::event< evStart > {
        void *ev_ptr;
-       EV_START(void *par = NULL) : ev_ptr(par) {};
+       evStart(void *par = NULL) : ev_ptr(par) {};
 };
 
 /**
- * EV_JAWS_DONE - Jaws are in requested position.
+ * evJawsDone - Jaws are in requested position.
  */
-struct EV_JAWS_DONE : sc::event<EV_JAWS_DONE>{
+struct evJawsDone : sc::event< evJawsDone > {
        void *ev_ptr;
-       EV_JAWS_DONE(void *par = NULL) : ev_ptr(par) {};
+       evJawsDone(void *par = NULL) : ev_ptr(par) {};
 };
 
 /**
- * EV_LIFT_DONE - Lift is in requested position.
+ * evLiftDone - Lift is in requested position.
  */
-struct EV_LIFT_DONE : sc::event<EV_LIFT_DONE>{
+struct evLiftDone : sc::event< evLiftDone > {
        void *ev_ptr;
-       EV_LIFT_DONE(void *par = NULL) : ev_ptr(par) {};
+       evLiftDone(void *par = NULL) : ev_ptr(par) {};
 };
 
 /**
- * EV_SWITCH_STRATEGY - Switch between strategies.
+ * evSwitchStrategy - Switch between strategies.
  */
-struct EV_SWITCH_STRATEGY : sc::event<EV_SWITCH_STRATEGY>{
+struct evSwitchStrategy : sc::event< evSwitchStrategy > {
        void *ev_ptr;
-       EV_SWITCH_STRATEGY(void *par = NULL) : ev_ptr(par) {};
+       evSwitchStrategy(void *par = NULL) : ev_ptr(par) {};
 };
 
 /**
- * EV_MOTION_DONE - Previously submitted motion is finished.
+ * evMotionDone - Previously submitted motion is finished.
  */
-struct EV_MOTION_DONE : sc::event<EV_MOTION_DONE>{
+struct evMotionDone : sc::event< evMotionDone > {
        void *ev_ptr;
-       EV_MOTION_DONE(void *par = NULL) : ev_ptr(par) {};
+       evMotionDone(void *par = NULL) : ev_ptr(par) {};
 };
 
 /**
- * EV_MOTION_ERROR - "Motion FSM cannot finish the requested command even after several attempts (obstacles on the road, lost several times etc.).
+ * evMotionError - "Motion FSM cannot finish the requested command even after several attempts (obstacles on the road, lost several times etc.).
  */
-struct EV_MOTION_ERROR : sc::event<EV_MOTION_ERROR>{
+struct evMotionError : sc::event< evMotionError > {
        void *ev_ptr;
-       EV_MOTION_ERROR(void *par = NULL) : ev_ptr(par) {};
+       evMotionError(void *par = NULL) : ev_ptr(par) {};
 };
 
 /**
- * EV_MOVE_STOP - Stop current motion as fast as possible.
+ * evMoveStop - Stop current motion as fast as possible.
  */
-struct EV_MOVE_STOP : sc::event<EV_MOVE_STOP>{
+struct evMoveStop : sc::event< evMoveStop > {
        void *ev_ptr;
-       EV_MOVE_STOP(void *par = NULL) : ev_ptr(par) {};
+       evMoveStop(void *par = NULL) : ev_ptr(par) {};
 };
 
 /**
- * EV_NEW_TARGET - New target (point or trajectory) is sent.
+ * evNewTarget - New target (point or trajectory) is sent.
  */
-struct EV_NEW_TARGET : sc::event<EV_NEW_TARGET>{
+struct evNewTarget : sc::event< evNewTarget > {
        void *ev_ptr;
-       EV_NEW_TARGET(void *par = NULL) : ev_ptr(par) {};
+       evNewTarget(void *par = NULL) : ev_ptr(par) {};
 };
 
 /**
- * EV_TRAJECTORY_LOST - Actual position of the robot is too far from reference.
+ * evTrajectoryLost - Actual position of the robot is too far from reference.
  */
-struct EV_TRAJECTORY_LOST : sc::event<EV_TRAJECTORY_LOST>{
+struct evTrajectoryLost : sc::event< evTrajectoryLost > {
        void *ev_ptr;
-       EV_TRAJECTORY_LOST(void *par = NULL) : ev_ptr(par) {};
+       evTrajectoryLost(void *par = NULL) : ev_ptr(par) {};
 };
 
 /**
- * EV_TRAJECTORY_DONE - Reference position is at the end of the previously submitted trajectory.
+ * evTrajectoryDone - Reference position is at the end of the previously submitted trajectory.
  */
-struct EV_TRAJECTORY_DONE : sc::event<EV_TRAJECTORY_DONE>{
+struct evTrajectoryDone : sc::event< evTrajectoryDone > {
        void *ev_ptr;
-       EV_TRAJECTORY_DONE(void *par = NULL) : ev_ptr(par) {};
+       evTrajectoryDone(void *par = NULL) : ev_ptr(par) {};
 };
 
 /**
- * EV_OBSTACLE - An obstacle is detected on actual trajectory - we must avoid it.
+ * evObstacle - An obstacle is detected on actual trajectory - we must avoid it.
  */
-struct EV_OBSTACLE : sc::event<EV_OBSTACLE>{
+struct evObstacle : sc::event< evObstacle > {
        void *ev_ptr;
-       EV_OBSTACLE(void *par = NULL) : ev_ptr(par) {};
+       evObstacle(void *par = NULL) : ev_ptr(par) {};
 };
 
 /**
- * EV_OBSTACLE_BEHIND - An obstacle is behind the robot.
+ * evObstacleBehind - An obstacle is behind the robot.
  */
-struct EV_OBSTACLE_BEHIND : sc::event<EV_OBSTACLE_BEHIND>{
+struct evObstacleBehind : sc::event< evObstacleBehind > {
        void *ev_ptr;
-       EV_OBSTACLE_BEHIND(void *par = NULL) : ev_ptr(par) {};
+       evObstacleBehind(void *par = NULL) : ev_ptr(par) {};
 };
 
 /**
- * EV_OBSTACLE_SIDE - An obstacle is beside the robot.
+ * evObstacleSide - An obstacle is beside the robot.
  */
-struct EV_OBSTACLE_SIDE : sc::event<EV_OBSTACLE_SIDE>{
+struct evObstacleSide : sc::event< evObstacleSide > {
        void *ev_ptr;
-       EV_OBSTACLE_SIDE(void *par = NULL) : ev_ptr(par) {};
+       evObstacleSide(void *par = NULL) : ev_ptr(par) {};
 };
 
 /**
- * EV_COMPETITON_TOUT - An obstacle is beside the robot.
+ * evCompetitionTimeout - An obstacle is beside the robot.
  */
-struct EV_COMPETITON_TOUT : sc::event<EV_COMPETITON_TOUT>{
+struct evCompetitionTimeout : sc::event< evCompetitionTimeout > {
        void *ev_ptr;
-       EV_COMPETITON_TOUT(void *par = NULL) : ev_ptr(par) {};
+       evCompetitionTimeout(void *par = NULL) : ev_ptr(par) {};
 };
 
 #endif
\ No newline at end of file
index 22a789915fef6decc2fd3240992edf07b5079e0d..4e882d577f98a5544c02c13ef425f819cf502186 100644 (file)
@@ -14,30 +14,27 @@ struct MainInit;
 struct Competing;
 struct approachBuillon;
 
-struct FSMMain : boost::statechart::asynchronous_state_machine<FSMMain, MainInit, Scheduler> {
+struct FSMMain : sc::asynchronous_state_machine< FSMMain, MainInit, Scheduler > {
        FSMMain(my_context ctx) : my_base(ctx) {
-               printf("%s\n", __FUNCTION__);
        }
 };
 
-struct MainInit : TimedState<MainInit, FSMMain> {
+struct MainInit : TimedState< MainInit, FSMMain > {
        Timer setTime;
        MainInit(my_context ctx) : base_state(ctx) {
-               printf("%s\n", __FUNCTION__);
                #ifdef WAIT_FOR_START
-                       runTimer(setTime, 1000, new EV_TIMER());
+                       runTimer(setTime, 1000, new evTimer());
                #else
-                       robot.sched.queue_event(robot.MAIN, new EV_START());
+                       robot.sched.queue_event(robot.MAIN, new evStart());
                #endif
        }
-       sc::result react(const EV_START &) {
+       sc::result react(const evStart &) {
 //             actuators_home();
 //             set_initial_position();
-               printf("%s EV_START\n", __FUNCTION__);
                return transit<Competing>();
        }
-       sc::result react(const EV_TIMER) {
-               runTimer(setTime, 1000, new EV_TIMER());
+       sc::result react(const evTimer) {
+               runTimer(setTime, 1000, new evTimer());
                // We set initial position periodically in
                // order for it to be updated on the display
                // if the team color is changed during waiting
@@ -48,17 +45,17 @@ struct MainInit : TimedState<MainInit, FSMMain> {
                return discard_event();
        }
        typedef boost::mpl::list<
-               sc::custom_reaction<EV_START>,
-               sc::custom_reaction<EV_TIMER> > reactions;
+               sc::custom_reaction< evStart >,
+               sc::custom_reaction< evTimer > > reactions;
 };
 
-struct Competing : TimedState<Competing, FSMMain, approachBuillon> {
+struct Competing : TimedState< Competing, FSMMain, approachBuillon > {
        Timer competeTime;
        Competing(my_context ctx) : base_state(ctx) {
                clock_gettime(CLOCK_MONOTONIC, &(robot.startTime));
-               runTimer(competeTime, 90000, new EV_COMPETITON_TOUT());
+               runTimer(competeTime, 90000, new evCompetitionTimeout());
        }
-       typedef boost::statechart::transition<EV_COMPETITON_TOUT, MainInit> reactions;
+       typedef boost::statechart::transition< evCompetitionTimeout, MainInit > reactions;
 };
 
 #endif
\ No newline at end of file
index c948857c4cc98ae3f581095f62d288764612f382..4109d88f17633743a239466d13c4cf2af9816500 100644 (file)
@@ -287,82 +287,80 @@ struct lost;
 struct wait_and_try_again;
 struct MotionBase;
 
-struct FSMMotion : boost::statechart::asynchronous_state_machine<FSMMotion, MotionBase, Scheduler> {
+struct FSMMotion : boost::statechart::asynchronous_state_machine< FSMMotion, MotionBase, Scheduler > {
        FSMMotion(my_context ctx) : my_base(ctx) {}
 };
 
-struct MotionBase : sc::simple_state<MotionBase, FSMMotion, wait_for_command> {
-       sc::result react(const EV_TRAJECTORY_DONE &) {
+struct MotionBase : sc::simple_state< MotionBase, FSMMotion, wait_for_command > {
+       sc::result react(const evTrajectoryDone &) {
 //             DBG_PRINT_EVENT("unhandled event");
                return discard_event();
        }
-       sc::result react(const EV_TRAJECTORY_LOST &) {
+       sc::result react(const evTrajectoryLost &) {
 //             DBG_PRINT_EVENT("unhandled event");
                return discard_event();
        }
-       sc::result react(const EV_MOVE_STOP &) {
+       sc::result react(const evMoveStop &) {
 //             DBG_PRINT_EVENT("unhandled event");
                return discard_event();
        }
-       sc::result react(const EV_OBSTACLE &) {
+       sc::result react(const evObstacle &) {
 //             DBG_PRINT_EVENT("unhandled event");
                return discard_event();
        }
-       sc::result react(const EV_OBSTACLE_BEHIND &) {
+       sc::result react(const evObstacleBehind &) {
 //             DBG_PRINT_EVENT("unhandled event");
                return discard_event();
        }
-       sc::result react(const EV_OBSTACLE_SIDE &) {
+       sc::result react(const evObstacleSide &) {
 //             DBG_PRINT_EVENT("unhandled event");
                return discard_event();
        }
-       sc::result react(const EV_RETURN &) {
+       sc::result react(const evReturn &) {
 //             DBG_PRINT_EVENT("unhandled event");
                return discard_event();
        }
-       sc::result react(const EV_NEW_TARGET &) {
+       sc::result react(const evNewTarget &) {
 //             DBG_PRINT_EVENT("unhandled event");
                return discard_event();
        }
        typedef mpl::list<
-               sc::custom_reaction<EV_TRAJECTORY_DONE>,
-               sc::custom_reaction<EV_TRAJECTORY_LOST>,
-               sc::custom_reaction<EV_MOVE_STOP>,
-               sc::custom_reaction<EV_OBSTACLE_SIDE>,
-               sc::custom_reaction<EV_OBSTACLE_BEHIND>,
-               sc::custom_reaction<EV_OBSTACLE>,
-               sc::custom_reaction<EV_RETURN>,
-               sc::custom_reaction<EV_NEW_TARGET> > reactions;
+               sc::custom_reaction< evTrajectoryDone >,
+               sc::custom_reaction< evTrajectoryLost >,
+               sc::custom_reaction< evMoveStop >,
+               sc::custom_reaction< evObstacleSide >,
+               sc::custom_reaction< evObstacleBehind >,
+               sc::custom_reaction< evObstacle >,
+               sc::custom_reaction< evReturn >,
+               sc::custom_reaction< evNewTarget > > reactions;
 };
 
-struct wait_for_command : TimedSimpleState<wait_for_command, MotionBase>
-{
+struct wait_for_command : TimedSimpleState< wait_for_command, MotionBase > {
        target_status ret;
        wait_for_command() {
                stop();
        }
-       sc::result react(const EV_NEW_TARGET &event) {
+       sc::result react(const evNewTarget &event) {
                ret = new_target((move_target*)event.ev_ptr);
                delete event.ev_ptr;
                switch (ret) {
                        case TARGET_OK: return transit<movement>(); 
                        case TARGET_INACC: return transit<wait_and_try_again>();
                        case TARGET_ERROR: 
-                         robot.sched.queue_event(robot.MAIN, new EV_MOTION_DONE());
+                         robot.sched.queue_event(robot.MAIN, new evMotionDone());
                          ul_logerr("Target error\n"); 
                }
                return discard_event();
        }
-       typedef sc::custom_reaction<EV_NEW_TARGET> reactions;
+       typedef sc::custom_reaction< evNewTarget > reactions;
 };
 
-struct movement : TimedSimpleState<movement, MotionBase>
-{
-       sc::result react(const EV_TRAJECTORY_DONE &) {
-               robot.sched.queue_event(robot.MAIN, new EV_MOTION_DONE());
+struct movement : TimedSimpleState< movement, MotionBase > {
+       sc::result react(const evTrajectoryDone &) {
+               robot.sched.queue_event(robot.MAIN, new evMotionDone());
                return transit<wait_for_command>();
        }
-       sc::result react(const EV_OBSTACLE &) {
+       sc::result react(const evObstacle &) {
                switch (recalculate_trajectory()) {
                        // We can go to the target:
                        case TARGET_OK: return discard_event();
@@ -370,7 +368,7 @@ struct movement : TimedSimpleState<movement, MotionBase>
                        case TARGET_INACC: return transit<wait_and_try_again>(); 
                        // Fatal error during planning
                        case TARGET_ERROR: 
-                         robot.sched.queue_event(robot.MAIN, new EV_MOTION_DONE());
+                         robot.sched.queue_event(robot.MAIN, new evMotionDone());
                           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
@@ -378,53 +376,53 @@ struct movement : TimedSimpleState<movement, MotionBase>
                }
                return discard_event();
        }
-       sc::result react(const EV_OBSTACLE_BEHIND &) {
+       sc::result react(const evObstacleBehind &) {
                if (back_bumpers())
                        return transit<wait_and_try_again>();
                return discard_event();
        }
-       sc::result react(const EV_OBSTACLE_SIDE &) {
+       sc::result react(const evObstacleSide &) {
                if (side_bumpers())
                        return transit<wait_and_try_again>();
                return discard_event();
        }
        typedef mpl::list<
-               sc::transition<EV_TRAJECTORY_LOST, lost>,
-               sc::transition<EV_MOVE_STOP, wait_for_command>,
-               sc::custom_reaction<EV_OBSTACLE_SIDE>,
-               sc::custom_reaction<EV_OBSTACLE_BEHIND>,
-               sc::custom_reaction<EV_OBSTACLE>,
-               sc::custom_reaction<EV_TRAJECTORY_DONE> > reactions;
+               sc::transition< evTrajectoryLost, lost >,
+               sc::transition< evMoveStop, wait_for_command >,
+               sc::custom_reaction< evObstacleSide >,
+               sc::custom_reaction< evObstacleBehind >,
+               sc::custom_reaction< evObstacle >,
+               sc::custom_reaction< evTrajectoryDone > > reactions;
 };
 
-struct lost : TimedState<lost, MotionBase>{
+struct lost : TimedState< lost, MotionBase > {
        Timer lost_tout;
        lost(my_context ctx) : base_state(ctx) {
                stop();
-               runTimer(lost_tout, 1000, new EV_TIMER());
+               runTimer(lost_tout, 1000, new evTimer());
        }
-       sc::result react(const EV_TIMER &) {
+       sc::result react(const evTimer &) {
                switch (recalculate_trajectory()) {
                        case TARGET_OK:    return transit<movement>();
                        case TARGET_INACC: return transit<wait_and_try_again>();
                        case TARGET_ERROR: 
-                           robot.sched.queue_event(robot.MAIN, new EV_MOTION_DONE());
+                           robot.sched.queue_event(robot.MAIN, new evMotionDone());
                            ul_logerr("Target error\n"); 
                }
                return discard_event();
        }
        typedef mpl::list<
-               sc::custom_reaction<EV_TIMER>,
-               sc::transition<EV_MOVE_STOP, wait_for_command>  > reactions;
+               sc::custom_reaction< evTimer >,
+               sc::transition< evMoveStop, wait_for_command > > reactions;
 };
 
-struct wait_and_try_again : TimedState<wait_and_try_again, MotionBase> {
+struct wait_and_try_again : TimedState< wait_and_try_again, MotionBase > {
        Timer wait_tout;
        wait_and_try_again(my_context ctx) : base_state(ctx) {
                stop();
-               runTimer(wait_tout, 1000, new EV_TIMER());
+               runTimer(wait_tout, 1000, new evTimer());
        }
-       sc::result react(const EV_TIMER &) {
+       sc::result react(const evTimer &) {
                switch (recalculate_trajectory()) {
                        // We can go to the target:
                        case TARGET_OK: return transit<movement>();
@@ -435,17 +433,17 @@ struct wait_and_try_again : TimedState<wait_and_try_again, MotionBase> {
                                /* FIXME (Filip): this could happen forever */ 
                        // Fatal error during planning
                        case TARGET_ERROR: 
-                               robot.sched.queue_event(robot.MAIN, new EV_MOTION_DONE());
+                               robot.sched.queue_event(robot.MAIN, new evMotionDone());
                                ul_logerr("Target error\n");
                }
                return discard_event();
        }
-       sc::result react(const EV_TRAJECTORY_DONE &) {
-               robot.sched.queue_event(robot.MAIN, new EV_MOTION_DONE());
+       sc::result react(const evTrajectoryDone &) {
+               robot.sched.queue_event(robot.MAIN, new evTrajectoryDone());
                return transit<wait_for_command>();
        }
        typedef mpl::list<
-               sc::custom_reaction<EV_TIMER>,
-               sc::custom_reaction<EV_TRAJECTORY_DONE>,
-               sc::transition<EV_MOVE_STOP, wait_for_command> > reactions;
+               sc::custom_reaction< evTimer >,
+               sc::custom_reaction< evTrajectoryDone >,
+               sc::transition< evMoveStop, wait_for_command > > reactions;
 };
index 1063df34a266fc0e9f6f4725c97416247e564a54..fc4bf5dddabab5123faa88cc2fd6396496121b0a 100644 (file)
@@ -8,9 +8,7 @@
  * License: GNU GPL v.2
  */
 
-//#define FSM_MAIN
 #include <robot.h>
-//#include <fsm.h>
 #include <unistd.h>
 #include <math.h>
 #include <movehelper.h>
@@ -22,8 +20,6 @@
 #include <error.h>
 #include "actuators.h"
 #include <trgen.h>
-//#include "match-timing.h"
-//#include "robot.h"
 #include "movehelper.h"
 #include <ul_log.h>
 #include "fsmhead.hpp"
 
 struct TrajectoryConstraints tcFast, tcSlow, tcVerySlow;
 
-/************************************************************************
- * FSM STATES DECLARATION
- ************************************************************************/
-
-//FSM_STATE_DECL(init);
-//FSM_STATE_DECL(wait_for_start);
-/* movement states - buillon */
-//FSM_STATE_DECL(aproach_buillon);
-/* Pushing the bottle */
-//FSM_STATE_DECL(push_bottle);
-
-/*
-FSM_STATE(init)
-{
-       switch (FSM_EVENT) {
-               case EV_ENTRY:
-                       
-                       FSM_TRANSITION(wait_for_start);
-                       break;
-               default:
-                       break;
-       }
-}
-*/
 void set_initial_position()
 {
        // TODO define initial position
@@ -75,94 +47,10 @@ void actuators_home()
        // unset the homing request
        //act_lift(0, 0, 0);
 }
-/*
-FSM_STATE(wait_for_start)
-{
-       pthread_t thid;
-       #ifdef WAIT_FOR_START
-               ul_logdeb("WAIT_FOR_START mode set\n");
-       #else
-               ul_logdeb("WAIT_FOR_START mode NOT set\n");
-       #endif
-       #ifdef COMPETITION
-               ul_logdeb("COMPETITION mode set\n");
-       #else
-               ul_logdeb("COMPETITION mode NOT set\n");
-       #endif
-       switch (FSM_EVENT) {
-               case EV_ENTRY:
-                       pthread_create(&thid, NULL, timing_thread, NULL);
-#ifdef WAIT_FOR_START
-                       FSM_TIMER(1000);
-                       break;
-#endif
-               case EV_START:*/
-                       /* start competition timer */
-/*                     sem_post(&robot.starT);
-                       actuators_home();
-                       set_initial_position();
-                       FSM_TRANSITION(aproach_buillon);
-                       break;
-               case EV_TIMER:
-                       FSM_TIMER(1000);
-                       // We set initial position periodically in
-                       // order for it to be updated on the display
-                       // if the team color is changed during waiting
-                       // for start.
-                       set_initial_position();
-                       if (robot.start_state == START_PLUGGED_IN)
-                               actuators_home();
-                       break;
-               case EV_RETURN:
-               case EV_MOTION_ERROR:
-               case EV_MOTION_DONE:
-               //case EV_VIDLE_DONE:
-               case EV_SWITCH_STRATEGY:
-                       DBG_PRINT_EVENT("unhandled event");
-                       break;
-               case EV_EXIT:
-                       break;
-               default:
-                       break;
-       }
-}
-
-FSM_STATE(aproach_buillon)
-{
-       switch(FSM_EVENT) {
-               case EV_ENTRY:
-                       robot.move_helper.trajectory_new(&tcSlow).
-                               add_point_trans( 0.65, PLAYGROUND_HEIGHT_M - (ROBOT_WIDTH_M/2.0)).
-                               add_point_trans( 0.65, 1.3).
-                               add_final_point_trans( 0.5, 1.1, NO_TURN());
-                       break;
-               case EV_MOTION_DONE:
-               case EV_TIMER:
-                       FSM_TRANSITION(push_bottle);
-                       break;
-               default:
-                       break;
-       }
-}
-
-FSM_STATE(push_bottle)
-{
-       switch(FSM_EVENT) {
-               case EV_ENTRY:
-                       robot.move_helper.trajectory_new(&tcSlow).
-                       add_point_trans( 0.64, 0.7).
-                       add_final_point_trans( 0.64 + 0.08, ROBOT_AXIS_TO_FRONT_M + 0.05, ARRIVE_FROM(DEG2RAD(270), 0.10));
-                       break;
-               case EV_MOTION_DONE:
-                       break;
-               default:
-                       break;
-       }
-}*/
 
 struct push_bottle;
 
-struct approachBuillon : TimedSimpleState<approachBuillon, Competing> {
+struct approachBuillon : TimedSimpleState< approachBuillon, Competing > {
        approachBuillon() {
                printf("%s\n", __FUNCTION__);
                set_initial_position();
@@ -171,24 +59,24 @@ struct approachBuillon : TimedSimpleState<approachBuillon, Competing> {
                                add_point_trans( 0.65, 1.3).
                                add_final_point_trans( 0.5, 1.1, NO_TURN());
        }
-       sc::result react(const EV_MOTION_DONE &) {
+       sc::result react(const evMotionDone &) {
                return transit<push_bottle>();
        }
-       typedef sc::custom_reaction<EV_MOTION_DONE> reactions;
+       typedef sc::custom_reaction< evMotionDone > reactions;
 };
 
-struct push_bottle : TimedSimpleState<push_bottle, Competing> {
+struct push_bottle : TimedSimpleState< push_bottle, Competing > {
        push_bottle() {
                printf("%s\n", __FUNCTION__);
                robot.move_helper.trajectory_new(&tcSlow).
                        add_point_trans( 0.64, 0.7).
                        add_final_point_trans( 0.64 + 0.08, ROBOT_AXIS_TO_FRONT_M + 0.05, ARRIVE_FROM(DEG2RAD(270), 0.10));
        }
-       sc::result react(const EV_MOTION_DONE &) {
-               //robot.sched.terminate();
+       sc::result react(const evMotionDone &) {
+               robot.sched.terminate();
                return discard_event();
        }
-       typedef sc::custom_reaction<EV_MOTION_DONE> reactions;
+       typedef sc::custom_reaction< evMotionDone > reactions;
 };
 /************************************************************************
  * MAIN FUNCTION
@@ -208,18 +96,8 @@ int main()
        robot.obstacle_avoidance_enabled = true;
        robot.team_color = VIOLET;
 
-       //robot.fsm.main.debug_states = 1;
-       //robot.fsm.motion.debug_states = 1;
-       //robot.fsm.act.debug_states = 1;
-
-       //robot.fsm.main.state = &fsm_state_main_init;
-       //robot.team_color = BLUE;
-       //robot.fsm.main.transition_callback = trans_callback;
-       //robot.fsm.motion.transition_callback = move_trans_callback;
-
         rv = robot.start();
        if (rv) error(1, errno, "robot_start() returned %d\n", rv);
-       //robot.sched();
        robot.destroy();
 
        return 0;
index 7e022b75ee5275a9938e74a36218fbc3e9c7a857..407a4d0fd83c2da33275593b2e3084c941775543 100644 (file)
@@ -130,14 +130,14 @@ static void notify_fsm(bool done, double error)
        if (error > MAX_POS_ERROR_M) {
                if (!lost_sent) {
                        lost_sent = true;
-                       robot.sched.queue_event(robot.MOTION, new EV_TRAJECTORY_LOST());
+                       robot.sched.queue_event(robot.MOTION, new evTrajectoryLost());
                }
        } else {
                lost_sent = false;
                if (done) {
                        if (error < CLOSE_TO_TARGET_M || !done_sent) {
                                done_sent = true;
-                               robot.sched.queue_event(robot.MOTION, new EV_TRAJECTORY_DONE());
+                               robot.sched.queue_event(robot.MOTION, new evTrajectoryDone());
                        }
                } else {
                        done_sent = false;
@@ -171,7 +171,7 @@ static void check_for_collision_in_future(Trajectory *traj, double current_time)
                        continue;
                if (map->cells[ycell][xcell].detected_obstacle > 0) {
                        if (sem_trywait(&recalculation_not_running) == 0) {
-                               robot.sched.queue_event(robot.MOTION, new EV_OBSTACLE());
+                               robot.sched.queue_event(robot.MOTION, new evObstacle());
                                break;
                        }
                }
index 0513fd3d4c95a02cf587a275dbe96365618ded99..7e5d2a8a6cbdce4eaf87fc16a9f21bb8368926d2 100644 (file)
@@ -114,7 +114,7 @@ MoveHelper& MoveHelper::add_final_point_notrans(double x_m, double y_m, move_tar
                target->heading = heading;
                target->trajectory = t;
                target->use_planning = false;
-               robot.sched.queue_event(robot.MOTION, new EV_NEW_TARGET(target));
+               robot.sched.queue_event(robot.MOTION, new evNewTarget(target));
                t = NULL; 
        } else {
                ul_logerr("%s: Error - No trajectory\n", __FUNCTION__);
@@ -147,7 +147,7 @@ bool MoveHelper::get_arrive_from_point(double target_x_m, double target_y_m, mov
  */
 void MoveHelper::stop()
 {
-       robot.sched.queue_event(robot.MOTION, new EV_MOVE_STOP());
+       robot.sched.queue_event(robot.MOTION, new evMoveStop());
 }
 
 
@@ -193,7 +193,7 @@ void MoveHelper::goto_notrans(double x, double y, move_target_heading heading, T
        if (tc) target->tc = *tc;
        else target->tc = trajectoryConstraintsDefault;
 
-       robot.sched.queue_event(robot.MOTION, new EV_NEW_TARGET(target));
+       robot.sched.queue_event(robot.MOTION, new evNewTarget(target));
 }
 
 /** 
@@ -224,7 +224,7 @@ void MoveHelper::move_by(double distance, move_target_heading heading, Trajector
        target->y = y;
        target->heading = heading;
        target->trajectory = t;
-       robot.sched.queue_event(robot.MOTION, new EV_NEW_TARGET(target));
+       robot.sched.queue_event(robot.MOTION, new evNewTarget(target));
        delete t;
 }
 
index 284b9fe5ed801124b6eee6b8732650f2c8849ad7..3162f3a682a382ba3ba5221adb4ba2eb46faedfa 100644 (file)
@@ -210,7 +210,7 @@ void Robot::destroy()
 
        robottype_roboorte_destroy(&orte);
 
-       sched.terminate();
+//     sched.terminate();
 //     fsm_destroy(&robot.fsm.main);
 //     fsm_destroy(&robot.fsm.motion);
 //     fsm_destroy(&robot.fsm.act);
index d5a275b629a3d9f942f617d218aae36a4920f259..46fbb5b6ecbeb0c10c6fe963bfe317a82ab2cb28 100644 (file)
@@ -289,7 +289,7 @@ void rcv_robot_cmd_cb(const ORTERecvInfo *info, void *vinstance,
                                        robot.status[COMPONENT_START] = STATUS_OK;
                                        /* Competition starts when plugged out */
                                        if (instance->start_condition) {
-                                               robot.sched.queue_event(robot.MAIN, new EV_START());
+                                               robot.sched.queue_event(robot.MAIN, new evStart());
                                                //FSM_SIGNAL(MAIN, EV_START, NULL);
                                                robot.start_state = COMPETITION_STARTED;
                                                ul_logmsg("STARTED\n");
@@ -391,10 +391,7 @@ void rcv_jaws_status_cb(const ORTERecvInfo *info, void *vinstance,
                             instance->response.right != last_response_right &&
                            instance->response.left == act.jaw_left_get_last_request() &&
                            instance->response.left == act.jaw_right_get_last_request())
-                               robot.sched.queue_event(robot.MAIN, new EV_JAWS_DONE());
-                                               
-//                       FSM_SIGNAL(MAIN, EV_JAWS_DONE, NULL);
-
+                               robot.sched.queue_event(robot.MAIN, new evJawsDone());
                        last_response_left = instance->response.left;
                        last_response_right = instance->response.right;
                        break;
@@ -420,9 +417,7 @@ void rcv_lift_status_cb(const ORTERecvInfo *info, void *vinstance,
 
                         if (instance->response != last_response &&
                             instance->response == act.lift_get_last_request())
-                         robot.sched.queue_event(robot.MAIN, new EV_LIFT_DONE());
-                                               
-//                                 FSM_SIGNAL(MAIN, EV_LIFT_DONE, NULL);
+                         robot.sched.queue_event(robot.MAIN, new evLiftDone());
                         last_response = instance->response;
                         break;
                 case DEADLINE:
@@ -443,9 +438,7 @@ void rcv_robot_switches_cb(const ORTERecvInfo *info, void *vinstance,
 
                        if (!last_strategy && instance->strategy) {
                                        /* strategy switching */
-                                       robot.sched.queue_event(robot.MAIN, new EV_SWITCH_STRATEGY());
-                                               
-//                                     FSM_SIGNAL(MAIN, EV_SWITCH_STRATEGY, NULL);
+                                       robot.sched.queue_event(robot.MAIN, new evSwitchStrategy());
                        }
                        last_strategy = instance->strategy;
                        break;
@@ -462,12 +455,12 @@ void rcv_robot_bumpers_cb(const ORTERecvInfo *info, void *vinstance,
        switch (info->status) {
                case NEW_DATA:
                        if (instance->bumper_right_across || instance->bumper_left_across || instance->bumper_rear_left || instance->bumper_rear_right)
-robot.sched.queue_event(robot.MOTION, new EV_OBSTACLE_BEHIND());
+robot.sched.queue_event(robot.MOTION, new evObstacleBehind());
                                                
                          //                            FSM_SIGNAL(MOTION, EV_OBSTACLE_BEHIND, NULL);
 
                        if (instance->bumper_left || instance->bumper_right) {
-      robot.sched.queue_event(robot.MOTION, new EV_OBSTACLE_SIDE());
+      robot.sched.queue_event(robot.MOTION, new evObstacleSide());
                                                
                          //                            FSM_SIGNAL(MOTION, EV_OBSTACLE_SIDE, NULL);
                        }
index 8d672bed6d81b27bdfeb3c1cf60d2970d7c56ecd..8df03b2dace494192bb278580b70f4a87fdab6f0 100644 (file)
 struct on;
 struct off;
 
-struct FSMMain : boost::statechart::asynchronous_state_machine<FSMMain, on, Scheduler> {
+struct FSMMain : boost::statechart::asynchronous_state_machine< FSMMain, on, Scheduler > {
        FSMMain(my_context ctx) : my_base(ctx) {
                printf("%s\n", __FUNCTION__);
        }
 };
 
-struct on : TimedState <on, FSMMain> {
+struct on : TimedState< on, FSMMain > {
        Timer onTime;
        on(my_context ctx) : base_state(ctx) {
                act.camera_on();
-               runTimer(onTime, 10000, new EV_TIMER());
+               runTimer(onTime, 10000, new evTimer());
        }
-       typedef sc::transition<EV_TIMER, off> reactions;
+       typedef sc::transition< evTimer, off > reactions;
 };
 
 
-struct off : TimedState <off, FSMMain> {
+struct off : TimedState< off, FSMMain > {
        Timer offTime;
        off(my_context ctx) : base_state(ctx) {
                act.camera_off();
-               runTimer(offTime, 10000, new EV_TIMER());
+               runTimer(offTime, 10000, new evTimer());
        }
-       typedef sc::transition<EV_TIMER, on> reactions;
+       typedef sc::transition< evTimer, on > reactions;
 };
 
 int main(int argc, char *argv[])
index d845a722c63b570c6acebaab9f34b9d07867a0c1..bad310add552d5698a43bbe4ff11d75af39d26c7 100644 (file)
@@ -29,22 +29,22 @@ struct rectangle;
 struct Wait;
 struct init;
 
-struct FSMMain : boost::statechart::asynchronous_state_machine<FSMMain, init, Scheduler> {
+struct FSMMain : boost::statechart::asynchronous_state_machine< FSMMain, init, Scheduler > {
        FSMMain(my_context ctx) : my_base(ctx) {
                printf("%s\n", __FUNCTION__);
        }
 };
 
-struct init : TimedState<init, FSMMain> {
+struct init : TimedState< init, FSMMain > {
        Timer timeTest;
        init(my_context ctx) : base_state(ctx) {
-               runTimer(timeTest, 10, new EV_TIMER());
+               runTimer(timeTest, 10, new evTimer());
        }
-       sc::result react (const EV_TIMER &) {
+       sc::result react (const evTimer &) {
                robot.set_est_pos_trans(0.5, 0.5, DEG2RAD(0));
-               return transit<rectangle>();
+               return transit< rectangle >();
        }
-       typedef sc::custom_reaction<EV_TIMER> reactions;
+       typedef sc::custom_reaction< evTimer > reactions;
 };
 
 
@@ -80,21 +80,21 @@ void follow_rectangle()
        //backward = !backward;
 }
 
-struct rectangle : TimedSimpleState<rectangle, FSMMain>
+struct rectangle : TimedSimpleState< rectangle, FSMMain >
 {
        rectangle() {
                follow_rectangle();
        }
-       typedef sc::transition<EV_MOTION_DONE, Wait> reactions;
+       typedef sc::transition< evMotionDone, Wait > reactions;
 };
 
-struct Wait : TimedState<Wait, FSMMain>
+struct Wait : TimedState< Wait, FSMMain >
 {
        Timer waitTout;
        Wait(my_context ctx) : base_state(ctx) {
-               runTimer(waitTout, 1000, new EV_TIMER());
+               runTimer(waitTout, 1000, new evTimer());
        }
-       typedef sc::transition<EV_TIMER, rectangle> reactions;
+       typedef sc::transition< evTimer, rectangle> reactions;
 };
 
 /*void transition_callback(struct robo_fsm *fsm)