diff --git a/conf/autopilot/subsystems/fixedwing/ahrs_int_cmpl_euler.makefile b/conf/autopilot/subsystems/fixedwing/ahrs_int_cmpl_euler.makefile index dbee272c3e..15b93a6404 100644 --- a/conf/autopilot/subsystems/fixedwing/ahrs_int_cmpl_euler.makefile +++ b/conf/autopilot/subsystems/fixedwing/ahrs_int_cmpl_euler.makefile @@ -18,28 +18,13 @@ ap.CFLAGS += $(AHRS_CFLAGS) ap.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.CFLAGS += -DAHRS_TYPE_H=\"subsystems/ahrs/ahrs_sim.h\" +sim.CFLAGS += -DUSE_AHRS -DAHRS_UPDATE_FW_ESTIMATOR sim.srcs += $(SRC_SUBSYSTEMS)/ahrs.c -sim.srcs += $(SRC_SUBSYSTEMS)/ahrs/ahrs_infrared.c +sim.srcs += $(SRC_SUBSYSTEMS)/ahrs/ahrs_sim.c endif diff --git a/conf/autopilot/subsystems/fixedwing/ahrs_int_cmpl_quat.makefile b/conf/autopilot/subsystems/fixedwing/ahrs_int_cmpl_quat.makefile index 7b5962b0f8..2bb2d580f9 100644 --- a/conf/autopilot/subsystems/fixedwing/ahrs_int_cmpl_quat.makefile +++ b/conf/autopilot/subsystems/fixedwing/ahrs_int_cmpl_quat.makefile @@ -22,27 +22,13 @@ ap.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.CFLAGS += -DAHRS_TYPE_H=\"subsystems/ahrs/ahrs_sim.h\" +sim.CFLAGS += -DUSE_AHRS -DAHRS_UPDATE_FW_ESTIMATOR sim.srcs += $(SRC_SUBSYSTEMS)/ahrs.c -sim.srcs += $(SRC_SUBSYSTEMS)/ahrs/ahrs_infrared.c +sim.srcs += $(SRC_SUBSYSTEMS)/ahrs/ahrs_sim.c endif diff --git a/conf/autopilot/subsystems/fixedwing/autopilot.makefile b/conf/autopilot/subsystems/fixedwing/autopilot.makefile index 97e3ec91be..e5b985c325 100644 --- a/conf/autopilot/subsystems/fixedwing/autopilot.makefile +++ b/conf/autopilot/subsystems/fixedwing/autopilot.makefile @@ -195,6 +195,9 @@ sim.srcs += downlink.c $(SRC_FIRMWARE)/datalink.c $(SRC_ARCH)/sim_gps.c $(SRC_ sim.srcs += subsystems/settings.c sim.srcs += $(SRC_ARCH)/subsystems/settings_arch.c +# hack: always compile some of the sim functions, so ocaml sim does not complain about no-existing functions +sim.srcs += $(SRC_ARCH)/sim_ahrs.c $(SRC_ARCH)/sim_ir.c + ###################################################################### ## ## JSBSIM THREAD SPECIFIC diff --git a/conf/modules/infrared_adc.xml b/conf/modules/infrared_adc.xml index f0363e0cb3..5474e70f35 100644 --- a/conf/modules/infrared_adc.xml +++ b/conf/modules/infrared_adc.xml @@ -35,9 +35,6 @@ endif ap.CFLAGS += -DADC_CHANNEL_IR_NB_SAMPLES=$(ADC_IR_NB_SAMPLES) - - - diff --git a/conf/modules/infrared_i2c.xml b/conf/modules/infrared_i2c.xml index b73dd757d6..b8c523a258 100644 --- a/conf/modules/infrared_i2c.xml +++ b/conf/modules/infrared_i2c.xml @@ -14,8 +14,5 @@ - - - diff --git a/sw/airborne/arch/sim/sim_ir.c b/sw/airborne/arch/sim/sim_ir.c index deb6a6b59d..8b443ecf5f 100644 --- a/sw/airborne/arch/sim/sim_ir.c +++ b/sw/airborne/arch/sim/sim_ir.c @@ -23,11 +23,11 @@ value set_ir_and_airspeed( value air_speed ) { // INFRARED_TELEMETRY : Stupid hack to use with modules -//#if defined USE_INFRARED || USE_INFRARED_TELEMETRY +#if defined USE_INFRARED || USE_INFRARED_TELEMETRY infrared.roll = Int_val(roll); infrared.pitch = Int_val(front); infrared.top = Int_val(top); -//#endif +#endif sim_air_speed = Double_val(air_speed); return Val_unit; } diff --git a/sw/airborne/firmwares/fixedwing/main_ap.c b/sw/airborne/firmwares/fixedwing/main_ap.c index fcd517803d..2ad7acd5be 100644 --- a/sw/airborne/firmwares/fixedwing/main_ap.c +++ b/sw/airborne/firmwares/fixedwing/main_ap.c @@ -768,7 +768,7 @@ static inline void on_mag_event(void) #endif } -#else // USE_IMU +#else // USE_IMU not defined static inline void on_ahrs_event(void) { #ifdef AHRS_UPDATE_FW_ESTIMATOR diff --git a/sw/airborne/subsystems/ahrs/ahrs_sim.c b/sw/airborne/subsystems/ahrs/ahrs_sim.c index 6ee4b23efb..7c3f4295be 100644 --- a/sw/airborne/subsystems/ahrs/ahrs_sim.c +++ b/sw/airborne/subsystems/ahrs/ahrs_sim.c @@ -28,21 +28,10 @@ #include #include -float sim_phi; -float sim_theta; -float sim_psi; -bool_t ahrs_sim_available; - -// Updates from Ocaml sim -value set_attitude(value phi, value theta, value psi) { - sim_phi = Double_val(phi); - sim_theta = Double_val(theta); - sim_psi = Double_val(psi); - - ahrs_sim_available = TRUE; - - return Val_unit; -} +extern float sim_phi; +extern float sim_theta; +extern float sim_psi; +extern bool_t ahrs_sim_available; void compute_body_orientation_and_rates(void); @@ -50,9 +39,7 @@ void compute_body_orientation_and_rates(void); void update_attitude_from_sim(void) { ahrs_float.ltp_to_imu_euler.phi = sim_phi; ahrs_float.ltp_to_imu_euler.theta = sim_theta; - ahrs_float.ltp_to_imu_euler.psi = -sim_psi; - FLOAT_ANGLE_NORMALIZE(ahrs_float.ltp_to_imu_euler.psi); - ahrs_float.ltp_to_imu_euler.psi += M_PI/2.; + ahrs_float.ltp_to_imu_euler.psi = sim_psi; /* set quaternion and rotation matrix representations as well */ FLOAT_QUAT_OF_EULERS(ahrs_float.ltp_to_imu_quat, ahrs_float.ltp_to_imu_euler); @@ -98,15 +85,12 @@ void ahrs_align(void) void ahrs_propagate(void) { - update_attitude_from_sim(); } void ahrs_update_accel(void) { - update_attitude_from_sim(); } void ahrs_update_mag(void) { - update_attitude_from_sim(); }