mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-05-13 05:27:35 +08:00
NuttX carry minimal c++ cmath (replacing Matrix stdlib_imports.hpp)
This commit is contained in:
@@ -41,6 +41,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include <matrix/matrix/math.hpp>
|
||||
|
||||
enum class AllocationMethod {
|
||||
|
||||
@@ -42,6 +42,8 @@
|
||||
#ifndef EKF_COMMON_H
|
||||
#define EKF_COMMON_H
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include <matrix/math.hpp>
|
||||
|
||||
namespace estimator
|
||||
|
||||
@@ -784,7 +784,7 @@ bool FlightTaskAuto::isTargetModified() const
|
||||
{
|
||||
const bool xy_modified = (_target - _position_setpoint).xy().longerThan(FLT_EPSILON);
|
||||
const bool z_valid = PX4_ISFINITE(_position_setpoint(2));
|
||||
const bool z_modified = z_valid && fabs((_target - _position_setpoint)(2)) > FLT_EPSILON;
|
||||
const bool z_modified = z_valid && std::fabs((_target - _position_setpoint)(2)) > FLT_EPSILON;
|
||||
|
||||
return xy_modified || z_modified;
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ matrix::Vector3f AttitudeControl::update(const Quatf &q) const
|
||||
// and multiply it by the yaw setpoint rate (yawspeed_setpoint).
|
||||
// This yields a vector representing the commanded rotatation around the world z-axis expressed in the body frame
|
||||
// such that it can be added to the rates setpoint.
|
||||
if (is_finite(_yawspeed_setpoint)) {
|
||||
if (std::isfinite(_yawspeed_setpoint)) {
|
||||
rate_setpoint += q.inversed().dcm_z() * _yawspeed_setpoint;
|
||||
}
|
||||
|
||||
|
||||
@@ -31,6 +31,8 @@
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#include <cmath>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <ControlMath.hpp>
|
||||
#include <px4_platform_common/defines.h>
|
||||
@@ -249,7 +251,7 @@ TEST(ControlMathTest, addIfNotNan)
|
||||
v = NAN;
|
||||
// both summands are NAN
|
||||
ControlMath::addIfNotNan(v, NAN);
|
||||
EXPECT_TRUE(isnan(v));
|
||||
EXPECT_TRUE(std::isnan(v));
|
||||
// regular value gets added to NAN and overwrites it
|
||||
ControlMath::addIfNotNan(v, 3.f);
|
||||
EXPECT_EQ(v, 3.f);
|
||||
|
||||
Reference in New Issue
Block a user