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
actuators.c
Go to the documentation of this file.
1/*
2 * Copyright (C) 2006 Pascal Brisset, Antoine Drouin
3 * Copyright (C) 2012 Gautier Hattenberger
4 *
5 * This file is part of paparazzi.
6 *
7 * paparazzi is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2, or (at your option)
10 * any later version.
11 *
12 * paparazzi is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with paparazzi; see the file COPYING. If not, write to
19 * the Free Software Foundation, 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
21 */
22
30#include "mcu_periph/sys_time.h"
31#ifdef INTERMCU_AP
33#endif
34#ifdef INTERMCU_FBW
35#include "main_fbw.h"
36#endif
37
38#if ACTUATORS_NB
39
40#if PERIODIC_TELEMETRY
42
43static void send_actuators_raw(struct transport_tx *trans, struct link_device *dev)
44{
45 // Downlink the actuators raw driver values
46 int16_t v[ACTUATORS_NB] = {0};
47 for (int i = 0; i < ACTUATORS_NB; i++) {
48 v[i] = actuators[i].driver_val;
49 }
51}
52
53static void send_actuators(struct transport_tx *trans, struct link_device *dev)
54{
55 // Downlink the actuators pprz actuator values
56 int16_t v[ACTUATORS_NB] = {0};
57 for (int i = 0; i < ACTUATORS_NB; i++) {
58 v[i] = actuators[i].pprz_val;
59 }
61}
62#endif
63
65
66// Can be used to directly control each actuator from the control algorithm
68
71
72void actuators_init(void)
73{
74
75#if defined ACTUATORS_START_DELAY && ! defined SITL
78#else
81#endif
82
83 // Init macro from generated airframe.h
84#if (defined INTERMCU_AP)
85 // TODO ApOnlyActuatorsInit();
86#elif (defined INTERMCU_FBW)
88#else
89 // default, init all actuators
91 // TODO ApOnlyActuatorsInit();
92#endif
93
94#if PERIODIC_TELEMETRY
97#endif
98}
99
104void actuators_periodic(void)
105{
106#if USE_COMMANDS
108 int i;
109 for (i = 0; i < COMMANDS_NB; i++) {trimmed_commands[i] = commands[i];}
110
111#ifdef COMMAND_ROLL
113#endif /* COMMAND_ROLL */
114
115#ifdef COMMAND_PITCH
117#endif /* COMMAND_PITCH */
118
119#ifdef COMMAND_YAW
121#endif /* COMMAND_YAW */
122
123#if (defined INTERMCU_AP)
125 // TODO SetApOnlyActuatorsFromCommands(ap_commands, autopilot_get_mode());
126#elif (defined INTERMCU_FBW)
128#else
129 // default, apply all commands
131 // TODO SetApOnlyActuatorsFromCommands(ap_commands, autopilot_get_mode());
132#endif
133#endif // USE_COMMANDS
134}
135
136#else // No command_laws section or no actuators
137
138void actuators_init(void) {}
140
141#endif
uint8_t autopilot_get_mode(void)
get autopilot mode
Definition autopilot.c:222
pprz_t command_pitch_trim
Definition commands.c:34
pprz_t command_roll_trim
Definition commands.c:33
pprz_t command_yaw_trim
Definition commands.c:35
Hardware independent code for commands handling.
static void send_actuators(struct transport_tx *trans, struct link_device *dev)
void intermcu_send_commands(pprz_t *command_values, uint8_t ap_mode)
send command vector over intermcu link instead of actuators
Inter-MCU on the AP side.
uint16_t foo
Definition main_demo5.c:58
Fly By Wire:
void actuators_periodic(void)
Definition actuators.c:139
void actuators_init(void)
Definition actuators.c:138
Hardware independent API for actuators (servos, motor controllers).
int16_t pprz_t
Definition paparazzi.h:6
#define MAX_PPRZ
Definition paparazzi.h:8
static const ShellCommand commands[]
Definition shell_arch.c:78
static const struct usb_device_descriptor dev
Definition usb_ser_hw.c:74
Architecture independent timing functions.
#define SysTimeTimerStart(_t)
Definition sys_time.h:227
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 int uint32_t
Typedef defining 32 bit unsigned int type.
short int16_t
Typedef defining 16 bit short type.