sc::custom_reaction<evTimer>,
sc::custom_reaction<evMotionDone>,
sc::transition<evMotionError, move_around>,
- sc::transition<evEntry, approach_target> > reactions;
+ sc::transition<evTargetDetected, approach_target> > reactions;
void do_work() {
// DBG_PRINT_EVENT("survey");
#if 1 // FIXME just for test
}
#endif
// target detected, go to the target
- robot.sched.queue_event(robot.MAIN, new evEntry());
+ robot.sched.queue_event(robot.MAIN, new evTargetDetected());
// DBG_PRINT_EVENT("Target detected!");
} else {
// no target detected in this heading, turn 120°
approach_target() {
// DBG_PRINT_EVENT("approaching target");
target_cntr = 0;
- max_target = detected_target.size();
- x_target = detected_target[target_cntr].x;
- y_tatget = detected_target[target_cntr].y;
- target_cntr++;
- printf("target %d / %d\n", target_cntr, max_target);
-
- get_approach_point(x_target, y_tatget, &x_approach, &y_approach, &phi_approach);
- robot.move_helper.goto_notrans(x_approach, y_approach, ARRIVE_FROM(phi_approach, 0.1), &tcSlow);
-
+ do_work();
}
~approach_target() {
target_cntr = 0;
return discard_event();
} else if (!robot.target_valid && (target_cntr < max_target)) {
// go for next target if any
- return transit<approach_target>();
+ do_work();
+ return discard_event();
} else {
// go to new point and survey
return transit<move_around>();
sc::custom_reaction<evMotionDone>,
sc::custom_reaction<evReturn>,
sc::custom_reaction<evMotionError> > reactions;
-
+ void do_work() {
+ max_target = detected_target.size();
+ x_target = detected_target[target_cntr].x;
+ y_tatget = detected_target[target_cntr].y;
+ target_cntr++;
+ printf("target %d / %d\n", target_cntr, max_target);
+
+ get_approach_point(x_target, y_tatget, &x_approach, &y_approach, &phi_approach);
+ robot.move_helper.goto_notrans(x_approach, y_approach, ARRIVE_FROM(phi_approach, 0.1), &tcSlow);
+ }
};
struct move_around : TimedSimpleState<move_around, competing> {