nd2.h
1 
2 /*****************************************************************************/
3 /* */
4 /* Fichero: nd2.h */
5 /* Autor: Javier Minguez */
6 /* Creado: 28/05/2003 */
7 /* Modificado: 21/06/2003 */
8 /* */
9 /*****************************************************************************/
10 /*
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24  *
25  */
26 #ifndef nd2_h
27 #define nd2_h
28 
29 #include "geometria.h"
30 
31 // ----------------------------------------------------------------------------
32 // CONSTANTES.
33 // ----------------------------------------------------------------------------
34 
35 // N�mero de sectores: m�ltiplo de 4.
36 #define SECTORES 180
37 
38 #define VERDADERO 1
39 #define FALSO 0
40 #define NO_SIGNIFICATIVO -1
41 
42 // ----------------------------------------------------------------------------
43 // TIPOS.
44 // ----------------------------------------------------------------------------
45 
46 // Informaci�n acerca del robot.
47 
48 // Dimensiones del robot.
49 // Consideramos el robot definido por un rect�ngulo. Numeramos sus
50 // dimensiones, medidas a partir de su centro en las direcciones principales,
51 // siguiendo la misma convenci�n que para los sectores:
52 // Dimension[0]: distancia desde el centro a la trasera del robot.
53 // Dimension[1]: distancia desde el centro a la izquierda del robot.
54 // Dimension[2]: distancia desde el centro al frontal del robot.
55 // Dimension[3]: distancia desde el centro a la derecha del robot.
56 typedef float TDimensiones[4];
57 
58 typedef float TMatriz2x2[2][2];
59 
60 typedef struct {
61 
62  TDimensiones Dimensiones;
63  float enlarge;
64 
65  short int geometriaRect; // Si es cuadrado o no
66 
67  float R; // radio del robot por si es circular
68 
69  short int holonomo;
70 
71  float E[SECTORES]; // Distancia desde el origen de SR2 al per�metro del robot.
72  float ds[SECTORES]; // Distancia de seguridad: desde el per�metro del robot al per�metro de seguridad.
73 
74  float velocidad_lineal_maxima;
75  float velocidad_angular_maxima;
76 
77  float aceleracion_lineal_maxima;
78  float aceleracion_angular_maxima;
79 
80  float discontinuidad; // Espacio m�nimo por el que cabe el robot.
81 
82  float T; // Per�odo.
83 
84  TMatriz2x2 H; // Generador de movimientos: "Inercia" del robot.
85  TMatriz2x2 G; // Generador de movimientos: "Fuerza" aplicada sobre el robot.
86 
87 } TInfoRobot;
88 
89 // Informaci�n acerca del objetivo.
90 
91 typedef struct {
92  TCoordenadas c0;
93  TCoordenadas c1;
95  int s; // Sector.
96 } TObjetivo;
97 
98 // Informaci�n acerca de la regi�n escogida.
99 
100 #define DIRECCION_OBJETIVO 0
101 #define DIRECCION_DISCONTINUIDAD_INICIAL 1
102 #define DIRECCION_DISCONTINUIDAD_FINAL 2
103 
104 typedef struct {
105  int principio;
106  int final;
107 
108  int principio_ascendente;
109  int final_ascendente;
110 
111  int descartada;
112 
113  int direccion_tipo;
114  int direccion_sector;
115  float direccion_angulo;
116 } TRegion;
117 
118 typedef struct {
119  int longitud;
120  TRegion vector[SECTORES];
121 } TVRegiones;
122 
123 // Informaci�n interna del m�todo de navegaci�n.
124 
125 typedef struct {
126 
127  TObjetivo objetivo;
128 
129  TSR SR1; // Estado actual del robot: posici�n y orientaci�n.
130  TVelocities velocidades; // Estado actual del robot: velocidades lineal y angular.
131 
132  TCoordenadasPolares d[SECTORES]; // Distancia desde el centro del robot al obst�culo m�s pr�ximo en cada sector (con �ngulos).
133  float dr[SECTORES]; // Distancia desde el per�metro del robot al obst�culo m�s pr�ximo en cada sector.
134 
135  TVRegiones regiones; // S�lo como informaci�n de cara al exterior: Lista de todas las regiones encontradas en el proceso de selecci�n.
136  int region; // Como almacenamos m�s de una regi�n debemos indicar cu�l es la escogida.
137 
138  int obstaculo_izquierda,obstaculo_derecha;
139 
140  float angulosin; // S�lo como informaci�n de cara al exterior: �ngulo antes de tener en cuenta los obst�culos m�s pr�ximos.
141  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.
142  char situacion[20]; // S�lo como informaci�n de cara al exterior: Situaci�n en la que se encuentra el robot.
143  char cutting[20]; // S�lo como informaci�n de cara al exterior: Cutting aplicado al movimiento del robot.
144 
145  float angulo; // Salida del algoritmo de navegaci�n y entrada al generador de movimientos: direcci�n de movimiento deseada.
146  float velocidad; // Salida del algoritmo de navegaci�n y entrada al generador de movimientos: velocidad lineal deseada.
147 
148 } TInfoND;
149 
150 // ----------------------------------------------------------------------------
151 // VARIABLES.
152 // ----------------------------------------------------------------------------
153 
154 extern TInfoRobot robot;
155 
156 // ----------------------------------------------------------------------------
157 // FUNCIONES.
158 // ----------------------------------------------------------------------------
159 
160 extern float sector2angulo(int sector);
161 
162 extern int angulo2sector(float angulo);
163 
164 
165 #endif
Definition: geometria.h:75
Definition: nd.h:55
Definition: nd.h:62
Definition: nd2.h:60
Definition: nd2.h:104
Definition: nd.h:140
Definition: nd2.h:125
Definition: nd2.h:91
Definition: nd2.h:118