00001
00002
00003
00004
00005 #ifndef CAJUN_PCAN_PCI_H
00006 #define CAJUN_PCAN_PCI_H
00007
00008 #include "pcan_frame.H"
00009
00010
00011 namespace cajun
00012 {
00013 using namespace pcan;
00014
00015 struct iteris_data
00016 {
00017 bool vehicle_speed_status;
00018 bool system_status;
00019 bool warning_on_left;
00020 bool warning_on_right;
00021 bool type_of_lanemark_on_left;
00022 bool type_of_lanemark_on_right;
00023 bool vehicle_crossing_left_lane;
00024 bool vehicle_crossing_right_lane;
00025 bool left_lateral_offset_validity;
00026 bool right_lateral_offset_validity;
00027 bool lane_curvature_validity;
00028 bool lane_angle_validity;
00029
00030 unsigned num_of_lines_on_right;
00031 unsigned num_of_lines_on_left;
00032 double lateral_offset_to_left_lane;
00033 double lateral_offset_to_right_lane;
00034 double bot_angle_wrt_lane;
00035 double lane_curvature;
00036 unsigned lane_detection_dist;
00037 };
00038
00039 class pcan_pci_t
00040 {
00041 public:
00042 pcan_pci_t ();
00043 ~pcan_pci_t ();
00044
00045 void handle_input (int fd);
00046 bool send_data_to_iteris (int fd, double velocity, bool left_turn_signal,
00047 bool right_turn_signal, bool set_warning_suppression);
00048
00049 bool send_data_to_ibeo (int fd, double steering_angle);
00050
00051 void debug (bool flag) { m_debug = flag; }
00052
00053 class observer_t
00054 {
00055 public:
00056 enum message_t
00057 {
00058 STATUS_OK,
00059 STATUS_FULL_BUFFER,
00060 STATUS_GARBAGE_DATA,
00061 UNKNOWN_MESSAGE_FORMAT,
00062 ERROR_DECODING_DATA,
00063 };
00064
00065 virtual ~observer_t () {}
00066
00067 virtual void publish_status (double tstamp_, message_t msg_) {}
00068
00069 virtual void publish_emc_data () {}
00070 virtual void steering (double tstamp_, unsigned value_) {}
00071 virtual void throttle (double tstamp_, unsigned value_) {}
00072 virtual void set_bot_speed (double speed_) {}
00073 virtual void set_generic_integer (unsigned value_) {}
00074 virtual void set_command_value (unsigned value_) {}
00075 virtual void set_vehicle_data (bool coil_pulse_, bool brake_lights_, bool park_lights_,
00076 bool steering_servo_engaged_, bool remote_off_switch_,
00077 bool throttle_clutch_engaged_) {}
00078 virtual void set_ignition_status (bool ignition_) {}
00079 virtual void set_battery_voltage (double battery_1_, double battery_2_) {}
00080 virtual void set_timestamp_for_vehicle_data (double tstamp_) {}
00081
00082
00083 virtual void iteris_lane_data (iteris_data ) {}
00084 };
00085
00086 void register_observer (observer_t *observer)
00087 { m_observer = observer; }
00088
00089 protected:
00090 observer_t *m_observer;
00091 bool m_debug;
00092 bool m_iteris_tracking;
00093
00094 void extract_iteris_frame (pcan::pcan_frame_t &frame_);
00095 void extract_emc_frame (pcan::pcan_frame_t &frame_);
00096 };
00097 };
00098
00099
00100 #endif