Paparazzi UAS v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
Loading...
Searching...
No Matches
logger_control_effectiveness.c
Go to the documentation of this file.
1/*
2 * Copyright (C) 2020 Gautier Hattenberger <gautier.hattenberger@enac.fr>
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, see
18 * <http://www.gnu.org/licenses/>.
19 *
20 */
21
28#include "mcu_periph/sys_time.h"
29#include "state.h"
30
31// define parameters logged by default
32
33#ifndef LOGGER_CONTROL_EFFECTIVENESS_COMMANDS
34#define LOGGER_CONTROL_EFFECTIVENESS_COMMANDS TRUE
35#endif
36
37#ifndef LOGGER_CONTROL_EFFECTIVENESS_ACTUATORS
38#define LOGGER_CONTROL_EFFECTIVENESS_ACTUATORS FALSE
39#endif
40
41#ifndef LOGGER_CONTROL_EFFECTIVENESS_POS
42#define LOGGER_CONTROL_EFFECTIVENESS_POS FALSE
43#endif
44
45#ifndef LOGGER_CONTROL_EFFECTIVENESS_SPEED
46#define LOGGER_CONTROL_EFFECTIVENESS_SPEED FALSE
47#endif
48
49#ifndef LOGGER_CONTROL_EFFECTIVENESS_AIRSPEED
50#define LOGGER_CONTROL_EFFECTIVENESS_AIRSPEED FALSE
51#endif
52
53// extra includes
54
55#if LOGGER_CONTROL_EFFECTIVENESS_COMMANDS
57#endif
58
59#if LOGGER_CONTROL_EFFECTIVENESS_ACTUATORS
61#endif
62
65{
66 if (pprzLogFile != -1) {
67 sdLogWriteLog(pprzLogFile, "time,gyro_p,gyro_q,gyro_r,ax,ay,az");
68#if LOGGER_CONTROL_EFFECTIVENESS_COMMANDS
69 for (unsigned int i = 0; i < COMMANDS_NB; i++) {
70 sdLogWriteLog(pprzLogFile, ",cmd_%d", i);
71 }
72#endif
73#if LOGGER_CONTROL_EFFECTIVENESS_ACTUATORS
74 for (unsigned int i = 0; i < ACTUATORS_NB; i++) {
75 sdLogWriteLog(pprzLogFile, ",act_%d", i);
76 }
77#endif
78#if LOGGER_CONTROL_EFFECTIVENESS_POS
79 sdLogWriteLog(pprzLogFile, ",pos_x,pos_y,pos_z");
80#endif
81#if LOGGER_CONTROL_EFFECTIVENESS_SPEED
82 sdLogWriteLog(pprzLogFile, ",speed_x,speed_y,speed_z");
83#endif
84#if LOGGER_CONTROL_EFFECTIVENESS_AIRSPEED
86#endif
88 }
89}
90
91
94{
95 if (pprzLogFile == -1) {
96 return;
97 }
98
99 struct Int32Rates *rates = stateGetBodyRates_i();
101
102 // log time, rate and accel
103 sdLogWriteLog(pprzLogFile, "%.5f,%ld,%ld,%ld,%ld,%ld,%ld",
105 rates->p,
106 rates->q,
107 rates->r,
108 accel_body->x,
109 accel_body->y,
110 accel_body->z);
111
112 // log commands
113#if LOGGER_CONTROL_EFFECTIVENESS_COMMANDS
114 for (unsigned int i = 0; i < COMMANDS_NB; i++) {
116 }
117#endif
118
119 // log actuators
120#if LOGGER_CONTROL_EFFECTIVENESS_ACTUATORS
121 for (unsigned int i = 0; i < ACTUATORS_NB; i++) {
123 }
124#endif
125
126 // log position
127#if LOGGER_CONTROL_EFFECTIVENESS_POS
128 struct EnuCoor_i *pos = stateGetPositionEnu_i();
129 sdLogWriteLog(pprzLogFile, ",%ld,%ld,%ld", pos->x, pos->y, pos->z);
130#endif
131
132 // log speed
133#if LOGGER_CONTROL_EFFECTIVENESS_SPEED
134 struct EnuCoor_i *speed = stateGetSpeedEnu_i();
135 sdLogWriteLog(pprzLogFile, ",%ld,%ld,%ld", speed->x, speed->y, speed->z);
136#endif
137
138 // log airspeed
139#if LOGGER_CONTROL_EFFECTIVENESS_AIRSPEED
141#endif
142
143 // end line
145}
146
Hardware independent code for commands handling.
int32_t p
in rad/s with INT32_RATE_FRAC
int32_t r
in rad/s with INT32_RATE_FRAC
int32_t q
in rad/s with INT32_RATE_FRAC
angular rates
int32_t y
North.
int32_t z
Up.
int32_t x
East.
vector in East North Up coordinates
static struct EnuCoor_i * stateGetPositionEnu_i(void)
Get position in local ENU coordinates (int).
Definition state.h:803
static struct Int32Rates * stateGetBodyRates_i(void)
Get vehicle body angular rate (int).
Definition state.h:1358
static struct Int32Vect3 * stateGetAccelBody_i(void)
Get acceleration in Body coordinates (int).
Definition state.h:1094
static struct EnuCoor_i * stateGetSpeedEnu_i(void)
Get ground speed in local ENU coordinates (int).
Definition state.h:1013
static float stateGetAirspeed_f(void)
Get airspeed (float).
Definition state.h:1590
void logger_control_effectiveness_periodic(void)
Log the values to file.
void logger_control_effectiveness_start(void)
Write the log header line according to the enabled parts.
Log data required to compute control effectiveness.
uint16_t foo
Definition main_demo5.c:58
Hardware independent API for actuators (servos, motor controllers).
FileDes pprzLogFile
static const ShellCommand commands[]
Definition shell_arch.c:78
API to get/set the generic vehicle states.
Architecture independent timing functions.
static float get_sys_time_float(void)
Get the time in seconds since startup.
Definition sys_time.h:138