diff --git a/conf/airframes/ENAC/quadrotor/anton_indi_aruco.xml b/conf/airframes/ENAC/quadrotor/anton_indi_aruco.xml index 6a496b44b9..7c2b17d61f 100644 --- a/conf/airframes/ENAC/quadrotor/anton_indi_aruco.xml +++ b/conf/airframes/ENAC/quadrotor/anton_indi_aruco.xml @@ -236,14 +236,13 @@
- - + diff --git a/conf/flight_plans/ENAC/demo_aruco_drop_indoor.xml b/conf/flight_plans/ENAC/demo_aruco_drop_indoor.xml index 8d69300690..84719a41f5 100644 --- a/conf/flight_plans/ENAC/demo_aruco_drop_indoor.xml +++ b/conf/flight_plans/ENAC/demo_aruco_drop_indoor.xml @@ -104,7 +104,10 @@ - + + + + @@ -115,7 +118,6 @@ - diff --git a/conf/flight_plans/competitions/IMAV2022_drop.xml b/conf/flight_plans/competitions/IMAV2022_drop.xml index 4c2f0d486d..3395b4d248 100644 --- a/conf/flight_plans/competitions/IMAV2022_drop.xml +++ b/conf/flight_plans/competitions/IMAV2022_drop.xml @@ -273,7 +273,7 @@ - + @@ -287,7 +287,7 @@ - + @@ -315,7 +315,7 @@ - + @@ -330,13 +330,13 @@ - + - + @@ -348,13 +348,13 @@ - + - + @@ -387,8 +387,8 @@ - - + + @@ -418,21 +418,21 @@ - + - + - + - + @@ -442,7 +442,7 @@ - + diff --git a/conf/modules/tag_tracking.xml b/conf/modules/tag_tracking.xml index 0a6c7918b0..599ab3ed55 100644 --- a/conf/modules/tag_tracking.xml +++ b/conf/modules/tag_tracking.xml @@ -2,11 +2,11 @@ - Track poistion of a tag (ArUco, QRcode, ...) detected by an onboard camera + Track position of a tag (ArUco, QRcode, ...) detected by an onboard camera The tag detection and pose computation is done outside of the module, only the estimation by fusion of AHRS and visual detection with a Kalman filter is performed in this module
- + diff --git a/sw/airborne/modules/computer_vision/tag_tracking.c b/sw/airborne/modules/computer_vision/tag_tracking.c index 0b81700633..19735d47a3 100644 --- a/sw/airborne/modules/computer_vision/tag_tracking.c +++ b/sw/airborne/modules/computer_vision/tag_tracking.c @@ -148,9 +148,6 @@ float speed_circle = 0.03; #define TAG_TRACKING_MAX_VZ 2.f #endif -#ifndef TAG_TRACKING_NB_WP_MAX -#define TAG_TRACKING_NB_WP_MAX 1 -#endif #define TAG_UNUSED_ID -1 @@ -160,8 +157,10 @@ static const float tag_track_dt = TAG_TRACKING_PROPAGATE_PERIOD; // global state structure struct tag_tracking { struct FloatVect3 meas; ///< measured position + struct FloatQuat cam_to_tag_quat; ///< measured quat struct FloatRMat body_to_cam; ///< Body to camera rotation + struct FloatQuat body_to_cam_quat; ///< Body to camera rotation in quaternion struct FloatVect3 cam_pos; ///< Position of camera in body frame float timeout; ///< timeout for lost flag [sec] @@ -186,10 +185,11 @@ struct wp_tracking { #if (defined TAG_TRACKING_WPS) -struct wp_tracking wp_track[TAG_TRACKING_NB_WP_MAX] = TAG_TRACKING_WPS; +struct wp_tracking wp_track[] = TAG_TRACKING_WPS; +const uint8_t tag_tracking_wps_len = sizeof(wp_track) / sizeof(struct wp_tracking); #else -#error "TAG_TRACKING_NB_WP_MAX not defined!" -struct wp_tracking wp_track[TAG_TRACKING_NB_WP_MAX] = {0}; +struct wp_tracking wp_track[] = {}; +const uint8_t tag_tracking_wps_len = 0; #endif @@ -197,6 +197,8 @@ struct tag_info tag_infos[TAG_TRACKING_NB_MAX]; struct tag_tracking_public dummy = {0}; +struct FloatQuat rot_x_quat; // quaternion to rotate tag to have Z down + // Abi bindings #ifndef TAG_TRACKING_ID #define TAG_TRACKING_ID ABI_BROADCAST @@ -206,22 +208,30 @@ static abi_event tag_track_ev; static void tag_tracking_propagate_start_tag(struct tag_info* tag_info); -struct tag_tracking_public* tag_tracking_get(uint8_t tag_id) { +struct tag_tracking_public* tag_tracking_get(int16_t tag_id) { for(int i=0; ined_to_tag_quat); + return DegOfRad(e.psi); +} + // update measure vect before calling static void update_tag_position(struct tag_info* tag_info) { @@ -236,6 +246,10 @@ static void update_tag_position(struct tag_info* tag_info) struct NedCoor_f * pos_ned = stateGetPositionNed_f(); VECT3_ADD(target_pos_ned, *pos_ned); + // TODO filter in kalman ? + float_quat_comp(&tag_info->tag_tracking.body_to_tag_quat, &tag_infos->tag_track_private.body_to_cam_quat, &tag_info->tag_track_private.cam_to_tag_quat); + float_quat_comp(&tag_info->tag_tracking.ned_to_tag_quat, stateGetNedToBodyQuat_f(), &tag_info->tag_tracking.body_to_tag_quat); + if (tag_info->tag_tracking.status == TAG_TRACKING_DISABLE) { // don't run kalman, just update pos, set speed to zero tag_info->tag_tracking.pos = target_pos_ned; @@ -265,23 +279,27 @@ static void tag_track_cb(uint8_t sender_id UNUSED, if (type == JEVOIS_MSG_D3) { int16_t tag_id = (int16_t)jevois_extract_nb(id); for(int i=0; i