Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef __CONTROLLER_HH__
00013 #define __CONTROLLER_HH__
00014
00015 #include "navigator_internal.h"
00016
00017 class Controller
00018 {
00019 public:
00020
00021 typedef enum
00022 {
00023
00024 OK,
00025 Caution,
00026 Beware,
00027 Unsafe,
00028 Blocked,
00029
00030 Collision,
00031 Finished,
00032 NotApplicable,
00033 NotImplemented,
00034 N_results
00035 } result_t;
00036
00037
00038 const char *result_name(result_t result)
00039 {
00040 static const char *rname[N_results] =
00041 {
00042 "OK",
00043 "Caution",
00044 "Beware",
00045 "Unsafe",
00046 "Blocked",
00047 "Collision",
00048 "Finished",
00049 "NotApplicable",
00050 "NotImplemented",
00051 };
00052 return rname[result];
00053 }
00054
00055 Controller(Navigator *navptr, int _verbose)
00056 {
00057 verbose = _verbose;
00058 nav = navptr;
00059
00060
00061 course = nav->course;
00062 estimate = &nav->estimate;
00063 navdata = &nav->navdata;
00064 obstacle = nav->obstacle;
00065 odom = nav->odometry;
00066 order = &nav->order;
00067 pops = nav->pops;
00068 config_ = &nav->config_;
00069
00070
00071
00072 reset_me();
00073 };
00074
00075 virtual ~Controller() {};
00076
00077
00078 virtual result_t control(pilot_command_t &pcmd)
00079 {
00080 return OK;
00081 };
00082
00083
00084 virtual void reset(void) {};
00085
00086
00087 virtual void trace(const char *name, const pilot_command_t &pcmd)
00088 {
00089 ROS_DEBUG_NAMED("trace", "%s: pcmd = (%.3f, %.3f) ",
00090 name, pcmd.velocity, pcmd.yawRate);
00091 }
00092
00093
00094 virtual void trace(const char *name, const pilot_command_t &pcmd,
00095 result_t res)
00096 {
00097 ROS_DEBUG_NAMED("trace", "%s: pcmd = (%.3f, %.3f), result = %s",
00098 name, pcmd.velocity, pcmd.yawRate,
00099 result_name(res));
00100 }
00101
00102
00103 virtual void trace_reset(const char *name)
00104 {
00105 if (verbose >= 2)
00106 ART_MSG(5, "%s::reset()", name);
00107 }
00108
00109 protected:
00110 Navigator *nav;
00111 int verbose;
00112
00113
00114 Course *course;
00115 Obstacle *obstacle;
00116 nav_msgs::Odometry *estimate;
00117 art_msgs::NavigatorState *navdata;
00118 nav_msgs::Odometry *odom;
00119 art_msgs::Order *order;
00120 PolyOps *pops;
00121 const Config *config_;
00122
00123
00124 virtual void reset_me(void) {};
00125 };
00126
00127 #endif // __CONTROLLER_HH__