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
autopilot_firmware.c
Go to the documentation of this file.
1/*
2 * Copyright (C) 2018 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
29
30#include "generated/modules.h"
31
32#include <stdint.h>
36
37#if USE_GPS
38#include "modules/gps/gps.h"
39#else
40#if NO_GPS_NEEDED_FOR_NAV
41#define GpsIsLost() FALSE
42#else
43#define GpsIsLost() TRUE
44#endif
45#endif
46
47
48/* Geofence exceptions */
50
51#if USE_MOTOR_MIXING
53#endif
54
55static void send_status(struct transport_tx *trans, struct link_device *dev)
56{
57#if USE_GPS
58 uint8_t fix = gps.fix;
59#else
60 uint8_t fix = 0;
61#endif
62 uint8_t motors_on = autopilot.motors_on;
66 &fix, &autopilot.mode, &motors_on,
68}
69
70static void send_energy(struct transport_tx *trans, struct link_device *dev)
71{
72 uint8_t throttle = 100 * autopilot.throttle / MAX_PPRZ;
73 float power = electrical.vsupply * electrical.current;
74 float avg_power = 0;
75 if(electrical.avg_cnt != 0) {
77 }
78
80 &throttle, &electrical.vsupply, &electrical.current, &power, &avg_power, &electrical.charge, &electrical.energy);
81}
82
107
108
109#ifdef RADIO_CONTROL
126#endif
127
138
143{
144}
145
struct pprz_autopilot autopilot
Global autopilot structure.
Definition autopilot.c:49
bool motors_on
motor status
Definition autopilot.h:68
pprz_t throttle
throttle level as will be displayed in GCS
Definition autopilot.h:66
uint8_t mode
current autopilot mode
Definition autopilot.h:63
uint16_t flight_time
flight time in seconds
Definition autopilot.h:65
struct Electrical electrical
Definition electrical.c:92
Interface for electrical status: supply voltage, current, battery status, etc.
uint32_t avg_power
average power sum
Definition electrical.h:53
float energy
consumed energy in Wh
Definition electrical.h:49
float current
current in A
Definition electrical.h:47
uint32_t avg_cnt
average power counter
Definition electrical.h:54
float charge
consumed electric charge in Ah
Definition electrical.h:48
float vsupply
supply voltage in V
Definition electrical.h:45
void autopilot_firmware_init(void)
Init function.
static void send_energy(struct transport_tx *trans, struct link_device *dev)
struct GpsState gps
global GPS state
Definition gps.c:74
Device independent GPS code (interface)
uint8_t fix
status of fix
Definition gps.h:107
#define ANGLE_BFP_OF_REAL(_af)
#define POS_BFP_OF_REAL(_af)
static struct Int32Eulers * stateGetNedToBodyEulers_i(void)
Get vehicle body attitude euler angles (int).
Definition state.h:1288
static struct EnuCoor_i * stateGetPositionEnu_i(void)
Get position in local ENU coordinates (int).
Definition state.h:803
static struct EnuCoor_i * stateGetSpeedEnu_i(void)
Get ground speed in local ENU coordinates (int).
Definition state.h:1013
uint16_t foo
Definition main_demo5.c:58
Motor Mixing.
Optional exceptions triggeringg HOME_MODE 1) GEOFENCE_DATALINK_LOST_TIME: go to HOME mode if datalink...
#define MAX_PPRZ
Definition paparazzi.h:8
float y
in meters
float x
in meters
struct RadioControl radio_control
Generic interface for radio control modules.
pprz_t values[RADIO_CONTROL_NB_CHANNEL]
uint8_t frame_rate
void autopilot_event(void)
autopilot event function
static void send_status(struct transport_tx *trans, struct link_device *dev)
static void send_rotorcraft_rc(struct transport_tx *trans, struct link_device *dev)
static void send_fp(struct transport_tx *trans, struct link_device *dev)
struct RotorcraftNavigation nav
Definition navigation.c:51
float heading
heading setpoint (in radians)
Definition navigation.h:133
struct EnuCoor_f carrot
carrot position (also used for GCS display)
Definition navigation.h:127
Rover specific autopilot interface and initialization.
static const struct usb_device_descriptor dev
Definition usb_ser_hw.c:74
volatile uint32_t nb_sec
full seconds since startup
Definition sys_time.h:72
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 short uint16_t
Typedef defining 16 bit unsigned short type.
int int32_t
Typedef defining 32 bit int type.
short int16_t
Typedef defining 16 bit short type.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.