diff --git a/Makefile b/Makefile index 4c6e6f9a90..42b3c57edf 100644 --- a/Makefile +++ b/Makefile @@ -113,6 +113,16 @@ include Makefile.ac sim : sim_static ac_h ac1 ac2 ac3 ac fbw ap: static conf +### +# +# temporary hack for quadrotor simulator +# +booz_sim: + make AIRCRAFT=BOOZ flt.compile + make AIRCRAFT=BOOZ ctl.compile + cd sw/simulator; make clean booz_sim + + ##### preliminary hard wired arm7 bootloader rules # # diff --git a/conf/Makefile.sim b/conf/Makefile.sim index 0f123aa8d7..6a38715c70 100644 --- a/conf/Makefile.sim +++ b/conf/Makefile.sim @@ -22,9 +22,14 @@ # +ifeq ($(SIM_TYPE),BOOZ) +sim.CFLAGS += `pkg-config glib-2.0 --cflags` -I /usr/include/meschach +sim.LDFLAGS += `pkg-config glib-2.0 --libs` -lm -lmeschach -lpcre -lglibivy +endif + + # -# This is the common Makefile for the avr-target. -# Edit the configuration part to suit your local install +# This is the common Makefile for the sim target. # SRC_ARCH = $(PAPARAZZI_SRC)/sw/airborne/sim @@ -48,13 +53,21 @@ INCLUDES += -I `ocamlc -where` CFLAGS = \ -W -Wall \ $(INCLUDES) \ - -Wstrict-prototypes \ $($(TARGET).CFLAGS) \ $(LOCAL_CFLAGS) \ -O2 \ +# meschach prototypes trigger numerous warnings +ifneq ($(SIM_TYPE),BOOZ) +CFLAGS += -Wstrict-prototypes +endif + + LDFLAGS = -lm \ +ifeq ($(SIM_TYPE),BOOZ) +LDFLAGS += $($(TARGET).LDFLAGS) +endif # # General rules # @@ -66,9 +79,17 @@ $(TARGET).objs = $($(TARGET).objso:%.S=$(OBJDIR)/%.o) all compile: $(OBJDIR)/simsitl + +ifeq ($(SIM_TYPE),BOOZ) +$(OBJDIR)/simsitl : $($(TARGET).objs) + @echo LD $@ + $(Q)$(CC) -o $@ $($(TARGET).objs) $(LDFLAGS) +else $(OBJDIR)/simsitl : $($(TARGET).objs) $(SITLCMA) $(SIMSITLML) @echo LD $@ $(Q)$(OCAMLC) -custom $(CAMLINCLUDES) -o $@ unix.cma str.cma xml-light.cma glibivy-ocaml.cma lib-pprz.cma lablgtk.cma $($(TARGET).objs) gtkInit.cmo $(SITLCMA) $(SIMSITLML) +endif + # The id of the A/C is hardcoded in the code (to be improved with dynlink ?) @@ -93,6 +114,11 @@ $(OBJDIR)/%.o: $(SRC_ARCH)/%.c $(OBJDIR)/%.o: $(SRC_ARCH)/%.S $(CC) $(CFLAGS) -c -o $@ $< +ifeq ($(SIM_TYPE),BOOZ) +$(OBJDIR)/%.o: $(SIMDIR)/%.c + @echo CC $@ + $(Q)$(CC) $(CFLAGS) -c -o $@ $< +endif avr_clean: rm -rf $(OBJDIR) diff --git a/conf/autopilot/conf_booz.makefile b/conf/autopilot/conf_booz.makefile index eabbdf80dc..51b4e32971 100644 --- a/conf/autopilot/conf_booz.makefile +++ b/conf/autopilot/conf_booz.makefile @@ -4,7 +4,7 @@ FLASH_MODE = IAP # -# FILTER CPU +# filter CPU # flt.ARCHDIR = $(ARCHI) @@ -96,7 +96,7 @@ ctl.srcs += booz_estimator.c \ booz_autopilot.c # -# Simulator +# SITL Simulator # SIM_TYPE = BOOZ @@ -106,12 +106,12 @@ sim.ARCH = sitl sim.TARGET = main sim.TARGETDIR = main -#sim.srcs = $(SIMDIR)/main_booz_sim.c \ -# $(SIMDIR)/booz_flight_model.c \ -# $(SIMDIR)/booz_flight_model_utils.c \ -# $(SIMDIR)/booz_sensors_model.c \ -# $(SIMDIR)/booz_flightgear.c \ -# $(SIMDIR)/booz_joystick.c \ +sim.srcs = $(SIMDIR)/main_booz_sim.c \ + $(SIMDIR)/booz_flight_model.c \ + $(SIMDIR)/booz_flight_model_utils.c \ + $(SIMDIR)/booz_sensors_model.c \ + $(SIMDIR)/booz_flightgear.c \ + $(SIMDIR)/booz_joystick.c \ sim.CFLAGS += -DSITL sim.CFLAGS += -DBOOZ_CONTROLLER_MCU diff --git a/sw/airborne/Makefile b/sw/airborne/Makefile index a123da0a0a..0123ed521c 100644 --- a/sw/airborne/Makefile +++ b/sw/airborne/Makefile @@ -25,6 +25,10 @@ OBJDIR = $(PAPARAZZI_HOME)/var/$(AIRCRAFT)/$(TARGET) VARINCLUDE=$(PAPARAZZI_HOME)/var/include ACINCLUDE = $(PAPARAZZI_HOME)/var/$(AIRCRAFT) +# +# WTF is that for ? VARINCLUDE=$(PAPARAZZI_HOME)/var/include and -I $(PAPARAZZI_SRC)/var/include in the line below ? +# + INCLUDES = -I $(PAPARAZZI_SRC)/sw/include -I $(PAPARAZZI_SRC)/var/include -I $(PAPARAZZI_SRC)/sw/airborne -I $(PAPARAZZI_SRC)/conf/autopilot -I $(PAPARAZZI_SRC)/sw/airborne/$($(TARGET).ARCHDIR) -I $(VARINCLUDE) -I $(ACINCLUDE) SRC_ARCH = $(PAPARAZZI_SRC)/sw/airborne/$(ARCHDIR) diff --git a/sw/airborne/multitilt.c b/sw/airborne/multitilt.c index fdef19d1f4..16649af620 100644 --- a/sw/airborne/multitilt.c +++ b/sw/airborne/multitilt.c @@ -152,7 +152,7 @@ static inline void multitilt_predict( const float* gyro ) { } -static void inline mtt_update_axis(float _err, float _P[2][2], float* angle, float* bias) { +static inline void mtt_update_axis(float _err, float _P[2][2], float* angle, float* bias) { const float Pct_0 = _P[0][0]; const float Pct_1 = _P[1][0]; /* E = C P C' + R */ diff --git a/sw/airborne/sim/adc_hw.c b/sw/airborne/sim/adc_hw.c index 71d7901746..ac60e63339 100644 --- a/sw/airborne/sim/adc_hw.c +++ b/sw/airborne/sim/adc_hw.c @@ -1,3 +1,5 @@ #include "adc.h" -void adc_buf_channel(uint8_t adc_channel, struct adc_buf* s, uint8_t av_nb_sample) {} +void adc_buf_channel(uint8_t adc_channel __attribute__ ((unused)), + struct adc_buf* s __attribute__ ((unused)), + uint8_t av_nb_sample __attribute__ ((unused))) {} diff --git a/sw/simulator/Makefile b/sw/simulator/Makefile index 26d532423f..a526293282 100644 --- a/sw/simulator/Makefile +++ b/sw/simulator/Makefile @@ -92,88 +92,3 @@ clean : ifneq ($(MAKECMDGOALS),clean) -include .depend endif - -AB=../airborne -AB_ARCH=$(AB)/sim - -CC = gcc -CFLAGS= -g -Wall `pkg-config glib-2.0 --cflags` -I /usr/include/meschach -I$(AB) -I../include -I../../var/BOOZ -I../../var/include -I../../conf/autopilot -I$(AB_ARCH) -LDFLAGS=`pkg-config glib-2.0 --libs` -lm -lmeschach -lpcre - - -BOOZ_SIM_SRCS = main_booz_sim.c \ - booz_flight_model.c \ - booz_flight_model_utils.c \ - booz_sensors_model.c \ - booz_flightgear.c \ - booz_joystick.c \ - -CFLAGS += -DSITL -CFLAGS += -DBOOZ_CONTROLLER_MCU -CFLAGS += -DCONFIG=\"conf_booz.h\" - -BOOZ_AB_SRCS += $(AB)/booz_controller_main.c - -BOOZ_AB_SRCS += $(AB)/sys_time.c - -CFLAGS += -DRADIO_CONTROL -BOOZ_AB_SRCS += $(AB)/radio_control.c \ - $(AB_ARCH)/ppm_hw.c - -CFLAGS += -DACTUATORS=\"actuators_buss_twi_blmc_hw.h\" -BOOZ_AB_SRCS += $(AB)/actuators.c \ - $(AB_ARCH)/actuators_buss_twi_blmc_hw.c \ - $(AB)/i2c.c $(AB_ARCH)/i2c_hw.c - -CFLAGS += -DDOWNLINK -BOOZ_AB_SRCS += $(AB)/booz_controller_telemetry.c \ - $(AB)/downlink.c - -#CFLAGS += -DDOWNLINK_TRANSPORT=PprzTransport -DPPRZ_UART=SimUart -DDOWNLINK_DEVICE=SimUart -DSIM_UART -#BOOZ_AB_SRCS += ../airborne/pprz_transport.c ../airborne/sim/sim_uart.c - -CFLAGS += -DDOWNLINK_TRANSPORT=IvyTransport -BOOZ_AB_SRCS += $(AB_ARCH)/ivy_transport.c -LDFLAGS += -lglibivy - -BOOZ_AB_SRCS += $(AB)/booz_inter_mcu.c -CFLAGS += -DUSE_SPI -BOOZ_AB_SRCS += $(AB)/booz_link_mcu.c $(AB_ARCH)/booz_link_mcu_hw.c -BOOZ_AB_SRCS += $(AB)/spi.c $(AB_ARCH)/spi_hw.c - -#CFLAGS += -DDATALINK=PPRZ -#BOOZ_AB_SRCS += ../airborne/datalink.c -BOOZ_AB_SRCS += $(AB)/booz_estimator.c -BOOZ_AB_SRCS += $(AB)/booz_control.c -BOOZ_AB_SRCS += $(AB)/booz_nav.c -BOOZ_AB_SRCS += $(AB)/booz_nav_hover.c - -BOOZ_AB_SRCS += $(AB)/booz_autopilot.c -BOOZ_AB_SRCS += $(AB)/commands.c - - -CFLAGS += -DBOOZ_FILTER_MCU -BOOZ_AB_SRCS += $(AB)/booz_filter_main.c - -CFLAGS += -DADC_CHANNEL_AX=1 -DADC_CHANNEL_AY=2 -DADC_CHANNEL_AZ=3 -DADC_CHANNEL_BAT=4 -BOOZ_AB_SRCS += $(AB_ARCH)/adc_hw.c - - -BOOZ_AB_SRCS += $(AB)/booz_filter_telemetry.c - -BOOZ_AB_SRCS += $(AB)/max1167.c $(AB_ARCH)/max1167_hw.c -BOOZ_AB_SRCS += $(AB)/micromag.c $(AB_ARCH)/micromag_hw.c -BOOZ_AB_SRCS += $(AB)/imu_v3.c $(AB_ARCH)/imu_v3_hw.c - - -BOOZ_AB_SRCS += $(AB)/booz_ahrs.c -CFLAGS += -DBOOZ_AHRS_TYPE=BOOZ_AHRS_MULTITILT -BOOZ_AB_SRCS += $(AB)/multitilt.c -#CFLAGS += -DBOOZ_AHRS_TYPE=BOOZ_AHRS_QUATERNION -DEKF_UPDATE_DISCRETE -#BOOZ_AB_SRCS += $(AB)/ahrs_quat_fast_ekf.c - -#$(OBJDIR)/%.c: %.o -# $(CC) $(CFLAGS) -c -o $@ $< - -booz_sim: $(BOOZ_SIM_SRCS) $(BOOZ_AB_SRCS) - $(CC) $(CFLAGS) -g -o $@ $^ $(LDFLAGS) diff --git a/sw/simulator/booz_flight_model.c b/sw/simulator/booz_flight_model.c index 2245f83b20..93c9fa378e 100644 --- a/sw/simulator/booz_flight_model.c +++ b/sw/simulator/booz_flight_model.c @@ -157,7 +157,7 @@ static VEC* booz_get_forces_body_frame( VEC* X, VEC* F , MAT* dcm, VEC* omega_sq compute the sum of external moments. assumes that omega_square is already precomputed from X */ -static VEC* booz_get_moments_body_frame( VEC* X, VEC* M, VEC* omega_square ) { +static VEC* booz_get_moments_body_frame( VEC* X __attribute__ ((unused)), VEC* M, VEC* omega_square ) { M = mv_mlt(bfm.props_moment_matrix, omega_square, M); return M; } diff --git a/sw/simulator/booz_joystick.c b/sw/simulator/booz_joystick.c index b345f50f38..9811c2784e 100644 --- a/sw/simulator/booz_joystick.c +++ b/sw/simulator/booz_joystick.c @@ -41,7 +41,9 @@ void booz_joystick_init(const char* device) { } -static gboolean on_data_received(GIOChannel *source, GIOCondition condition, gpointer data) { +static gboolean on_data_received(GIOChannel *source, + GIOCondition condition __attribute__ ((unused)), + gpointer data __attribute__ ((unused))) { struct js_event js; gsize len; diff --git a/sw/simulator/booz_sensors_model.c b/sw/simulator/booz_sensors_model.c index edab64e64d..fda9d0ece9 100644 --- a/sw/simulator/booz_sensors_model.c +++ b/sw/simulator/booz_sensors_model.c @@ -392,6 +392,6 @@ static VEC* v_add_gaussian_noise(VEC* in, VEC* std_dev, VEC* out) { one = v_ones(one); tmp = v_mltadd(one, tmp, -2., tmp); tmp = v_star(tmp, std_dev, tmp); - out = v_add(out, tmp, out); + out = v_add(in, tmp, out); return out; } diff --git a/sw/simulator/main_booz_sim.c b/sw/simulator/main_booz_sim.c index dcd3e9e376..86e8b1569b 100644 --- a/sw/simulator/main_booz_sim.c +++ b/sw/simulator/main_booz_sim.c @@ -52,7 +52,7 @@ static void on_DL_SETTING(IvyClientPtr app, void *user_data, int argc, char *arg volatile bool_t ppm_valid; -static gboolean booz_sim_periodic(gpointer data) { +static gboolean booz_sim_periodic(gpointer data __attribute__ ((unused))) { /* read actuators positions */ booz_sim_read_actuators(); @@ -80,7 +80,7 @@ static gboolean booz_sim_periodic(gpointer data) { /* this will update the controller estimator */ booz_controller_main_event_task(); /* cheat in simulation : psi not available from filter yet */ - booz_estimator_set_psi(bfm.state->ve[BFMS_PSI]); + // booz_estimator_set_psi(bfm.state->ve[BFMS_PSI]); /* in simulation compute dcm as a helper for for nav */ booz_estimator_compute_dcm(); /* in simulation feed speed and pos estimations ( with a pos sensor :( ) */ @@ -360,7 +360,9 @@ static void ivy_transport_init(void) { #include "std.h" #include "settings.h" #include "booz_controller_telemetry.h" -static void on_DL_SETTING(IvyClientPtr app, void *user_data, int argc, char *argv[]){ +static void on_DL_SETTING(IvyClientPtr app __attribute__ ((unused)), + void *user_data __attribute__ ((unused)), + int argc __attribute__ ((unused)), char *argv[]){ uint8_t index = atoi(argv[2]); float value = atof(argv[3]); DlSetting(index, value); @@ -404,3 +406,8 @@ static void sim_uart_init(void) { + + + + +