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_sim_hitl.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2014 Sergey Krukowski <softsr@yahoo.de>
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 
27 #ifndef GPS_SIM_HITL_H
28 #define GPS_SIM_HITL_H
29 
30 #include "std.h"
31 #include "state.h"
32 #include "guidance/guidance_h.h"
33 #include "guidance/guidance_v.h"
34 
35 extern bool_t gps_available;
37 
38 #define GpsEvent(_sol_available_callback) { \
39  if (SysTimeTimer(gps_sim_hitl_timer) > 100000) { \
40  SysTimeTimerStart(gps_sim_hitl_timer); \
41  gps.last_msg_ticks = sys_time.nb_sec_rem; \
42  gps.last_msg_time = sys_time.nb_sec; \
43  if (state.ned_initialized_i) { \
44  if (!autopilot_in_flight) { \
45  struct Int32Vect2 zero_vector; \
46  INT_VECT2_ZERO(zero_vector); \
47  gh_set_ref(zero_vector, zero_vector, zero_vector); \
48  INT_VECT2_ZERO(guidance_h_pos_ref); \
49  INT_VECT2_ZERO(guidance_h_speed_ref); \
50  INT_VECT2_ZERO(guidance_h_accel_ref); \
51  gv_set_ref(0, 0, 0); \
52  guidance_v_z_ref = 0; \
53  guidance_v_zd_ref = 0; \
54  guidance_v_zdd_ref = 0; \
55  } \
56  struct NedCoor_i ned_c; \
57  ned_c.x = guidance_h_pos_ref.x * INT32_POS_OF_CM_DEN / INT32_POS_OF_CM_NUM; \
58  ned_c.y = guidance_h_pos_ref.y * INT32_POS_OF_CM_DEN / INT32_POS_OF_CM_NUM; \
59  ned_c.z = guidance_v_z_ref * INT32_POS_OF_CM_DEN / INT32_POS_OF_CM_NUM; \
60  ecef_of_ned_point_i(&gps.ecef_pos, &state.ned_origin_i, &ned_c); \
61  gps.lla_pos.alt = state.ned_origin_i.lla.alt - ned_c.z; \
62  gps.hmsl = state.ned_origin_i.hmsl - ned_c.z; \
63  ned_c.x = guidance_h_speed_ref.x * INT32_SPEED_OF_CM_S_DEN / INT32_SPEED_OF_CM_S_NUM; \
64  ned_c.y = guidance_h_speed_ref.y * INT32_SPEED_OF_CM_S_DEN / INT32_SPEED_OF_CM_S_NUM; \
65  ned_c.z = guidance_v_zd_ref * INT32_SPEED_OF_CM_S_DEN / INT32_SPEED_OF_CM_S_NUM; \
66  ecef_of_ned_vect_i(&gps.ecef_vel, &state.ned_origin_i, &ned_c); \
67  gps.fix = GPS_FIX_3D; \
68  gps.last_3dfix_ticks = sys_time.nb_sec_rem; \
69  gps.last_3dfix_time = sys_time.nb_sec; \
70  gps_available = TRUE; \
71  } \
72  else { \
73  struct Int32Vect2 zero_vector; \
74  INT_VECT2_ZERO(zero_vector); \
75  gh_set_ref(zero_vector, zero_vector, zero_vector); \
76  gv_set_ref(0, 0, 0); \
77  } \
78  _sol_available_callback(); \
79  gps_available = FALSE; \
80  } \
81  }
82 
83 #endif /* GPS_SIM_HITL_H */
bool_t gps_available
Is set to TRUE when a new REMOTE_GPS packet is received and parsed.
Definition: gps_datalink.c:32
unsigned long uint32_t
Definition: types.h:18
API to get/set the generic vehicle states.
Horizontal guidance for rotorcrafts.
uint32_t gps_sim_hitl_timer
Definition: gps_sim_hitl.c:30