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
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"
40 #include "subsystems/chibios-libopencm3/sdLog.h"
41 #include "subsystems/chibios-libopencm3/chibios_sdlog.h"
42 
43 #include "subsystems/gps.h"
45 
46 struct MF_DAQ mf_daq;
47 bool_t log_started;
48 
49 #ifndef MF_DAQ_POWER_INIT
50 #define MF_DAQ_POWER_INIT TRUE
51 #endif
52 
53 #if !(defined MF_DAQ_POWER_PORT) && !(defined MF_DAQ_POWER_PIN)
54 INFO("MF_DAQ power pin is not defined")
55 #endif
56 
57 void init_mf_daq(void) {
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
65 }
66 
67 void mf_daq_send_state(void) {
68  // Send aircraft state to DAQ board
69  DOWNLINK_SEND_MF_DAQ_STATE(PprzTransport, EXTRA_PPRZ_UART,
72  &stateGetBodyRates_f()->q,
73  &stateGetBodyRates_f()->r,
75  &stateGetNedToBodyEulers_f()->theta,
77  &stateGetAccelNed_f()->x,
78  &stateGetAccelNed_f()->y,
79  &stateGetAccelNed_f()->z,
80  &stateGetSpeedEnu_f()->x,
81  &stateGetSpeedEnu_f()->y,
82  &stateGetSpeedEnu_f()->z,
83  &stateGetPositionLla_f()->lat,
84  &stateGetPositionLla_f()->lon,
85  &stateGetPositionLla_f()->alt,
88 }
89 
90 void mf_daq_send_report(void) {
91  // Send report over normal telemetry
92  if (mf_daq.nb > 0) {
93  DOWNLINK_SEND_PAYLOAD_FLOAT(DefaultChannel, DefaultDevice, 9, mf_daq.values);
94  }
95  // Test if log is started
96  if (pprzLogFile.fs != NULL) {
97  if (log_started == FALSE) {
98  // Log MD5SUM once
99  DOWNLINK_SEND_ALIVE(PprzLogTransport, SDLOG, 16, MD5SUM);
100  log_started = TRUE;
101  }
102  // Log GPS for time reference
103  uint8_t foo = 0;
104  int16_t climb = -gps.ned_vel.z;
105  int16_t course = (DegOfRad(gps.course)/((int32_t)1e6));
106  DOWNLINK_SEND_GPS(PprzLogTransport, SDLOG, &gps.fix,
108  &course, &gps.hmsl, &gps.gspeed, &climb,
109  &gps.week, &gps.tow, &gps.utm_pos.zone, &foo);
110  }
111 }
112 
113 void parse_mf_daq_msg(void) {
114  mf_daq.nb = DL_PAYLOAD_FLOAT_values_length(dl_buffer);
115  if (mf_daq.nb > 0) {
117  // Store data struct directly from dl_buffer
118  memcpy(mf_daq.values, DL_PAYLOAD_FLOAT_values(dl_buffer), mf_daq.nb * sizeof(float));
119  // Log on SD card
120  if (log_started) {
121  DOWNLINK_SEND_PAYLOAD_FLOAT(PprzLogTransport, SDLOG, mf_daq.nb, mf_daq.values);
122  DOWNLINK_SEND_MF_DAQ_STATE(PprzLogTransport, SDLOG,
125  &stateGetBodyRates_f()->q,
126  &stateGetBodyRates_f()->r,
128  &stateGetNedToBodyEulers_f()->theta,
130  &stateGetAccelNed_f()->x,
131  &stateGetAccelNed_f()->y,
132  &stateGetAccelNed_f()->z,
133  &stateGetSpeedEnu_f()->x,
134  &stateGetSpeedEnu_f()->y,
135  &stateGetSpeedEnu_f()->z,
136  &stateGetPositionLla_f()->lat,
137  &stateGetPositionLla_f()->lon,
138  &stateGetPositionLla_f()->alt,
141  }
142  }
143 }
144 
145 
struct NedCoor_i ned_vel
speed NED in cm/s
Definition: gps.h:69
int32_t course
GPS course over ground in rad*1e7, [0, 2*Pi]*1e7 (CW/north)
Definition: gps.h:72
static struct FloatEulers * stateGetNedToBodyEulers_f(void)
Get vehicle body attitude euler angles (float).
Definition: state.h:1027
void mf_daq_send_state(void)
uint8_t zone
UTM zone number.
uint16_t autopilot_flight_time
flight time in seconds.
Definition: autopilot.c:47
void init_mf_daq(void)
bool_t log_started
#define MF_DAQ_SIZE
static struct LlaCoor_f * stateGetPositionLla_f(void)
Get position in LLA coordinates (float).
Definition: state.h:679
int32_t hmsl
height above mean sea level in mm
Definition: gps.h:67
uint8_t fix
status of fix
Definition: gps.h:78
int16_t week
GPS week.
Definition: gps.h:79
#define FALSE
Definition: imu_chimu.h:141
#define meteo_france_DAQ_SetPower(_x)
uint32_t tow
GPS time of week in ms.
Definition: gps.h:80
int32_t z
Down.
float values[MF_DAQ_SIZE]
int16_t gspeed
norm of 2d ground speed in cm/s
Definition: gps.h:70
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:938
signed short int16_t
Definition: types.h:17
uint8_t nb
uint16_t foo
Definition: main_demo5.c:54
int32_t north
in centimeters
Communication module with the Data Acquisition board from Meteo France.
uint8_t power
static struct FloatRates * stateGetBodyRates_f(void)
Get vehicle body angular rate (float).
Definition: state.h:1078
signed long int32_t
Definition: types.h:19
#define TRUE
Definition: imu_chimu.h:144
void parse_mf_daq_msg(void)
int32_t east
in centimeters
unsigned char uint8_t
Definition: types.h:14
API to get/set the generic vehicle states.
#define MF_DAQ_POWER_INIT
static void gpio_setup_output(uint32_t port, uint32_t gpios)
Setup one or more pins of the given GPIO port as outputs.
Definition: gpio_arch.h:76
static struct EnuCoor_f * stateGetSpeedEnu_f(void)
Get ground speed in local ENU coordinates (float).
Definition: state.h:840
static struct FloatVect2 * stateGetHorizontalWindspeed_f(void)
Get horizontal windspeed (float).
Definition: state.h:1192
uint8_t dl_buffer[MSG_SIZE]
Definition: main_demo5.c:59
void mf_daq_send_report(void)
static float p[2][2]
struct UtmCoor_i utm_pos
position in UTM (north,east: cm; alt: mm over ellipsoid)
Definition: gps.h:66
struct GpsState gps
global GPS state
Definition: gps.c:41