1111
1212#define BLEND_COUNTER_FAILURE_INCREMENT 10
1313
14+ // returns true if the instance at offset i should be included in this blend
15+ bool AP_GPS_Blended::should_include_instance_in_blend (uint8_t i) const
16+ {
17+ // do not blend blending backends (including this one!) This
18+ // probably wants to be a "gps.provides_real_sensor_data()"
19+ // callback when we add a median-filter backend
20+ if (gps.params [i].type == AP_GPS::GPS_TYPE_BLENDED) {
21+ return false ;
22+ }
23+ if (gps.state [i].status <= AP_GPS::GPS_OK_FIX_2D) {
24+ return false ;
25+ }
26+ if ((params.mask & (1U <<i)) == 0 ) {
27+ return false ;
28+ }
29+
30+ return true ;
31+ }
32+
1433/*
1534 calculate the weightings used to blend GPSs location and velocity data
1635*/
@@ -32,10 +51,7 @@ bool AP_GPS_Blended::_calc_weights(void)
3251 // don't blend blended backends (including ourself...). This
3352 // probably wants to be a "gps.provides_real_sensor_data()"
3453 // callback when we add a median-filter backend
35- if (gps.params [i].type == AP_GPS::GPS_TYPE_BLENDED) {
36- continue ;
37- }
38- if (gps.state [i].status <= AP_GPS::NO_FIX) {
54+ if (!should_include_instance_in_blend (i)) {
3955 continue ;
4056 }
4157 good_fix_count += 1 ;
@@ -50,9 +66,7 @@ bool AP_GPS_Blended::_calc_weights(void)
5066 uint32_t min_ms = -1 ; // oldest non-zero system time of arrival of a GPS message
5167 uint32_t max_rate_ms = 0 ; // largest update interval of a GPS receiver
5268 for (uint8_t i=0 ; i<GPS_MAX_INSTANCES; i++) {
53- // don't blend blended backends (including ourself...). This
54- // probably wants to be a "gps.provides_real_sensor_data()"
55- // callback when we add a median-filter backend
69+ // don't blend blended backends (including ourself...).
5670 if (gps.params [i].type == AP_GPS::GPS_TYPE_BLENDED) {
5771 continue ;
5872 }
@@ -252,7 +266,7 @@ bool AP_GPS_Blended::_calc_weights(void)
252266 // don't blend blended backends (including ourself...). This
253267 // probably wants to be a "gps.provides_real_sensor_data()"
254268 // callback when we add a median-filter backend
255- if (gps. params [i]. type == AP_GPS::GPS_TYPE_BLENDED ) {
269+ if (! should_include_instance_in_blend (i) ) {
256270 continue ;
257271 }
258272 _blend_weights[i] = (hpos_blend_weights[i] + vpos_blend_weights[i] + spd_blend_weights[i]) / sum_of_all_weights;
0 commit comments