00001 // Copyright (C) 2003, 2004 Pablo Mejia 00002 00003 00004 #ifndef CAJUN_ROUTE_H 00005 #define CAJUN_ROUTE_H 00006 00007 00008 #include "proj_util.H" 00009 00010 00011 #include <vector> 00012 #include <cassert> 00013 00014 00015 namespace cajun 00016 { 00017 class route_t 00018 { 00019 public: 00020 // Native format 00021 bool read (char const *path); 00022 void write (char const *path = NULL) const; 00023 00024 // External formats 00025 bool read_RDDF (char const *path, proj_t proj); 00026 bool read_relative (char const *path, 00027 double x, double y, double heading); 00028 00029 void relocate (double bot_x, double bot_y, double bot_heading); 00030 // FIXME: This is a hack for the simulator. 00031 // FIXME: Fix the simulator to not need this and remove it. 00032 void normalize (void); 00033 00034 00035 struct waypoint_t 00036 { 00037 unsigned id; 00038 00039 double x; // meters 00040 double y; // meters 00041 double lateral_boundary; // meters 00042 double speed_limit; // meters / second 00043 00044 // Derived fields (calculated from above) 00045 double azimuth; // radians 00046 double seek_radius; // meters 00047 double segment_length; // meters 00048 double path_length; // meters 00049 }; 00050 00051 unsigned num_waypoints (void) const 00052 { return (m_waypoint.size ()); } 00053 00054 waypoint_t waypoint (unsigned i) const 00055 { 00056 assert (i < num_waypoints ()); 00057 return (m_waypoint[i]); 00058 } 00059 00060 std::vector<waypoint_t> get_waypoints (void) const 00061 { return (m_waypoint); } 00062 00063 00064 void add_waypoint (waypoint_t w_); 00065 void update_derived_fields (void); 00066 00067 protected: 00068 std::vector<waypoint_t> m_waypoint; 00069 }; 00070 }; 00071 00072 00073 00074 #endif