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
ahrs_sim.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2008-2011 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/ahrs.h"
32 #include "generated/airframe.h"
33 
34 extern float sim_phi;
35 extern float sim_theta;
36 extern float sim_psi;
37 extern float sim_p;
38 extern float sim_q;
39 extern float sim_r;
40 extern bool_t ahrs_sim_available;
41 
42 #ifdef AHRS_UPDATE_FW_ESTIMATOR
43 // remotely settable
44 #ifndef INS_ROLL_NEUTRAL_DEFAULT
45 #define INS_ROLL_NEUTRAL_DEFAULT 0
46 #endif
47 #ifndef INS_PITCH_NEUTRAL_DEFAULT
48 #define INS_PITCH_NEUTRAL_DEFAULT 0
49 #endif
52 #endif //AHRS_UPDATE_FW_ESTIMATOR
53 
55 
56  struct FloatEulers ltp_to_imu_euler = { sim_phi, sim_theta, sim_psi };
57 #ifdef AHRS_UPDATE_FW_ESTIMATOR
58  ltp_to_imu_euler.phi -= ins_roll_neutral;
59  ltp_to_imu_euler.theta -= ins_pitch_neutral;
60 #endif
61  struct FloatRates imu_rate = { sim_p, sim_q, sim_r };
62  /* set ltp_to_body to same as ltp_to_imu, currently no difference simulated */
63  stateSetNedToBodyEulers_f(&ltp_to_imu_euler);
64  stateSetBodyRates_f(&imu_rate);
65 
66 }
67 
68 
69 void ahrs_init(void) {
70  //ahrs_float.status = AHRS_UNINIT;
71  // set to running for now
73 
75 
76 }
77 
78 void ahrs_align(void)
79 {
80  /* Currently not really simulated
81  * body and imu have the same frame and always set to true value from sim
82  */
83 
85 
87 }
88 
89 
90 void ahrs_propagate(void) {
91  if (ahrs_sim_available) {
94  }
95 }
96 
static void stateSetNedToBodyEulers_f(struct FloatEulers *ned_to_body_eulers)
Set vehicle body attitude from euler angles (float).
Definition: state.h:995
bool_t ahrs_sim_available
Definition: jsbsim_ahrs.c:17
Attitude and Heading Reference System interface.
angular rates
struct Ahrs ahrs
global AHRS state
Definition: ahrs.c:30
#define INS_ROLL_NEUTRAL_DEFAULT
void ahrs_propagate(void)
Propagation.
Definition: ahrs_sim.c:90
float theta
in radians
euler angles
float sim_phi
in radians
Definition: jsbsim_ahrs.c:11
#define FALSE
Definition: imu_chimu.h:141
Paparazzi floating point algebra.
float phi
in radians
float sim_theta
in radians
Definition: jsbsim_ahrs.c:12
uint8_t status
status of the AHRS, AHRS_UNINIT or AHRS_RUNNING
Definition: ahrs.h:45
#define INS_PITCH_NEUTRAL_DEFAULT
void update_ahrs_from_sim(void)
Definition: ahrs_sim.c:54
float sim_r
in radians/s
Definition: jsbsim_ahrs.c:16
float sim_q
in radians/s
Definition: jsbsim_ahrs.c:15
void ahrs_align(void)
Aligns the AHRS.
Definition: ahrs_sim.c:78
float ins_pitch_neutral
Definition: ins_arduimu.c:15
float ins_roll_neutral
Definition: ins_arduimu.c:14
static void stateSetBodyRates_f(struct FloatRates *body_rate)
Set vehicle body angular rate (float).
Definition: state.h:1062
float sim_p
in radians/s
Definition: jsbsim_ahrs.c:14
float sim_psi
in radians
Definition: jsbsim_ahrs.c:13
#define AHRS_RUNNING
Definition: ahrs.h:36
Interface to set the AHRS from the simple OCaml simulator.
void ahrs_init(void)
AHRS initialization.
Definition: ahrs_sim.c:69