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_gps_passthrough_utm.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2004-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 
29 #include "subsystems/ins.h"
30 
31 #include <inttypes.h>
32 #include <math.h>
33 
34 #include "state.h"
35 #include "subsystems/gps.h"
37 
39 
40 void ins_gps_utm_init(void)
41 {
42  struct UtmCoor_f utm0 = { nav_utm_north0, nav_utm_east0, 0., nav_utm_zone0 };
44  stateSetPositionUtm_f(&utm0);
45 }
46 
48 {
49  struct UtmCoor_f utm;
50 #ifdef GPS_USE_LATLONG
51  /* Recompute UTM coordinates in this zone */
52  struct LlaCoor_f lla;
54  utm.zone = (gps.lla_pos.lon / 1e7 + 180) / 6 + 1;
55  utm_of_lla_f(&utm, &lla);
56 #else
57  utm.zone = gps.utm_pos.zone;
58  utm.east = gps.utm_pos.east / 100.0f;
59  utm.north = gps.utm_pos.north / 100.0f;
60 #endif
61  // ground_alt
62  utm.alt = gps.hmsl / 1000.0f;
63  // reset state UTM ref
65 }
66 
68 {
69  struct UtmCoor_f utm = state.utm_origin_f;
70  utm.alt = gps.hmsl / 1000.0f;
72 }
73 
74 
75 #include "subsystems/abi.h"
77 
78 static void gps_cb(uint8_t sender_id __attribute__((unused)),
79  uint32_t stamp __attribute__((unused)),
80  struct GpsState *gps_s)
81 {
82  struct UtmCoor_f utm;
83  utm.east = gps_s->utm_pos.east / 100.0f;
84  utm.north = gps_s->utm_pos.north / 100.0f;
85  utm.zone = nav_utm_zone0;
86  utm.alt = gps_s->hmsl / 1000.0f;
87 
88  // set position
90 
91  struct NedCoor_f ned_vel = {
92  gps_s->ned_vel.x / 100.0f,
93  gps_s->ned_vel.y / 100.0f,
94  gps_s->ned_vel.z / 100.0f
95  };
96  // set velocity
97  stateSetSpeedNed_f(&ned_vel);
98 }
99 
101 {
103  AbiBindMsgGPS(ABI_BROADCAST, &gps_ev, gps_cb);
104 }
Event structure to store callbacks in a linked list.
Definition: abi_common.h:65
int32_t north
in centimeters
float east
in meters
float north
in meters
void ins_reset_altitude_ref(void)
INS altitude reference reset.
float alt
in meters above WGS84 reference ellipsoid
Main include for ABI (AirBorneInterface).
uint8_t nav_utm_zone0
Definition: common_nav.c:44
Integrated Navigation System interface.
position in UTM coordinates Units: meters
int32_t east
in centimeters
int32_t z
Down.
struct UtmCoor_i utm_pos
position in UTM (north,east: cm; alt: mm over ellipsoid)
Definition: gps.h:70
int32_t y
East.
static void stateSetPositionUtm_f(struct UtmCoor_f *utm_pos)
Set position from UTM coordinates (float).
Definition: state.h:565
uint8_t zone
UTM zone number.
vector in Latitude, Longitude and Altitude
static void stateSetSpeedNed_f(struct NedCoor_f *ned_speed)
Set ground speed in local NED coordinates (float).
Definition: state.h:792
int32_t hmsl
height above mean sea level in mm
Definition: gps.h:71
static void gps_cb(uint8_t sender_id, uint32_t stamp, struct GpsState *gps_s)
void ins_gps_utm_register(void)
int32_t nav_utm_north0
Definition: common_nav.c:43
vector in North East Down coordinates Units: meters
data structure for GPS information
Definition: gps.h:67
void ins_reset_local_origin(void)
INS local origin reset.
Device independent GPS code (interface)
int32_t x
North.
unsigned long uint32_t
Definition: types.h:18
void ins_gps_utm_init(void)
int32_t lon
in degrees*1e7
uint8_t zone
UTM zone number.
struct UtmCoor_f utm_origin_f
Definition of the origin of Utm coordinate system.
Definition: state.h:228
unsigned char uint8_t
Definition: types.h:14
API to get/set the generic vehicle states.
int32_t nav_utm_east0
Definition: common_nav.c:42
Simply passes GPS UTM position and velocity through to the state interface.
#define ABI_BROADCAST
Broadcast address.
Definition: abi_common.h:56
static abi_event gps_ev
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
struct NedCoor_i ned_vel
speed NED in cm/s
Definition: gps.h:73
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)
struct State state
Definition: state.c:36
void utm_of_lla_f(struct UtmCoor_f *utm, struct LlaCoor_f *lla)