Paparazzi UAS  v5.8.2_stable-0-g6260b7c
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
ins.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2008-2012 The Paparazzi Team
3  *
4  * This file is part of paparazzi.
5  *
6  * paparazzi is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2, or (at your option)
9  * any later version.
10  *
11  * paparazzi is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with paparazzi; see the file COPYING. If not, write to
18  * the Free Software Foundation, 59 Temple Place - Suite 330,
19  * Boston, MA 02111-1307, USA.
20  */
21 
28 #include "subsystems/ins.h"
29 
30 #if USE_GPS
31 // for ins_reset_utm_zone
32 #include "subsystems/gps.h"
33 #include "state.h"
34 #endif
35 
36 #ifndef DefaultInsImpl
37 #warning "DefaultInsImpl not set!"
38 #else
39 PRINT_CONFIG_VAR(DefaultInsImpl)
40 #endif
41 
42 #define __DefaultInsRegister(_x) _x ## _register()
43 #define _DefaultInsRegister(_x) __DefaultInsRegister(_x)
44 #define DefaultInsRegister() _DefaultInsRegister(DefaultInsImpl)
45 
47 struct Ins {
49 };
50 
51 struct Ins ins;
52 
54 {
55  ins.init = init;
56 
57  ins.init();
58 }
59 
60 void ins_init(void)
61 {
62  ins.init = NULL;
63 
64 #ifdef DefaultInsImpl
66 #endif
67 }
68 
69 
70 // weak functions, used if not explicitly provided by implementation
71 
72 void WEAK ins_reset_local_origin(void)
73 {
74 #if USE_GPS
75  struct UtmCoor_f utm;
76 #ifdef GPS_USE_LATLONG
77  /* Recompute UTM coordinates in this zone */
78  struct LlaCoor_f lla;
80  utm.zone = (gps.lla_pos.lon / 1e7 + 180) / 6 + 1;
81  utm_of_lla_f(&utm, &lla);
82 #else
83  utm.zone = gps.utm_pos.zone;
84  utm.east = gps.utm_pos.east / 100.0f;
85  utm.north = gps.utm_pos.north / 100.0f;
86 #endif
87  // ground_alt
88  utm.alt = gps.hmsl / 1000.0f;
89 
90  // reset state UTM ref
92 #endif
93 }
94 
95 void WEAK ins_reset_altitude_ref(void) {}
96 
97 #if USE_GPS
98 void WEAK ins_reset_utm_zone(struct UtmCoor_f *utm)
99 {
100  struct LlaCoor_f lla0;
101  lla_of_utm_f(&lla0, utm);
102 #ifdef GPS_USE_LATLONG
103  utm->zone = (gps.lla_pos.lon / 1e7 + 180) / 6 + 1;
104 #else
105  utm->zone = gps.utm_pos.zone;
106 #endif
107  utm_of_lla_f(utm, &lla0);
108 
110 }
111 #else
112 void WEAK ins_reset_utm_zone(struct UtmCoor_f *utm __attribute__((unused))) {}
113 #endif
114 
struct Ins ins
Definition: ins.c:51
int32_t north
in centimeters
InsInit init
Definition: ins.c:48
#define DefaultInsRegister()
Definition: ins.c:44
float east
in meters
void WEAK ins_reset_utm_zone(struct UtmCoor_f *utm)
INS utm zone reset.
Definition: ins.c:98
float north
in meters
float alt
in meters above WGS84 reference ellipsoid
Integrated Navigation System interface.
position in UTM coordinates Units: meters
int32_t east
in centimeters
struct UtmCoor_i utm_pos
position in UTM (north,east: cm; alt: mm over ellipsoid)
Definition: gps.h:70
void(* InsInit)(void)
Definition: ins.h:40
void WEAK ins_reset_altitude_ref(void)
INS altitude reference reset.
Definition: ins.c:95
uint8_t zone
UTM zone number.
vector in Latitude, Longitude and Altitude
#define DefaultInsImpl
Definition: ins_alt_float.h:56
int32_t hmsl
height above mean sea level in mm
Definition: gps.h:71
Device independent GPS code (interface)
void ins_init(void)
INS initialization.
Definition: ins.c:60
void lla_of_utm_f(struct LlaCoor_f *lla, struct UtmCoor_f *utm)
int32_t lon
in degrees*1e7
uint8_t zone
UTM zone number.
void WEAK ins_reset_local_origin(void)
INS local origin reset.
Definition: ins.c:72
Inertial Navigation System state.
Definition: ins.c:47
API to get/set the generic vehicle states.
struct LlaCoor_i lla_pos
position in LLA (lat,lon: deg*1e7; alt: mm over ellipsoid)
Definition: gps.h:69
void ins_register_impl(InsInit init)
Definition: ins.c:53
static void stateSetLocalUtmOrigin_f(struct UtmCoor_f *utm_def)
Set the local (flat earth) coordinate frame origin from UTM (float).
Definition: state.h:460
struct GpsState gps
global GPS state
Definition: gps.c:41
#define LLA_FLOAT_OF_BFP(_o, _i)
void utm_of_lla_f(struct UtmCoor_f *utm, struct LlaCoor_f *lla)