[ARDrone] Reorganise .h, clean includes

This commit is contained in:
Matteo Cypriani 2011-08-18 10:00:45 +02:00
parent 2c91f5b976
commit fe8846cca9
2 changed files with 64 additions and 54 deletions

View File

@ -2,15 +2,20 @@
* This file is part of the rtap localisation project. * This file is part of the rtap localisation project.
*/ */
#include "../libowlps-client/owlps-client.h"
#include "owlps-drone.h" #include "owlps-drone.h"
#include <owlps-client.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#include <inttypes.h> #include <inttypes.h>
#include <string.h> #include <string.h>
#include <math.h>
#include <pthread.h>
#include <arpa/inet.h>
#include <net/if.h> #include <net/if.h>
#include <time.h> #include <time.h>
@ -20,13 +25,11 @@
#include <sys/time.h> #include <sys/time.h>
#include <fcntl.h> #include <fcntl.h>
#include <assert.h>
#include <signal.h> #include <signal.h>
#include <semaphore.h> #include <semaphore.h>
#define SEPARATOR ','
#define EOL '$' #include <assert.h>
#define TYPE "GPS"
/* Options */ /* Options */

View File

@ -1,13 +1,11 @@
#include <stdio.h> #ifndef _OWLPS_ARDRONE_H_
#include <pthread.h> #define _OWLPS_ARDRONE_H_
#include <math.h>
#include "oc.h" #include "oc.h"
/* Lenght of string algo */
#define ALGO_STRLEN 15 /* Program arguments (getopt string) */
/* Error codes */ #define OPTIONS "d:hi:l::n:p:t:V"
#define ERR_BAD_USAGE 1 // Bad program call (bad number of arguments)
/* Number of packets to send */ /* Number of packets to send */
#define DEFAULT_NBPKT_CALIB 20 // 20 packets when calibrating #define DEFAULT_NBPKT_CALIB 20 // 20 packets when calibrating
@ -17,48 +15,31 @@
#define DEFAULT_DELAY_CALIB 50000 // Calibration request #define DEFAULT_DELAY_CALIB 50000 // Calibration request
#define DEFAULT_DELAY_NORMAL 25000 // Localisation request #define DEFAULT_DELAY_NORMAL 25000 // Localisation request
/* Program arguments (getopt string) */ /* Maximum length of the algorithm name */
#define OPTIONS "d:hi:l::n:p:t:V" #define ALGO_STRLEN 15
/* GPS inputs */
#define SEPARATOR ','
#define EOL '$'
#define TYPE "GPS"
//Define send command /* Drone commands */
#define LENSTR 1000 #define LENSTR 1000
#define ATREF "AT*REF=" #define ATREF "AT*REF="
#define LANDING ",290717696" #define LANDING ",290717696"
#define TAKEOFF ",290718208" #define TAKEOFF ",290718208"
//Define socket
//#define IP "172.20.105.4" /* Socket parameters */
#define IP "192.168.1.1" #define IP "192.168.1.1"
#define PORT 5556 #define PORT 5556
/* Function headers */ /* Error codes */
void parse_command_line(int argc, char **argv) ; #define ERR_BAD_USAGE 1 // Bad program call (bad number of arguments)
void parse_main_options(int argc, char **argv) ;
void check_destination_ip(void) ;
void parse_calibration_data(int argc, char **argv) ;
void check_configuration(void) ;
#ifdef DEBUG
void print_configuration(void) ;
#endif // DEBUG
void create_socket(void) ;
void make_packet(void) ;
void send_request(void) ;
void* receive_position(void*) ;
void print_usage(void) ;
void string2data(char*) ;
void traficGPS(int);
void* thread_gps(void*) ;
void* thread_send(void*) ;
void* thread_control(void*) ;
void print_error(char*) ;
void print_version(void) ;
void drone_handler_sigint(const int);
typedef struct result result;
typedef struct gps gps;
/* Struct */
struct result
/* Received result */
typedef struct _result
{ {
char algo[ALGO_STRLEN]; char algo[ALGO_STRLEN];
float x; float x;
@ -66,9 +47,9 @@ struct result
float z; float z;
char *check; char *check;
float err; float err;
}; } result ;
struct gps typedef struct _gps
{ {
float time; float time;
char state; char state;
@ -80,7 +61,7 @@ struct gps
float cap; float cap;
int date; int date;
float decmag; float decmag;
}; } gps ;
typedef struct _consigne typedef struct _consigne
{ {
@ -91,33 +72,59 @@ typedef struct _consigne
struct _consigne *next; struct _consigne *next;
} consigne ; } consigne ;
typedef struct _point typedef struct _point_consigne
{ {
double lat; double lat;
double lon; double lon;
double alt; double alt;
} point_consigne ; } point_consigne ;
/* Prototype drone */
/* Function headers */
void parse_command_line(int argc, char **argv) ;
void parse_main_options(int argc, char **argv) ;
void check_destination_ip(void) ;
void parse_calibration_data(int argc, char **argv) ;
void check_configuration(void) ;
#ifdef DEBUG
void print_configuration(void) ;
#endif // DEBUG
void print_usage(void) ;
void print_version(void) ;
void drone_handler_sigint(const int) ;
void create_socket(void) ;
void make_packet(void) ;
void send_request(void) ;
void* receive_position(void*) ;
void string2data(char*) ;
void traficGPS(int);
void* thread_gps(void*) ;
void* thread_send(void*) ;
void* thread_control(void*) ;
void print_error(char*) ;
void drone_err(int); void drone_err(int);
//Position
int read_position(char*); int read_position(char*);
//Socket
int drone_socket_create(void); int drone_socket_create(void);
void* drone_socket_watchdog(void*); void* drone_socket_watchdog(void*);
int drone_socket_close(void); int drone_socket_close(void);
//Commands drone
int cmd_drone_take_off(void); //Add socket int cmd_drone_take_off(void); //Add socket
int cmd_drone_landing(void); //Add socket int cmd_drone_landing(void); //Add socket
int cmd_drone_move(float, int); int cmd_drone_move(float, int);
int cmd_drone_init_direction(void); //Add socket int cmd_drone_init_direction(void); //Add socket
//Algo
void calcul_trajectory(float*, float*); void calcul_trajectory(float*, float*);
float calcul_speed(float); float calcul_speed(float);
int check_destination(struct point, struct point); int check_destination(struct point, struct point);
float calcul_angle(void); float calcul_angle(void);
//Liste chaine
consigne* list_add_front(consigne*, double, double, double); consigne* list_add_front(consigne*, double, double, double);
consigne* list_add_back(consigne*, double, double, double); consigne* list_add_back(consigne*, double, double, double);
void list_print(consigne*); void list_print(consigne*);
#endif //_OWLPS_ARDRONE_H_