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_gx3.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2013 Michal Podhradsky
3  * Utah State University, http://aggieair.usu.edu/
4  *
5  * This file is part of paparazzi.
6  *
7  * paparazzi is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2, or (at your option)
10  * any later version.
11  *
12  * paparazzi is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with paparazzi; see the file COPYING. If not, write to
19  * the Free Software Foundation, 59 Temple Place - Suite 330,
20  * Boston, MA 02111-1307, USA.
21  */
32 #ifndef AHRS_GX3_H
33 #define AHRS_GX3_H
34 
35 #include "generated/airframe.h"
36 #include "subsystems/imu.h"
37 #include "subsystems/ahrs.h"
38 #include "subsystems/ins.h"
39 #include "subsystems/gps.h"
40 #include "mcu_periph/uart.h"
42 
43 #include "state.h"
44 #include "led.h"
45 
46 #ifdef ImuScaleGyro
47 #undef ImuScaleGyro
48 #endif
49 #define ImuScaleGyro(_imu) {}
50 
51 #ifdef ImuScaleAccel
52 #undef ImuScaleAccel
53 #endif
54 #define ImuScaleAccel(_imu) {}
55 
56 #ifdef ImuScaleMag
57 #undef ImuScaleMag
58 #endif
59 #define ImuScaleMag(_imu) {}
60 
61 #define GX3_MAX_PAYLOAD 128
62 #define GX3_MSG_LEN 67
63 #define GX3_HEADER 0xC8
64 #define GX3_MIN_FREQ 300
65 
66 #define IMU_GX3_LONG_DELAY 4000000
67 
68 extern void gx3_packet_read_message(void);
69 extern void gx3_packet_parse(uint8_t c);
70 
71 struct GX3Packet {
72  bool_t msg_available;
78 };
79 
83 };
84 
85 enum GX3Status {
88 };
89 
90 //AHRS
91 struct AhrsFloatQuat {
93  float mag_offset;
94 
97  float gx3_freq;
104 };
105 
106 extern struct AhrsFloatQuat ahrs_impl;
107 
108 static inline void ReadGX3Buffer(void) {
110  gx3_packet_parse(uart_getch(&GX3_PORT));
111 }
112 
113 static inline void ImuEvent(void (* _gyro_handler)(void), void (* _accel_handler)(void), void (* _mag_handler)(void)) {
114  if (uart_char_available(&GX3_PORT)) {
115  ReadGX3Buffer();
116  }
119  _gyro_handler();
120  _accel_handler();
121  _mag_handler();
123  }
124 }
125 
126 #ifdef AHRS_UPDATE_FW_ESTIMATOR
127 extern float ins_roll_neutral;
128 extern float ins_pitch_neutral;
129 #endif
130 
131 #endif /* AHRS_GX3_H*/
Interface to align the AHRS via low-passed measurements at startup.
unsigned short uint16_t
Definition: types.h:16
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
rotation matrix
void gx3_packet_read_message(void)
Definition: ahrs_gx3.c:229
uint8_t uart_getch(struct uart_periph *p)
Definition: uart.c:204
Attitude and Heading Reference System interface.
uint8_t status
Definition: ahrs_gx3.h:76
static void ImuEvent(void(*_gyro_handler)(void), void(*_accel_handler)(void), void(*_mag_handler)(void))
Definition: ahrs_gx3.h:113
struct FloatRates gx3_rate
measured angular rates in IMU frame
Definition: ahrs_gx3.h:102
static uint16_t uart_char_available(struct uart_periph *p)
Check UART for available chars in receive buffer.
Definition: uart.h:87
struct GX3Packet gx3_packet
Packet struct.
Definition: ahrs_gx3.h:95
angular rates
float gx3_freq
data frequency
Definition: ahrs_gx3.h:97
Integrated Navigation System interface.
GX3Status
Definition: ahrs_gx3.h:85
void gx3_packet_parse(uint8_t c)
Definition: ahrs_gx3.c:296
GX3PacketStatus
Definition: ahrs_gx3.h:80
#define FALSE
Definition: imu_chimu.h:141
float mag_offset
Difference between true and magnetic north.
Definition: ahrs_gx3.h:93
Roation quaternion.
Device independent GPS code (interface)
struct AhrsFloatQuat ahrs_impl
Definition: ahrs_ardrone2.c:45
unsigned long uint32_t
Definition: types.h:18
uint32_t hdr_error
Definition: ahrs_gx3.h:74
uint8_t msg_buf[GX3_MAX_PAYLOAD]
Definition: ahrs_gx3.h:75
Inertial Measurement Unit interface.
#define GX3_MAX_PAYLOAD
Definition: ahrs_gx3.h:61
bool_t msg_available
Definition: ahrs_gx3.h:72
float ins_pitch_neutral
Definition: ins_arduimu.c:15
uint32_t gx3_time
GX3 time stamp.
Definition: ahrs_gx3.h:99
enum GX3Status gx3_status
GX3 status.
Definition: ahrs_gx3.h:96
struct FloatRMat gx3_rmat
measured attitude in IMU frame (rotational matrix)
Definition: ahrs_gx3.h:103
unsigned char uint8_t
Definition: types.h:14
API to get/set the generic vehicle states.
uint8_t msg_idx
Definition: ahrs_gx3.h:77
uint16_t gx3_chksm
aux variable for checksum
Definition: ahrs_gx3.h:98
static void ReadGX3Buffer(void)
Definition: ahrs_gx3.h:108
arch independent LED (Light Emitting Diodes) API
struct FloatQuat ltp_to_imu_quat
Rotation from LocalTangentPlane to IMU frame as quaternions.
Definition: ahrs_gx3.h:92
float ins_roll_neutral
Definition: ins_arduimu.c:14
uint32_t gx3_ltime
aux time stamp
Definition: ahrs_gx3.h:100
struct FloatVect3 gx3_accel
measured acceleration in IMU frame
Definition: ahrs_gx3.h:101
uint32_t chksm_error
Definition: ahrs_gx3.h:73