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
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_impl_init(void)
31 {
32 
36 
37 }
38 
39 void imu_periodic(void)
40 {
41 }
42 
43 
45 {
46 
47  RATES_ASSIGN(imu.gyro_unscaled, sensors.gyro.value.x, sensors.gyro.value.y, sensors.gyro.value.z);
48  VECT3_ASSIGN(imu.accel_unscaled, sensors.accel.value.x, sensors.accel.value.y, sensors.accel.value.z);
49 
50  // set availability flags...
53 
54 }
55 
56 
57 void imu_feed_mag(void)
58 {
59 
60  VECT3_ASSIGN(imu.mag_unscaled, sensors.mag.value.x, sensors.mag.value.y, sensors.mag.value.z);
62 
63 }
64 
65 void imu_nps_event(void)
66 {
67  uint32_t now_ts = get_sys_time_usec();
68  if (imu_nps.gyro_available) {
71  AbiSendMsgIMU_GYRO_INT32(IMU_BOARD_ID, now_ts, &imu.gyro);
72  }
76  AbiSendMsgIMU_ACCEL_INT32(IMU_BOARD_ID, now_ts, &imu.accel);
77  }
78  if (imu_nps.mag_available) {
81  AbiSendMsgIMU_MAG_INT32(IMU_BOARD_ID, now_ts, &imu.mag);
82  }
83 }
void imu_scale_gyro(struct Imu *_imu)
Definition: ahrs_gx3.c:349
Definition: imu_nps.h:72
#define IMU_BOARD_ID
void imu_scale_accel(struct Imu *_imu)
Definition: ahrs_gx3.c:350
void imu_nps_event(void)
Definition: imu_nps.c:65
#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).
uint8_t accel_available
Definition: imu_nps.h:74
#define FALSE
Definition: std.h:5
static uint32_t get_sys_time_usec(void)
Get the time in microseconds since startup.
Definition: sys_time_arch.h:39
struct Int32Vect3 mag_unscaled
unscaled magnetometer measurements
Definition: imu.h:52
struct Int32Rates gyro_unscaled
unscaled gyroscope measurements
Definition: imu.h:50
#define TRUE
Definition: std.h:4
void imu_feed_mag(void)
Definition: imu_nps.c:57
struct Int32Vect3 accel
accelerometer measurements in m/s^2 in BFP with INT32_ACCEL_FRAC
Definition: imu.h:43
struct Imu imu
global IMU state
Definition: imu_aspirin2.c:43
unsigned long uint32_t
Definition: types.h:18
struct Int32Vect3 mag
magnetometer measurements scaled to 1 in BFP with INT32_MAG_FRAC
Definition: imu.h:44
Inertial Measurement Unit interface.
void imu_feed_gyro_accel(void)
Definition: imu_nps.c:44
void imu_scale_mag(struct Imu *_imu)
Definition: ahrs_gx3.c:351
struct Int32Vect3 accel_unscaled
unscaled accelerometer measurements
Definition: imu.h:51
void imu_periodic(void)
optional.
Definition: imu_nps.c:39
uint8_t gyro_available
Definition: imu_nps.h:75
void imu_impl_init(void)
must be defined by underlying hardware
Definition: imu_nps.c:30
uint8_t mag_available
Definition: imu_nps.h:73
struct Int32Rates gyro
gyroscope measurements in rad/s in BFP with INT32_RATE_FRAC
Definition: imu.h:42
struct ImuNps imu_nps
Definition: imu_nps.c:28