/*-------------------------------------------------------------------- * project ....: Darpa Urban Challenge 2007 * authors ....: Team AnnieWAY * organization: Transregional Collaborative Research Center 28 / * Cognitive Automobiles * creation ...: xx/xx/2007 * revisions ..: $Id:$ ---------------------------------------------------------------------*/ #include "aw_StWaitForActivation.hpp" #include "aw_StActive.hpp" #include "aw_StPause.hpp" #include "aw_StReplan.hpp" namespace vlr { StWaitForActivation::StWaitForActivation(my_context ctx) : my_base(ctx), kogmo_base(std::string("StWaitForActivation")), moved(false) { waitUntil.now(); waitUntil += MIN_WAIT_ACTIVATION; ChsmPlanner& planner = context (); if (planner.distance(planner.robot_pose_in_pause_) > TRIGGER_DIST_CLEAR_HISTORY) { planner.addMessage("car moved while in pause -> clearing history"); context ().clear_deep_history (); moved = true; } else { planner.addMessage("resuming with history"); } context ().velocity_desired_ = 0; } StWaitForActivation::~StWaitForActivation() { } sc::result StWaitForActivation::react(const EvProcess&) { if (detectedErrornousTransitions()) return transit (); ChsmPlanner& planner = context (); Topology* topology = planner.topology; // set velocity to 0 -> park mode context ().generateStopTrajectory(); context ().vehiclecmd.beeper_on = 1; context ().vehiclecmd.hazard_lights_on = 1; if (isExpired(waitUntil)) { // Transition: Replanning (because ego vehicle is off track) if (topology->isOffTrack() || moved) return transit (); // Transition: History restoren return transit (); } else { return forward_event(); } } sc::result StWaitForActivation::react(const sc::exception_thrown&) { if (detectedErrornousTransitions()) return transit (); try { throw ; } /* we can catch special exceptions here and handle them catch ( const std::runtime_error & ) { // only std::runtime_errors will lead to a transition // to Defective ... return transit< StError >(); }*/ catch ( ... ) { return forward_event(); } } } // namespace vlr