Paparazzi UAS v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
imu_vectornav.c
Go to the documentation of this file.
1/*
2 * Copyright (C) 2016 Michal Podhradsky, michal.podhradsky@aggiemail.usu.edu
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
30
31// Systime
32#include "mcu_periph/sys_time.h"
33
34// Abi
35#include "modules/core/abi.h"
36
37// Generated
38#include "generated/airframe.h"
39
41
42#if PERIODIC_TELEMETRY
44
45
46static void send_vn_info(struct transport_tx *trans, struct link_device *dev)
47{
48 static uint16_t last_cnt = 0;
49 static uint16_t sec_cnt = 0;
50
52 imu_vn.vn_freq = sec_cnt; // update frequency counter
53
58 &sec_cnt,
64 // update counter
66
67 // reset mode
69}
70#endif
71
72
77{
78 // Initialize variables
80 imu_vn.vn_freq = 0;
81
82 // Initialize packet
91
92 // initialize data structs
93 memset(&(imu_vn.vn_data), 0, sizeof(struct VNData));
94
95#if PERIODIC_TELEMETRY
97#endif
98}
99
100
101
106{
107 // receive data
109
110 // read message
115 }
116}
117
118
125{
126 static uint16_t last_cnt = 0;
127 static uint16_t sec_cnt = 0;
128
130 imu_vn.vn_freq = sec_cnt; // update frequency counter
131
132 // we want at least 75% of periodic frequency to be able to control the airfcraft
133 if (imu_vn.vn_freq >= (PERIODIC_FREQUENCY*0.75)) {
135 }
136 else {
138 }
139}
140
141
146{
149
150 // Send accel and gyro data separate for other AHRS algorithms
153}
Main include for ABI (AirBorneInterface).
#define IMU_VECTORNAV_ID
float phi
in radians
float theta
in radians
float psi
in radians
void imu_vectornav_init(void)
Init IMU struct and set up ABI messages.
void imu_vectornav_event(void)
Event function to read and parse data from the serial port.
struct ImuVectornav imu_vn
void imu_vectornav_periodic(void)
Periodic function checks for the frequency of packets, triggers warning in case the IMU stops sending...
void imu_vectornav_propagate(void)
Send ABI messages.
static void send_vn_info(struct transport_tx *trans, struct link_device *dev)
Vectornav VN-200 IMU module, to be used with other AHRS/INS algorithms.
float vn_freq
data frequency
struct VNData vn_data
Data struct.
enum VNStatus vn_status
VN status.
struct VNPacket vn_packet
Packet struct.
uint16_t foo
Definition main_demo5.c:58
static const struct usb_device_descriptor dev
Definition usb_ser_hw.c:74
Architecture independent timing functions.
int8_t register_periodic_telemetry(struct periodic_telemetry *_pt, uint8_t _id, telemetry_cb _cb)
Register a telemetry callback function.
Definition telemetry.c:51
Periodic telemetry system header (includes downlink utility and generated code).
#define DefaultPeriodic
Set default periodic telemetry.
Definition telemetry.h:66
unsigned short uint16_t
Typedef defining 16 bit unsigned short type.
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.
unsigned long long uint64_t
void vn200_read_message(struct VNPacket *vn_packet, struct VNData *vn_data)
Read received message and populate data struct with new measurements.
void vn200_event(struct VNPacket *vnp)
uint16_t framing_error
uint32_t hdr_error
uint8_t err
see page 122 of VN-200 datasheet
@ VNNotTracking
@ VNOK
uint16_t overrun_error
struct FloatRates gyro
Rates in the imu frame m/s.
struct FloatEulers ypr_u
Attitude uncertainty, 1sigma, float, [degrees], yaw, pitch, roll.
struct FloatVect3 accel
Acceleration in the imu frame, m/s.
uint8_t mode
0-not tracking, 1 - poor performance, 2- OK
float timestamp
Time since VN startup [s].
@ VNMsgSync
uint16_t counter
uint64_t nanostamp
bool msg_available
uint16_t noise_error
uint32_t chksm_error
uint8_t msg_idx
enum VNMsgStatus status