mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-07-02 17:00:34 +08:00
avoid double promotions
This commit is contained in:
committed by
Lorenz Meier
parent
412f956636
commit
4b8bedef48
@@ -675,7 +675,7 @@ bool AttitudeEstimatorQ::update(float dt)
|
||||
const float fifty_dps = 0.873f;
|
||||
|
||||
if (spinRate > fifty_dps) {
|
||||
gainMult = fmin(spinRate / fifty_dps, 10.0f);
|
||||
gainMult = math::min(spinRate / fifty_dps, 10.0f);
|
||||
}
|
||||
|
||||
// Project magnetometer correction to body frame
|
||||
|
||||
@@ -475,7 +475,7 @@ int blockRandGaussTest()
|
||||
mean = newMean;
|
||||
}
|
||||
|
||||
float stdDev = sqrt(sum / (n - 1));
|
||||
float stdDev = sqrtf(sum / (n - 1));
|
||||
(void)(stdDev);
|
||||
ASSERT_CL(equal(mean, blockRandGauss.getMean(), 1e-1));
|
||||
ASSERT_CL(equal(stdDev, blockRandGauss.getStdDev(), 1e-1));
|
||||
|
||||
@@ -35,7 +35,6 @@ px4_add_module(
|
||||
MAIN fw_pos_control_l1
|
||||
STACK_MAIN 1200
|
||||
COMPILE_FLAGS
|
||||
-Weffc++
|
||||
SRCS
|
||||
fw_pos_control_l1_main.cpp
|
||||
landingslope.cpp
|
||||
|
||||
@@ -366,46 +366,46 @@ int update_parameters(const ParameterHandles ¶meter_handles, Parameters &par
|
||||
param_get(parameter_handles.rc_fails_thr, &(parameters.rc_fails_thr));
|
||||
param_get(parameter_handles.rc_assist_th, &(parameters.rc_assist_th));
|
||||
parameters.rc_assist_inv = (parameters.rc_assist_th < 0);
|
||||
parameters.rc_assist_th = fabs(parameters.rc_assist_th);
|
||||
parameters.rc_assist_th = fabsf(parameters.rc_assist_th);
|
||||
param_get(parameter_handles.rc_auto_th, &(parameters.rc_auto_th));
|
||||
parameters.rc_auto_inv = (parameters.rc_auto_th < 0);
|
||||
parameters.rc_auto_th = fabs(parameters.rc_auto_th);
|
||||
parameters.rc_auto_th = fabsf(parameters.rc_auto_th);
|
||||
param_get(parameter_handles.rc_rattitude_th, &(parameters.rc_rattitude_th));
|
||||
parameters.rc_rattitude_inv = (parameters.rc_rattitude_th < 0);
|
||||
parameters.rc_rattitude_th = fabs(parameters.rc_rattitude_th);
|
||||
parameters.rc_rattitude_th = fabsf(parameters.rc_rattitude_th);
|
||||
param_get(parameter_handles.rc_posctl_th, &(parameters.rc_posctl_th));
|
||||
parameters.rc_posctl_inv = (parameters.rc_posctl_th < 0);
|
||||
parameters.rc_posctl_th = fabs(parameters.rc_posctl_th);
|
||||
parameters.rc_posctl_th = fabsf(parameters.rc_posctl_th);
|
||||
param_get(parameter_handles.rc_return_th, &(parameters.rc_return_th));
|
||||
parameters.rc_return_inv = (parameters.rc_return_th < 0);
|
||||
parameters.rc_return_th = fabs(parameters.rc_return_th);
|
||||
parameters.rc_return_th = fabsf(parameters.rc_return_th);
|
||||
param_get(parameter_handles.rc_loiter_th, &(parameters.rc_loiter_th));
|
||||
parameters.rc_loiter_inv = (parameters.rc_loiter_th < 0);
|
||||
parameters.rc_loiter_th = fabs(parameters.rc_loiter_th);
|
||||
parameters.rc_loiter_th = fabsf(parameters.rc_loiter_th);
|
||||
param_get(parameter_handles.rc_acro_th, &(parameters.rc_acro_th));
|
||||
parameters.rc_acro_inv = (parameters.rc_acro_th < 0);
|
||||
parameters.rc_acro_th = fabs(parameters.rc_acro_th);
|
||||
parameters.rc_acro_th = fabsf(parameters.rc_acro_th);
|
||||
param_get(parameter_handles.rc_offboard_th, &(parameters.rc_offboard_th));
|
||||
parameters.rc_offboard_inv = (parameters.rc_offboard_th < 0);
|
||||
parameters.rc_offboard_th = fabs(parameters.rc_offboard_th);
|
||||
parameters.rc_offboard_th = fabsf(parameters.rc_offboard_th);
|
||||
param_get(parameter_handles.rc_killswitch_th, &(parameters.rc_killswitch_th));
|
||||
parameters.rc_killswitch_inv = (parameters.rc_killswitch_th < 0);
|
||||
parameters.rc_killswitch_th = fabs(parameters.rc_killswitch_th);
|
||||
parameters.rc_killswitch_th = fabsf(parameters.rc_killswitch_th);
|
||||
param_get(parameter_handles.rc_armswitch_th, &(parameters.rc_armswitch_th));
|
||||
parameters.rc_armswitch_inv = (parameters.rc_armswitch_th < 0);
|
||||
parameters.rc_armswitch_th = fabs(parameters.rc_armswitch_th);
|
||||
parameters.rc_armswitch_th = fabsf(parameters.rc_armswitch_th);
|
||||
param_get(parameter_handles.rc_trans_th, &(parameters.rc_trans_th));
|
||||
parameters.rc_trans_inv = (parameters.rc_trans_th < 0);
|
||||
parameters.rc_trans_th = fabs(parameters.rc_trans_th);
|
||||
parameters.rc_trans_th = fabsf(parameters.rc_trans_th);
|
||||
param_get(parameter_handles.rc_gear_th, &(parameters.rc_gear_th));
|
||||
parameters.rc_gear_inv = (parameters.rc_gear_th < 0);
|
||||
parameters.rc_gear_th = fabs(parameters.rc_gear_th);
|
||||
parameters.rc_gear_th = fabsf(parameters.rc_gear_th);
|
||||
param_get(parameter_handles.rc_stab_th, &(parameters.rc_stab_th));
|
||||
parameters.rc_stab_inv = (parameters.rc_stab_th < 0);
|
||||
parameters.rc_stab_th = fabs(parameters.rc_stab_th);
|
||||
parameters.rc_stab_th = fabsf(parameters.rc_stab_th);
|
||||
param_get(parameter_handles.rc_man_th, &(parameters.rc_man_th));
|
||||
parameters.rc_man_inv = (parameters.rc_man_th < 0);
|
||||
parameters.rc_man_th = fabs(parameters.rc_man_th);
|
||||
parameters.rc_man_th = fabsf(parameters.rc_man_th);
|
||||
|
||||
param_get(parameter_handles.rc_flt_smp_rate, &(parameters.rc_flt_smp_rate));
|
||||
parameters.rc_flt_smp_rate = math::max(1.0f, parameters.rc_flt_smp_rate);
|
||||
|
||||
@@ -147,7 +147,7 @@ protected:
|
||||
/// since it will give you better error reporting of the actual values being compared.
|
||||
#define ut_compare_float(message, v1, v2, precision) \
|
||||
do { \
|
||||
int _p = pow(10, precision); \
|
||||
int _p = pow(10.0f, precision); \
|
||||
int _v1 = (int)(v1 * _p + 0.5f); \
|
||||
int _v2 = (int)(v2 * _p + 0.5f); \
|
||||
if (_v1 != _v2) { \
|
||||
|
||||
@@ -40,11 +40,12 @@
|
||||
*/
|
||||
|
||||
#include "vtol_type.h"
|
||||
#include "drivers/drv_pwm_output.h"
|
||||
#include <px4_defines.h>
|
||||
#include <float.h>
|
||||
#include "vtol_att_control_main.h"
|
||||
|
||||
#include <cfloat>
|
||||
#include <px4_defines.h>
|
||||
#include <matrix/math.hpp>
|
||||
|
||||
VtolType::VtolType(VtolAttitudeControl *att_controller) :
|
||||
_attc(att_controller),
|
||||
_vtol_mode(ROTARY_WING)
|
||||
@@ -209,7 +210,7 @@ void VtolType::check_quadchute_condition()
|
||||
// fixed-wing maximum pitch angle
|
||||
if (_params->fw_qc_max_pitch > 0) {
|
||||
|
||||
if (fabs(euler.theta()) > fabs(math::radians(_params->fw_qc_max_pitch))) {
|
||||
if (fabsf(euler.theta()) > fabsf(math::radians(_params->fw_qc_max_pitch))) {
|
||||
_attc->abort_front_transition("Maximum pitch angle exceeded");
|
||||
}
|
||||
}
|
||||
@@ -217,7 +218,7 @@ void VtolType::check_quadchute_condition()
|
||||
// fixed-wing maximum roll angle
|
||||
if (_params->fw_qc_max_roll > 0) {
|
||||
|
||||
if (fabs(euler.phi()) > fabs(math::radians(_params->fw_qc_max_roll))) {
|
||||
if (fabsf(euler.phi()) > fabsf(math::radians(_params->fw_qc_max_roll))) {
|
||||
_attc->abort_front_transition("Maximum roll angle exceeded");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user