Perform geo.cpp's mathlib calls in double point precision

This commit is contained in:
Kamil Ritz 2020-04-12 11:28:38 +02:00 committed by Lorenz Meier
parent a013bb9314
commit 1fa6870cd6
5 changed files with 19 additions and 109 deletions

View File

@ -142,9 +142,6 @@ if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
add_dependencies(prebuild_targets matrix) add_dependencies(prebuild_targets matrix)
include_directories(${CMAKE_BINARY_DIR}/matrix-prefix/src/matrix) include_directories(${CMAKE_BINARY_DIR}/matrix-prefix/src/matrix)
# mathlib only needed in standalone build
add_subdirectory(mathlib)
endif() endif()
# santiziers (ASAN) # santiziers (ASAN)

View File

@ -55,7 +55,7 @@ add_library(ecl_EKF
add_dependencies(ecl_EKF prebuild_targets) add_dependencies(ecl_EKF prebuild_targets)
target_compile_definitions(ecl_EKF PRIVATE -DMODULE_NAME="ecl/EKF") target_compile_definitions(ecl_EKF PRIVATE -DMODULE_NAME="ecl/EKF")
target_include_directories(ecl_EKF PUBLIC ${ECL_SOURCE_DIR}) target_include_directories(ecl_EKF PUBLIC ${ECL_SOURCE_DIR})
target_link_libraries(ecl_EKF PRIVATE ecl_geo ecl_geo_lookup mathlib) target_link_libraries(ecl_EKF PRIVATE ecl_geo ecl_geo_lookup)
set_target_properties(ecl_EKF PROPERTIES PUBLIC_HEADER "ekf.h") set_target_properties(ecl_EKF PROPERTIES PUBLIC_HEADER "ekf.h")

View File

@ -1,39 +0,0 @@
############################################################################
#
# Copyright (c) 2018 ECL Development Team. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
# 3. Neither the name ECL nor the names of its contributors may be
# used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
############################################################################
add_library(mathlib
mathlib.cpp
)
add_dependencies(mathlib prebuild_targets)
target_include_directories(mathlib INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})

View File

@ -1,59 +0,0 @@
/****************************************************************************
*
* Copyright (C) 2012, 2014 PX4 Development Team. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name PX4 nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
/**
* @file mathlib.cpp
*
* Definition of math namespace function for POSIX SHARED
*
* @author Siddharth Bharat Purohit <siddharthbharatpurohit@gmail.com>
*/
#include "mathlib.h"
#ifdef ECL_STANDALONE
namespace math {
float min(float val1, float val2) { return (val1 < val2) ? val1 : val2; }
float max(float val1, float val2) { return (val1 > val2) ? val1 : val2; }
float constrain(float val, float min, float max) { return (val < min) ? min : ((val > max) ? max : val); }
float radians(float degrees) { return (degrees / 180.0f) * M_PI_F; }
float degrees(float radians) { return (radians * 180.0f) / M_PI_F; }
} // namespace math
#endif /* ECL_STANDALONE */

View File

@ -51,14 +51,25 @@
#define M_PI_2_F (M_PI / 2.0f) #define M_PI_2_F (M_PI / 2.0f)
#endif #endif
namespace math { #ifndef M_PI
// using namespace Eigen; #define M_PI 3.141592653589793238462643383280
#endif
float min(float val1, float val2); namespace math {
float max(float val1, float val2); template <typename Type>
float constrain(float val, float min, float max); Type min(Type val1, Type val2) { return (val1 < val2) ? val1 : val2; }
float radians(float degrees);
float degrees(float radians); template <typename Type>
Type max(Type val1, Type val2) { return (val1 > val2) ? val1 : val2; }
template <typename Type>
Type constrain(Type val, Type min, Type max) { return (val < min) ? min : ((val > max) ? max : val); }
template <typename Type>
Type radians(Type degrees) { return (degrees / Type(180)) * Type(M_PI); }
template <typename Type>
Type degrees(Type radians) { return (radians * Type(180)) / Type(M_PI); }
} // namespace math } // namespace math
#else #else