31 #include "generated/modules.h"
42 #if NO_GPS_NEEDED_FOR_NAV
43 #define GpsIsLost() FALSE
45 #define GpsIsLost() TRUE
56 #ifndef AUTOPILOT_IN_FLIGHT_TIME
57 #define AUTOPILOT_IN_FLIGHT_TIME 20
61 #ifndef AUTOPILOT_IN_FLIGHT_MIN_SPEED
62 #define AUTOPILOT_IN_FLIGHT_MIN_SPEED 0.2
66 #ifndef AUTOPILOT_IN_FLIGHT_MIN_ACCEL
67 #define AUTOPILOT_IN_FLIGHT_MIN_ACCEL 2.0
71 #ifndef AUTOPILOT_IN_FLIGHT_MIN_THRUST
72 #define AUTOPILOT_IN_FLIGHT_MIN_THRUST 500
76 #ifndef THRESHOLD_GROUND_DETECT
77 #define THRESHOLD_GROUND_DETECT 25.0
130 pprz_msg_send_ROTORCRAFT_STATUS(trans,
dev, AC_ID,
131 &imu_nb_err, &_motor_nb_err,
147 pprz_msg_send_ENERGY(trans,
dev, AC_ID,
151 static void send_fp(
struct transport_tx *trans,
struct link_device *
dev)
157 #if GUIDANCE_INDI_HYBRID
165 pprz_msg_send_ROTORCRAFT_FP(trans,
dev, AC_ID,
185 pprz_msg_send_BODY_RATES_ACCEL(trans,
dev, AC_ID,
202 pprz_msg_send_ROTORCRAFT_FP_MIN(trans,
dev, AC_ID,
212 #ifdef RADIO_KILL_SWITCH
217 pprz_msg_send_ROTORCRAFT_RADIO_CONTROL(trans,
dev, AC_ID,
228 #if defined(COMMAND_ROLL) && defined(COMMAND_PITCH) && defined(COMMAND_YAW)
231 pprz_msg_send_ROTORCRAFT_CMD(trans,
dev, AC_ID,
struct pprz_autopilot autopilot
Global autopilot structure.
bool motors_on
motor status
bool ground_detected
automatic detection of landing
uint8_t arming_status
arming status
pprz_t throttle
throttle level as will be displayed in GCS
bool detect_ground_once
enable automatic detection of ground (one shot)
uint8_t mode
current autopilot mode
bool in_flight
in flight status
uint16_t flight_time
flight time in seconds
struct Electrical electrical
Interface for electrical status: supply voltage, current, battery status, etc.
uint32_t avg_power
average power sum
float energy
consumed energy in Wh
float current
current in A
uint32_t avg_cnt
average power counter
float charge
consumed electric charge in Ah
float vboard
board voltage in V
float vsupply
supply voltage in V
void autopilot_firmware_init(void)
Init function.
void autopilot_send_mode(void)
Report autopilot mode on default downlink channel.
struct GpsState gps
global GPS state
Device independent GPS code (interface)
uint16_t gspeed
norm of 2d ground speed in cm/s
void float_eulers_of_quat_zxy(struct FloatEulers *e, struct FloatQuat *q)
euler rotation 'ZXY' This rotation order is useful if you need 90 deg pitch
#define EULERS_BFP_OF_REAL(_ei, _ef)
int32_t phi
in rad with INT32_ANGLE_FRAC
int32_t psi
in rad with INT32_ANGLE_FRAC
int32_t theta
in rad with INT32_ANGLE_FRAC
#define ANGLE_BFP_OF_REAL(_af)
vector in East North Up coordinates
static struct NedCoor_f * stateGetAccelNed_f(void)
Get acceleration in NED coordinates (float).
static struct Int32Eulers * stateGetNedToBodyEulers_i(void)
Get vehicle body attitude euler angles (int).
static struct FloatQuat * stateGetNedToBodyQuat_f(void)
Get vehicle body attitude quaternion (float).
static struct EnuCoor_i * stateGetPositionEnu_i(void)
Get position in local ENU coordinates (int).
static struct FloatRates * stateGetBodyRates_f(void)
Get vehicle body angular rate (float).
static float stateGetHorizontalSpeedNorm_f(void)
Get norm of horizontal ground speed (float).
static struct EnuCoor_i * stateGetSpeedEnu_i(void)
Get ground speed in local ENU coordinates (int).
static struct NedCoor_f * stateGetSpeedNed_f(void)
Get ground speed in local NED coordinates (float).
static struct Int32Vect3 * stateGetAccelBody_i(void)
Get acceleration in Body coordinates (int).
struct FloatEulers eulers_zxy
state eulers in zxy order
struct MotorMixing motor_mixing
Optional exceptions triggeringg HOME_MODE 1) GEOFENCE_DATALINK_LOST_TIME: go to HOME mode if datalink...
vector in North East Down coordinates Units: meters
struct RadioControl radio_control
Generic interface for radio control modules.
pprz_t values[RADIO_CONTROL_NB_CHANNEL]
#define RADIO_KILL_SWITCH
#define RADIO_ROLL
Redefining RADIO_* Do not use with radio.h (ppm rc)
void autopilot_event(void)
autopilot event function
#define AUTOPILOT_IN_FLIGHT_MIN_SPEED
minimum vertical speed for in_flight condition in m/s
static void send_status(struct transport_tx *trans, struct link_device *dev)
uint8_t autopilot_mode_auto2
#define AUTOPILOT_IN_FLIGHT_TIME
time steps for in_flight detection (at 20Hz, so 20=1second)
static void send_energy(struct transport_tx *trans, struct link_device *dev)
static void send_body_rates_accel(struct transport_tx *trans, struct link_device *dev)
#define THRESHOLD_GROUND_DETECT
Z-acceleration threshold to detect ground in m/s^2.
bool WEAK autopilot_in_flight_end_detection(bool motors_on UNUSED)
Default end-of-in-flight detection estimation based on thrust and speed.
static void send_rotorcraft_rc(struct transport_tx *trans, struct link_device *dev)
void autopilot_check_in_flight(bool motors_on)
in flight check utility function
static void send_fp_min(struct transport_tx *trans, struct link_device *dev)
#define AUTOPILOT_IN_FLIGHT_MIN_ACCEL
minimum vertical acceleration for in_flight condition in m/s^2
static void send_rotorcraft_cmd(struct transport_tx *trans UNUSED, struct link_device *dev UNUSED)
static void send_fp(struct transport_tx *trans, struct link_device *dev)
bool WEAK autopilot_ground_detection(void)
Default ground-detection estimation based on accelerometer shock.
static uint32_t autopilot_in_flight_counter
void autopilot_reset_in_flight_counter(void)
reset in_flight counter
#define AUTOPILOT_IN_FLIGHT_MIN_THRUST
minimum thrust for in_flight condition in pprz_t units (max = 9600)
Rotorcraft specific autopilot interface and initialization.
struct HorizontalGuidance guidance_h
struct HorizontalGuidanceSetpoint sp
setpoints
struct VerticalGuidance guidance_v
int32_t z_sp
altitude setpoint in meters (input).
struct Stabilization stabilization
int32_t cmd[COMMANDS_NB]
output command vector, range from [-MAX_PPRZ:MAX_PPRZ] (store for messages)
static const struct usb_device_descriptor dev
struct Int32Vect2 pos
horizontal position setpoint in NED.
volatile uint32_t nb_sec
full seconds since startup
int8_t register_periodic_telemetry(struct periodic_telemetry *_pt, uint8_t _id, telemetry_cb _cb)
Register a telemetry callback function.
Periodic telemetry system header (includes downlink utility and generated code).
#define DefaultPeriodic
Set default periodic telemetry.
unsigned short uint16_t
Typedef defining 16 bit unsigned short type.
int int32_t
Typedef defining 32 bit int type.
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.
short int16_t
Typedef defining 16 bit short type.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.