-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
gps_ardrone2.c
86 lines (73 loc) · 2.4 KB
/
gps_ardrone2.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/*
*
* Copyright (C) 2013 Freek van Tienen <freek.v.tienen@gmail.com>
*
* This file is part of paparazzi.
*
* paparazzi is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* paparazzi is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with paparazzi; see the file COPYING. If not, write to
* the Free Software Foundation, 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
*/
/**
* @file subsystems/gps/gps_ardrone2.c
* ARdrone 2 gps trough navdata for the SDK version and only works in combination with the ahrs ardrone2.
*/
#ifdef ARDRONE2_DEBUG
# include <stdio.h>
#endif
#include "subsystems/gps.h"
#include "subsystems/abi.h"
#include "math/pprz_geodetic_double.h"
void gps_impl_init(void)
{
}
void gps_ardrone2_parse(navdata_gps_t *navdata_gps)
{
int i;
#ifdef ARDRONE2_DEBUG
printf("state = %d\n", navdata_gps->gps_state);
#endif
// Set the lla double struct from the navdata
struct LlaCoor_d gps_lla_d;
gps_lla_d.lat = RadOfDeg(navdata_gps->lat);
gps_lla_d.lon = RadOfDeg(navdata_gps->lon);
gps_lla_d.alt = navdata_gps->elevation;
// Convert it to ecef
struct EcefCoor_d gps_ecef_d;
ecef_of_lla_d(&gps_ecef_d, &gps_lla_d);
// Convert the lla and ecef to int and set them in gps
ECEF_BFP_OF_REAL(gps.ecef_pos, gps_ecef_d);
LLA_BFP_OF_REAL(gps.lla_pos, gps_lla_d);
// TODO: parse other stuff
gps.nb_channels = GPS_NB_CHANNELS;
for (i = 0; i < GPS_NB_CHANNELS; i++) {
gps.svinfos[i].svid = navdata_gps->channels[i].sat;
gps.svinfos[i].cno = navdata_gps->channels[i].cn0;
}
// Check if we have a fix TODO: check if 2D or 3D fix?
if (navdata_gps->gps_state == 1) {
gps.fix = GPS_FIX_3D;
} else {
gps.fix = GPS_FIX_NONE;
}
gps.last_msg_ticks = sys_time.nb_sec_rem;
gps.last_msg_time = sys_time.nb_sec;
if (gps.fix == GPS_FIX_3D) {
gps.last_3dfix_ticks = sys_time.nb_sec_rem;
gps.last_3dfix_time = sys_time.nb_sec;
}
uint32_t now_ts = get_sys_time_usec();
AbiSendMsgGPS(GPS_ARDRONE2_ID, now_ts, &gps);
}