Paparazzi UAS  v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
actuators_hitl.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2023 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 
28 #include "modules/core/commands.h"
30 #include "generated/airframe.h"
31 #if ROTORCRAFT_FIRMWARE && NPS_NO_MOTOR_MIXING
33 #endif
34 
35 
36 #ifndef HITL_DEVICE
37 #error "HITL_DEVICE must be defined"
38 #endif
39 
40 // for sending only
41 static struct pprz_transport actuators_hitl_tp;
42 
44 {
45  pprz_transport_init(&actuators_hitl_tp);
46 }
47 
49 {
50 #if FIXEDWING_FIRMWARE
51  pprz_msg_send_COMMANDS(&actuators_hitl_tp.trans_tx, &(HITL_DEVICE).device, AC_ID,
52  COMMANDS_NB, commands);
53 #endif
54 #if ROTORCRAFT_FIRMWARE
55 #if NPS_NO_MOTOR_MIXING
56  pprz_msg_send_ACTUATORS(&actuators_hitl_tp.trans_tx, &(HITL_DEVICE).device, AC_ID,
57  ACTUATORS_NB, actuators_pprz);
58 #else // use motor mixing
59  int16_t motors[MOTOR_MIXING_NB_MOTOR];
60  for (uint8_t i = 0; i < MOTOR_MIXING_NB_MOTOR; i++)
61  {
62  motors[i] = (int16_t)motor_mixing.commands[i];
63  }
64  pprz_msg_send_MOTOR_MIXING(&actuators_hitl_tp.trans_tx, &(HITL_DEVICE).device, AC_ID,
65  MOTOR_MIXING_NB_MOTOR, motors);
66 #endif
67 #endif
68 }
69 
70 
void actuators_hitl_periodic(void)
void actuators_hitl_init(void)
static struct pprz_transport actuators_hitl_tp
pprz_t commands[COMMANDS_NB]
Definition: commands.c:30
Hardware independent code for commands handling.
Hardware independent API for actuators (servos, motor controllers).
struct MotorMixing motor_mixing
Definition: motor_mixing.c:94
Motor Mixing.
int32_t commands[MOTOR_MIXING_NB_MOTOR]
Definition: motor_mixing.h:37
Periodic telemetry system header (includes downlink utility and generated code).
short int16_t
Typedef defining 16 bit short type.
Definition: vl53l1_types.h:93
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.
Definition: vl53l1_types.h:98