diff --git a/conf/autopilot/subsystems/fixedwing/ahrs_float_dcm.makefile b/conf/autopilot/subsystems/fixedwing/ahrs_float_dcm.makefile index 8020cc652a..2369faecb8 100644 --- a/conf/autopilot/subsystems/fixedwing/ahrs_float_dcm.makefile +++ b/conf/autopilot/subsystems/fixedwing/ahrs_float_dcm.makefile @@ -3,11 +3,10 @@ # attitude estimation for fixedwings via dcm algorithm -$(TARGET).CFLAGS += -DAHRS_TYPE_H=\"subsystems/ahrs/ahrs_float_dcm.h\" -$(TARGET).CFLAGS += -DUSE_AHRS_ALIGNER - ifeq ($(TARGET), ap) +ap.CFLAGS += -DAHRS_TYPE_H=\"subsystems/ahrs/ahrs_float_dcm.h\" +ap.CFLAGS += -DUSE_AHRS_ALIGNER ap.CFLAGS += -DUSE_AHRS ap.srcs += $(SRC_SUBSYSTEMS)/ahrs.c @@ -37,7 +36,10 @@ ap.CFLAGS += -DAHRS_CORRECT_FREQUENCY=$(AHRS_CORRECT_FREQUENCY) endif -# since there is currently no SITL sim for the Analog IMU, we use the infrared sim + + +# since there is currently no SITL sim for the IMU, we use the infrared sim +# and the ahrs_infrared subsystem ifeq ($(TARGET), sim) @@ -51,6 +53,13 @@ sim.srcs += subsystems/sensors/infrared_adc.c sim.srcs += $(SRC_ARCH)/sim_ir.c sim.srcs += $(SRC_ARCH)/sim_imu.c + +sim.CFLAGS += -DAHRS_TYPE_H=\"subsystems/ahrs/ahrs_infrared.h\" +sim.CFLAGS += -DUSE_AHRS + +sim.srcs += $(SRC_SUBSYSTEMS)/ahrs.c +sim.srcs += $(SRC_SUBSYSTEMS)/ahrs/ahrs_infrared.c + endif jsbsim.srcs += $(SRC_ARCH)/jsbsim_ir.c diff --git a/conf/autopilot/subsystems/fixedwing/ahrs_int_cmpl_euler.makefile b/conf/autopilot/subsystems/fixedwing/ahrs_int_cmpl_euler.makefile index d66dd0183c..dbee272c3e 100644 --- a/conf/autopilot/subsystems/fixedwing/ahrs_int_cmpl_euler.makefile +++ b/conf/autopilot/subsystems/fixedwing/ahrs_int_cmpl_euler.makefile @@ -17,8 +17,32 @@ AHRS_SRCS += subsystems/ahrs/ahrs_aligner.c ap.CFLAGS += $(AHRS_CFLAGS) ap.srcs += $(AHRS_SRCS) -sim.CFLAGS += $(AHRS_CFLAGS) -sim.srcs += $(AHRS_SRCS) + + +# since there is currently no ocaml SITL sim for the IMU, we use the infrared sim +# and the ahrs_infrared subsystem + +ifeq ($(TARGET), sim) + +sim.CFLAGS += -DIR_ROLL_NEUTRAL_DEFAULT=0 +sim.CFLAGS += -DIR_PITCH_NEUTRAL_DEFAULT=0 + +sim.CFLAGS += -DUSE_INFRARED +sim.srcs += subsystems/sensors/infrared.c +sim.srcs += subsystems/sensors/infrared_adc.c + +sim.srcs += $(SRC_ARCH)/sim_ir.c +sim.srcs += $(SRC_ARCH)/sim_imu.c + + +sim.CFLAGS += -DAHRS_TYPE_H=\"subsystems/ahrs/ahrs_infrared.h\" +sim.CFLAGS += -DUSE_AHRS + +sim.srcs += $(SRC_SUBSYSTEMS)/ahrs.c +sim.srcs += $(SRC_SUBSYSTEMS)/ahrs/ahrs_infrared.c + +endif + # Extra stuff for fixedwings diff --git a/conf/autopilot/subsystems/fixedwing/ahrs_int_cmpl_quat.makefile b/conf/autopilot/subsystems/fixedwing/ahrs_int_cmpl_quat.makefile index 7f2ef85695..7b5962b0f8 100644 --- a/conf/autopilot/subsystems/fixedwing/ahrs_int_cmpl_quat.makefile +++ b/conf/autopilot/subsystems/fixedwing/ahrs_int_cmpl_quat.makefile @@ -20,8 +20,31 @@ AHRS_SRCS += subsystems/ahrs/ahrs_aligner.c ap.CFLAGS += $(AHRS_CFLAGS) ap.srcs += $(AHRS_SRCS) -sim.CFLAGS += $(AHRS_CFLAGS) -sim.srcs += $(AHRS_SRCS) + + +# since there is currently no ocaml SITL sim for the IMU, we use the infrared sim +# and the ahrs_infrared subsystem + +ifeq ($(TARGET), sim) + +sim.CFLAGS += -DIR_ROLL_NEUTRAL_DEFAULT=0 +sim.CFLAGS += -DIR_PITCH_NEUTRAL_DEFAULT=0 + +sim.CFLAGS += -DUSE_INFRARED +sim.srcs += subsystems/sensors/infrared.c +sim.srcs += subsystems/sensors/infrared_adc.c + +sim.srcs += $(SRC_ARCH)/sim_ir.c +sim.srcs += $(SRC_ARCH)/sim_imu.c + + +sim.CFLAGS += -DAHRS_TYPE_H=\"subsystems/ahrs/ahrs_infrared.h\" +sim.CFLAGS += -DUSE_AHRS + +sim.srcs += $(SRC_SUBSYSTEMS)/ahrs.c +sim.srcs += $(SRC_SUBSYSTEMS)/ahrs/ahrs_infrared.c + +endif # Extra stuff for fixedwings diff --git a/sw/airborne/ap_downlink.h b/sw/airborne/ap_downlink.h index da8d98444a..a7f5962a03 100644 --- a/sw/airborne/ap_downlink.h +++ b/sw/airborne/ap_downlink.h @@ -124,6 +124,7 @@ #endif #if defined USE_INFRARED || USE_INFRARED_TELEMETRY +#include "subsystems/sensors/infrared.h" #define PERIODIC_SEND_IR_SENSORS(_chan) DOWNLINK_SEND_IR_SENSORS(_chan, &infrared.value.ir1, &infrared.value.ir2, &infrared.pitch, &infrared.roll, &infrared.top); #else #define PERIODIC_SEND_IR_SENSORS(_chan) ; diff --git a/sw/airborne/arch/sim/sim_imu.c b/sw/airborne/arch/sim/sim_imu.c index 0169091122..7ec14cf240 100644 --- a/sw/airborne/arch/sim/sim_imu.c +++ b/sw/airborne/arch/sim/sim_imu.c @@ -6,7 +6,6 @@ #include -#include "subsystems/sensors/infrared.h" #include "generated/airframe.h" #include diff --git a/sw/airborne/subsystems/ahrs/ahrs_infrared.h b/sw/airborne/subsystems/ahrs/ahrs_infrared.h index 0972c7cebd..82fe3109ad 100644 --- a/sw/airborne/subsystems/ahrs/ahrs_infrared.h +++ b/sw/airborne/subsystems/ahrs/ahrs_infrared.h @@ -25,6 +25,12 @@ #include "subsystems/ahrs.h" #include "std.h" +// TODO: harmonize infrared neutrals with ins_neutrals +// or get rid of ins neutrals +// this ins only needed for sim right now +extern float ins_roll_neutral; +extern float ins_pitch_neutral; + extern void ahrs_update_gps(void); extern void ahrs_update_infrared(void);