Paparazzi UAS  v5.2.2_stable-0-gd6b9f29
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
gps_ardrone2.c
Go to the documentation of this file.
1 /*
2  *
3  * Copyright (C) 2013 Freek van Tienen <freek.v.tienen@gmail.com>
4  *
5  * This file is part of paparazzi.
6  *
7  * paparazzi is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2, or (at your option)
10  * any later version.
11  *
12  * paparazzi is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with paparazzi; see the file COPYING. If not, write to
19  * the Free Software Foundation, 59 Temple Place - Suite 330,
20  * Boston, MA 02111-1307, USA.
21  *
22  */
23 
29 #ifdef ARDRONE2_DEBUG
30 # include <stdio.h>
31 #endif
32 
33 #include "subsystems/gps.h"
35 
37 
38 void gps_impl_init( void ) {
40 }
41 
42 void gps_ardrone2_parse(navdata_gps_t *navdata_gps) {
43  int i;
44 
45 #ifdef ARDRONE2_DEBUG
46  printf("state = %d\n", navdata_gps->gps_state);
47 #endif
48  // Set the lla double struct from the navdata
49  struct LlaCoor_d gps_lla_d;
50  gps_lla_d.lat = RadOfDeg(navdata_gps->lat);
51  gps_lla_d.lon = RadOfDeg(navdata_gps->lon);
52  gps_lla_d.alt = navdata_gps->elevation;
53 
54  // Convert it to ecef
55  struct EcefCoor_d gps_ecef_d;
56  ecef_of_lla_d(&gps_ecef_d, &gps_lla_d);
57 
58  // Convert the lla and ecef to int and set them in gps
59  ECEF_BFP_OF_REAL(gps.ecef_pos, gps_ecef_d);
60  LLA_BFP_OF_REAL(gps.lla_pos, gps_lla_d);
61 
62  // TODO: parse other stuff
64 
65  for(i = 0; i < GPS_NB_CHANNELS; i++) {
66  gps.svinfos[i].svid = navdata_gps->channels[i].sat;
67  gps.svinfos[i].cno = navdata_gps->channels[i].cn0;
68  }
69 
70  // Check if we have a fix TODO: check if 2D or 3D fix?
71  if (navdata_gps->gps_state == 1)
72  gps.fix = GPS_FIX_3D;
73  else
75 
76  // Set that there is a packet
78 }
struct LlaCoor_i lla_pos
position in LLA (lat,lon: deg*1e7; alt: mm over ellipsoid)
Definition: gps.h:65
double alt
in meters above WGS84 reference ellipsoid
float64_t elevation
Definition: at_com.h:162
#define ECEF_BFP_OF_REAL(_o, _i)
void gps_impl_init(void)
Definition: gps_ardrone2.c:38
uint8_t fix
status of fix
Definition: gps.h:78
#define GPS_FIX_3D
Definition: gps.h:43
float64_t lat
Definition: at_com.h:160
struct EcefCoor_i ecef_pos
position in ECEF in cm
Definition: gps.h:64
#define GPS_NB_CHANNELS
Definition: gps_ardrone2.h:33
#define FALSE
Definition: imu_chimu.h:141
Paparazzi double-precision floating point math for geodetic calculations.
void ecef_of_lla_d(struct EcefCoor_d *ecef, struct LlaCoor_d *lla)
struct _navdata_gps_t::@10 channels[12]
uint8_t sat
Definition: at_com.h:180
vector in EarthCenteredEarthFixed coordinates
#define GPS_FIX_NONE
Definition: gps.h:41
Device independent GPS code (interface)
#define LLA_BFP_OF_REAL(_o, _i)
double lon
in radians
uint32_t gps_state
Definition: at_com.h:170
float64_t lon
Definition: at_com.h:161
bool_t gps_ardrone2_available
Definition: gps_ardrone2.c:36
struct SVinfo svinfos[GPS_NB_CHANNELS]
holds information from the Space Vehicles (Satellites)
Definition: gps.h:83
#define TRUE
Definition: imu_chimu.h:144
void gps_ardrone2_parse(navdata_gps_t *navdata_gps)
Definition: gps_ardrone2.c:42
double lat
in radians
uint8_t svid
Satellite ID.
Definition: gps.h:54
vector in Latitude, Longitude and Altitude
struct GpsState gps
global GPS state
Definition: gps.c:41
uint8_t cn0
Definition: at_com.h:181
uint8_t cno
Carrier to Noise Ratio (Signal Strength) in dbHz.
Definition: gps.h:57
uint8_t nb_channels
Number of scanned satellites.
Definition: gps.h:82