mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-05-24 05:45:59 +08:00
if_calib.[ch] -----> rc_settings.[ch]
This commit is contained in:
+1
-1
@@ -80,7 +80,7 @@ $(FLIGHT_PLAN_XML) : $(CONF)/$(FLIGHT_PLAN) $(CONF_XML)
|
||||
$(Q)$(TOOLS)/gen_flight_plan.out -dump $< > /tmp/fp.xml
|
||||
$(Q)mv /tmp/fp.xml $@
|
||||
|
||||
$(INFLIGHT_CALIB_H) : $(CONF)/$(FLIGHT_PLAN) $(CONF_XML)
|
||||
$(INFLIGHT_CALIB_H) : $(CONF)/$(FLIGHT_PLAN) $(CONF_XML) $(TOOLS)/gen_calib.out
|
||||
@echo BUILD $@
|
||||
$(Q)$(TOOLS)/gen_calib.out $< > /tmp/c.h
|
||||
$(Q)mv /tmp/c.h $@
|
||||
|
||||
@@ -123,7 +123,7 @@ ap.CFLAGS += -DMODEM -DDOWNLINK_AP_DEVICE=Modem
|
||||
ap.srcs += $(SRC_ARCH)/modem_hw.c
|
||||
|
||||
ap.CFLAGS += -DRADIO_CONTROL_CALIB
|
||||
ap.srcs += if_calib.c
|
||||
ap.srcs += rc_settings.c
|
||||
|
||||
</makefile>
|
||||
</airframe>
|
||||
|
||||
@@ -116,7 +116,7 @@ ap.CFLAGS += -DMODEM -DDOWNLINK_AP_DEVICE=Modem
|
||||
ap.srcs += $(SRC_ARCH)/modem_hw.c
|
||||
|
||||
ap.CFLAGS += -DRADIO_CONTROL_CALIB
|
||||
ap.srcs += if_calib.c
|
||||
ap.srcs += rc_settings.c
|
||||
|
||||
# Config for SITL simulation
|
||||
include $(PAPARAZZI_SRC)/conf/autopilot/sitl.makefile
|
||||
|
||||
@@ -126,7 +126,7 @@ ap.CFLAGS += -DMODEM -DDOWNLINK_AP_DEVICE=Modem
|
||||
ap.srcs += $(SRC_ARCH)/modem_hw.c
|
||||
|
||||
ap.CFLAGS += -DRADIO_CONTROL_CALIB
|
||||
ap.srcs += if_calib.c
|
||||
ap.srcs += rc_settings.c
|
||||
|
||||
# Config for SITL simulation
|
||||
include $(PAPARAZZI_SRC)/conf/autopilot/sitl.makefile
|
||||
|
||||
@@ -128,8 +128,8 @@ ap.srcs += pprz_transport.c downlink.c
|
||||
ap.CFLAGS += -DMODEM -DDOWNLINK_AP_DEVICE=Modem
|
||||
ap.srcs += $(SRC_ARCH)/modem_hw.c
|
||||
|
||||
ap.CFLAGS += -DRADIO_CONTROL_CALIB
|
||||
ap.srcs += if_calib.c
|
||||
ap.CFLAGS += -DRADIO_CONTROL_SETTINGS
|
||||
ap.srcs += rc_settings.c
|
||||
|
||||
ap.CFLAGS += -DDATALINK=WAVECARD
|
||||
ap.srcs += traffic_info.c datalink.c
|
||||
|
||||
@@ -2,5 +2,5 @@ sim.ARCHDIR = $(ARCHI)
|
||||
sim.ARCH = sitl
|
||||
sim.TARGET = autopilot
|
||||
sim.TARGETDIR = autopilot
|
||||
sim.CFLAGS += -DSITL -DAP -DFBW -DRADIO_CONTROL -DINTER_MCU -DDOWNLINK -DDOWNLINK_TRANSPORT=IvyTransport -DINFRARED -DRADIO_CONTROL_CALIB
|
||||
sim.srcs = radio_control.c downlink.c commands.c gps.c inter_mcu.c infrared.c pid.c nav.c estimator.c cam.c sys_time.c main_fbw.c main_ap.c if_calib.c $(SRC_ARCH)/ppm_hw.c $(SRC_ARCH)/sim_gps.c $(SRC_ARCH)/sim_ir.c $(SRC_ARCH)/sim_ap.c $(SRC_ARCH)/ivy_transport.c
|
||||
sim.CFLAGS += -DSITL -DAP -DFBW -DRADIO_CONTROL -DINTER_MCU -DDOWNLINK -DDOWNLINK_TRANSPORT=IvyTransport -DINFRARED -DRADIO_CONTROL_SETTINGS
|
||||
sim.srcs = radio_control.c downlink.c commands.c gps.c inter_mcu.c infrared.c pid.c nav.c estimator.c cam.c sys_time.c main_fbw.c main_ap.c rc_settings.c $(SRC_ARCH)/ppm_hw.c $(SRC_ARCH)/sim_gps.c $(SRC_ARCH)/sim_ir.c $(SRC_ARCH)/sim_ap.c $(SRC_ARCH)/ivy_transport.c
|
||||
|
||||
@@ -68,7 +68,7 @@
|
||||
DOWNLINK_SEND_ATTITUDE(&phi, &psi, &theta); \
|
||||
})
|
||||
|
||||
#define PERIODIC_SEND_PPRZ_MODE() DOWNLINK_SEND_PPRZ_MODE(&pprz_mode, &vertical_mode, &lateral_mode, &horizontal_mode, &inflight_calib_mode, &mcu1_status, &ir_estim_mode);
|
||||
#define PERIODIC_SEND_PPRZ_MODE() DOWNLINK_SEND_PPRZ_MODE(&pprz_mode, &vertical_mode, &lateral_mode, &horizontal_mode, &rc_settings_mode, &mcu1_status, &ir_estim_mode);
|
||||
#define PERIODIC_SEND_DESIRED() DOWNLINK_SEND_DESIRED(&desired_roll, &desired_pitch, &desired_x, &desired_y, &desired_altitude, &desired_climb);
|
||||
|
||||
#define PERIODIC_SEND_NAVIGATION_REF() DOWNLINK_SEND_NAVIGATION_REF(&nav_utm_east0, &nav_utm_north0, &nav_utm_zone0);
|
||||
@@ -96,8 +96,8 @@
|
||||
} \
|
||||
}
|
||||
|
||||
#ifdef RADIO_CONTROL_CALIB
|
||||
#define PERIODIC_SEND_SETTINGS() if (inflight_calib_mode != IF_CALIB_MODE_NONE) DOWNLINK_SEND_SETTINGS(&slider_1_val, &slider_2_val);
|
||||
#ifdef RADIO_CONTROL_SETTINGS
|
||||
#define PERIODIC_SEND_SETTINGS() if (!RcSettingsOff()) DOWNLINK_SEND_SETTINGS(&slider_1_val, &slider_2_val);
|
||||
#else
|
||||
#define PERIODIC_SEND_SETTINGS() {}
|
||||
#endif
|
||||
|
||||
@@ -98,12 +98,12 @@ extern float slider_1_val, slider_2_val;
|
||||
|
||||
extern bool_t launch;
|
||||
|
||||
|
||||
#define ModeUpdate(_mode, _value) { \
|
||||
/** Assignment, returning _old_value != _value
|
||||
* Using GCC expression statements */
|
||||
#define ModeUpdate(_mode, _value) ({ \
|
||||
uint8_t new_mode = _value; \
|
||||
if (_mode != new_mode) { _mode = new_mode; return TRUE; } \
|
||||
return FALSE; \
|
||||
}
|
||||
(_mode != new_mode ? _mode = new_mode, TRUE : FALSE); \
|
||||
})
|
||||
|
||||
#define CheckEvent(_event) (_event ? _event = FALSE, TRUE : FALSE)
|
||||
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
#ifndef IF_CALIB_H
|
||||
|
||||
#include "inter_mcu.h"
|
||||
|
||||
extern uint8_t inflight_calib_mode;
|
||||
void inflight_calib(bool_t calib_mode_changed);
|
||||
|
||||
|
||||
#define IF_CALIB_MODE_NONE 0
|
||||
#define IF_CALIB_MODE_DOWN 1
|
||||
#define IF_CALIB_MODE_UP 2
|
||||
|
||||
#define IF_CALIB_MODE_OF_PULSE(pprz) (pprz < TRESHOLD1 ? IF_CALIB_MODE_UP : \
|
||||
(pprz < TRESHOLD2 ? IF_CALIB_MODE_NONE : \
|
||||
IF_CALIB_MODE_DOWN))
|
||||
|
||||
#endif // IF_CALIB_H
|
||||
+13
-27
@@ -43,7 +43,7 @@
|
||||
#include "nav.h"
|
||||
#include "autopilot.h"
|
||||
#include "estimator.h"
|
||||
#include "if_calib.h"
|
||||
#include "rc_settings.h"
|
||||
#include "cam.h"
|
||||
#include "traffic_info.h"
|
||||
#include "link_mcu.h"
|
||||
@@ -64,7 +64,8 @@
|
||||
#define LOW_BATTERY_DECIVOLT (LOW_BATTERY*10)
|
||||
|
||||
|
||||
uint8_t inflight_calib_mode = IF_CALIB_MODE_NONE;
|
||||
/** FIXME: should be in rc_settings but required by telemetry (ap_downlink.h)*/
|
||||
uint8_t rc_settings_mode = RC_SETTINGS_MODE_NONE;
|
||||
|
||||
|
||||
/** Define minimal speed for takeoff in m/s */
|
||||
@@ -108,7 +109,7 @@ static inline uint8_t pprz_mode_update( void ) {
|
||||
if ((pprz_mode != PPRZ_MODE_HOME &&
|
||||
pprz_mode != PPRZ_MODE_GPS_OUT_OF_ORDER)
|
||||
|| CheckEvent(rc_event_1)) {
|
||||
ModeUpdate(pprz_mode, PPRZ_MODE_OF_PULSE(fbw_state->channels[RADIO_MODE], fbw_state->status));
|
||||
return ModeUpdate(pprz_mode, PPRZ_MODE_OF_PULSE(fbw_state->channels[RADIO_MODE], fbw_state->status));
|
||||
} else
|
||||
return FALSE;
|
||||
}
|
||||
@@ -118,7 +119,7 @@ static inline uint8_t pprz_mode_update( void ) {
|
||||
* \brief update ir estimation if RADIO_LLS is true \n
|
||||
*/
|
||||
inline uint8_t ir_estim_mode_update( void ) {
|
||||
ModeUpdate(ir_estim_mode, IR_ESTIM_MODE_OF_PULSE(fbw_state->channels[RADIO_LLS]));
|
||||
return ModeUpdate(ir_estim_mode, IR_ESTIM_MODE_OF_PULSE(fbw_state->channels[RADIO_LLS]));
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -133,12 +134,9 @@ static inline uint8_t mcu1_status_update( void ) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/** Delay between @@@@@ A FIXER @@@@@ */
|
||||
/** Minimum delay before an event is enabled */
|
||||
#define EVENT_DELAY 20
|
||||
|
||||
/** \def EventUpdate(_cpt, _cond, _event)
|
||||
* @@@@@ A FIXER @@@@@
|
||||
*/
|
||||
#define EventUpdate(_cpt, _cond, _event) \
|
||||
if (_cond) { \
|
||||
if (_cpt < EVENT_DELAY) { \
|
||||
@@ -151,26 +149,14 @@ static inline uint8_t mcu1_status_update( void ) {
|
||||
}
|
||||
|
||||
|
||||
#if defined RADIO_CALIB && defined RADIO_CONTROL_CALIB
|
||||
static inline uint8_t inflight_calib_mode_update ( void ) {
|
||||
ModeUpdate(inflight_calib_mode, IF_CALIB_MODE_OF_PULSE(fbw_state->channels[RADIO_CALIB]));
|
||||
}
|
||||
#define EventPos(_cpt, _channel, _event) \
|
||||
EventUpdate(_cpt, (inflight_calib_mode==IF_CALIB_MODE_NONE && fbw_state->channels[_channel]>(int)(0.75*MAX_PPRZ)), _event)
|
||||
|
||||
#define EventNeg(_cpt, _channel, _event) \
|
||||
EventUpdate(_cpt, (inflight_calib_mode==IF_CALIB_MODE_NONE && fbw_state->channels[_channel]<(int)(-0.75*MAX_PPRZ)), _event)
|
||||
|
||||
#else // RADIO_CALIB && defined RADIO_CONTROL_CALIB
|
||||
#define Event(_cpt, _channel, _event, _cond) \
|
||||
EventUpdate(_cpt, (RcSettingsOff() && fbw_state->channels[_channel] _cond), _event)
|
||||
|
||||
#define EventPos(_cpt, _channel, _event) \
|
||||
EventUpdate(_cpt, (fbw_state->channels[_channel]>(int)(0.75*MAX_PPRZ)), _event)
|
||||
Event(_cpt, _channel, _event, >(int)(0.75*MAX_PPRZ))
|
||||
|
||||
#define EventNeg(_cpt, _channel, _event) \
|
||||
EventUpdate(_cpt, (fbw_state->channels[_channel]<(int)(-0.75*MAX_PPRZ)), _event)
|
||||
|
||||
#endif // RADIO_CALIB && defined RADIO_CONTROL_CALIB
|
||||
|
||||
Event(_cpt, _channel, _event, <(int)(-0.75*MAX_PPRZ))
|
||||
|
||||
|
||||
|
||||
@@ -235,9 +221,9 @@ inline void telecommand_task( void ) {
|
||||
#ifdef RADIO_LLS
|
||||
mode_changed |= ir_estim_mode_update();
|
||||
#endif
|
||||
#if defined RADIO_CALIB && defined RADIO_CONTROL_CALIB
|
||||
bool_t calib_mode_changed = inflight_calib_mode_update();
|
||||
inflight_calib(calib_mode_changed || pprz_mode_changed);
|
||||
#if defined RADIO_CALIB && defined RADIO_CONTROL_SETTINGS
|
||||
bool_t calib_mode_changed = RcSettingsModeUpdate(fbw_state->channels);
|
||||
rc_settings(calib_mode_changed || pprz_mode_changed);
|
||||
mode_changed |= calib_mode_changed;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -25,12 +25,13 @@
|
||||
|
||||
|
||||
#include <inttypes.h>
|
||||
#include "rc_settings.h"
|
||||
#include "radio.h"
|
||||
#include "autopilot.h"
|
||||
#include "if_calib.h"
|
||||
#include "infrared.h"
|
||||
#include "pid.h"
|
||||
#include "nav.h"
|
||||
#include "estimator.h"
|
||||
|
||||
|
||||
#define ParamValInt16(param_init_val, param_travel, cur_pulse, init_pulse) \
|
||||
@@ -39,10 +40,6 @@
|
||||
#define ParamValFloat(param_init_val, param_travel, cur_pulse, init_pulse) \
|
||||
(param_init_val + ((float)(cur_pulse - init_pulse)) * param_travel / (float)MAX_PPRZ)
|
||||
|
||||
|
||||
|
||||
#include "estimator.h"
|
||||
|
||||
#define RcChannel(x) (fbw_state->channels[x])
|
||||
|
||||
/** Includes generated code from airframe.xml */
|
||||
@@ -0,0 +1,43 @@
|
||||
/** \file rc_settings.h
|
||||
* \brief Variable setting though the radio control
|
||||
*
|
||||
* The <rc_control> section of a XML flight plan allows the user to change the
|
||||
* value of an autopilot internal variable through the rc transmitter.
|
||||
* C code is generated from this XML code (var/AC/inflight_calib.h). This
|
||||
* module handles the control of this setting mode.
|
||||
*
|
||||
* Note that this functionnality is deprecated since datalink use is a lot more
|
||||
* easier (<dl_settings> section)
|
||||
*/
|
||||
|
||||
#ifndef RC_SETTINGS_H
|
||||
|
||||
#include "std.h"
|
||||
#include "radio.h"
|
||||
|
||||
#define RC_SETTINGS_MODE_NONE 0
|
||||
#define RC_SETTINGS_MODE_DOWN 1
|
||||
#define RC_SETTINGS_MODE_UP 2
|
||||
|
||||
#if defined RADIO_CALIB && defined RADIO_CONTROL_SETTINGS
|
||||
|
||||
#define RcSettingsOff() (rc_settings_mode==RC_SETTINGS_MODE_NONE)
|
||||
|
||||
#define RC_SETTINGS_MODE_OF_PULSE(pprz) (pprz < TRESHOLD1 ? RC_SETTINGS_MODE_UP : \
|
||||
(pprz < TRESHOLD2 ? RC_SETTINGS_MODE_NONE : \
|
||||
RC_SETTINGS_MODE_DOWN))
|
||||
|
||||
#define RcSettingsModeUpdate(_rc_channels) \
|
||||
ModeUpdate(rc_settings_mode, RC_SETTINGS_MODE_OF_PULSE(_rc_channels[RADIO_CALIB]))
|
||||
|
||||
extern uint8_t rc_settings_mode;
|
||||
void rc_settings(bool_t mode_changed);
|
||||
|
||||
|
||||
#else /* RADIO_CALIB && defined RADIO_CONTROL_SETTINGS */
|
||||
|
||||
#define RcSettingsOff() TRUE
|
||||
|
||||
#endif /* ! (RADIO_CALIB && defined RADIO_CONTROL_SETTINGS) */
|
||||
|
||||
#endif // RC_SETTINGS_H
|
||||
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* XML preprocessing for in flight calibration
|
||||
*
|
||||
* Copyright (C) 2003 Pascal Brisset, Antoine Drouin
|
||||
* Copyright (C) 2003-2006 Pascal Brisset, Antoine Drouin
|
||||
*
|
||||
* This file is part of paparazzi.
|
||||
*
|
||||
@@ -60,7 +60,7 @@ let parse_setting = fun xml ->
|
||||
let param_macro = param_macro_of_type t in
|
||||
let var_init = var ^ "_init" in
|
||||
|
||||
lprintf "if (inflight_calib_mode == IF_CALIB_MODE_%s) {\n" (String.uppercase cm);
|
||||
lprintf "if (rc_settings_mode == RC_SETTINGS_MODE_%s) {\n" (String.uppercase cm);
|
||||
right ();
|
||||
lprintf "static %s %s;\n" (inttype t) var_init;
|
||||
lprintf "static int16_t slider%d_init;\n" cursor;
|
||||
@@ -93,7 +93,7 @@ let _ =
|
||||
let xml = start_and_begin xml_file h_name in
|
||||
|
||||
let rc_control = try ExtXml.child xml "rc_control" with Not_found -> failwith (sprintf "Error: 'rc_control' child expected in %s" (Xml.to_string xml)) in
|
||||
lprintf "void inflight_calib(bool_t mode_changed) {\n";
|
||||
lprintf "void rc_settings(bool_t mode_changed) {\n";
|
||||
right ();
|
||||
parse_modes rc_control;
|
||||
left (); lprintf "}\n";
|
||||
|
||||
Reference in New Issue
Block a user