00001
00002
00003
00004
00005 #ifndef CAJUN_STEERING_PID_H
00006 #define CAJUN_STEERING_PID_H
00007
00008 #include "base_steering.H"
00009 #include "interp.H"
00010 #include "integral.H"
00011
00012 namespace cajun
00013 {
00014
00015 class steering_pid_v1_t : public base_steering_t
00016 {
00017 private:
00018 interp_table_t m_kp;
00019 double m_ki;
00020 interp_table_t m_kd;
00021
00022 double m_heading_error;
00023 double m_heading[2];
00024 double m_tstamp[2];
00025
00026 public:
00027 virtual void init()
00028 {
00029 for (unsigned i = 0; i < 2; i++)
00030 {
00031 m_tstamp[i] = 0;
00032 m_heading_error = 0;
00033 m_heading[0] = 0;
00034 }
00035 }
00036 steering_pid_v1_t (const conf_t &conf);
00037 bool read_config (const conf_t &conf);
00038 void steer (steering_data_t &steering,
00039 double steering_position,
00040 guide_data_t const &gd,
00041 heading_data_t const &heading_data,
00042 double speed_, bool forward, bool tight_path);
00043 };
00044
00045 class steering_pid_v2_t : public base_steering_t
00046 {
00047 private:
00048 interp_table_t m_kp;
00049 double m_ki;
00050 interp_table_t m_kd;
00051
00052 integral pidIntegral;
00053
00054 double m_error[2];
00055 double m_tstamp[2];
00056
00057 double previous_steer;
00058 double max_turn;
00059
00060 public:
00061 virtual void init()
00062 {
00063 for (unsigned i = 0; i < 2; i++)
00064 {
00065 m_tstamp[i] = 0;
00066 m_error[i] = 0;
00067 }
00068 previous_steer = 0;
00069 }
00070 steering_pid_v2_t (const conf_t &conf);
00071 bool read_config (const conf_t &conf);
00072 void steer (steering_data_t &steering,
00073 double steering_position,
00074 guide_data_t const &gd,
00075 heading_data_t const &heading_data,
00076 double speed_, bool forward, bool tight_path);
00077 };
00078 };
00079 #endif