00001
00002
00003 #ifndef CAJUN_RAY_SENSOR_H
00004 #define CAJUN_RAY_SENSOR_H
00005
00006 #define DELAY_RAY_SENSOR 0.1
00007
00008 #include "sim_world_object.H"
00009 #include "queue_generator.H"
00010 #include "components.H"
00011 #include "timer.H"
00012
00013 namespace cajun
00014 {
00015 class ray_sensor_observer_t;
00016
00017 class ray_sensor_t: public components_t
00018 {
00019 friend class ray_sensor_observer_t;
00020 public:
00021
00022 ray_sensor_t (dSpaceID s1,dGeomID ground, sim_world_object_t *object,
00023 timer_t * timer, int id, double length, double pos[3],
00024 double orientation[3]);
00025
00026 virtual ~ray_sensor_t ();
00027
00028 void test_ray_sensor_collision (double *px,double *py, double *pz);
00029 void get_orientation_matrix (double orientation_matrix[3][4]);
00030 void get_ray_beam_position (double start_position[3],double end_position[3]);
00031 void update_position ();
00032 void update_position (dBodyID carb);
00033 void simulate_component ();
00034 void command (int cmd, double value);
00035 private:
00036 dGeomID m_raySensor_ray;
00037 double m_end_pos[3];
00038 double m_raySensorRange;
00039 double m_raySensorDepth;
00040
00041 dGeomID m_thisGround;
00042 dSpaceID m_thisSpace;
00043 sim_world_object_t *m_robot;
00044 ray_sensor_observer_t *m_ray_sensor_observer;
00045
00046 int m_ray_sensor_id;
00047 };
00048
00050 class ray_sensor_observer_t : public timer_t::observer_t
00051 {
00052 public:
00053 ray_sensor_observer_t (ray_sensor_t *ray_sensor ,
00054 double interval_v, int id);
00055 bool timeout (double currTime);
00056 virtual ~ray_sensor_observer_t ();
00057 private:
00058 ray_sensor_t *m_ray_sensor;
00059 int m_ray_sensor_id;
00060 };
00061 };
00062 #endif