00001 // Copyright (C) 2004 University of Louisiana at Lafayette 00002 // Authors: Suresh Golconda, Nitin, Arun Pratap 00003 00004 #ifndef CAJUN_ROBOT_VISUALIZATION_H 00005 #define CAJUN_ROBOT_VISUALIZATION_H 00006 00007 #define MAX_TRACE_POINTS 500 00008 #define NUM_BOT_TRACE_OPTION_VALUE 3 00009 00010 #include <vector> 00011 #include "draw_lasers.H" 00012 #include <list> 00013 00014 namespace cajun 00015 { 00016 struct trace_pos_t 00017 { 00018 double x; 00019 double z; 00020 }; 00021 00022 class robot_trace_t 00023 { 00024 private: 00025 // true= draw boxs at traces, else draw joining lines 00026 // 0 - do not trace, 1- trace by square points, 2 -by lines 00027 unsigned m_trace_bot_position; 00028 // true = draw path followed by robot, else do not draw 00029 trace_pos_t m_trace_pos[MAX_TRACE_POINTS]; 00030 00031 unsigned m_start_index; 00032 double m_cbviz_origin[3]; 00033 // size of the dot at trace position 00034 float m_traceDistance; 00035 // number of trace points noted 00036 int size; 00037 00038 float m_traceSize; 00039 inline unsigned index (unsigned index_) 00040 { 00041 return ((m_start_index + index_) % MAX_TRACE_POINTS); 00042 } 00043 inline void pop_back () 00044 { 00045 if (size > 0) 00046 { 00047 m_start_index = ((m_start_index + 1) % (MAX_TRACE_POINTS)) ; 00048 size--; 00049 } 00050 } 00051 void push_entry (double val_[3]); 00052 void draw_trace_by_lines (); 00053 void draw_trace_by_box (); 00054 public: 00055 bool m_draw_line_to_bumper; 00056 robot_trace_t (double cbviz_origin[3], conf_t &viz_conf_); 00057 void draw_robot_trace (); 00058 void note_robot_position (double bot_pos[3]); 00059 void toggle_display_mode (); 00060 }; 00061 00062 class draw_robot_t : public component_interface_t 00063 { 00064 private: 00065 world_state_t *m_world_state; 00066 Model *pCajunbot; 00067 Model *pWheel; 00068 double m_robot_width; 00069 double m_robot_length; 00070 double m_robot_height; 00071 double m_wheel_radius; 00072 double m_wheel_width; 00073 double m_max_linear_velocity; 00074 double m_throttle_rate; 00075 double m_lever_rate; 00076 double cbviz_origin[3]; 00077 bool m_display; 00078 motion_data_t m_motion_data; 00079 nav_data_t m_nav_data; 00080 drive_data_t m_drive_data; 00081 bool m_textured_bot; 00082 int m_viz_mode; 00083 bool m_draw_bot; 00084 bool m_draw_mesh; 00085 00086 double m_pos[3]; 00087 double m_bumper_pos [3]; 00088 double m_orient[16]; 00089 00090 laser_visualization_t *m_laser_visualization; 00091 void draw_robot_heading (double pos[3]); 00092 void draw_line_to_bumper (); 00093 bool get_bumper_position (double pos[3]); 00094 public: 00095 robot_trace_t *m_robot_trace; 00096 draw_robot_t (double cbviz_origin_pos[3], 00097 char const * robot_model_file, 00098 conf_t &viz_conf_, int viz_mode, 00099 world_state_t *ws_); 00100 00101 void read_config_file (char const*); 00102 bool get_robot_position (double pos[3]); 00103 bool get_robot_orientation_matrix (double rot[16]); 00104 bool get_robot_orientation_euler (double rot[3]); 00105 double get_robot_height (); 00106 double get_robot_length (); 00107 double get_robot_width (); 00108 00109 void init_data (); 00110 void display_robot_components (int component_type); 00111 void update_data (double bot_pos_[3]); 00112 void display (double pos_[3]); 00113 void toggle_display (); 00114 }; 00115 }; 00116 #endif