nd2.h
00001 
00002 /*****************************************************************************/
00003 /*                                                                           */
00004 /*  Fichero:     nd2.h                                                       */
00005 /*  Autor:       Javier Minguez                                              */
00006 /*  Creado:      28/05/2003                                                  */
00007 /*  Modificado:  21/06/2003                                                  */
00008 /*                                                                           */
00009 /*****************************************************************************/
00010 /*
00011  *  This program is free software; you can redistribute it and/or modify
00012  *  it under the terms of the GNU General Public License as published by
00013  *  the Free Software Foundation; either version 2 of the License, or
00014  *  (at your option) any later version.
00015  *
00016  *  This program is distributed in the hope that it will be useful,
00017  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  *  GNU General Public License for more details.
00020  *
00021  *  You should have received a copy of the GNU General Public License
00022  *  along with this program; if not, write to the Free Software
00023  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00024  *
00025  */
00026 #ifndef nd2_h
00027 #define nd2_h
00028 
00029 #include "geometria.h"
00030 
00031 // ----------------------------------------------------------------------------
00032 // CONSTANTES.
00033 // ----------------------------------------------------------------------------
00034 
00035 // N�mero de sectores: m�ltiplo de 4.
00036 #define SECTORES 180
00037 
00038 #define VERDADERO 1
00039 #define FALSO 0
00040 #define NO_SIGNIFICATIVO -1
00041 
00042 // ----------------------------------------------------------------------------
00043 // TIPOS.
00044 // ----------------------------------------------------------------------------
00045 
00046 // Informaci�n acerca del robot.
00047 
00048 // Dimensiones del robot.
00049 //   Consideramos el robot definido por un rect�ngulo. Numeramos sus
00050 //   dimensiones, medidas a partir de su centro en las direcciones principales,
00051 //   siguiendo la misma convenci�n que para los sectores:
00052 //     Dimension[0]: distancia desde el centro a la trasera del robot.
00053 //     Dimension[1]: distancia desde el centro a la izquierda del robot.
00054 //     Dimension[2]: distancia desde el centro al frontal del robot.
00055 //     Dimension[3]: distancia desde el centro a la derecha del robot.
00056 typedef float TDimensiones[4];
00057 
00058 typedef float TMatriz2x2[2][2];
00059 
00060 typedef struct {
00061 
00062   TDimensiones Dimensiones;
00063   float enlarge;
00064 
00065   short int geometriaRect; // Si es cuadrado o no
00066 
00067   float R; // radio del robot por si es circular
00068 
00069   short int holonomo;
00070 
00071   float E[SECTORES]; // Distancia desde el origen de SR2 al per�metro del robot.
00072   float ds[SECTORES];  // Distancia de seguridad: desde el per�metro del robot al per�metro de seguridad.
00073 
00074   float velocidad_lineal_maxima;
00075   float velocidad_angular_maxima;
00076 
00077   float aceleracion_lineal_maxima;
00078   float aceleracion_angular_maxima;
00079 
00080   float discontinuidad; // Espacio m�nimo por el que cabe el robot.
00081 
00082   float T; // Per�odo.
00083 
00084   TMatriz2x2 H; // Generador de movimientos: "Inercia" del robot.
00085   TMatriz2x2 G; // Generador de movimientos: "Fuerza" aplicada sobre el robot.
00086 
00087 } TInfoRobot;
00088 
00089 // Informaci�n acerca del objetivo.
00090 
00091 typedef struct {
00092   TCoordenadas c0;
00093   TCoordenadas c1;
00094   TCoordenadasPolares p1;
00095   int s; // Sector.
00096 } TObjetivo;
00097 
00098 // Informaci�n acerca de la regi�n escogida.
00099 
00100 #define DIRECCION_OBJETIVO                0
00101 #define DIRECCION_DISCONTINUIDAD_INICIAL  1
00102 #define DIRECCION_DISCONTINUIDAD_FINAL    2
00103 
00104 typedef struct {
00105   int principio;
00106   int final;
00107 
00108   int principio_ascendente;
00109   int final_ascendente;
00110 
00111   int descartada;
00112 
00113   int direccion_tipo;
00114   int direccion_sector;
00115   float direccion_angulo;
00116 } TRegion;
00117 
00118 typedef struct {
00119   int longitud;
00120   TRegion vector[SECTORES];
00121 } TVRegiones;
00122 
00123 // Informaci�n interna del m�todo de navegaci�n.
00124 
00125 typedef struct {
00126 
00127   TObjetivo objetivo;
00128 
00129   TSR SR1;                  // Estado actual del robot: posici�n y orientaci�n.
00130   TVelocities velocidades; // Estado actual del robot: velocidades lineal y angular.
00131 
00132   TCoordenadasPolares d[SECTORES]; // Distancia desde el centro del robot al obst�culo m�s pr�ximo en cada sector (con �ngulos).
00133   float dr[SECTORES]; // Distancia desde el per�metro del robot al obst�culo m�s pr�ximo en cada sector.
00134 
00135   TVRegiones regiones; // S�lo como informaci�n de cara al exterior: Lista de todas las regiones encontradas en el proceso de selecci�n.
00136   int region;          // Como almacenamos m�s de una regi�n debemos indicar cu�l es la escogida.
00137 
00138   int obstaculo_izquierda,obstaculo_derecha;
00139 
00140   float angulosin;    // S�lo como informaci�n de cara al exterior: �ngulo antes de tener en cuenta los obst�culos m�s pr�ximos.
00141   float angulocon;    // S�lo como informaci�n de cara al exterior: �ngulo despu�s de tener en cuenta los obst�culos m�s pr�ximos.
00142   char situacion[20]; // S�lo como informaci�n de cara al exterior: Situaci�n en la que se encuentra el robot.
00143   char cutting[20];   // S�lo como informaci�n de cara al exterior: Cutting aplicado al movimiento del robot.
00144 
00145   float angulo;    // Salida del algoritmo de navegaci�n y entrada al generador de movimientos: direcci�n de movimiento deseada.
00146   float velocidad; // Salida del algoritmo de navegaci�n y entrada al generador de movimientos: velocidad lineal deseada.
00147 
00148 } TInfoND;
00149 
00150 // ----------------------------------------------------------------------------
00151 // VARIABLES.
00152 // ----------------------------------------------------------------------------
00153 
00154 extern TInfoRobot robot;
00155 
00156 // ----------------------------------------------------------------------------
00157 // FUNCIONES.
00158 // ----------------------------------------------------------------------------
00159 
00160 extern float sector2angulo(int sector);
00161 
00162 extern int angulo2sector(float angulo);
00163 
00164 
00165 #endif 

Last updated 12 September 2005 21:38:45