Skip to content

Commit 3edee8a

Browse files
peterbarkerGeoracer
authored andcommitted
AP_TECS: avoid use of cosphi_squared dcm matrix trick
Issue #7817 pointed out that the order in which we are retrieving the euler angles from the transformation matrix is incorrect. Testing shows that there is a discrepancy between these values and the values retrieved directly from the AHRS. Since we are simply attempting to retrieve the roll angle, extract it directly from the AHRS. Co-authored-by: George Zogopoulos <[email protected]>
1 parent 8504ca4 commit 3edee8a

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

libraries/AP_TECS/AP_TECS.cpp

+2-6
Original file line numberDiff line numberDiff line change
@@ -749,12 +749,10 @@ void AP_TECS::_update_throttle_with_airspeed(void)
749749

750750
// Calculate feed-forward throttle
751751
const float nomThr = aparm.throttle_cruise * 0.01f;
752-
const Matrix3f &rotMat = _ahrs.get_rotation_body_to_ned();
753752
// Use the demanded rate of change of total energy as the feed-forward demand, but add
754753
// additional component which scales with (1/(cos(bank angle)**2) - 1) to compensate for induced
755754
// drag increase during turns.
756-
const float cosPhi_squared = (rotMat.a.y*rotMat.a.y) + (rotMat.b.y*rotMat.b.y);
757-
STEdot_dem = STEdot_dem + _rollComp * (1.0f/constrain_float(cosPhi_squared, 0.1f, 1.0f) - 1.0f);
755+
STEdot_dem = STEdot_dem + _rollComp * (1.0f/constrain_float(sq(_ahrs.cos_roll()), 0.1f, 1.0f) - 1.0f);
758756
const float ff_throttle = nomThr + STEdot_dem / K_thr2STE;
759757

760758
// Calculate PD + FF throttle
@@ -920,12 +918,10 @@ void AP_TECS::_update_throttle_without_airspeed(int16_t throttle_nudge, float pi
920918
}
921919

922920
// Calculate additional throttle for turn drag compensation including throttle nudging
923-
const Matrix3f &rotMat = _ahrs.get_rotation_body_to_ned();
924921
// Use the demanded rate of change of total energy as the feed-forward demand, but add
925922
// additional component which scales with (1/(cos(bank angle)**2) - 1) to compensate for induced
926923
// drag increase during turns.
927-
const float cosPhi_squared = (rotMat.a.y*rotMat.a.y) + (rotMat.b.y*rotMat.b.y);
928-
float STEdot_dem = _rollComp * (1.0f/constrain_float(cosPhi_squared, 0.1f, 1.0f) - 1.0f);
924+
float STEdot_dem = _rollComp * (1.0f/constrain_float(sq(_ahrs.cos_roll()), 0.1f, 1.0f) - 1.0f);
929925
_throttle_dem = _throttle_dem + STEdot_dem / (_STEdot_max - _STEdot_min) * (_THRmaxf - _THRminf);
930926

931927
constrain_throttle();

0 commit comments

Comments
 (0)