road.h
Go to the documentation of this file.
00001 /* -*- mode: C++ -*-
00002  *
00003  *  Navigator road controller finite state machine
00004  *
00005  *  Copyright (C) 2007, 2010, Austin Robot Technology
00006  *  License: Modified BSD Software License Agreement
00007  *
00008  *  $Id: road.h 1639 2011-08-11 23:39:23Z jack.oquin $
00009  */
00010 
00011 #ifndef __ROAD_HH__
00012 #define __ROAD_HH__
00013 
00014 #include <art_nav/NavRoadState.h>
00015 #include "NavRoadEvent.h"
00016 
00017 //class Evade;
00018 class FollowLane;
00019 class FollowSafely;
00020 class Halt;
00021 class Passing;
00022 class NavTimer;
00023 //class RealZone;
00024 class Uturn;
00025 
00026 class Road: public Controller
00027 {
00028 public:
00029 
00030   Road(Navigator *navptr, int _verbose);
00031   ~Road();
00032   result_t control(pilot_command_t &pcmd);
00033   void reset(void);
00034 
00035   NavRoadState State(void)
00036   {
00037     return state;
00038   }
00039 
00040 private:
00041 
00042   bool passing_first;
00043 
00044   // state transition action method pointer
00045   typedef result_t (Road::*action_t)(pilot_command_t &pcmd);
00046 
00047   // state transition table entry
00048   typedef struct
00049   {
00050     NavRoadState next;
00051     action_t     action;
00052   } transtion_t;
00053 
00054   NavRoadState  prev;
00055   NavRoadState  state;
00056   NavRoadEvent  event;                  // current event
00057   NavRoadEvent  pending_event;
00058   Observation::_oid_type crossing_observer;
00059   Course::direction_t lane_direction;
00060   transtion_t   ttable[NavRoadEvent::N_events][NavRoadState::N_states];
00061 
00062   // ActionInWaitStop() state:
00063   int32_t prev_nobjects;                // previous number of cars
00064 
00065   // subordinate controllers
00066   //Evade       *evade;
00067   FollowLane    *follow_lane;
00068   FollowSafely  *follow_safely;
00069   Halt          *halt;
00070   Passing       *passing;
00071   Uturn *uturn;
00072   //RealZone    *zone;
00073 
00074   // timers
00075   NavTimer              *passing_timer;
00076   NavTimer              *precedence_timer;
00077   NavTimer              *roadblock_timer;
00078   NavTimer              *stop_line_timer;
00079 
00080   // add a transition to the table
00081   void Add(NavRoadEvent::event_t event, action_t action,
00082            NavRoadState::state_t from_state, NavRoadState::state_t to_state);
00083 
00084   // private methods
00085   void cancel_all_timers(void);
00086   void reset_me(void);
00087   void set_waypt_event(void);
00088 
00090   // state transition action methods
00092 
00093   result_t ActionError(pilot_command_t &pcmd);
00094   result_t ActionFail(pilot_command_t &pcmd);
00095 
00096   // steady state actions
00097 
00098   result_t ActionInBlock(pilot_command_t &pcmd);
00099   result_t ActionInEvade(pilot_command_t &pcmd);
00100   result_t ActionInFollow(pilot_command_t &pcmd);
00101   result_t ActionInInit(pilot_command_t &pcmd);
00102   result_t ActionInPass(pilot_command_t &pcmd);
00103   result_t ActionInUturn(pilot_command_t &pcmd);
00104   result_t ActionInWaitCross(pilot_command_t &pcmd);
00105   result_t ActionInWaitLane(pilot_command_t &pcmd);
00106   result_t ActionInWaitPass(pilot_command_t &pcmd);
00107   result_t ActionInWaitStop(pilot_command_t &pcmd);
00108   result_t ActionInZone(pilot_command_t &pcmd);
00109 
00110   // state entry actions
00111 
00112   result_t ActionEvadeToFollow(pilot_command_t &pcmd);
00113   result_t ActionPassToBlock(pilot_command_t &pcmd);
00114   result_t ActionPassToEvade(pilot_command_t &pcmd);
00115   result_t ActionPassToFollow(pilot_command_t &pcmd);
00116   result_t ActionToBlock(pilot_command_t &pcmd);
00117   result_t ActionToEvade(pilot_command_t &pcmd);
00118   result_t ActionToFollow(pilot_command_t &pcmd);
00119   result_t ActionToPass(pilot_command_t &pcmd);
00120   result_t ActionToUturn(pilot_command_t &pcmd);
00121   result_t ActionToWaitCross(pilot_command_t &pcmd);
00122   result_t ActionToWaitLane(pilot_command_t &pcmd);
00123   result_t ActionToWaitPass(pilot_command_t &pcmd);
00124   result_t ActionToWaitStop(pilot_command_t &pcmd);
00125   result_t ActionToZone(pilot_command_t &pcmd);
00126   result_t ActionWaitPassToFollow(pilot_command_t &pcmd);
00127   result_t ActionZoneToWaitCross(pilot_command_t &pcmd);
00128 };
00129 
00130 #endif // __ROAD_HH__


art_nav
Author(s): Austin Robot Technology, Jack O'Quin
autogenerated on Fri Jan 3 2014 11:08:43