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
nps_autopilot_rotorcraft.c
Go to the documentation of this file.
1/*
2 * Copyright (C) 2009 Antoine Drouin <poinix@gmail.com>
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, write to
18 * the Free Software Foundation, 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
20 */
21
22#include "nps_autopilot.h"
23
24#include "main_ap.h"
25#include "nps_sensors.h"
26#include "nps_radio_control.h"
27#include "nps_electrical.h"
28#include "nps_fdm.h"
29
31#include "modules/imu/imu.h"
32#include "mcu_periph/sys_time.h"
33#include "state.h"
34#include "modules/ahrs/ahrs.h"
35#include "modules/ins/ins.h"
36#include "math/pprz_algebra.h"
37
38#ifdef NPS_USE_COMMANDS
40#define NPS_NO_MOTOR_MIXING TRUE
41#endif
42
43#ifndef NPS_NO_MOTOR_MIXING
45#if NPS_COMMANDS_NB != MOTOR_MIXING_NB_MOTOR
46#warning "NPS_COMMANDS_NB does not match MOTOR_MIXING_NB_MOTOR!"
47#endif
48#endif
49
50#include "modules/core/abi.h"
51
52#include "pprzlink/messages.h"
54
55// for datalink_time hack
58
62
63#ifndef NPS_BYPASS_AHRS
64#define NPS_BYPASS_AHRS FALSE
65#endif
66
67#ifndef NPS_BYPASS_INS
68#define NPS_BYPASS_INS FALSE
69#endif
70
71#if INDI_RPM_FEEDBACK
72#error "INDI_RPM_FEEDBACK can not be used in simulation!"
73#endif
74
88
93
94#include <stdio.h>
95#include "modules/gps/gps.h"
96
97void nps_autopilot_run_step(double time)
98{
99
101
102#if RADIO_CONTROL && !RADIO_CONTROL_TYPE_DATALINK
106 }
107#endif
108
112 }
113
115 imu_feed_mag();
117 }
118
121 float pressure = (float) sensors.baro.value;
124 }
125
129 }
130
131#if USE_AIRSPEED
133 AbiSendMsgAIRSPEED(AIRSPEED_NPS_ID, (float)sensors.airspeed.value);
135 }
136#endif
137
138#if USE_SONAR
141 float dist = (float) sensors.sonar.value;
142 if (dist >= 0.0) {
144 }
145
146#ifdef SENSOR_SYNC_SEND_SONAR
147 uint16_t foo = 0;
149#endif
150
152 }
153#endif
154
155#if USE_GPS
159 }
160#endif
161
162 if (nps_bypass_ahrs) {
164 }
165
166 if (nps_bypass_ins) {
168 }
169
171
172 /* scale final motor commands to 0-1 for feeding the fdm */
173 for (uint8_t i = 0; i < NPS_COMMANDS_NB; i++) {
174#if NPS_NO_MOTOR_MIXING
175 #if NPS_USE_COMMANDS
178 #else
181 #endif
182#else
184#endif
185 }
186}
187
188
190{
191
192 struct FloatQuat quat_f;
195
196 struct FloatRates rates_f;
199
200}
201
203{
204
205 struct NedCoor_f ltp_pos;
206 VECT3_COPY(ltp_pos, fdm.ltpprz_pos);
208
209 struct NedCoor_f ltp_speed;
210 VECT3_COPY(ltp_speed, fdm.ltpprz_ecef_vel);
212
213 struct NedCoor_f ltp_accel;
214 VECT3_COPY(ltp_accel, fdm.ltpprz_ecef_accel);
216
217}
Main include for ABI (AirBorneInterface).
#define BARO_SIM_SENDER_ID
#define AGL_SONAR_NPS_ID
#define AIRSPEED_NPS_ID
bool autopilot_get_motors_on(void)
get motors status
Definition autopilot.c:295
#define sensors(...)
static void sys_tick_handler(void)
uint32_t get_sys_time_usec(void)
Get the time in microseconds since startup.
Hardware independent code for commands handling.
Device independent GPS code (interface)
void gps_feed_value(void)
Definition gps_sim_nps.c:32
Roation quaternion.
angular rates
#define RATES_COPY(_a, _b)
#define QUAT_COPY(_qo, _qi)
#define VECT3_COPY(_a, _b)
static void stateSetAccelNed_f(uint16_t id, struct NedCoor_f *ned_accel)
Set acceleration in NED coordinates (float).
Definition state.h:1147
static void stateSetNedToBodyQuat_f(uint16_t id, struct FloatQuat *ned_to_body_quat)
Set vehicle body attitude from quaternion (float).
Definition state.h:1253
static void stateSetPositionNed_f(uint16_t id, struct NedCoor_f *ned_pos)
Set position from local NED coordinates (float).
Definition state.h:718
static void stateSetBodyRates_f(uint16_t id, struct FloatRates *body_rate)
Set vehicle body angular rate (float).
Definition state.h:1346
static void stateSetSpeedNed_f(uint16_t id, struct NedCoor_f *ned_speed)
Set ground speed in local NED coordinates (float).
Definition state.h:947
Inertial Measurement Unit interface.
void imu_feed_mag(void)
Definition imu_nps.c:76
void imu_feed_gyro_accel(void)
Definition imu_nps.c:65
Integrated Navigation System interface.
void main_ap_periodic(void)
Definition main_ap.c:119
void main_ap_event(void)
Definition main_ap.c:146
void main_ap_init(void)
Definition main_ap.c:79
Autopilot main loop.
uint16_t foo
Definition main_demo5.c:58
Hardware independent API for actuators (servos, motor controllers).
struct MotorMixing motor_mixing
Motor Mixing.
int32_t commands[MOTOR_MIXING_NB_MOTOR]
double commands[NPS_COMMANDS_NB]
#define NPS_COMMANDS_NB
Number of commands sent to the FDM of NPS.
struct NpsAutopilot nps_autopilot
void nps_autopilot_run_step(double time)
#define NPS_BYPASS_INS
void nps_autopilot_init(enum NpsRadioControlType type_rc, int num_rc_script, char *rc_dev)
bool nps_bypass_ahrs
bool nps_bypass_ins
void sim_overwrite_ins(void)
void nps_autopilot_run_systime_step(void)
void sim_overwrite_ahrs(void)
#define NPS_BYPASS_AHRS
void nps_electrical_init(void)
void nps_electrical_run_step(double time)
Electrical status (bat voltage) for NPS.
struct NedCoor_d ltpprz_ecef_vel
velocity in ltppprz frame, wrt ECEF frame
Definition nps_fdm.h:79
struct NedCoor_d ltpprz_pos
Definition nps_fdm.h:54
struct NedCoor_d ltpprz_ecef_accel
accel in ltppprz frame, wrt ECEF frame
Definition nps_fdm.h:81
struct DoubleQuat ltp_to_body_quat
Definition nps_fdm.h:91
struct DoubleRates body_ecef_rotvel
Definition nps_fdm.h:97
struct NpsFdm fdm
Holds all necessary NPS FDM state information.
void nps_radio_control_init(enum NpsRadioControlType type, int num_script, char *js_dev)
bool nps_radio_control_available(double time)
NpsRadioControlType
bool nps_sensors_airspeed_available(void)
Definition nps_sensors.c:85
bool nps_sensors_sonar_available(void)
Definition nps_sensors.c:76
bool nps_sensors_mag_available(void)
Definition nps_sensors.c:49
bool nps_sensors_gps_available(void)
Definition nps_sensors.c:67
bool nps_sensors_baro_available(void)
Definition nps_sensors.c:58
bool nps_sensors_gyro_available(void)
Definition nps_sensors.c:40
bool nps_sensors_temperature_available(void)
Definition nps_sensors.c:94
#define MAX_PPRZ
Definition paparazzi.h:8
Paparazzi generic algebra macros.
vector in North East Down coordinates Units: meters
Generic interface for radio control modules.
static const ShellCommand commands[]
Definition shell_arch.c:78
void radio_control_feed(void)
Definition ppm_arch.c:42
API to get/set the generic vehicle states.
#define TRUE
Definition std.h:4
Architecture independent timing functions.
unsigned short uint16_t
Typedef defining 16 bit unsigned short type.
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.