From 9e00fddf4355aeaf8b3dcacf90bde40abc89face Mon Sep 17 00:00:00 2001 From: Robot Date: Mon, 3 Jul 2017 21:48:09 +0800 Subject: [PATCH] fixed bug of abs --- src/model/quadrotor.cxx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/model/quadrotor.cxx b/src/model/quadrotor.cxx index 42ecbe60..ebbccffb 100644 --- a/src/model/quadrotor.cxx +++ b/src/model/quadrotor.cxx @@ -41,10 +41,10 @@ void QRCalculateAllRotorPos(const float* pos, const float* att, float strut, flo float v4[3] = {0.0, -strut, 0.0}; #else // shape: x - float v1[3] = {strut/1.41421356, strut/1.41421356, 0.0}; - float v2[3] = {-strut/1.41421356, strut/1.41421356, 0.0}; - float v3[3] = {-strut/1.41421356, -strut/1.41421356, 0.0}; - float v4[3] = {strut/1.41421356, -strut/1.41421356, 0.0}; + float v1[3] = {strut/(float)1.41421356, strut/(float)1.41421356, 0.0}; + float v2[3] = {-strut/(float)1.41421356, strut/(float)1.41421356, 0.0}; + float v3[3] = {-strut/(float)1.41421356, -strut/(float)1.41421356, 0.0}; + float v4[3] = {strut/(float)1.41421356, -strut/(float)1.41421356, 0.0}; #endif rotate_vector(v1, rpos1, att[0]*RAD2DEG, att[1]*RAD2DEG, att[2]*RAD2DEG); @@ -365,7 +365,7 @@ void QRdynamic::quadrotor_controller_pid(void) /* Phase 3: Yaw, heading control */ float err_yaw = QR_yaw_ref - QR_att[2]; // ref = 0. (North) float err_yaw_sign; - if (abs(err_yaw) > M_PI) { + if (std::abs(err_yaw) > M_PI) { if (err_yaw > M_PI) err_yaw_sign = -1.; else