Paparazzi UAS  v5.12_stable-4-g9b43e9b
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
imu_nps.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012 Felix Ruess <felix.ruess@gmail.com
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 
22 #include "subsystems/imu.h"
23 #include "subsystems/abi.h"
24 #include "generated/airframe.h"
25 
26 #include "nps_sensors.h"
27 
28 struct ImuNps imu_nps;
29 
30 void imu_nps_init(void)
31 {
32 
33  imu_nps.gyro_available = false;
34  imu_nps.mag_available = false;
35  imu_nps.accel_available = false;
36 
37 }
38 
39 
41 {
42 
45 
46  // set availability flags...
47  imu_nps.accel_available = true;
48  imu_nps.gyro_available = true;
49 
50 }
51 
52 
53 void imu_feed_mag(void)
54 {
55 
57  imu_nps.mag_available = true;
58 
59 }
60 
61 void imu_nps_event(void)
62 {
63  uint32_t now_ts = get_sys_time_usec();
64  if (imu_nps.gyro_available) {
65  imu_nps.gyro_available = false;
67  AbiSendMsgIMU_GYRO_INT32(IMU_BOARD_ID, now_ts, &imu.gyro);
68  }
70  imu_nps.accel_available = false;
72  AbiSendMsgIMU_ACCEL_INT32(IMU_BOARD_ID, now_ts, &imu.accel);
73  }
74  if (imu_nps.mag_available) {
75  imu_nps.mag_available = false;
77  AbiSendMsgIMU_MAG_INT32(IMU_BOARD_ID, now_ts, &imu.mag);
78  }
79 }
struct NpsSensorAccel accel
Definition: nps_sensors.h:19
Definition: imu_nps.h:72
#define IMU_BOARD_ID
void imu_nps_event(void)
Definition: imu_nps.c:61
#define VECT3_ASSIGN(_a, _x, _y, _z)
Definition: pprz_algebra.h:124
#define RATES_ASSIGN(_ra, _p, _q, _r)
Definition: pprz_algebra.h:329
Main include for ABI (AirBorneInterface).
struct NpsSensorGyro gyro
Definition: nps_sensors.h:18
void imu_nps_init(void)
Definition: imu_nps.c:30
struct Imu imu
global IMU state
Definition: imu.c:108
uint8_t accel_available
Definition: imu_nps.h:74
struct DoubleVect3 value
struct Int32Vect3 mag_unscaled
unscaled magnetometer measurements
Definition: imu.h:48
struct Int32Rates gyro_unscaled
unscaled gyroscope measurements
Definition: imu.h:46
void imu_feed_mag(void)
Definition: imu_nps.c:53
struct Int32Vect3 accel
accelerometer measurements in m/s^2 in BFP with INT32_ACCEL_FRAC
Definition: imu.h:39
struct DoubleVect3 value
unsigned long uint32_t
Definition: types.h:18
struct NpsSensors sensors
Definition: nps_sensors.c:6
struct Int32Vect3 mag
magnetometer measurements scaled to 1 in BFP with INT32_MAG_FRAC
Definition: imu.h:40
Inertial Measurement Unit interface.
void imu_scale_gyro(struct Imu *_imu)
Definition: imu_vectornav.c:43
void imu_feed_gyro_accel(void)
Definition: imu_nps.c:40
void imu_scale_mag(struct Imu *_imu)
Definition: ahrs_gx3.c:351
struct Int32Vect3 accel_unscaled
unscaled accelerometer measurements
Definition: imu.h:47
void imu_scale_accel(struct Imu *_imu)
Definition: imu_vectornav.c:44
uint8_t gyro_available
Definition: imu_nps.h:75
uint32_t get_sys_time_usec(void)
Get the time in microseconds since startup.
Definition: sys_time_arch.c:68
struct DoubleVect3 value
uint8_t mag_available
Definition: imu_nps.h:73
struct NpsSensorMag mag
Definition: nps_sensors.h:20
struct Int32Rates gyro
gyroscope measurements in rad/s in BFP with INT32_RATE_FRAC
Definition: imu.h:38
struct ImuNps imu_nps
Definition: imu_nps.c:28