diff --git a/conf/airframes/ENAC/fixed-wing/merlin.xml b/conf/airframes/ENAC/fixed-wing/merlin.xml index 0979202cf2..1d1273e99d 100644 --- a/conf/airframes/ENAC/fixed-wing/merlin.xml +++ b/conf/airframes/ENAC/fixed-wing/merlin.xml @@ -18,7 +18,6 @@ - @@ -36,6 +35,7 @@ + diff --git a/conf/airframes/LAAS/mmlaas_N1.xml b/conf/airframes/LAAS/mmlaas_N1.xml index 079f9e71af..bb0693ab0f 100644 --- a/conf/airframes/LAAS/mmlaas_N1.xml +++ b/conf/airframes/LAAS/mmlaas_N1.xml @@ -21,7 +21,6 @@ - @@ -34,15 +33,16 @@ - + - - - - - - - + + + + + + + + diff --git a/conf/airframes/LAAS/mmlaas_N2.xml b/conf/airframes/LAAS/mmlaas_N2.xml index 4bb7f089c5..b85ce26dc8 100644 --- a/conf/airframes/LAAS/mmlaas_N2.xml +++ b/conf/airframes/LAAS/mmlaas_N2.xml @@ -21,7 +21,6 @@ - @@ -41,6 +40,7 @@ + diff --git a/conf/airframes/LAAS/mmlaas_N3.xml b/conf/airframes/LAAS/mmlaas_N3.xml index 60211c4a9e..3164150fea 100644 --- a/conf/airframes/LAAS/mmlaas_N3.xml +++ b/conf/airframes/LAAS/mmlaas_N3.xml @@ -21,7 +21,6 @@ - @@ -41,6 +40,7 @@ + diff --git a/conf/airframes/examples/delta_wing_minimal.xml b/conf/airframes/examples/delta_wing_minimal.xml index 3b2a94c9c3..20d0b293a6 100644 --- a/conf/airframes/examples/delta_wing_minimal.xml +++ b/conf/airframes/examples/delta_wing_minimal.xml @@ -17,7 +17,6 @@ - @@ -25,6 +24,7 @@ + diff --git a/conf/airframes/examples/easy_glider.xml b/conf/airframes/examples/easy_glider.xml index 8727684dc4..d1e5b76b57 100644 --- a/conf/airframes/examples/easy_glider.xml +++ b/conf/airframes/examples/easy_glider.xml @@ -170,7 +170,6 @@ - @@ -185,6 +184,7 @@ + diff --git a/conf/airframes/examples/easystar.xml b/conf/airframes/examples/easystar.xml index 5a3bb6259a..0dbccfdb9f 100644 --- a/conf/airframes/examples/easystar.xml +++ b/conf/airframes/examples/easystar.xml @@ -18,7 +18,6 @@ - @@ -28,6 +27,11 @@ + + + + + diff --git a/conf/airframes/examples/easystar_ets.xml b/conf/airframes/examples/easystar_ets.xml index 2012c95c80..be144c7be8 100644 --- a/conf/airframes/examples/easystar_ets.xml +++ b/conf/airframes/examples/easystar_ets.xml @@ -23,7 +23,6 @@ - @@ -38,6 +37,7 @@ + diff --git a/conf/airframes/examples/funjet.xml b/conf/airframes/examples/funjet.xml index 2cb5c2318b..4b3b338e25 100644 --- a/conf/airframes/examples/funjet.xml +++ b/conf/airframes/examples/funjet.xml @@ -26,7 +26,6 @@ - @@ -35,6 +34,7 @@ + diff --git a/conf/airframes/examples/funjet_cam.xml b/conf/airframes/examples/funjet_cam.xml index b91d524560..01f14aac26 100644 --- a/conf/airframes/examples/funjet_cam.xml +++ b/conf/airframes/examples/funjet_cam.xml @@ -26,7 +26,6 @@ - @@ -47,6 +46,7 @@ + diff --git a/conf/airframes/examples/microjet.xml b/conf/airframes/examples/microjet.xml index 4887422204..14cafe74d4 100644 --- a/conf/airframes/examples/microjet.xml +++ b/conf/airframes/examples/microjet.xml @@ -175,13 +175,12 @@ - -
+
@@ -197,6 +196,7 @@ + diff --git a/conf/airframes/examples/twinjet.xml b/conf/airframes/examples/twinjet.xml index 93fe181c06..77e92c03ad 100644 --- a/conf/airframes/examples/twinjet.xml +++ b/conf/airframes/examples/twinjet.xml @@ -20,7 +20,6 @@ - @@ -41,6 +40,7 @@ + diff --git a/conf/airframes/examples/twinstar.xml b/conf/airframes/examples/twinstar.xml index 77cc38b320..b4f8ead3ac 100644 --- a/conf/airframes/examples/twinstar.xml +++ b/conf/airframes/examples/twinstar.xml @@ -21,7 +21,6 @@ - @@ -33,6 +32,7 @@ + diff --git a/conf/airframes/twinjet_overo.xml b/conf/airframes/twinjet_overo.xml index a5508b17cc..b9012da23f 100644 --- a/conf/airframes/twinjet_overo.xml +++ b/conf/airframes/twinjet_overo.xml @@ -23,7 +23,6 @@ - @@ -43,6 +42,7 @@ + diff --git a/conf/airframes/usb_test.xml b/conf/airframes/usb_test.xml index 238921cbbe..4889a11d4a 100644 --- a/conf/airframes/usb_test.xml +++ b/conf/airframes/usb_test.xml @@ -14,7 +14,6 @@ - @@ -29,6 +28,7 @@ + diff --git a/conf/firmwares/subsystems/fixedwing/ahrs_infrared.makefile b/conf/firmwares/subsystems/fixedwing/ahrs_infrared.makefile index 0552c73f8a..d7f4d2bb81 100644 --- a/conf/firmwares/subsystems/fixedwing/ahrs_infrared.makefile +++ b/conf/firmwares/subsystems/fixedwing/ahrs_infrared.makefile @@ -1,13 +1 @@ -# Hey Emacs, this is a -*- makefile -*- - -# attitude estimation for fixedwings using infrared sensors - - -# usage of this ahrs subsystem implies USE_INFRARED -$(TARGET).CFLAGS += -DUSE_INFRARED - -$(TARGET).CFLAGS += -DAHRS_TYPE_H=\"subsystems/ahrs/ahrs_infrared.h\" -$(TARGET).CFLAGS += -DUSE_AHRS - -$(TARGET).srcs += $(SRC_SUBSYSTEMS)/ahrs.c -$(TARGET).srcs += $(SRC_SUBSYSTEMS)/ahrs/ahrs_infrared.c +$(error The ahrs_infrared subsystem has converted to a module, please remove it and add to your module section.) diff --git a/conf/modules/ahrs_infrared.xml b/conf/modules/ahrs_infrared.xml new file mode 100644 index 0000000000..63d0ffc6ae --- /dev/null +++ b/conf/modules/ahrs_infrared.xml @@ -0,0 +1,22 @@ + + + + + + AHRS infrared. + Attitude estimation using infrared sensors detecting the horizon. + For fixedwings only: + - GPS course is used as heading. + - ADC channels can be used for gyros. + + + infrared_adc +
+ +
+ + + + + +
diff --git a/conf/modules/infrared_adc.xml b/conf/modules/infrared_adc.xml index 839469e3bf..c662624692 100644 --- a/conf/modules/infrared_adc.xml +++ b/conf/modules/infrared_adc.xml @@ -32,7 +32,7 @@ - + diff --git a/conf/modules/infrared_i2c.xml b/conf/modules/infrared_i2c.xml index 7440a0fe1e..6a441b9820 100644 --- a/conf/modules/infrared_i2c.xml +++ b/conf/modules/infrared_i2c.xml @@ -31,7 +31,7 @@ - + diff --git a/sw/airborne/arch/sim/sim_ir.c b/sw/airborne/arch/sim/sim_ir.c index 83ccec2c2b..41223d34f9 100644 --- a/sw/airborne/arch/sim/sim_ir.c +++ b/sw/airborne/arch/sim/sim_ir.c @@ -24,8 +24,9 @@ value set_ir_and_airspeed( value air_speed ) { - // INFRARED_TELEMETRY : Stupid hack to use with modules -#if USE_INFRARED || USE_INFRARED_TELEMETRY + // USE_INFRARED : Stupid hack, since sim always calls this function, + // but we don't always have an infrared module +#if USE_INFRARED infrared.roll = Int_val(roll); infrared.pitch = Int_val(front); infrared.top = Int_val(top); diff --git a/sw/airborne/firmwares/fixedwing/main_ap.c b/sw/airborne/firmwares/fixedwing/main_ap.c index 7a77b4ce43..effb7812ff 100644 --- a/sw/airborne/firmwares/fixedwing/main_ap.c +++ b/sw/airborne/firmwares/fixedwing/main_ap.c @@ -200,7 +200,7 @@ void init_ap(void) #endif #if USE_AHRS -#if defined SITL && !USE_NPS && !USE_INFRARED +#if defined SITL && !USE_NPS ahrs_sim_init(); #else ahrs_init(); @@ -568,10 +568,6 @@ volatile uint8_t new_ins_attitude = 0; void attitude_loop(void) { -#if USE_INFRARED - ahrs_update_infrared(); -#endif /* USE_INFRARED */ - if (pprz_mode >= PPRZ_MODE_AUTO2) { if (v_ctl_mode == V_CTL_MODE_AUTO_THROTTLE) { v_ctl_throttle_setpoint = nav_throttle_setpoint; @@ -630,7 +626,7 @@ void sensors_task(void) #endif // USE_IMU //FIXME: this is just a kludge -#if USE_AHRS && defined SITL && !USE_NPS && !USE_INFRARED +#if USE_AHRS && defined SITL && !USE_NPS update_ahrs_from_sim(); #endif @@ -779,7 +775,9 @@ static inline void on_gyro_event(void) // current timestamp uint32_t now_ts = get_sys_time_usec(); +#if USE_AHRS ahrs_timeout_counter = 0; +#endif imu_scale_gyro(&imu); diff --git a/sw/airborne/subsystems/ahrs/ahrs_infrared.c b/sw/airborne/modules/ahrs/ahrs_infrared.c similarity index 91% rename from sw/airborne/subsystems/ahrs/ahrs_infrared.c rename to sw/airborne/modules/ahrs/ahrs_infrared.c index a2cf3a6fe9..dcb4598b2e 100644 --- a/sw/airborne/subsystems/ahrs/ahrs_infrared.c +++ b/sw/airborne/modules/ahrs/ahrs_infrared.c @@ -20,7 +20,7 @@ */ /** - * @file subsystems/ahrs/ahrs_infrared.c + * @file modules/ahrs/ahrs_infrared.c * * Attitude estimation using infrared sensors detecting the horizon. * For fixedwings only: @@ -29,7 +29,7 @@ * */ -#include "subsystems/ahrs/ahrs_infrared.h" +#include "modules/ahrs/ahrs_infrared.h" #include "subsystems/sensors/infrared.h" #include "subsystems/imu.h" @@ -38,9 +38,7 @@ #include "state.h" #include "subsystems/abi.h" -struct AhrsInfrared ahrs_infrared; - -float heading; +static float heading; /** ABI binding for gyro data. * Used for gyro ABI messages. @@ -76,15 +74,9 @@ static void send_status(struct transport_tx *trans, struct link_device *dev) } #endif -void ahrs_infrared_register(void) -{ - ahrs_register_impl(ahrs_infrared_init, ahrs_infrared_update_gps); -} void ahrs_infrared_init(void) { - ahrs_infrared.is_aligned = TRUE; - heading = 0.; AbiBindMsgIMU_GYRO_INT32(AHRS_INFRARED_GYRO_ID, &gyro_ev, gyro_cb); @@ -95,9 +87,9 @@ void ahrs_infrared_init(void) #endif } + void ahrs_infrared_update_gps(void) { - float hspeed_mod_f = gps.gspeed / 100.; float course_f = gps.course / 1e7; @@ -112,7 +104,7 @@ void ahrs_infrared_update_gps(void) } -void ahrs_update_infrared(void) +void ahrs_infrared_periodic(void) { float phi = atan2(infrared.roll, infrared.top) - infrared.roll_neutral; float theta = atan2(infrared.pitch, infrared.top) - infrared.pitch_neutral; @@ -128,5 +120,4 @@ void ahrs_update_infrared(void) struct FloatEulers att = { phi, theta, heading }; stateSetNedToBodyEulers_f(&att); - } diff --git a/sw/airborne/subsystems/ahrs/ahrs_infrared.h b/sw/airborne/modules/ahrs/ahrs_infrared.h similarity index 76% rename from sw/airborne/subsystems/ahrs/ahrs_infrared.h rename to sw/airborne/modules/ahrs/ahrs_infrared.h index 8e40ee013a..bb0a09cf55 100644 --- a/sw/airborne/subsystems/ahrs/ahrs_infrared.h +++ b/sw/airborne/modules/ahrs/ahrs_infrared.h @@ -20,7 +20,7 @@ */ /** - * @file subsystems/ahrs/ahrs_infrared.h + * @file modules/ahrs/ahrs_infrared.h * * Fixedwing attitude estimation using infrared sensors. * @@ -30,20 +30,11 @@ #define AHRS_INFRARED_H #include "std.h" -#include "subsystems/ahrs.h" -#include "math/pprz_orientation_conversion.h" -struct AhrsInfrared { - bool_t is_aligned; -}; - -extern struct AhrsInfrared ahrs_infrared; - -extern void ahrs_infrared_register(void); extern void ahrs_infrared_init(void); -extern void ahrs_update_infrared(void); +extern void ahrs_infrared_periodic(void); extern void ahrs_infrared_update_gps(void); -#define DefaultAhrsImpl ahrs_infrared +#define GPS_TRIGGERED_FUNCTION ahrs_infrared_update_gps #endif /* AHRS_INFRARED_H */ diff --git a/sw/airborne/subsystems/sensors/infrared.c b/sw/airborne/subsystems/sensors/infrared.c index ca3cafb41e..3ae8c20d82 100644 --- a/sw/airborne/subsystems/sensors/infrared.c +++ b/sw/airborne/subsystems/sensors/infrared.c @@ -27,10 +27,6 @@ #include "subsystems/sensors/infrared.h" #include "generated/airframe.h" -#ifdef INFRARED -#error "The flag INFRARED has been deprecated. Please replace it with USE_INFRARED." -#endif - struct Infrared infrared; /** \brief Initialisation of \a ir structure