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
27#include "modules/loggers/logger_utils"
28#include "mcu_periph/sys_time.h"
29#include "state.h"
30
31#if USE_CHIBIOS_RTOS
32#define LogFormatHeader "%.5f,%ld,%ld,%ld,%ld,%ld,%ld"
33#define LogFormatVect3 ",%ld,%ld,%ld"
34
35#else // assume Linux based OS
36#define LogFormatHeader "%.5f,%d,%d,%d,%d,%d,%d"
37#define LogFormatVect3 ",%d,%d,%d"
39
40/* Set the default log path to bebop storage */
41#ifndef LOGGER_CONTROL_EFFECTIVENESS_FILE_PATH
42#define LOGGER_CONTROL_EFFECTIVENESS_FILE_PATH /data/ftp/internal_000/control_eff
43#endif
44
45#endif
46
47// define parameters logged by default
48
49#ifndef LOGGER_CONTROL_EFFECTIVENESS_COMMANDS
50#define LOGGER_CONTROL_EFFECTIVENESS_COMMANDS TRUE
51#endif
52
53#ifndef LOGGER_CONTROL_EFFECTIVENESS_ACTUATORS
54#define LOGGER_CONTROL_EFFECTIVENESS_ACTUATORS FALSE
55#endif
56
57#ifndef LOGGER_CONTROL_EFFECTIVENESS_POS
58#define LOGGER_CONTROL_EFFECTIVENESS_POS FALSE
59#endif
60
61#ifndef LOGGER_CONTROL_EFFECTIVENESS_SPEED
62#define LOGGER_CONTROL_EFFECTIVENESS_SPEED FALSE
63#endif
64
65#ifndef LOGGER_CONTROL_EFFECTIVENESS_AIRSPEED
66#define LOGGER_CONTROL_EFFECTIVENESS_AIRSPEED FALSE
67#endif
68
69// extra includes
70
71#if LOGGER_CONTROL_EFFECTIVENESS_COMMANDS
73#endif
74
75#if LOGGER_CONTROL_EFFECTIVENESS_ACTUATORS
77#endif
78
81{
83
85 LogWrite(pprzLogFile, "time,gyro_p,gyro_q,gyro_r,ax,ay,az");
86#if LOGGER_CONTROL_EFFECTIVENESS_COMMANDS
87 for (unsigned int i = 0; i < COMMANDS_NB; i++) {
88 LogWrite(pprzLogFile, ",cmd_%d", i);
89 }
90#endif
91#if LOGGER_CONTROL_EFFECTIVENESS_ACTUATORS
92 for (unsigned int i = 0; i < ACTUATORS_NB; i++) {
93 LogWrite(pprzLogFile, ",act_%d", i);
94 }
95#endif
96#if LOGGER_CONTROL_EFFECTIVENESS_POS
97 LogWrite(pprzLogFile, ",pos_x,pos_y,pos_z");
98#endif
99#if LOGGER_CONTROL_EFFECTIVENESS_SPEED
100 LogWrite(pprzLogFile, ",speed_x,speed_y,speed_z");
101#endif
102#if LOGGER_CONTROL_EFFECTIVENESS_AIRSPEED
103 LogWrite(pprzLogFile, ",eas");
104#endif
105 LogWrite(pprzLogFile,"\n");
106 }
107}
108
115
118{
120 return;
121 }
122
123 struct Int32Rates *rates = stateGetBodyRates_i();
125
126 // log time, rate and accel
129 rates->p,
130 rates->q,
131 rates->r,
132 accel_body->x,
133 accel_body->y,
134 accel_body->z);
135
136 // log commands
137#if LOGGER_CONTROL_EFFECTIVENESS_COMMANDS
138 for (unsigned int i = 0; i < COMMANDS_NB; i++) {
139 LogWrite(pprzLogFile, ",%d", commands[i]);
140 }
141#endif
142
143 // log actuators
144#if LOGGER_CONTROL_EFFECTIVENESS_ACTUATORS
145 for (unsigned int i = 0; i < ACTUATORS_NB; i++) {
147 }
148#endif
149
150 // log position
151#if LOGGER_CONTROL_EFFECTIVENESS_POS
152 struct EnuCoor_i *pos = stateGetPositionEnu_i();
153 LogWrite(pprzLogFile, LogFormatVect3, pos->x, pos->y, pos->z);
154#endif
155
156 // log speed
157#if LOGGER_CONTROL_EFFECTIVENESS_SPEED
158 struct EnuCoor_i *speed = stateGetSpeedEnu_i();
159 LogWrite(pprzLogFile, LogFormatVect3, speed->x, speed->y, speed->z);
160#endif
161
162 // log airspeed
163#if LOGGER_CONTROL_EFFECTIVENESS_AIRSPEED
165#endif
166
167 // end line
168 LogWrite(pprzLogFile,"\n");
169}
170
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:1366
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:1598
void logger_control_effectiveness_periodic(void)
Log the values to file.
#define LOGGER_CONTROL_EFFECTIVENESS_FILE_PATH
void logger_control_effectiveness_start(void)
Write the log header line according to the enabled parts.
#define LogFormatHeader
static FILE * pprzLogFile
void logger_control_effectiveness_stop(void)
#define LogFormatVect3
Log data required to compute control effectiveness.
#define LogOpen(_file, _path, _name)
#define LogFileIsOpen(_file)
#define LogWrite
#define LogClose(_file)
uint16_t foo
Definition main_demo5.c:58
Hardware independent API for actuators (servos, motor controllers).
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:168