121 lines
2.6 KiB
C
121 lines
2.6 KiB
C
#ifndef _OWLPS_ARDRONE_H_
|
|
#define _OWLPS_ARDRONE_H_
|
|
|
|
#include "oc.h"
|
|
|
|
|
|
/* Program arguments (getopt string) */
|
|
#define OPTIONS "d:hi:l::n:p:t:V"
|
|
|
|
/* Number of packets to send */
|
|
#define DEFAULT_NBPKT_CALIB 20 // 20 packets when calibrating
|
|
#define DEFAULT_NBPKT_NORMAL 10 // 10 packets when requesting the position
|
|
|
|
/* Delay between two packet transmissions (in microseconds) */
|
|
#define DEFAULT_DELAY_CALIB 50000 // Calibration request
|
|
#define DEFAULT_DELAY_NORMAL 25000 // Localisation request
|
|
|
|
/* Maximum length of the algorithm & area names */
|
|
#define ALGO_STRLEN 15
|
|
#define AREA_STRLEN 50
|
|
|
|
/* GPS inputs */
|
|
#define SEPARATOR ','
|
|
#define EOL '$'
|
|
#define TYPE "GPS"
|
|
|
|
/* Drone commands */
|
|
#define LENSTR 1000
|
|
#define ATREF "AT*REF="
|
|
#define LANDING ",290717696"
|
|
#define TAKEOFF ",290718208"
|
|
|
|
/* Socket parameters */
|
|
#define IP "192.168.1.1"
|
|
#define PORT 5556
|
|
|
|
|
|
/* Error codes */
|
|
#define ERR_BAD_USAGE 1 // Bad program call (bad number of arguments)
|
|
|
|
|
|
typedef struct _gps
|
|
{
|
|
float time;
|
|
char state;
|
|
double latitude;
|
|
char orilat;
|
|
double longitude;
|
|
char orilon;
|
|
float speed;
|
|
float cap;
|
|
int date;
|
|
float decmag;
|
|
} gps ;
|
|
|
|
typedef struct _consigne
|
|
{
|
|
double lat;
|
|
double lon;
|
|
double alt;
|
|
|
|
struct _consigne *next;
|
|
} consigne ;
|
|
|
|
typedef struct _point_consigne
|
|
{
|
|
double lat;
|
|
double lon;
|
|
double alt;
|
|
} point_consigne ;
|
|
|
|
|
|
/* 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);
|
|
int read_position(char*);
|
|
int drone_socket_create(void);
|
|
void* drone_socket_watchdog(void*);
|
|
int drone_socket_close(void);
|
|
|
|
int cmd_drone_take_off(void); //Add socket
|
|
int cmd_drone_landing(void); //Add socket
|
|
int cmd_drone_move(float, int);
|
|
int cmd_drone_init_direction(void); //Add socket
|
|
|
|
void calcul_trajectory(float*, float*);
|
|
float calcul_speed(float);
|
|
int check_destination(struct point, struct point);
|
|
float calcul_angle(void);
|
|
|
|
consigne* list_add_front(consigne*, double, double, double);
|
|
consigne* list_add_back(consigne*, double, double, double);
|
|
void list_print(consigne*);
|
|
|
|
#endif //_OWLPS_ARDRONE_H_
|