Paparazzi UAS  v5.10_stable-5-g83a0da5-dirty
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
meteo_france_DAQ.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2014 Gautier Hattenberger
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 
35 
36 #include "state.h"
37 #include "autopilot.h"
41 
42 #include "subsystems/gps.h"
44 
45 struct MF_DAQ mf_daq;
47 
48 #ifndef MF_DAQ_POWER_INIT
49 #define MF_DAQ_POWER_INIT TRUE
50 #endif
51 
52 #if !(defined MF_DAQ_POWER_PORT) && !(defined MF_DAQ_POWER_PIN)
53 INFO("MF_DAQ power pin is not defined")
54 #endif
55 
56 void init_mf_daq(void)
57 {
58  mf_daq.nb = 0;
60 #if (defined MF_DAQ_POWER_PORT) && (defined MF_DAQ_POWER_PIN)
61  gpio_setup_output(MF_DAQ_POWER_PORT, MF_DAQ_POWER_PIN);
62 #endif
64  log_started = false;
65 }
66 
68 {
69  // Send aircraft state to DAQ board
70  DOWNLINK_SEND_MF_DAQ_STATE(extra_pprz_tp, EXTRA_DOWNLINK_DEVICE,
73  &stateGetBodyRates_f()->q,
74  &stateGetBodyRates_f()->r,
76  &stateGetNedToBodyEulers_f()->theta,
78  &stateGetAccelNed_f()->x,
79  &stateGetAccelNed_f()->y,
80  &stateGetAccelNed_f()->z,
81  &stateGetSpeedEnu_f()->x,
82  &stateGetSpeedEnu_f()->y,
83  &stateGetSpeedEnu_f()->z,
84  &stateGetPositionLla_f()->lat,
85  &stateGetPositionLla_f()->lon,
86  &stateGetPositionLla_f()->alt,
89 }
90 
92 {
93  // Send report over normal telemetry
94  if (mf_daq.nb > 0) {
95  DOWNLINK_SEND_PAYLOAD_FLOAT(DefaultChannel, DefaultDevice, 9, mf_daq.values);
96  }
97  // Test if log is started
98  if (pprzLogFile != -1) {
99  if (log_started == FALSE) {
100  // Log MD5SUM once
101  DOWNLINK_SEND_ALIVE(pprzlog_tp, chibios_sdlog, 16, MD5SUM);
102  log_started = true;
103  }
104  // Log GPS for time reference
105  uint8_t foo = 0;
106  int16_t climb = -gps.ned_vel.z;
107  int16_t course = (DegOfRad(gps.course) / ((int32_t)1e6));
108  struct UtmCoor_f utm = *stateGetPositionUtm_f();
109  int32_t east = utm.east * 100;
110  int32_t north = utm.north * 100;
111  DOWNLINK_SEND_GPS(pprzlog_tp, chibios_sdlog, &gps.fix,
112  &east, &north, &course, &gps.hmsl, &gps.gspeed, &climb,
113  &gps.week, &gps.tow, &utm.zone, &foo);
114  }
115 }
116 
118 {
119  mf_daq.nb = dl_buffer[2];
120  if (mf_daq.nb > 0) {
121  if (mf_daq.nb > MF_DAQ_SIZE) { mf_daq.nb = MF_DAQ_SIZE; }
122  // Store data struct directly from dl_buffer
123  float *buf = (float*)(dl_buffer+3);
124  memcpy(mf_daq.values, buf, mf_daq.nb * sizeof(float));
125  // Log on SD card
126  if (log_started) {
127  DOWNLINK_SEND_PAYLOAD_FLOAT(pprzlog_tp, chibios_sdlog, mf_daq.nb, mf_daq.values);
128  DOWNLINK_SEND_MF_DAQ_STATE(pprzlog_tp, chibios_sdlog,
131  &stateGetBodyRates_f()->q,
132  &stateGetBodyRates_f()->r,
134  &stateGetNedToBodyEulers_f()->theta,
136  &stateGetAccelNed_f()->x,
137  &stateGetAccelNed_f()->y,
138  &stateGetAccelNed_f()->z,
139  &stateGetSpeedEnu_f()->x,
140  &stateGetSpeedEnu_f()->y,
141  &stateGetSpeedEnu_f()->z,
142  &stateGetPositionLla_f()->lat,
143  &stateGetPositionLla_f()->lon,
147  }
148  }
149 }
150 
151 
Extra datalink using PPRZ protocol.
float east
in meters
float north
in meters
static struct FloatEulers * stateGetNedToBodyEulers_f(void)
Get vehicle body attitude euler angles (float).
Definition: state.h:1125
float alt
in meters (above WGS84 reference ellipsoid or above MSL)
void mf_daq_send_state(void)
uint16_t autopilot_flight_time
flight time in seconds.
Definition: autopilot.c:48
uint16_t week
GPS week.
Definition: gps.h:100
void init_mf_daq(void)
#define MF_DAQ_SIZE
static struct LlaCoor_f * stateGetPositionLla_f(void)
Get position in LLA coordinates (float).
Definition: state.h:722
position in UTM coordinates Units: meters
int32_t z
Down.
void gpio_setup_output(ioportid_t port, uint16_t gpios)
Setup one or more pins of the given GPIO port as outputs.
Definition: gpio_arch.c:33
#define FALSE
Definition: std.h:5
chibios_sdlog structure
Definition: sdlog_chibios.h:55
bool log_started
#define meteo_france_DAQ_SetPower(_x)
int32_t hmsl
height above mean sea level (MSL) in mm
Definition: gps.h:88
struct pprz_transport extra_pprz_tp
Definition: extra_pprz_dl.c:26
uint32_t tow
GPS time of week in ms.
Definition: gps.h:101
struct MF_DAQ mf_daq
Device independent GPS code (interface)
static struct NedCoor_f * stateGetAccelNed_f(void)
Get acceleration in NED coordinates (float).
Definition: state.h:1020
signed short int16_t
Definition: types.h:17
uint16_t foo
Definition: main_demo5.c:59
FileDes pprzLogFile
Definition: sdlog_chibios.c:76
uint8_t zone
UTM zone number.
Communication module with the Data Acquisition board from Meteo France.
static struct FloatRates * stateGetBodyRates_f(void)
Get vehicle body angular rate (float).
Definition: state.h:1182
signed long int32_t
Definition: types.h:19
void parse_mf_daq_msg(void)
static struct UtmCoor_f * stateGetPositionUtm_f(void)
Get position in UTM coordinates (float).
Definition: state.h:686
unsigned char uint8_t
Definition: types.h:14
API to get/set the generic vehicle states.
int32_t course
GPS course over ground in rad*1e7, [0, 2*Pi]*1e7 (CW/north)
Definition: gps.h:93
#define MF_DAQ_POWER_INIT
static struct EnuCoor_f * stateGetSpeedEnu_f(void)
Get ground speed in local ENU coordinates (float).
Definition: state.h:905
static struct FloatVect2 * stateGetHorizontalWindspeed_f(void)
Get horizontal windspeed (float).
Definition: state.h:1359
static int16_t course[3]
Definition: airspeed_uADC.c:57
uint8_t dl_buffer[MSG_SIZE]
Definition: main_demo5.c:64
void mf_daq_send_report(void)
static float p[2][2]
uint16_t gspeed
norm of 2d ground speed in cm/s
Definition: gps.h:91
float values[MF_DAQ_SIZE]
uint8_t fix
status of fix
Definition: gps.h:99
struct NedCoor_i ned_vel
speed NED in cm/s
Definition: gps.h:90
struct GpsState gps
global GPS state
Definition: gps.c:75
uint8_t nb
uint8_t power