From dc3ba412221d992614a418c210c254236c4e5969 Mon Sep 17 00:00:00 2001 From: Matteo Cypriani Date: Thu, 18 Aug 2011 09:54:50 +0200 Subject: [PATCH] [ARDrone] Create oc.h Create oc.h from oc.c, include it in owlps-drone.h instead of directly oc.c. Compile oc.o separately. --- owlps-ardrone/Makefile | 11 +++++------ owlps-ardrone/Makefile_drone | 21 +++++++++------------ owlps-ardrone/oc.c | 16 ++++------------ owlps-ardrone/oc.h | 30 ++++++++++++++++++++++++++++++ owlps-ardrone/owlps-drone.h | 8 ++------ 5 files changed, 50 insertions(+), 36 deletions(-) create mode 100644 owlps-ardrone/oc.h diff --git a/owlps-ardrone/Makefile b/owlps-ardrone/Makefile index 281835a..d367575 100644 --- a/owlps-ardrone/Makefile +++ b/owlps-ardrone/Makefile @@ -22,7 +22,7 @@ CP=cp -v # Cible TARGET=owlps-drone -HEADER= +DEPS = oc.o # Flags LIBOWLPS_DIR = ../libowlps @@ -46,15 +46,14 @@ dynamic : $(TARGET) static : $(TARGET).static all : dynamic static -% : %.o - $(CC) $(LDFLAGS) $(STRIPFLAGS) $(XCFLAGS) -o $@ $^ $(LIBS) -%.o : %.c $(HEADER) +%.o : %.c %.h $(CC) $(XCFLAGS) $(OWLPSFLAGS) -c $< # Compilation du programme -$(TARGET) : $(TARGET).o $(HEADER) +$(TARGET) : $(TARGET).o $(DEPS) + $(CC) $(LDFLAGS) $(STRIPFLAGS) $(XCFLAGS) -o $@ $^ $(LIBS) -$(TARGET).static : $(TARGET).c $(HEADER) +$(TARGET).static : $(TARGET).o $(DEPS) $(CC) $(LDFLAGS) -static $(STRIPFLAGS) $(XCFLAGS) -o $@ $^ $(LIBS) $(STATIC_LIBS) diff --git a/owlps-ardrone/Makefile_drone b/owlps-ardrone/Makefile_drone index a1e3d88..cd59342 100644 --- a/owlps-ardrone/Makefile_drone +++ b/owlps-ardrone/Makefile_drone @@ -25,7 +25,7 @@ CP=cp -v # Cible TARGET=owlps-drone -HEADER= +DEPS = oc.o # Flags LIBOWLPS_DIR = ../libowlps @@ -58,19 +58,16 @@ all: semistatic static # Cancel implicit make rule %: %.c -#%: %.o -# $(CC) $(STRIPFLAGS) $(XCFLAGS) -o $@ $^ $(LDFLAGS) $(DYNAMIC_LIBS) - -%: %.o - $(CC) $(STRIPFLAGS) $(XCFLAGS) $(OWLPSFLAGS) -o $@ $^ $(LDFLAGS) $(SEMISTATIC_LIBS) - -%.static: %.o - $(CC) $(STRIPFLAGS) $(XCFLAGS) -o $@ $^ $(LDFLAGS) $(STATIC_LIBS) \ - -static - -%.o: %.c $(HEADER) +%.o: %.c %.h $(CC) $(XCFLAGS) $(IATHEROS) $(OWLPSFLAGS) -c $< +# Compilation du programme +$(TARGET) : $(TARGET).o $(DEPS) + $(CC) $(LDFLAGS) $(STRIPFLAGS) $(XCFLAGS) -o $@ $^ $(LIBS) + +$(TARGET).static : $(TARGET).o $(DEPS) + $(CC) $(LDFLAGS) -static $(STRIPFLAGS) $(XCFLAGS) -o $@ $^ $(LIBS) $(STATIC_LIBS) + ## Installation / désinstallation ## diff --git a/owlps-ardrone/oc.c b/owlps-ardrone/oc.c index 04c50b7..2c69b7c 100644 --- a/owlps-ardrone/oc.c +++ b/owlps-ardrone/oc.c @@ -1,21 +1,10 @@ // Bibliotheque OpenCoordinate : fonctions coordonnees geographiques -#ifndef M_PI -#define M_PI 3.14159265358979323846 -#endif +#include "oc.h" #include #include -struct point { - int date; - float time; - double lat, lon, alt, cap; -} point; - -struct point_relatif { - double x, y, z; -} point_relatif; double oc_distance_between(struct point a, struct point b) { // retourne la distance entre les 2 points en metres @@ -29,6 +18,7 @@ double oc_distance_between(struct point a, struct point b) { return R * c; } + struct point_relatif oc_convert(struct point o, struct point a) { //convert transforme des coordonnes WGS84 en metres par rapport au referentiel r struct point proj_x, proj_y; @@ -45,6 +35,7 @@ struct point_relatif oc_convert(struct point o, struct point a) { return pr; } + /* function unconvert(x,y) { if (origine==null) return null; @@ -64,6 +55,7 @@ struct point_relatif oc_convert(struct point o, struct point a) { } */ + double oc_cap(struct point o, struct point a) { struct point_relatif pr=oc_convert(a, o); double alpha; diff --git a/owlps-ardrone/oc.h b/owlps-ardrone/oc.h new file mode 100644 index 0000000..dd79f95 --- /dev/null +++ b/owlps-ardrone/oc.h @@ -0,0 +1,30 @@ +#ifndef _LIBOPENCOORDINATES_ +#define _LIBOPENCOORDINATES_ + + +/* Define M_PI if it is not defined */ +#ifndef M_PI +# define M_PI 3.14159265358979323846 +#endif + + +struct point +{ + int date; + float time; + double lat, lon, alt, cap; +} point; + + +struct point_relatif +{ + double x, y, z; +} point_relatif; + + +double oc_distance_between(struct point a, struct point b) ; +struct point_relatif oc_convert(struct point o, struct point a) ; +double oc_cap(struct point o, struct point a) ; + + +#endif // _LIBOPENCOORDINATES_ diff --git a/owlps-ardrone/owlps-drone.h b/owlps-ardrone/owlps-drone.h index bfc1ca3..895c0aa 100644 --- a/owlps-ardrone/owlps-drone.h +++ b/owlps-ardrone/owlps-drone.h @@ -1,8 +1,8 @@ #include #include #include -/* include OpenCoordinate */ -#include "oc.c" + +#include "oc.h" /* Lenght of string algo */ #define ALGO_STRLEN 15 @@ -20,10 +20,6 @@ /* Program arguments (getopt string) */ #define OPTIONS "d:hi:l::n:p:t:V" -/* Define M_PI if is not define */ -#ifndef M_PI -#define M_PI 3.14159265358979323846 -#endif //Define send command #define LENSTR 1000