00001 #include "malloc.h"
00002 #include "2Dlib.h"
00003 #include "saphira.h"
00004 #include "process.h"
00005 #include "pt_poly.h"
00006 #include "mil.h"
00007 #include "conio.h"
00008
00009 #define DLL_EXPORT extern "C" __declspec(dllexport)
00010 #define DLL_IMPORT extern "C" __declspec(dllimport)
00011 #define STD __stdcall
00012 #define PI 3.141592
00013 #define LISTA_MAX 100
00014 #define CHILDBUFFER_WIDTH 210
00015 #define CHILDBUFFER_HEIGHT 210
00016 #define MOVIMIENTO 0
00017 #define ESTACIONARIO 1
00018
00019 typedef double** matriz;
00020
00021 FILE *in,*map;
00022
00024
00026
00034 typedef struct {
00035 Pt2D P1;
00036 Pt2D P2;
00037 Pt2D P3;
00038 Pt2D P4;
00039 Pt2D P5;
00040 Pt2D P6;
00041 Pt2D P7;
00042 Pt2D P8;
00043 Pt2D centro;
00044 Pt2D BaseFlecha;
00045 Pt2D PuntaFlechaC;
00046 Pt2D PuntaFlechaL;
00047 Pt2D PuntaFlechaR;
00048 }posicion;
00049
00059 typedef struct {
00060 Pt2D uno;
00061 Pt2D dos;
00062 Pt2D tres;
00063 Pt2D cuatro;
00064 Pt2D Cono1L;
00065 Pt2D Cono1R;
00066 }vision;
00067
00077 typedef struct {
00079 Pt2D EsqSupIzq;
00081 Pt2D EsqInfDrch;
00084 bool UsarZona;
00085 }zona;
00086
00096 typedef struct nodo{
00098 struct nodo *next;
00100 Pt2D value;
00101 }nodo;
00102
00103 typedef nodo *nodo_ptr;
00104
00105
00110 typedef struct {
00112 char *nombre;
00114 char *codigo;
00116 Pt2D Posicion;
00118 double Horientacion;
00120 nodo_ptr ultimo;
00121 }poligono;
00122
00123 typedef poligono *lista;
00124
00126
00128
00129 MIL_ID BufferBackground, MilUnderlayBuffer;
00130 MIL_ID disp2,temp;
00131 MIL_ID WorkingDisplay,WorkingBuffer;
00132 MIL_ID RefreshDisplay,RefreshBuffer;
00133 MIL_ID SonaresDisplay,SonaresBuffer;
00134 matriz Giro,Traslacion,Simetria_X,Base,InversaBase;
00135 matriz MatrizRobot,MatrizCamaras;
00136 matriz MatrizObjetos;
00137 Pt2D PosicionActual;
00138 posicion Robot,Coordenadas;
00139 vision camaras;
00140 zona ZonaAltaDensidad;
00141 bool PararSonares=false;
00142 double ESCALA_PixPorMM, AlturaImagen;
00144 long TransparentColor;
00145 long Buffer_Width,Buffer_Height;
00146
00147
00148 Pt2D SonarBuffer[3*CBUF_LEN];
00149 int SonarBufferIndex;
00150
00151 Pt2D ListaFIFO[LISTA_MAX];
00152 int Indice1=0,Indice2=0;
00153
00154 Pt2D old_sonar_lectures[LISTA_MAX];
00155 int IndiceBorrado1=0, IndiceBorrado2=0;
00156 bool BorrarLecturasViejas=false;
00157
00158
00159 lista Mundo[30];
00160
00162
00164
00165 DLL_EXPORT void STD AbrirMapaMIL (HWND WindowHandle,char *FICHERO,char *DIRECTORIO_OBJETOS,
00166 long *alto,long *ancho,double escala,double *PosX,double *PosY,
00167 double *Heading,MIL_ID sys,MIL_ID *disp,MIL_ID *mapa);
00168
00169 DLL_EXPORT void STD NuevoMapaMIL (HWND WindowHandle,long alto, long ancho ,
00170 double escala,MIL_ID sys,MIL_ID *disp,
00171 MIL_ID *mapa);
00172
00173 DLL_EXPORT void STD SalvarMapaMIL (char *Filename);
00174
00175 DLL_EXPORT void STD RecalcularMapaMIL (double escala,double DesplazamientoH,
00176 double DesplazamientoV,double AnguloGiro,
00177 long EjeGiroX,long EjeGiroY,int modo);
00178
00179 DLL_EXPORT void STD CerrarMapaMIL (MIL_ID disp);
00180
00181 DLL_EXPORT void STD UsarZonaAltaResolucion (void);
00182
00183 DLL_EXPORT void STD AjustarZonaAltaResolucion (long XSupIzq,long YSupIzq,
00184 long XInfDrch,long YInfDrch);
00185
00186 DLL_EXPORT void STD NoUsarZonaAltaResolucion (void);
00187
00188 DLL_EXPORT void STD PosicionarRobotVirtual (double x, double y, double Angulo,
00189 double AnguloCamaras, long modo);
00190
00191 DLL_EXPORT void STD ActualizarVista (double x, double y, double Angulo
00192 ,double AnguloCamaras, long modo);
00193
00194 DLL_EXPORT void STD ObtenerLecturaSonares (void);
00195
00196 DLL_EXPORT void STD VaciarBufferLecturasSonares (void);
00197
00198
00199
00200 DLL_EXPORT void STD TransfMundoDispositivo (double PosXMundo, double PosYMundo,
00201 double *PosXDisp, double *PosYDisp);
00202
00203 DLL_EXPORT void STD TransfDispositivoMundo (double PosXDisp, double PosYDisp,
00204 double *PosXMundo, double *PosYMundo);
00205
00206 DLL_EXPORT void STD SplineTracer (double x1, double y1, double x2, double y2);
00207
00208 DLL_EXPORT void STD PintarPuntoTrayectoria (double x1, double y1);
00209
00210
00211
00212 matriz IniciarMatrizCambioBase (matriz *giro,matriz *trasl,matriz *simetria_x
00213 ,double AlturaImagen, double DesplazamientoH,
00214 double DesplazamientoV,double AnguloGiro,
00215 long EjeGiroX,long EjeGiroY);
00216
00217 void IniciarMatrices (matriz *giro,matriz *trasl,matriz *MatrizRobot,
00218 matriz *matrizcamaras, Pt2D *PosicionActual,
00219 double AnguloActual,double AnguloCamaras);
00220
00221 void IniMatrizCamaras (matriz PosCamaras,matriz giro,matriz traslacion,double angulo);
00222 void PintaRobot (matriz MatrizRobot);
00223 void PintaCamaras (matriz MatrizCamaras);
00224 void PintaZona (zona ZonaAltaDensidad);
00225 posicion CalculaPosRobot (posicion robot,matriz matrix);
00226 vision CalculaPosCamaras (vision camara, matriz matrix);
00227 void s_actualitzar (void);
00228 bool BuscarLectura (Pt2D Valor);
00229 void BorrarRobot (void);
00230 void ComprobarPosChildBuffer (void);
00231 void LeerMundo (lista *objetos,char *Mapa,char *DirectorioObjetos,Pt2D *lugar
00232 ,double *Horientacion);
00233 void BorrarMundo (lista *objetos);
00234 lista CrearLista ();
00235 void BorrarLista (lista Lista_a_Borrar);
00236 lista AnadirNodo (lista l,Pt2D valor);
00237 void BorrarNodo (nodo_ptr Nodo_a_Borrar);
00238 nodo_ptr CrearNodo ();
00239 void PintarMundo (lista *objetos,int modo);
00240 void PintarObjeto (lista objeto,int modo);
00241 void RellenarObjeto (lista objeto,MIL_ID buffer,int color);
00242 bool Punto_en_Buffer (Pt2D Punto);
00243
00244 DLL_EXPORT void STD GrabarBuffer ();