laser-nav.h

00001 /*
00002  * @(#)lasernav.h       07/03/21
00003  * 
00004  * License      : GNU GPL v.2
00005  * Description  : Robot navigation using 3 passive laser reflectors.
00006  * Author       : Tran Duy Khanh (www.tran.cz)
00007  */
00008 
00060 /* verbose level 0-3 */
00061 /*#ifndef DEBUG
00062 #define DEBUG 1
00063 #endif*/
00064 
00068 /*define this macro to use red reflectors instead of default blue reflectors*/
00069 /*#define USE_RED_REFLECTORS*/
00070 
00074 #define FWIDTH                  3000
00075 #define FHEIGHT                 2100
00076 #define SET_POINT_A(p)          SET_POINT((p), 0.0, 0.0)
00077 #define SET_POINT_B(p)          SET_POINT((p), FWIDTH, 0.0)
00078 #define SET_POINT_C(p)          SET_POINT((p), FWIDTH, FHEIGHT)
00079 #define SET_POINT_D(p)          SET_POINT((p), 0.0, FHEIGHT)
00080 #define SET_POINT_E(p)          SET_POINT((p), FWIDTH/2, 0)
00081 #define SET_POINT_F(p)          SET_POINT((p), FWIDTH/2, FHEIGHT)
00082 #define SET_POINT_G(p)          SET_POINT((p), FWIDTH/2, FHEIGHT/4)
00083 #define SET_POINT_H(p)          SET_POINT((p), FWIDTH/2, FHEIGHT/4*3)
00084 
00085 /* use red reflectors */
00086 #ifdef USE_RED_REFLECTORS
00087   #define SET_POINT_K(p)        SET_POINT((p), FWIDTH, FHEIGHT/2)
00088   #define SET_POINT_L(p)        SET_POINT((p), 0, FHEIGHT/2)
00089   #define SET_POINT_R1(p)       SET_POINT_K(p)
00090   #define SET_POINT_R2(p)       SET_POINT_A(p)
00091   #define SET_POINT_R3(p)       SET_POINT_D(p)
00092 /* use blue reflectors */
00093 #else
00094   #define SET_POINT_K(p)        SET_POINT((p), 0, FHEIGHT/2)
00095   #define SET_POINT_L(p)        SET_POINT((p), FWIDTH, FHEIGHT/2)
00096   #define SET_POINT_R1(p)       SET_POINT_K(p)
00097   #define SET_POINT_R2(p)       SET_POINT_B(p)
00098   #define SET_POINT_R3(p)       SET_POINT_C(p)
00099 #endif
00100 
00104 #define TIME2ANGLE(p,t)         (((double)t)/((double)p)*2*M_PI)
00105 #define SET_POINT(p,a,b)        ({(p).x=(a); (p).y=(b);})
00106 
00107 /* 2D point */
00108 struct pln_point {
00109         double x;
00110         double y;
00111 };
00112 
00113 /* parameters of line */
00114 struct pln_line {
00115         double k;       /* slope */
00116         double q;       /* y-intercept */
00117 };
00118 
00119 /* complex variable */
00120 struct pln_compl {
00121         double real;
00122         double imag;
00123 };
00124 
00125 /* parameters of circle */
00126 struct pln_circle {
00127         double x0;      /* center */
00128         double y0;      /* center */
00129         double radius;  /* radius */
00130 };
00131 
00132 /* parameters of the quadratic equation with 2 variables */
00133 /* ax*X^2 + bx*X + cx + ay*Y^2 + by*Y + cy = r */
00134 struct pln_fquad_2var {
00135         double ax;
00136         double cx;
00137         double bx;
00138         double ay;
00139         double by;
00140         double cy;
00141         double rs;
00142 };
00143 
00144 /* parameters of the quadratic equation */
00145 struct pln_fquad {
00146         double a;
00147         double b;
00148         double c;
00149 };
00150 
00151 /* used to count the circle */
00152 struct pln_circ {
00153         double angle;
00154         /* 3 already known points */
00155         struct pln_point pl;
00156         struct pln_point pc;
00157         struct pln_point pr;
00158 };
00159 
00160 /* position state */
00161 struct pln_pos_state {
00162         double x;
00163         double y;
00164         double head;
00165 };
00166 
00167 /* time periods and enumerated angles from the laser */
00168 struct pln_time_state {
00169         /* reflection time (absolute to the refrence point) */
00170         double t_theta[3];
00171         double period;
00172 };
00173 
00174 /* absolute angles between head and reflectors */
00175 struct pln_aangle_state {
00176         double theta[3];
00177         double head;
00178 };
00179 
00180 /* relative angles between reflectors */
00181 struct pln_angle_state {
00182         double alfa;
00183         double beta;
00184         double gama;
00185 };
00186 
00187 /* angle and it`s evaluation */
00188 struct pln_angle_eval {
00189         double angle;
00190         double eval;
00191 };
00192 
00193 /* fixed points */
00194 struct pln_point A, B, C, D, E, F, G, H, K, L, R1, R2, R3;
00195 
00199 double evaluate_gaussian(double val, double sigma);
00200 void pln_get_position(struct pln_angle_state as, struct pln_pos_state *pos);
00201 void pln_set_points();
00202 void pln_pos2ang(struct pln_pos_state ps, struct pln_aangle_state *aas);
00203 void pln_coordinate(struct pln_pos_state estpos, struct pln_aangle_state aas, 
00204                         struct pln_angle_state *as);
00205 void pln_sel_angles(struct pln_pos_state estpos, double *angles, 
00206                         int angcount, struct pln_aangle_state *maas);
00207 void pln_cal_position(unsigned int *times, unsigned int timecnt, 
00208                         struct pln_pos_state act_pos, 
00209                         struct pln_pos_state *est_pos);

Generated on Thu Sep 13 11:28:28 2007 for DCE-Eurobot by  doxygen 1.5.3