mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-11-02 06:01:35 +08:00
cmake standalone build
This commit is contained in:
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
*.DS_Store
|
*.DS_Store
|
||||||
*~
|
*~
|
||||||
.cache/
|
.cache/
|
||||||
Build/
|
build/
|
||||||
EKF/tests/pytest/__pycache__/
|
EKF/tests/pytest/__pycache__/
|
||||||
|
|||||||
@@ -1,3 +0,0 @@
|
|||||||
[submodule "matrix"]
|
|
||||||
path = matrix
|
|
||||||
url = https://github.com/PX4/Matrix
|
|
||||||
+60
-28
@@ -1,6 +1,6 @@
|
|||||||
############################################################################
|
############################################################################
|
||||||
#
|
#
|
||||||
# Copyright (c) 2015 ECL Development Team. All rights reserved.
|
# Copyright (c) 2015-2018 ECL Development Team. All rights reserved.
|
||||||
#
|
#
|
||||||
# Redistribution and use in source and binary forms, with or without
|
# Redistribution and use in source and binary forms, with or without
|
||||||
# modification, are permitted provided that the following conditions
|
# modification, are permitted provided that the following conditions
|
||||||
@@ -30,31 +30,63 @@
|
|||||||
# POSSIBILITY OF SUCH DAMAGE.
|
# POSSIBILITY OF SUCH DAMAGE.
|
||||||
#
|
#
|
||||||
############################################################################
|
############################################################################
|
||||||
include_directories(.)
|
|
||||||
px4_add_library(ecl
|
cmake_minimum_required(VERSION 3.0)
|
||||||
airdata/WindEstimator.cpp
|
|
||||||
attitude_fw/ecl_controller.cpp
|
project(ECL CXX)
|
||||||
attitude_fw/ecl_pitch_controller.cpp
|
|
||||||
attitude_fw/ecl_roll_controller.cpp
|
execute_process(
|
||||||
attitude_fw/ecl_wheel_controller.cpp
|
COMMAND git describe --always --tags
|
||||||
attitude_fw/ecl_yaw_controller.cpp
|
OUTPUT_VARIABLE git_tag
|
||||||
EKF/airspeed_fusion.cpp
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
EKF/control.cpp
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
EKF/covariance.cpp
|
|
||||||
EKF/drag_fusion.cpp
|
|
||||||
EKF/ekf.cpp
|
|
||||||
EKF/ekf_helper.cpp
|
|
||||||
EKF/estimator_interface.cpp
|
|
||||||
EKF/gps_checks.cpp
|
|
||||||
EKF/mag_fusion.cpp
|
|
||||||
EKF/optflow_fusion.cpp
|
|
||||||
EKF/sideslip_fusion.cpp
|
|
||||||
EKF/terrain_estimator.cpp
|
|
||||||
EKF/vel_pos_fusion.cpp
|
|
||||||
geo/geo.cpp
|
|
||||||
geo_lookup/geo_mag_declination.cpp
|
|
||||||
l1/ecl_l1_pos_controller.cpp
|
|
||||||
tecs/tecs.cpp
|
|
||||||
validation/data_validator.cpp
|
|
||||||
validation/data_validator_group.cpp
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
message(STATUS "PX4 ECL: Very lightweight Estimation & Control Library ${git_tag}")
|
||||||
|
|
||||||
|
set(CMAKE_CXX_STANDARD 11)
|
||||||
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||||
|
|
||||||
|
set(ECL_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
|
|
||||||
|
if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
|
||||||
|
# ECL standalone build
|
||||||
|
add_definitions(-DECL_STANDALONE)
|
||||||
|
|
||||||
|
add_custom_target(prebuild_targets)
|
||||||
|
|
||||||
|
add_compile_options(
|
||||||
|
-pedantic
|
||||||
|
|
||||||
|
-Wall
|
||||||
|
-Wextra
|
||||||
|
-Werror
|
||||||
|
|
||||||
|
-Wno-unused-parameter
|
||||||
|
)
|
||||||
|
|
||||||
|
# fetch latest matrix from github
|
||||||
|
include(ExternalProject)
|
||||||
|
ExternalProject_Add(matrix
|
||||||
|
GIT_REPOSITORY "https://github.com/PX4/Matrix.git"
|
||||||
|
UPDATE_COMMAND ""
|
||||||
|
PATCH_COMMAND ""
|
||||||
|
CONFIGURE_COMMAND ""
|
||||||
|
BUILD_COMMAND ""
|
||||||
|
INSTALL_COMMAND ""
|
||||||
|
)
|
||||||
|
add_dependencies(prebuild_targets matrix)
|
||||||
|
include_directories(${CMAKE_BINARY_DIR}/matrix-prefix/src/matrix)
|
||||||
|
|
||||||
|
add_subdirectory(mathlib)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
add_subdirectory(airdata)
|
||||||
|
add_subdirectory(attitude_fw)
|
||||||
|
add_subdirectory(EKF)
|
||||||
|
add_subdirectory(geo)
|
||||||
|
add_subdirectory(geo_lookup)
|
||||||
|
add_subdirectory(l1)
|
||||||
|
add_subdirectory(tecs)
|
||||||
|
add_subdirectory(validation)
|
||||||
|
|||||||
+11
-47
@@ -1,6 +1,6 @@
|
|||||||
############################################################################
|
############################################################################
|
||||||
#
|
#
|
||||||
# Copyright (c) 2015 ECL Development Team. All rights reserved.
|
# Copyright (c) 2015-2018 ECL Development Team. All rights reserved.
|
||||||
#
|
#
|
||||||
# Redistribution and use in source and binary forms, with or without
|
# Redistribution and use in source and binary forms, with or without
|
||||||
# modification, are permitted provided that the following conditions
|
# modification, are permitted provided that the following conditions
|
||||||
@@ -31,27 +31,7 @@
|
|||||||
#
|
#
|
||||||
############################################################################
|
############################################################################
|
||||||
|
|
||||||
cmake_minimum_required(VERSION 2.8)
|
add_library(ecl_EKF
|
||||||
|
|
||||||
project(ECL CXX)
|
|
||||||
|
|
||||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
|
||||||
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})
|
|
||||||
|
|
||||||
set(MATRIX_DIR ${CMAKE_SOURCE_DIR}/../matrix)
|
|
||||||
if(NOT EXISTS "${MATRIX_DIR}/.git")
|
|
||||||
message(SEND_ERROR "The git submodules are not available. Please run git submodule update --init --recursive")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
include_directories(
|
|
||||||
..
|
|
||||||
${MATRIX_DIR}
|
|
||||||
)
|
|
||||||
|
|
||||||
set(SRCS
|
|
||||||
../geo/geo.cpp
|
|
||||||
../geo_lookup/geo_mag_declination.cpp
|
|
||||||
../mathlib/mathlib.cpp
|
|
||||||
airspeed_fusion.cpp
|
airspeed_fusion.cpp
|
||||||
control.cpp
|
control.cpp
|
||||||
covariance.cpp
|
covariance.cpp
|
||||||
@@ -65,28 +45,12 @@ set(SRCS
|
|||||||
sideslip_fusion.cpp
|
sideslip_fusion.cpp
|
||||||
terrain_estimator.cpp
|
terrain_estimator.cpp
|
||||||
vel_pos_fusion.cpp
|
vel_pos_fusion.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
add_definitions(-DPOSIX_SHARED)
|
add_dependencies(ecl_EKF prebuild_targets)
|
||||||
add_compile_options(
|
|
||||||
-pedantic
|
|
||||||
-std=c++11
|
|
||||||
|
|
||||||
-Wall
|
target_include_directories(ecl_EKF PUBLIC ${ECL_SOURCE_DIR})
|
||||||
-Werror
|
target_link_libraries(ecl_EKF PRIVATE ecl_geo_lookup)
|
||||||
|
|
||||||
-Wno-deprecated-declarations
|
|
||||||
-Wno-enum-compare
|
|
||||||
-Wno-unused-local-typedefs
|
|
||||||
-Wno-unused-parameter
|
|
||||||
)
|
|
||||||
|
|
||||||
# clang tolerate unknown gcc options
|
|
||||||
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
|
||||||
add_compile_options(-Wno-unknown-warning-option)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
add_library(ecl SHARED ${SRCS})
|
|
||||||
|
|
||||||
# Python bindings & tests
|
# Python bindings & tests
|
||||||
# Use cmake -DPythonTests=1 ../EKF && make pytest
|
# Use cmake -DPythonTests=1 ../EKF && make pytest
|
||||||
@@ -120,27 +84,27 @@ if(PythonTests)
|
|||||||
swig_link_libraries(ecl ${PYTHON_LIBRARIES} ecl)
|
swig_link_libraries(ecl ${PYTHON_LIBRARIES} ecl)
|
||||||
|
|
||||||
add_custom_target(pytest
|
add_custom_target(pytest
|
||||||
env PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR}/tests/pytest/ekf_test --verbose
|
env PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/tests/pytest/ekf_test --verbose
|
||||||
)
|
)
|
||||||
add_dependencies(pytest ${SWIG_MODULE_ecl_REAL_NAME})
|
add_dependencies(pytest ${SWIG_MODULE_ecl_REAL_NAME})
|
||||||
|
|
||||||
add_custom_target(pytest-quick
|
add_custom_target(pytest-quick
|
||||||
env PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR}/tests/pytest/ekf_test --quick --verbose
|
env PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/tests/pytest/ekf_test --quick --verbose
|
||||||
)
|
)
|
||||||
add_dependencies(pytest-quick ${SWIG_MODULE_ecl_REAL_NAME})
|
add_dependencies(pytest-quick ${SWIG_MODULE_ecl_REAL_NAME})
|
||||||
|
|
||||||
add_custom_target(pytest-benchmark
|
add_custom_target(pytest-benchmark
|
||||||
env PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR}/tests/pytest/ekf_test --benchmark
|
env PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/tests/pytest/ekf_test --benchmark
|
||||||
)
|
)
|
||||||
add_dependencies(pytest-benchmark ${SWIG_MODULE_ecl_REAL_NAME})
|
add_dependencies(pytest-benchmark ${SWIG_MODULE_ecl_REAL_NAME})
|
||||||
|
|
||||||
add_custom_target(pytest-plots
|
add_custom_target(pytest-plots
|
||||||
env PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR}/tests/pytest/ekf_test --plots
|
env PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/tests/pytest/ekf_test --plots
|
||||||
)
|
)
|
||||||
add_dependencies(pytest-plots ${SWIG_MODULE_ecl_REAL_NAME})
|
add_dependencies(pytest-plots ${SWIG_MODULE_ecl_REAL_NAME})
|
||||||
|
|
||||||
add_custom_target(pytest-lint
|
add_custom_target(pytest-lint
|
||||||
COMMAND cd ${CMAKE_SOURCE_DIR}/tests/pytest/ && ${CMAKE_SOURCE_DIR}/tests/pytest/lint
|
COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR}/tests/pytest/ && ${CMAKE_CURRENT_SOURCE_DIR}/tests/pytest/lint
|
||||||
)
|
)
|
||||||
add_dependencies(pytest-lint ${SWIG_MODULE_ecl_REAL_NAME})
|
add_dependencies(pytest-lint ${SWIG_MODULE_ecl_REAL_NAME})
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
@@ -1,90 +0,0 @@
|
|||||||
# - Try to find Eigen3 lib
|
|
||||||
#
|
|
||||||
# This module supports requiring a minimum version, e.g. you can do
|
|
||||||
# find_package(Eigen3 3.1.2)
|
|
||||||
# to require version 3.1.2 or newer of Eigen3.
|
|
||||||
#
|
|
||||||
# Once done this will define
|
|
||||||
#
|
|
||||||
# EIGEN3_FOUND - system has eigen lib with correct version
|
|
||||||
# EIGEN3_INCLUDE_DIR - the eigen include directory
|
|
||||||
# EIGEN3_VERSION - eigen version
|
|
||||||
#
|
|
||||||
# This module reads hints about search locations from
|
|
||||||
# the following enviroment variables:
|
|
||||||
#
|
|
||||||
# EIGEN3_ROOT
|
|
||||||
# EIGEN3_ROOT_DIR
|
|
||||||
|
|
||||||
# Copyright (c) 2006, 2007 Montel Laurent, <montel@kde.org>
|
|
||||||
# Copyright (c) 2008, 2009 Gael Guennebaud, <g.gael@free.fr>
|
|
||||||
# Copyright (c) 2009 Benoit Jacob <jacob.benoit.1@gmail.com>
|
|
||||||
# Redistribution and use is allowed according to the terms of the 2-clause BSD license.
|
|
||||||
|
|
||||||
if(NOT Eigen3_FIND_VERSION)
|
|
||||||
if(NOT Eigen3_FIND_VERSION_MAJOR)
|
|
||||||
set(Eigen3_FIND_VERSION_MAJOR 2)
|
|
||||||
endif(NOT Eigen3_FIND_VERSION_MAJOR)
|
|
||||||
if(NOT Eigen3_FIND_VERSION_MINOR)
|
|
||||||
set(Eigen3_FIND_VERSION_MINOR 91)
|
|
||||||
endif(NOT Eigen3_FIND_VERSION_MINOR)
|
|
||||||
if(NOT Eigen3_FIND_VERSION_PATCH)
|
|
||||||
set(Eigen3_FIND_VERSION_PATCH 0)
|
|
||||||
endif(NOT Eigen3_FIND_VERSION_PATCH)
|
|
||||||
|
|
||||||
set(Eigen3_FIND_VERSION "${Eigen3_FIND_VERSION_MAJOR}.${Eigen3_FIND_VERSION_MINOR}.${Eigen3_FIND_VERSION_PATCH}")
|
|
||||||
endif(NOT Eigen3_FIND_VERSION)
|
|
||||||
|
|
||||||
macro(_eigen3_check_version)
|
|
||||||
file(READ "${EIGEN3_INCLUDE_DIR}/Eigen/src/Core/util/Macros.h" _eigen3_version_header)
|
|
||||||
|
|
||||||
string(REGEX MATCH "define[ \t]+EIGEN_WORLD_VERSION[ \t]+([0-9]+)" _eigen3_world_version_match "${_eigen3_version_header}")
|
|
||||||
set(EIGEN3_WORLD_VERSION "${CMAKE_MATCH_1}")
|
|
||||||
string(REGEX MATCH "define[ \t]+EIGEN_MAJOR_VERSION[ \t]+([0-9]+)" _eigen3_major_version_match "${_eigen3_version_header}")
|
|
||||||
set(EIGEN3_MAJOR_VERSION "${CMAKE_MATCH_1}")
|
|
||||||
string(REGEX MATCH "define[ \t]+EIGEN_MINOR_VERSION[ \t]+([0-9]+)" _eigen3_minor_version_match "${_eigen3_version_header}")
|
|
||||||
set(EIGEN3_MINOR_VERSION "${CMAKE_MATCH_1}")
|
|
||||||
|
|
||||||
set(EIGEN3_VERSION ${EIGEN3_WORLD_VERSION}.${EIGEN3_MAJOR_VERSION}.${EIGEN3_MINOR_VERSION})
|
|
||||||
if(${EIGEN3_VERSION} VERSION_LESS ${Eigen3_FIND_VERSION})
|
|
||||||
set(EIGEN3_VERSION_OK FALSE)
|
|
||||||
else(${EIGEN3_VERSION} VERSION_LESS ${Eigen3_FIND_VERSION})
|
|
||||||
set(EIGEN3_VERSION_OK TRUE)
|
|
||||||
endif(${EIGEN3_VERSION} VERSION_LESS ${Eigen3_FIND_VERSION})
|
|
||||||
|
|
||||||
if(NOT EIGEN3_VERSION_OK)
|
|
||||||
|
|
||||||
message(STATUS "Eigen3 version ${EIGEN3_VERSION} found in ${EIGEN3_INCLUDE_DIR}, "
|
|
||||||
"but at least version ${Eigen3_FIND_VERSION} is required")
|
|
||||||
endif(NOT EIGEN3_VERSION_OK)
|
|
||||||
endmacro(_eigen3_check_version)
|
|
||||||
|
|
||||||
if (EIGEN3_INCLUDE_DIR)
|
|
||||||
|
|
||||||
# in cache already
|
|
||||||
_eigen3_check_version()
|
|
||||||
set(EIGEN3_FOUND ${EIGEN3_VERSION_OK})
|
|
||||||
|
|
||||||
else (EIGEN3_INCLUDE_DIR)
|
|
||||||
|
|
||||||
find_path(EIGEN3_INCLUDE_DIR NAMES signature_of_eigen3_matrix_library
|
|
||||||
HINTS
|
|
||||||
ENV EIGEN3_ROOT
|
|
||||||
ENV EIGEN3_ROOT_DIR
|
|
||||||
PATHS
|
|
||||||
${CMAKE_INSTALL_PREFIX}/include
|
|
||||||
${KDE4_INCLUDE_DIR}
|
|
||||||
PATH_SUFFIXES eigen3 eigen
|
|
||||||
)
|
|
||||||
|
|
||||||
if(EIGEN3_INCLUDE_DIR)
|
|
||||||
_eigen3_check_version()
|
|
||||||
endif(EIGEN3_INCLUDE_DIR)
|
|
||||||
|
|
||||||
include(FindPackageHandleStandardArgs)
|
|
||||||
find_package_handle_standard_args(Eigen3 DEFAULT_MSG EIGEN3_INCLUDE_DIR EIGEN3_VERSION_OK)
|
|
||||||
|
|
||||||
mark_as_advanced(EIGEN3_INCLUDE_DIR)
|
|
||||||
|
|
||||||
endif(EIGEN3_INCLUDE_DIR)
|
|
||||||
|
|
||||||
+1
-1
@@ -40,7 +40,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <matrix/matrix/math.hpp>
|
#include <matrix/math.hpp>
|
||||||
|
|
||||||
namespace estimator
|
namespace estimator
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -43,7 +43,7 @@
|
|||||||
#include "RingBuffer.h"
|
#include "RingBuffer.h"
|
||||||
|
|
||||||
#include <geo/geo.h>
|
#include <geo/geo.h>
|
||||||
#include <matrix/matrix/math.hpp>
|
#include <matrix/math.hpp>
|
||||||
#include <mathlib/mathlib.h>
|
#include <mathlib/mathlib.h>
|
||||||
|
|
||||||
using namespace estimator;
|
using namespace estimator;
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
function posNED = LLH2NED(LLH,refLLH)
|
function posNED = LLH2NED(LLH,refLLH)
|
||||||
|
|
||||||
radius = 6378137;
|
radius = 6378137;
|
||||||
flattening = 1/298.257223563;
|
flattening = 1/298.257223563;
|
||||||
e = sqrt(flattening*(2-flattening));
|
e = sqrt(flattening*(2-flattening));
|
||||||
Rm = radius*(1-e^2)/(1-e^2*sin(refLLH(1)*pi/180)^2)^(3/2);
|
Rm = radius*(1-e^2)/(1-e^2*sin(refLLH(1)*pi/180)^2)^(3/2);
|
||||||
Rn = radius/(1-e^2*sin(refLLH(1)*pi/180)^2)^(1/2);
|
Rn = radius/(1-e^2*sin(refLLH(1)*pi/180)^2)^(1/2);
|
||||||
posN = (LLH(1,:)-refLLH(1))*pi/180.*(Rm+LLH(3,:));
|
posN = (LLH(1,:)-refLLH(1))*pi/180.*(Rm+LLH(3,:));
|
||||||
posE = (LLH(2,:)-refLLH(2))*pi/180.*(Rn+LLH(3,:))*cos(refLLH(1)*pi/180);
|
posE = (LLH(2,:)-refLLH(2))*pi/180.*(Rn+LLH(3,:))*cos(refLLH(1)*pi/180);
|
||||||
posD = -(LLH(3,:)-refLLH(3));
|
posD = -(LLH(3,:)-refLLH(3));
|
||||||
posNED = [posN;posE;posD];
|
posNED = [posN;posE;posD];
|
||||||
end
|
end
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user