diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d176b3066b5e09dd442ac2bf1a8219f98ccc6d4a..22758b2128be81ae6316de961a630a2e68cd3388 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,107 +1,154 @@ -image: labrobotica/ceres:1.14 +stages: + - license + - build_and_test -before_script: - ## +############ YAML ANCHORS ############ +.preliminaries_template: &preliminaries_definition ## Install ssh-agent if not already installed, it is required by Docker. ## (change apt-get to yum if you use an RPM-based image) - ## - 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )' - ## ## Run ssh-agent (inside the build environment) - ## - eval $(ssh-agent -s) - ## ## Add the SSH key stored in SSH_PRIVATE_KEY variable to the agent store ## We're using tr to fix line endings which makes ed25519 keys work ## without extra base64 encoding. ## https://gitlab.com/gitlab-examples/ssh-private-key/issues/1#note_48526556 - ## - mkdir -p ~/.ssh - chmod 700 ~/.ssh - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null # - echo "$SSH_KNOWN_HOSTS" > $HOME/.ssh/known_hosts - ssh-keyscan -H -p 2202 gitlab.iri.upc.edu >> $HOME/.ssh/known_hosts - ## - ## Create the SSH directory and give it the right permissions - ## - - ls + # update apt - apt-get update - - apt-get install -y build-essential cmake -# SPDLOG -# - apt-get install -y libspdlog-dev - - if [ -d spdlog ]; then - - echo "directory exists" - - if [ "$(ls -A ./spdlog)" ]; then - - echo "directory not empty" - - cd spdlog - - git pull - - else - - echo "directory empty" - - git clone https://github.com/gabime/spdlog.git - - cd spdlog - - fi + # create 'ci_deps' folder (if not exists) + - mkdir -pv ci_deps + +.license_header_template: &license_header_definition + - cd $CI_PROJECT_DIR + + # configure git + - export CI_NEW_BRANCH=ci_processing$RANDOM + - echo creating new temporary branch... $CI_NEW_BRANCH + - git config --global user.email "${CI_EMAIL}" + - git config --global user.name "${CI_USERNAME}" + - git checkout -b $CI_NEW_BRANCH # temporary branch + + # license headers + - export CURRENT_YEAR=$( date +'%Y' ) + - echo "current year:" ${CURRENT_YEAR} + - if [ -f license_header_${CURRENT_YEAR}.txt ]; then + # add license headers to new files + - echo "File license_header_${CURRENT_YEAR}.txt already exists. License headers are assumed to be updated. Adding headers to new files..." + - ./ci_deps/wolf/wolf_scripts/license_manager.sh --add --path=. --license-header=license_header_${CURRENT_YEAR}.txt --exclude=ci_deps - else - - echo "directory inexistent" - - git clone https://github.com/gabime/spdlog.git - - cd spdlog + # update license headers of all files + - export PREV_YEAR=$(( CURRENT_YEAR-1 )) + - echo "Creating new file license_header_${CURRENT_YEAR}.txt..." + - git mv license_header_${PREV_YEAR}.txt license_header_${CURRENT_YEAR}.txt + - sed -i "s/${PREV_YEAR}/${PREV_YEAR},${CURRENT_YEAR}/g" license_header_${CURRENT_YEAR}.txt + - ./ci_deps/wolf/wolf_scripts/license_manager.sh --update --path=. --license-header=license_header_${CURRENT_YEAR}.txt --exclude=ci_deps - fi - - git fetch - - git checkout v0.17.0 - - mkdir -pv build - - cd build - - ls - - cmake -DCMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS} -fPIC" -DSPDLOG_BUILD_TESTING=OFF .. - - make install - - cd ../.. -# YAML -# - apt-get install -y libyaml-cpp-dev - - if [ -d yaml-cpp ]; then - - echo "directory exists" - - if [ "$(ls -A ./yaml-cpp)" ]; then - - echo "directory not empty" - - cd yaml-cpp - - git pull - - else - - echo "directory empty" - - git clone https://github.com/jbeder/yaml-cpp.git - - cd yaml-cpp - - fi + # push changes (if any) + - if git commit -a -m "[skip ci] license headers added or modified" ; then + - git remote set-url --push origin "ssh://git@gitlab.iri.upc.edu:2202/${CI_PROJECT_PATH}.git" + - git push origin $CI_NEW_BRANCH:${CI_COMMIT_REF_NAME} - else - - echo "directory inexistent" - - git clone https://github.com/jbeder/yaml-cpp.git - - cd yaml-cpp + - echo "No changes, nothing to commit!" + - fi + +.install_wolf_template: &install_wolf_definition + - cd ${CI_PROJECT_DIR}/ci_deps + - if [ -d wolf ]; then + - echo "directory wolf exists" + - cd wolf + - git checkout devel + - git pull + - git checkout $WOLF_CORE_BRANCH + - git pull + - else + - git clone -b $WOLF_CORE_BRANCH ssh://git@gitlab.iri.upc.edu:2202/mobile_robotics/wolf_projects/wolf_lib/wolf.git + - cd wolf - fi - mkdir -pv build - cd build - - ls - - cmake -DCMAKE_CXX_FLAGS="${CMAKE_CXX_FLAGS} -fPIC" -DYAML_CPP_BUILD_TESTS=OFF .. + - cmake -DCMAKE_BUILD_TYPE=release -DBUILD_DEMOS=OFF -DBUILD_TESTS=OFF .. + - make -j$(nproc) - make install - - cd ../.. -#Wolf core - - git clone ssh://git@gitlab.iri.upc.edu:2202/mobile_robotics/wolf_projects/wolf_lib/wolf.git - - cd wolf + +.build_and_test_template: &build_and_test_definition + - cd $CI_PROJECT_DIR - mkdir -pv build - cd build - - cmake -DCMAKE_BUILD_TYPE=release -DBUILD_EXAMPLES=ON -DBUILD_TESTS=ON .. + - cmake -DCMAKE_BUILD_TYPE=release -DBUILD_TESTS=ON .. - make -j$(nproc) - ctest -j$(nproc) - make install - - cd ../.. -wolf_build_and_test: - stage: build +############ LICENSE HEADERS ############ +license_headers: + stage: license + image: labrobotica/wolf_deps:16.04 + cache: + - key: wolf-xenial + paths: + - ci_deps/wolf/ + except: + - master + before_script: + - *preliminaries_definition + - *install_wolf_definition + script: + - *license_header_definition + +############ UBUNTU 16.04 TESTS ############ +build_and_test:xenial: + stage: build_and_test + image: labrobotica/wolf_deps:16.04 + cache: + - key: wolf-xenial + paths: + - ci_deps/wolf/ + except: + - master + before_script: + - *preliminaries_definition + - *install_wolf_definition + script: + - *build_and_test_definition + +############ UBUNTU 18.04 TESTS ############ +build_and_test:bionic: + stage: build_and_test + image: labrobotica/wolf_deps:18.04 + cache: + - key: wolf-bionic + paths: + - ci_deps/wolf/ + except: + - master + before_script: + - *preliminaries_definition + - *install_wolf_definition + script: + - *build_and_test_definition + +############ UBUNTU 20.04 TESTS ############ +build_and_test:focal: + stage: build_and_test + image: labrobotica/wolf_deps:20.04 + cache: + - key: wolf-focal + paths: + - ci_deps/wolf/ except: - master + before_script: + - *preliminaries_definition + - *install_wolf_definition script: - - mkdir -pv build - - cd build - - ls # we can check whether the directory was already full - - cmake -DCMAKE_BUILD_TYPE=release -DBUILD_EXAMPLES=ON -DBUILD_TESTS=ON .. - - make -j$(nproc) - - ctest -j$(nproc) - - make install + - *build_and_test_definition diff --git a/CMakeLists.txt b/CMakeLists.txt index 5b854cf7e93d2472fa231aaa20850309d3e0fffb..ea892d9b6b3b197e573e295313227fcb62286c09 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ # Pre-requisites about cmake itself -CMAKE_MINimuM_REQUIRED(VERSION 2.6) +CMAKE_MINimuM_REQUIRED(VERSION 2.8) if(COMMAND cmake_policy) cmake_policy(SET CMP0005 NEW) @@ -8,11 +8,11 @@ endif(COMMAND cmake_policy) # MAC OSX RPATH SET(CMAKE_MACOSX_RPATH 1) - # The project name PROJECT(imu) set(PLUGIN_NAME "wolf${PROJECT_NAME}") +MESSAGE("Starting ${PROJECT_NAME} CMakeLists ...") SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/bin) SET(LIBRARY_OUTPUT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/lib) @@ -27,18 +27,14 @@ message(STATUS "Configured to compile in ${CMAKE_BUILD_TYPE} mode.") SET(CMAKE_CXX_FLAGS_DEBUG "-g -Wall -O0 -D_REENTRANT") SET(CMAKE_CXX_FLAGS_RELEASE "-O3 -D_REENTRANT") -#Set compiler according C++11 support +#Set compiler according C++14 support include(CheckCXXCompilerFlag) -CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11) -CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X) -if(COMPILER_SUPPORTS_CXX11) - message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has C++11 support.") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") -elseif(COMPILER_SUPPORTS_CXX0X) - message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has C++0x support.") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") +CHECK_CXX_COMPILER_FLAG("-std=c++14" COMPILER_SUPPORTS_CXX14) +if(COMPILER_SUPPORTS_CXX14) + message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has C++14 support.") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14") else() - message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.") + message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++14 support. Please use a different C++ compiler.") endif() if(UNIX) @@ -71,35 +67,24 @@ if(BUILD_TESTS) enable_testing() endif() -MESSAGE("Starting ${PROJECT_NAME} CMakeLists ...") -CMAKE_MINimuM_REQUIRED(VERSION 2.8) - #CMAKE modules - SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake_modules") MESSAGE(STATUS ${CMAKE_MODULE_PATH}) # Some wolf compilation options - IF((CMAKE_BUILD_TYPE MATCHES DEBUG) OR (CMAKE_BUILD_TYPE MATCHES debug) OR (CMAKE_BUILD_TYPE MATCHES Debug)) set(_WOLF_DEBUG true) ENDIF() option(_WOLF_TRACE "Enable wolf tracing macro" ON) -# Does this has any other interest -# but for the examples ? -# yes, for the tests ! -IF(BUILD_EXAMPLES OR BUILD_TESTS) - string(TOUPPER ${PROJECT_NAME} UPPER_NAME) - set(_WOLF_ROOT_DIR ${CMAKE_SOURCE_DIR}) -ENDIF(BUILD_EXAMPLES OR BUILD_TESTS) - - -#find dependencies. -# ============EXAMPLE================== +# ============ DEPENDENCIES ============ FIND_PACKAGE(wolfcore REQUIRED) +# ============ config.h ============ +string(TOUPPER ${PROJECT_NAME} UPPER_NAME) +set(_WOLF_ROOT_DIR ${CMAKE_SOURCE_DIR}) + # Define the directory where will be the configured config.h SET(WOLF_CONFIG_DIR ${PROJECT_BINARY_DIR}/conf/${PROJECT_NAME}/internal) @@ -117,20 +102,11 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/internal/config.h.in "${WOLF_CONFIG_D message("CONFIG DIRECTORY ${PROJECT_BINARY_DIR}") include_directories("${PROJECT_BINARY_DIR}/conf") -#INCLUDES SECTION -# ============EXAMPLE================== +# ============ INCLUDES SECTION ============ INCLUDE_DIRECTORIES(${wolfcore_INCLUDE_DIRS}) INCLUDE_DIRECTORIES(BEFORE "include") -#HEADERS - -SET(HDRS_COMMON - ) -SET(HDRS_MATH - include/imu/math/imu_tools.h - ) -SET(HDRS_UTILS - ) +# ============ HEADERS ============ SET(HDRS_CAPTURE include/imu/capture/capture_compass.h include/imu/capture/capture_imu.h @@ -145,7 +121,8 @@ SET(HDRS_FEATURE include/imu/feature/feature_imu.h include/imu/feature/feature_imu2d.h ) -SET(HDRS_LANDMARK +SET(HDRS_MATH + include/imu/math/imu_tools.h ) SET(HDRS_PROCESSOR include/imu/processor/processor_compass.h @@ -157,33 +134,15 @@ SET(HDRS_SENSOR include/imu/sensor/sensor_imu.h include/imu/sensor/sensor_imu2d.h ) -SET(HDRS_SOLVER - ) -SET(HDRS_DTASSC - ) - -#SOURCES - -SET(SRCS_COMMON - ) -SET(SRCS_MATH - include/imu/math/imu_tools.h - include/imu/math/imu2d_tools.h - ) -SET(SRCS_UTILS - ) +# ============ SOURCES ============ SET(SRCS_CAPTURE src/capture/capture_imu.cpp ) -SET(SRCS_FACTOR - ) SET(SRCS_FEATURE src/feature/feature_imu.cpp src/feature/feature_imu2d.cpp ) -SET(SRCS_LANDMARK - ) SET(SRCS_PROCESSOR src/processor/processor_compass.cpp src/processor/processor_imu.cpp @@ -196,55 +155,20 @@ SET(SRCS_SENSOR src/sensor/sensor_imu.cpp src/sensor/sensor_imu2d.cpp ) -SET(SRCS_DTASSC - ) -SET(SRCS_SOLVER - ) SET(SRCS_YAML src/yaml/processor_imu_yaml.cpp src/yaml/processor_imu2d_yaml.cpp src/yaml/sensor_imu_yaml.cpp src/yaml/sensor_imu2d_yaml.cpp ) -#OPTIONALS -#optional HDRS and SRCS -# ==================EXAMPLE=============== -# IF (Ceres_FOUND) -# SET(HDRS_WRAPPER -# include/base/solver_suitesparse/sparse_utils.h -# include/base/solver/solver_manager.h -# include/base/ceres_wrapper/ceres_manager.h -# include/base/ceres_wrapper/cost_function_wrapper.h -# include/base/ceres_wrapper/create_numeric_diff_cost_function.h -# include/base/ceres_wrapper/local_parametrization_wrapper.h -# ) -# SET(SRCS_WRAPPER -# src/solver/solver_manager.cpp -# src/ceres_wrapper/ceres_manager.cpp -# src/ceres_wrapper/local_parametrization_wrapper.cpp -# ) -# ELSE(Ceres_FOUND) -# SET(HDRS_WRAPPER) -# SET(SRCS_WRAPPER) -# ENDIF(Ceres_FOUND) - # create the shared library ADD_LIBRARY(${PLUGIN_NAME} SHARED - ${SRCS_BASE} ${SRCS_CAPTURE} - ${SRCS_COMMON} - ${SRCS_DTASSC} - ${SRCS_FACTOR} ${SRCS_FEATURE} - ${SRCS_LANDMARK} - ${SRCS_MATH} ${SRCS_PROCESSOR} ${SRCS_SENSOR} - ${SRCS_SOLVER} - ${SRCS_UTILS} - ${SRCS_WRAPPER} ${SRCS_YAML} ) @@ -260,71 +184,44 @@ elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") # using GCC endif() - #Link the created libraries -#===============EXAMPLE========================= -# IF (Ceres_FOUND) -# TARGET_LINK_LIBRARIES(${PLUGIN_NAME} ${CERES_LIBRARIES}) -# ENDIF(Ceres_FOUND) TARGET_LINK_LIBRARIES(${PLUGIN_NAME} ${wolfcore_LIBRARIES}) - -#Build tests -#===============EXAMPLE========================= +#===============Build tests========================= IF(BUILD_TESTS) MESSAGE("Building tests.") add_subdirectory(test) ENDIF(BUILD_TESTS) #install library - -#============================================================= INSTALL(TARGETS ${PLUGIN_NAME} EXPORT ${PLUGIN_NAME}Targets RUNTIME DESTINATION bin - LIBRARY DESTINATION lib/iri-algorithms - ARCHIVE DESTINATION lib/iri-algorithms) + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib) install(EXPORT ${PLUGIN_NAME}Targets DESTINATION lib/cmake/${PLUGIN_NAME}) #install headers -INSTALL(FILES ${HDRS_DTASSC} - DESTINATION include/iri-algorithms/wolf/plugin_${PROJECT_NAME}/${PROJECT_NAME}/association) -INSTALL(FILES ${HDRS_MATH} - DESTINATION include/iri-algorithms/wolf/plugin_${PROJECT_NAME}/${PROJECT_NAME}/math) -INSTALL(FILES ${HDRS_COMMON} - DESTINATION include/iri-algorithms/wolf/plugin_${PROJECT_NAME}/${PROJECT_NAME}/common) -INSTALL(FILES ${HDRS_UTILS} - DESTINATION include/iri-algorithms/wolf/plugin_${PROJECT_NAME}/${PROJECT_NAME}/utils) INSTALL(FILES ${HDRS_CAPTURE} DESTINATION include/iri-algorithms/wolf/plugin_${PROJECT_NAME}/${PROJECT_NAME}/capture) INSTALL(FILES ${HDRS_FACTOR} DESTINATION include/iri-algorithms/wolf/plugin_${PROJECT_NAME}/${PROJECT_NAME}/factor) INSTALL(FILES ${HDRS_FEATURE} DESTINATION include/iri-algorithms/wolf/plugin_${PROJECT_NAME}/${PROJECT_NAME}/feature) -INSTALL(FILES ${HDRS_SENSOR} - DESTINATION include/iri-algorithms/wolf/plugin_${PROJECT_NAME}/${PROJECT_NAME}/sensor) +INSTALL(FILES ${HDRS_MATH} + DESTINATION include/iri-algorithms/wolf/plugin_${PROJECT_NAME}/${PROJECT_NAME}/math) INSTALL(FILES ${HDRS_PROCESSOR} DESTINATION include/iri-algorithms/wolf/plugin_${PROJECT_NAME}/${PROJECT_NAME}/processor) -INSTALL(FILES ${HDRS_LANDMARK} - DESTINATION include/iri-algorithms/wolf/plugin_${PROJECT_NAME}/${PROJECT_NAME}/landmark) -INSTALL(FILES ${HDRS_WRAPPER} - DESTINATION include/iri-algorithms/wolf/plugin_${PROJECT_NAME}/${PROJECT_NAME}/ceres_wrapper) -#INSTALL(FILES ${HDRS_SOLVER_SUITESPARSE} -# DESTINATION include/iri-algorithms/wolf/plugin_${PROJECT_NAME}/${PROJECT_NAME}/solver_suitesparse) -INSTALL(FILES ${HDRS_SOLVER} - DESTINATION include/iri-algorithms/wolf/plugin_${PROJECT_NAME}/${PROJECT_NAME}/solver) -INSTALL(FILES ${HDRS_SERIALIZATION} - DESTINATION include/iri-algorithms/wolf/plugin_${PROJECT_NAME}/${PROJECT_NAME}/serialization) -INSTALL(FILES ${HDRS_YAML} - DESTINATION include/iri-algorithms/wolf/plugin_${PROJECT_NAME}/${PROJECT_NAME}/yaml) +INSTALL(FILES ${HDRS_SENSOR} + DESTINATION include/iri-algorithms/wolf/plugin_${PROJECT_NAME}/${PROJECT_NAME}/sensor) +FILE(WRITE imu.found "") INSTALL(FILES ${PROJECT_NAME}.found DESTINATION include/iri-algorithms/wolf/plugin_${PROJECT_NAME}) -FILE(WRITE imu.found "") - INSTALL(FILES "${WOLF_CONFIG_DIR}/config.h" DESTINATION include/iri-algorithms/wolf/plugin_${PROJECT_NAME}/${PROJECT_NAME}/internal) INSTALL(FILES "${CMAKE_SOURCE_DIR}/cmake_modules/${PLUGIN_NAME}Config.cmake" DESTINATION "lib/cmake/${PLUGIN_NAME}") + INSTALL(DIRECTORY ${SPDLOG_INCLUDE_DIRS} DESTINATION "include/iri-algorithms/") export(PACKAGE ${PLUGIN_NAME}) diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..ea713a415e0a702b7e0098a2889919b53643d8ad --- /dev/null +++ b/LICENSE @@ -0,0 +1,620 @@ + + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/> + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. diff --git a/README.md b/README.md index dd79d5e177365518822ce675cf4fce278e65e45f..2345eb53e24a8f4179ea43625f727662fba7df26 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ WOLF - Windowed Localization Frames | IMU Plugin =================================== -For installation guide and code documentation, please visit the [documentation website](http://mobile_robotics.pages.iri.upc-csic.es/wolf_projects/wolf_lib/wolf_doc/). \ No newline at end of file +For installation guide and code documentation, please visit the [documentation website](http://mobile_robotics.pages.iri.upc-csic.es/wolf_projects/wolf_lib/wolf-doc-sphinx/). diff --git a/cmake_modules/wolfimuConfig.cmake b/cmake_modules/wolfimuConfig.cmake index b157cd3870468e1fbfad10b206b4ba55e310244b..97662cc09eb78aaf9b2b80e5b32cad9c59579bfc 100644 --- a/cmake_modules/wolfimuConfig.cmake +++ b/cmake_modules/wolfimuConfig.cmake @@ -12,7 +12,7 @@ ENDIF(wolfimu_INCLUDE_DIRS) FIND_LIBRARY( wolfimu_LIBRARIES NAMES libwolfimu.so libwolfimu.dylib - PATHS /usr/local/lib/iri-algorithms) + PATHS /usr/local/lib) IF(wolfimu_LIBRARIES) MESSAGE("Found wolf imu lib: ${wolfimu_LIBRARIES}") ELSE(wolfimu_LIBRARIES) @@ -77,3 +77,8 @@ if(NOT wolf_FOUND) list(APPEND wolfimu_LIBRARIES ${wolfcore_LIBRARIES}) list(REVERSE wolfimu_LIBRARIES) endif() + +# provide both INCLUDE_DIR and INCLUDE_DIRS +SET(wolfimu_INCLUDE_DIR ${wolfimu_INCLUDE_DIRS}) +# provide both LIBRARY and LIBRARIES +SET(wolfimu_LIBRARY ${wolfimu_LIBRARIES}) diff --git a/demos/demo_factor_imu.cpp b/demos/demo_factor_imu.cpp index 581d7429331d13a0bf67f847f7d9924c0814358e..9b0e262c6c41715f619ea5b25b4be67b9672d3c5 100644 --- a/demos/demo_factor_imu.cpp +++ b/demos/demo_factor_imu.cpp @@ -1,3 +1,24 @@ +//--------LICENSE_START-------- +// +// Copyright (C) 2020,2021,2022 Institut de Robòtica i Informà tica Industrial, CSIC-UPC. +// Authors: Joan Solà Ortega (jsola@iri.upc.edu) +// All rights reserved. +// +// This file is part of WOLF +// WOLF is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see <http://www.gnu.org/licenses/>. +// +//--------LICENSE_END-------- //Wolf #include <core/ceres_wrapper/solver_ceres.h> @@ -46,7 +67,7 @@ int main(int argc, char** argv) // Set the origin Eigen::VectorXd x0(16); x0 << 0,0,0, 0,0,0,1, 0,0,0, 0,0,.001, 0,0,.002; // Try some non-zero biases - wolf_problem_ptr_->getProcessorIsMotion()->setOrigin(x0, t); //this also creates a keyframe at origin + wolf_problem_ptr_->getMotionProvider()->setOrigin(x0, t); //this also creates a keyframe at origin wolf_problem_ptr_->getTrajectory()->getFrameList().front()->fix(); //fix the keyframe at origin TimeStamp ts(0); @@ -78,14 +99,14 @@ int main(int argc, char** argv) /// ******************************************************************************************** /// /// factor creation //create FrameIMU - ts = wolf_problem_ptr_->getProcessorIsMotion()->getBuffer().back().ts_; - state_vec = wolf_problem_ptr_->getProcessorIsMotion()->getCurrentState(); + ts = wolf_problem_ptr_->getMotionProvider()->getBuffer().back().ts_; + state_vec = wolf_problem_ptr_->getMotionProvider()->getCurrentState(); FrameIMUPtr last_frame = std::make_shared<FrameIMU>(KEY, ts, state_vec); wolf_problem_ptr_->getTrajectory()->addFrame(last_frame); //create a feature - delta_preint_cov = wolf_problem_ptr_->getProcessorIsMotion()->getCurrentDeltaPreintCov(); - delta_preint = wolf_problem_ptr_->getProcessorIsMotion()->getMotion().delta_integr_; + delta_preint_cov = wolf_problem_ptr_->getMotionProvider()->getCurrentDeltaPreintCov(); + delta_preint = wolf_problem_ptr_->getMotionProvider()->getMotion().delta_integr_; std::shared_ptr<FeatureIMU> feat_imu = std::make_shared<FeatureIMU>(delta_preint, delta_preint_cov); feat_imu->setCapture(imu_ptr); @@ -114,7 +135,7 @@ int main(int argc, char** argv) std::cout << "residuals : " << residu.transpose() << std::endl; //reset origin of motion to new frame - wolf_problem_ptr_->getProcessorIsMotion()->setOrigin(last_frame); + wolf_problem_ptr_->getMotionProvider()->setOrigin(last_frame); imu_ptr->setFrame(last_frame); } /// ******************************************************************************************** /// @@ -139,14 +160,14 @@ int main(int argc, char** argv) /// ******************************************************************************************** /// /// factor creation //create FrameIMU - ts = wolf_problem_ptr_->getProcessorIsMotion()->getBuffer().back().ts_; - state_vec = wolf_problem_ptr_->getProcessorIsMotion()->getCurrentState(); + ts = wolf_problem_ptr_->getMotionProvider()->getBuffer().back().ts_; + state_vec = wolf_problem_ptr_->getMotionProvider()->getCurrentState(); FrameIMUPtr last_frame = std::make_shared<FrameIMU>(KEY, ts, state_vec); wolf_problem_ptr_->getTrajectory()->addFrame(last_frame); //create a feature - delta_preint_cov = wolf_problem_ptr_->getProcessorIsMotion()->getCurrentDeltaPreintCov(); - delta_preint = wolf_problem_ptr_->getProcessorIsMotion()->getMotion().delta_integr_; + delta_preint_cov = wolf_problem_ptr_->getMotionProvider()->getCurrentDeltaPreintCov(); + delta_preint = wolf_problem_ptr_->getMotionProvider()->getMotion().delta_integr_; std::shared_ptr<FeatureIMU> feat_imu = std::make_shared<FeatureIMU>(delta_preint, delta_preint_cov); feat_imu->setCapture(imu_ptr); @@ -175,7 +196,7 @@ int main(int argc, char** argv) std::cout << "residuals : " << residu.transpose() << std::endl; //reset origin of motion to new frame - wolf_problem_ptr_->getProcessorIsMotion()->setOrigin(last_frame); + wolf_problem_ptr_->getMotionProvider()->setOrigin(last_frame); imu_ptr->setFrame(last_frame); } @@ -197,14 +218,14 @@ int main(int argc, char** argv) //create the factor //create FrameIMU - ts = wolf_problem_ptr_->getProcessorIsMotion()->getBuffer().back().ts_; - state_vec = wolf_problem_ptr_->getProcessorIsMotion()->getCurrentState(); + ts = wolf_problem_ptr_->getMotionProvider()->getBuffer().back().ts_; + state_vec = wolf_problem_ptr_->getMotionProvider()->getCurrentState(); FrameIMUPtr last_frame = std::make_shared<FrameIMU>(KEY, ts, state_vec); wolf_problem_ptr_->getTrajectory()->addFrame(last_frame); //create a feature - delta_preint_cov = wolf_problem_ptr_->getProcessorIsMotion()->getCurrentDeltaPreintCov(); - delta_preint = wolf_problem_ptr_->getProcessorIsMotion()->getMotion().delta_integr_; + delta_preint_cov = wolf_problem_ptr_->getMotionProvider()->getCurrentDeltaPreintCov(); + delta_preint = wolf_problem_ptr_->getMotionProvider()->getMotion().delta_integr_; std::shared_ptr<FeatureIMU> feat_imu = std::make_shared<FeatureIMU>(delta_preint, delta_preint_cov); feat_imu->setCapture(imu_ptr); @@ -239,13 +260,13 @@ int main(int argc, char** argv) ///having a look at covariances Eigen::MatrixXd predelta_cov; predelta_cov.resize(9,9); - predelta_cov = wolf_problem_ptr_->getProcessorIsMotion()->getCurrentDeltaPreintCov(); + predelta_cov = wolf_problem_ptr_->getMotionProvider()->getCurrentDeltaPreintCov(); //std::cout << "predelta_cov : \n" << predelta_cov << std::endl; ///Optimization // PRIOR //FrameBasePtr first_frame = wolf_problem_ptr_->getTrajectory()->getFrameList().front(); - wolf_problem_ptr_->getProcessorIsMotion()->setOrigin(wolf_problem_ptr_->getTrajectory()->getFrameList().front()); + wolf_problem_ptr_->getMotionProvider()->setOrigin(wolf_problem_ptr_->getTrajectory()->getFrameList().front()); //SensorBasePtr sensorbase = std::make_shared<SensorBase>("ABSOLUTE POSE", nullptr, nullptr, nullptr, 0); //CapturePosePtr initial_covariance = std::make_shared<CaptureFix>(TimeStamp(0), sensorbase, first_frame->getState().head(7), Eigen::Matrix6d::Identity() * 0.01); //first_frame->addCapture(initial_covariance); diff --git a/demos/demo_imuDock.cpp b/demos/demo_imuDock.cpp index e218a88cbf8f48b7537954f52d02ce7c7ee957f1..b9d4db8a650c799465f8f176156a55d065e884f9 100644 --- a/demos/demo_imuDock.cpp +++ b/demos/demo_imuDock.cpp @@ -1,3 +1,24 @@ +//--------LICENSE_START-------- +// +// Copyright (C) 2020,2021,2022 Institut de Robòtica i Informà tica Industrial, CSIC-UPC. +// Authors: Joan Solà Ortega (jsola@iri.upc.edu) +// All rights reserved. +// +// This file is part of WOLF +// WOLF is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see <http://www.gnu.org/licenses/>. +// +//--------LICENSE_END-------- /** * \file test_imuDock.cpp * diff --git a/demos/demo_imuDock_autoKFs.cpp b/demos/demo_imuDock_autoKFs.cpp index d5bd9aa8bc357f6be1c5135d8c1ad7730c4858da..6b8fee70fa055ecfa00bc9317d4d427fdea71236 100644 --- a/demos/demo_imuDock_autoKFs.cpp +++ b/demos/demo_imuDock_autoKFs.cpp @@ -1,3 +1,24 @@ +//--------LICENSE_START-------- +// +// Copyright (C) 2020,2021,2022 Institut de Robòtica i Informà tica Industrial, CSIC-UPC. +// Authors: Joan Solà Ortega (jsola@iri.upc.edu) +// All rights reserved. +// +// This file is part of WOLF +// WOLF is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see <http://www.gnu.org/licenses/>. +// +//--------LICENSE_END-------- /** * \file test_imuDock_autoKFs.cpp * diff --git a/demos/demo_imuPlateform_Offline.cpp b/demos/demo_imuPlateform_Offline.cpp index 628c4b65ed2e8b88a3cdfbedc8f07ef80f906001..7fd1d9488c9ff3b9625aa8b2e6c9fb6938f1f850 100644 --- a/demos/demo_imuPlateform_Offline.cpp +++ b/demos/demo_imuPlateform_Offline.cpp @@ -1,3 +1,24 @@ +//--------LICENSE_START-------- +// +// Copyright (C) 2020,2021,2022 Institut de Robòtica i Informà tica Industrial, CSIC-UPC. +// Authors: Joan Solà Ortega (jsola@iri.upc.edu) +// All rights reserved. +// +// This file is part of WOLF +// WOLF is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see <http://www.gnu.org/licenses/>. +// +//--------LICENSE_END-------- //Wolf #include <core/ceres_wrapper/solver_ceres.h> @@ -145,9 +166,9 @@ int main(int argc, char** argv) } TimeStamp t0, tf; - t0 = wolf_problem_ptr_->getProcessorIsMotion()->getBuffer().front().ts_; - tf = wolf_problem_ptr_->getProcessorIsMotion()->getBuffer().back().ts_; - int N = wolf_problem_ptr_->getProcessorIsMotion()->getBuffer().size(); + t0 = wolf_problem_ptr_->getMotionProvider()->getBuffer().front().ts_; + tf = wolf_problem_ptr_->getMotionProvider()->getBuffer().back().ts_; + int N = wolf_problem_ptr_->getMotionProvider()->getBuffer().size(); //Finally, process the only one odom input mot_ptr->setTimeStamp(ts); @@ -168,20 +189,20 @@ int main(int argc, char** argv) std::cout << "Initial state: " << std::fixed << std::setprecision(3) << std::setw(8) << x_origin.head(16).transpose() << std::endl; std::cout << "Integrated delta: " << std::fixed << std::setprecision(3) << std::setw(8) - << wolf_problem_ptr_->getProcessorIsMotion()->getMotion().delta_integr_.transpose() << std::endl; + << wolf_problem_ptr_->getMotionProvider()->getMotion().delta_integr_.transpose() << std::endl; std::cout << "Integrated state: " << std::fixed << std::setprecision(3) << std::setw(8) - << wolf_problem_ptr_->getProcessorIsMotion()->getCurrentState().head(16).transpose() << std::endl; + << wolf_problem_ptr_->getMotionProvider()->getCurrentState().head(16).transpose() << std::endl; std::cout << "Integrated std : " << std::fixed << std::setprecision(3) << std::setw(8) - << (wolf_problem_ptr_->getProcessorIsMotion()->getMotion().delta_integr_cov_.diagonal().transpose()).array().sqrt() << std::endl; + << (wolf_problem_ptr_->getMotionProvider()->getMotion().delta_integr_cov_.diagonal().transpose()).array().sqrt() << std::endl; // Print statistics std::cout << "\nStatistics -----------------------------------------------------------------------------------" << std::endl; std::cout << "If you want meaningful CPU metrics, remove all couts in the loop / remove DEBUG_RESULTS definition variable, and compile in RELEASE mode!" << std::endl; /*TimeStamp t0, tf; - t0 = wolf_problem_ptr_->getProcessorIsMotion()->getBuffer().front().ts_; - tf = wolf_problem_ptr_->getProcessorIsMotion()->getBuffer().back().ts_; - int N = wolf_problem_ptr_->getProcessorIsMotion()->getBuffer().size();*/ + t0 = wolf_problem_ptr_->getMotionProvider()->getBuffer().front().ts_; + tf = wolf_problem_ptr_->getMotionProvider()->getBuffer().back().ts_; + int N = wolf_problem_ptr_->getMotionProvider()->getBuffer().size();*/ std::cout << "t0 : " << t0.get() << " s" << std::endl; std::cout << "tf : " << tf.get() << " s" << std::endl; std::cout << "duration : " << tf-t0 << " s" << std::endl; diff --git a/demos/demo_imu_constrained0.cpp b/demos/demo_imu_constrained0.cpp index 66db5c1c71e81035aa6ea70e000a8a92d29b4af6..3837895eb78d85b15dd9a8818b4b459ca425aee9 100644 --- a/demos/demo_imu_constrained0.cpp +++ b/demos/demo_imu_constrained0.cpp @@ -1,3 +1,24 @@ +//--------LICENSE_START-------- +// +// Copyright (C) 2020,2021,2022 Institut de Robòtica i Informà tica Industrial, CSIC-UPC. +// Authors: Joan Solà Ortega (jsola@iri.upc.edu) +// All rights reserved. +// +// This file is part of WOLF +// WOLF is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see <http://www.gnu.org/licenses/>. +// +//--------LICENSE_END-------- //Wolf #include <core/ceres_wrapper/solver_ceres.h> @@ -223,20 +244,20 @@ int main(int argc, char** argv) std::cout << "Initial state: " << std::fixed << std::setprecision(3) << std::setw(8) << x_origin.head(16).transpose() << std::endl; std::cout << "Integrated delta: " << std::fixed << std::setprecision(3) << std::setw(8) - << wolf_problem_ptr_->getProcessorIsMotion()->getMotion().delta_integr_.transpose() << std::endl; + << wolf_problem_ptr_->getMotionProvider()->getMotion().delta_integr_.transpose() << std::endl; std::cout << "Integrated state: " << std::fixed << std::setprecision(3) << std::setw(8) - << wolf_problem_ptr_->getProcessorIsMotion()->getCurrentState().head(16).transpose() << std::endl; + << wolf_problem_ptr_->getMotionProvider()->getCurrentState().head(16).transpose() << std::endl; std::cout << "Integrated std : " << std::fixed << std::setprecision(3) << std::setw(8) - << (wolf_problem_ptr_->getProcessorIsMotion()->getMotion().delta_integr_cov_.diagonal()).array().sqrt() << std::endl; + << (wolf_problem_ptr_->getMotionProvider()->getMotion().delta_integr_cov_.diagonal()).array().sqrt() << std::endl; // Print statistics std::cout << "\nStatistics -----------------------------------------------------------------------------------" << std::endl; std::cout << "If you want meaningful CPU metrics, remove all couts in the loop / remove DEBUG_RESULTS definition variable, and compile in RELEASE mode!" << std::endl; TimeStamp t0, tf; - t0 = wolf_problem_ptr_->getProcessorIsMotion()->getBuffer().front().ts_; - tf = wolf_problem_ptr_->getProcessorIsMotion()->getBuffer().back().ts_; - int N = wolf_problem_ptr_->getProcessorIsMotion()->getBuffer().size(); + t0 = wolf_problem_ptr_->getMotionProvider()->getBuffer().front().ts_; + tf = wolf_problem_ptr_->getMotionProvider()->getBuffer().back().ts_; + int N = wolf_problem_ptr_->getMotionProvider()->getBuffer().size(); std::cout << "t0 : " << t0.get() << " s" << std::endl; std::cout << "tf : " << tf.get() << " s" << std::endl; std::cout << "duration : " << tf-t0 << " s" << std::endl; diff --git a/demos/demo_processor_imu.cpp b/demos/demo_processor_imu.cpp index 5439f2624415c6115ccedb3bb438596fc1d0bf38..ad49116d06753947d87d141e9eb89908242caba6 100644 --- a/demos/demo_processor_imu.cpp +++ b/demos/demo_processor_imu.cpp @@ -1,3 +1,24 @@ +//--------LICENSE_START-------- +// +// Copyright (C) 2020,2021,2022 Institut de Robòtica i Informà tica Industrial, CSIC-UPC. +// Authors: Joan Solà Ortega (jsola@iri.upc.edu) +// All rights reserved. +// +// This file is part of WOLF +// WOLF is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see <http://www.gnu.org/licenses/>. +// +//--------LICENSE_END-------- /** * \file test_processor_imu.cpp * @@ -93,7 +114,7 @@ int main(int argc, char** argv) // Set the origin Eigen::VectorXd x0(16); x0 << 0,0,0, 0,0,0,1, 0,0,0, 0,0,0, 0,0,0; // Try some non-zero biases - problem_ptr_->getProcessorIsMotion()->setOrigin(x0, t); + problem_ptr_->getMotionProvider()->setOrigin(x0, t); // Create one capture to store the IMU data arriving from (sensor / callback / file / etc.) CaptureIMUPtr imu_ptr = make_shared<CaptureIMU>(t, sensor_ptr, data, data_cov, Vector6d::Zero()); @@ -132,18 +153,18 @@ int main(int argc, char** argv) << data.transpose() << std::endl; std::cout << "Current delta: " << std::fixed << std::setprecision(3) << std::setw(8) << std::right - << problem_ptr_->getProcessorIsMotion()->getMotion().delta_.transpose() << std::endl; + << problem_ptr_->getMotionProvider()->getMotion().delta_.transpose() << std::endl; std::cout << "Integrated delta: " << std::fixed << std::setprecision(3) << std::setw(8) - << problem_ptr_->getProcessorIsMotion()->getMotion().delta_integr_.transpose() << std::endl; + << problem_ptr_->getMotionProvider()->getMotion().delta_integr_.transpose() << std::endl; - Eigen::VectorXd x = problem_ptr_->getProcessorIsMotion()->getCurrentState(); + Eigen::VectorXd x = problem_ptr_->getMotionProvider()->getCurrentState(); std::cout << "Integrated state: " << std::fixed << std::setprecision(3) << std::setw(8) << x.head(10).transpose() << std::endl; std::cout << "Integrated std : " << std::fixed << std::setprecision(3) << std::setw(8) - << (problem_ptr_->getProcessorIsMotion()->getMotion().delta_integr_cov_.diagonal().transpose()).array().sqrt() << std::endl; + << (problem_ptr_->getMotionProvider()->getMotion().delta_integr_cov_.diagonal().transpose()).array().sqrt() << std::endl; std::cout << std::endl; @@ -155,10 +176,10 @@ int main(int argc, char** argv) Eigen::VectorXd x_debug; TimeStamp ts; - delta_debug = problem_ptr_->getProcessorIsMotion()->getMotion().delta_; - delta_integr_debug = problem_ptr_->getProcessorIsMotion()->getMotion().delta_integr_; - x_debug = problem_ptr_->getProcessorIsMotion()->getCurrentState(); - ts = problem_ptr_->getProcessorIsMotion()->getBuffer().back().ts_; + delta_debug = problem_ptr_->getMotionProvider()->getMotion().delta_; + delta_integr_debug = problem_ptr_->getMotionProvider()->getMotion().delta_integr_; + x_debug = problem_ptr_->getMotionProvider()->getCurrentState(); + ts = problem_ptr_->getMotionProvider()->getBuffer().back().ts_; if(debug_results) debug_results << ts.get() << "\t" << delta_debug(0) << "\t" << delta_debug(1) << "\t" << delta_debug(2) << "\t" << delta_debug(3) << "\t" << delta_debug(4) << "\t" @@ -178,11 +199,11 @@ int main(int argc, char** argv) std::cout << "Initial state: " << std::fixed << std::setprecision(3) << std::setw(8) << x0.head(16).transpose() << std::endl; std::cout << "Integrated delta: " << std::fixed << std::setprecision(3) << std::setw(8) - << problem_ptr_->getProcessorIsMotion()->getMotion().delta_integr_.transpose() << std::endl; + << problem_ptr_->getMotionProvider()->getMotion().delta_integr_.transpose() << std::endl; std::cout << "Integrated state: " << std::fixed << std::setprecision(3) << std::setw(8) - << problem_ptr_->getProcessorIsMotion()->getCurrentState().head(16).transpose() << std::endl; + << problem_ptr_->getMotionProvider()->getCurrentState().head(16).transpose() << std::endl; // std::cout << "Integrated std : " << std::fixed << std::setprecision(3) << std::setw(8) -// << (problem_ptr_->getProcessorIsMotion()->getMotion().delta_integr_cov_.diagonal().transpose()).array().sqrt() << std::endl; +// << (problem_ptr_->getMotionProvider()->getMotion().delta_integr_cov_.diagonal().transpose()).array().sqrt() << std::endl; // Print statistics std::cout << "\nStatistics -----------------------------------------------------------------------------------" << std::endl; @@ -194,9 +215,9 @@ int main(int argc, char** argv) #endif TimeStamp t0, tf; - t0 = problem_ptr_->getProcessorIsMotion()->getBuffer().front().ts_; - tf = problem_ptr_->getProcessorIsMotion()->getBuffer().back().ts_; - int N = problem_ptr_->getProcessorIsMotion()->getBuffer().size(); + t0 = problem_ptr_->getMotionProvider()->getBuffer().front().ts_; + tf = problem_ptr_->getMotionProvider()->getBuffer().back().ts_; + int N = problem_ptr_->getMotionProvider()->getBuffer().size(); std::cout << "t0 : " << t0.get() << " s" << std::endl; std::cout << "tf : " << tf.get() << " s" << std::endl; std::cout << "duration : " << tf-t0 << " s" << std::endl; diff --git a/demos/demo_processor_imu_jacobians.cpp b/demos/demo_processor_imu_jacobians.cpp index 6c0714c9c9968db72b580c2004f7a1810925e4c0..2cbc0518a97beb6f178603e7a0f7538356899cfe 100644 --- a/demos/demo_processor_imu_jacobians.cpp +++ b/demos/demo_processor_imu_jacobians.cpp @@ -1,3 +1,24 @@ +//--------LICENSE_START-------- +// +// Copyright (C) 2020,2021,2022 Institut de Robòtica i Informà tica Industrial, CSIC-UPC. +// Authors: Joan Solà Ortega (jsola@iri.upc.edu) +// All rights reserved. +// +// This file is part of WOLF +// WOLF is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see <http://www.gnu.org/licenses/>. +// +//--------LICENSE_END-------- /** * \file test_processor_imu_jacobians.cpp * @@ -49,7 +70,7 @@ int main(int argc, char** argv) Eigen::VectorXd x0(16); x0 << 0,1,0, 0,0,0,1, 1,0,0, 0,0,.000, 0,0,.000; // P Q V B B - //wolf_problem_ptr_->getProcessorIsMotion()->setOrigin(x0, t); + //wolf_problem_ptr_->getMotionProvider()->setOrigin(x0, t); //CaptureIMU* imu_ptr; diff --git a/include/imu/capture/capture_compass.h b/include/imu/capture/capture_compass.h index 1a77f7ce5282fbaf6b615c8cea1950eaa7cbe274..dc1fef50b1e6cc25acf4154634da98af698f6e65 100644 --- a/include/imu/capture/capture_compass.h +++ b/include/imu/capture/capture_compass.h @@ -1,3 +1,24 @@ +//--------LICENSE_START-------- +// +// Copyright (C) 2020,2021,2022 Institut de Robòtica i Informà tica Industrial, CSIC-UPC. +// Authors: Joan Solà Ortega (jsola@iri.upc.edu) +// All rights reserved. +// +// This file is part of WOLF +// WOLF is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see <http://www.gnu.org/licenses/>. +// +//--------LICENSE_END-------- #ifndef CAPTURE_COMPASS_H_ #define CAPTURE_COMPASS_H_ diff --git a/include/imu/capture/capture_imu.h b/include/imu/capture/capture_imu.h index 274d74d494ec4897e11360b4a25bd497098aa6bd..4b4e05a1caf32f4627a7bc78d8fffdc413a1acf8 100644 --- a/include/imu/capture/capture_imu.h +++ b/include/imu/capture/capture_imu.h @@ -1,3 +1,24 @@ +//--------LICENSE_START-------- +// +// Copyright (C) 2020,2021,2022 Institut de Robòtica i Informà tica Industrial, CSIC-UPC. +// Authors: Joan Solà Ortega (jsola@iri.upc.edu) +// All rights reserved. +// +// This file is part of WOLF +// WOLF is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see <http://www.gnu.org/licenses/>. +// +//--------LICENSE_END-------- #ifndef CAPTURE_IMU_H #define CAPTURE_IMU_H diff --git a/include/imu/factor/factor_compass_3d.h b/include/imu/factor/factor_compass_3d.h index 6bb877776b886236d74f69abb1ec8062dad0bec5..3772950880281c9b6e6261192d9ac3edb0f563cd 100644 --- a/include/imu/factor/factor_compass_3d.h +++ b/include/imu/factor/factor_compass_3d.h @@ -1,3 +1,24 @@ +//--------LICENSE_START-------- +// +// Copyright (C) 2020,2021,2022 Institut de Robòtica i Informà tica Industrial, CSIC-UPC. +// Authors: Joan Solà Ortega (jsola@iri.upc.edu) +// All rights reserved. +// +// This file is part of WOLF +// WOLF is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see <http://www.gnu.org/licenses/>. +// +//--------LICENSE_END-------- #ifndef FACTOR_COMPASS_3D_H_ #define FACTOR_COMPASS_3D_H_ diff --git a/include/imu/factor/factor_fix_bias.h b/include/imu/factor/factor_fix_bias.h index e989b9b8861fa83d7f0568f2ea545dd50bed647e..2de0cf321f0cf93aefb50808c44afe3301f67fb1 100644 --- a/include/imu/factor/factor_fix_bias.h +++ b/include/imu/factor/factor_fix_bias.h @@ -1,3 +1,24 @@ +//--------LICENSE_START-------- +// +// Copyright (C) 2020,2021,2022 Institut de Robòtica i Informà tica Industrial, CSIC-UPC. +// Authors: Joan Solà Ortega (jsola@iri.upc.edu) +// All rights reserved. +// +// This file is part of WOLF +// WOLF is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see <http://www.gnu.org/licenses/>. +// +//--------LICENSE_END-------- #ifndef FACTOR_FIX_BIAS_H_ #define FACTOR_FIX_BIAS_H_ diff --git a/include/imu/factor/factor_imu.h b/include/imu/factor/factor_imu.h index 17c80316246bdd977ed59b4edc0aea6f34dca4f7..7bbae22c3f2f0598b60c19f1bad5d45e177ab0c0 100644 --- a/include/imu/factor/factor_imu.h +++ b/include/imu/factor/factor_imu.h @@ -1,9 +1,31 @@ +//--------LICENSE_START-------- +// +// Copyright (C) 2020,2021,2022 Institut de Robòtica i Informà tica Industrial, CSIC-UPC. +// Authors: Joan Solà Ortega (jsola@iri.upc.edu) +// All rights reserved. +// +// This file is part of WOLF +// WOLF is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see <http://www.gnu.org/licenses/>. +// +//--------LICENSE_END-------- #ifndef FACTOR_IMU_THETA_H_ #define FACTOR_IMU_THETA_H_ //Wolf includes #include "imu/feature/feature_imu.h" #include "imu/sensor/sensor_imu.h" +#include "imu/processor/processor_imu.h" #include "core/factor/factor_autodiff.h" #include "core/math/rotations.h" @@ -235,9 +257,9 @@ Eigen::Vector9d FactorImu::error() Map<const Vector3d > acc_bias(bias.data()); Map<const Vector3d > gyro_bias(bias.data() + 3); - Eigen::Vector9d delta_exp = expectation(); + Eigen::Vector10d delta_exp = expectation(); - Eigen::Vector9d delta_preint = getMeasurement(); + Eigen::Vector10d delta_preint = getMeasurement(); Eigen::Vector9d delta_step; @@ -247,9 +269,9 @@ Eigen::Vector9d FactorImu::error() Eigen::VectorXd delta_corr = imu::plus(delta_preint, delta_step); - Eigen::Vector9d res = imu::diff(delta_exp, delta_corr); + Eigen::Vector9d err = imu::diff(delta_exp, delta_corr); - return res; + return err; } template<typename D1, typename D2, typename D3> diff --git a/include/imu/factor/factor_imu2d.h b/include/imu/factor/factor_imu2d.h index bfba5016736dd0173d9bec19142806c08dbe1b38..5158c590fb2a6ecaf570cf6e0830fbc697437ded 100644 --- a/include/imu/factor/factor_imu2d.h +++ b/include/imu/factor/factor_imu2d.h @@ -1,3 +1,24 @@ +//--------LICENSE_START-------- +// +// Copyright (C) 2020,2021,2022 Institut de Robòtica i Informà tica Industrial, CSIC-UPC. +// Authors: Joan Solà Ortega (jsola@iri.upc.edu) +// All rights reserved. +// +// This file is part of WOLF +// WOLF is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see <http://www.gnu.org/licenses/>. +// +//--------LICENSE_END-------- #ifndef FACTOR_IMU2D_THETA_H_ #define FACTOR_IMU2D_THETA_H_ diff --git a/include/imu/feature/feature_imu.h b/include/imu/feature/feature_imu.h index 9248608f14b2c6a0d339af5776ae2459d96ad8ab..6aa5f45116edbe33ac4459868cf34b9819af4e3c 100644 --- a/include/imu/feature/feature_imu.h +++ b/include/imu/feature/feature_imu.h @@ -1,3 +1,24 @@ +//--------LICENSE_START-------- +// +// Copyright (C) 2020,2021,2022 Institut de Robòtica i Informà tica Industrial, CSIC-UPC. +// Authors: Joan Solà Ortega (jsola@iri.upc.edu) +// All rights reserved. +// +// This file is part of WOLF +// WOLF is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see <http://www.gnu.org/licenses/>. +// +//--------LICENSE_END-------- #ifndef FEATURE_IMU_H_ #define FEATURE_IMU_H_ diff --git a/include/imu/feature/feature_imu2d.h b/include/imu/feature/feature_imu2d.h index 713df8f8489fad8be3fe7d6fbf3988e61a44cb60..58f64b31afcd6610783359458a1261394d2726fa 100644 --- a/include/imu/feature/feature_imu2d.h +++ b/include/imu/feature/feature_imu2d.h @@ -1,3 +1,24 @@ +//--------LICENSE_START-------- +// +// Copyright (C) 2020,2021,2022 Institut de Robòtica i Informà tica Industrial, CSIC-UPC. +// Authors: Joan Solà Ortega (jsola@iri.upc.edu) +// All rights reserved. +// +// This file is part of WOLF +// WOLF is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see <http://www.gnu.org/licenses/>. +// +//--------LICENSE_END-------- #ifndef FEATURE_IMU2D_H_ #define FEATURE_IMU2D_H_ diff --git a/include/imu/math/imu2d_tools.h b/include/imu/math/imu2d_tools.h index e53f5bcee20c056d0f887aa76c829fdf89151287..4f2a1ef535d9a538c03228a81d6940e67c7439a2 100644 --- a/include/imu/math/imu2d_tools.h +++ b/include/imu/math/imu2d_tools.h @@ -1,3 +1,24 @@ +//--------LICENSE_START-------- +// +// Copyright (C) 2020,2021,2022 Institut de Robòtica i Informà tica Industrial, CSIC-UPC. +// Authors: Joan Solà Ortega (jsola@iri.upc.edu) +// All rights reserved. +// +// This file is part of WOLF +// WOLF is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see <http://www.gnu.org/licenses/>. +// +//--------LICENSE_END-------- /* * imu2d_tools.h * diff --git a/include/imu/math/imu_tools.h b/include/imu/math/imu_tools.h index d9b0b58454132c8abaa11d50a5847d18b829337f..e696966cde5f21034b3e04d464c9c3305f5e4ec7 100644 --- a/include/imu/math/imu_tools.h +++ b/include/imu/math/imu_tools.h @@ -1,3 +1,24 @@ +//--------LICENSE_START-------- +// +// Copyright (C) 2020,2021,2022 Institut de Robòtica i Informà tica Industrial, CSIC-UPC. +// Authors: Joan Solà Ortega (jsola@iri.upc.edu) +// All rights reserved. +// +// This file is part of WOLF +// WOLF is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see <http://www.gnu.org/licenses/>. +// +//--------LICENSE_END-------- /* * imu_tools.h * @@ -566,7 +587,7 @@ inline void plus(const MatrixBase<D1>& dp1, const MatrixBase<D2>& dq1, const Mat template<typename D1, typename D2, typename D3> inline void plus(const MatrixBase<D1>& d1, const MatrixBase<D2>& d2, - MatrixBase<D3>& d_pert) + MatrixBase<D3>& d) { Map<const Matrix<typename D1::Scalar, 3, 1> > dp1 ( & d1(0) ); Map<const Quaternion<typename D1::Scalar> > dq1 ( & d1(3) ); @@ -574,11 +595,11 @@ inline void plus(const MatrixBase<D1>& d1, Map<const Matrix<typename D2::Scalar, 3, 1> > dp2 ( & d2(0) ); Map<const Matrix<typename D2::Scalar, 3, 1> > do2 ( & d2(3) ); Map<const Matrix<typename D2::Scalar, 3, 1> > dv2 ( & d2(6) ); - Map<Matrix<typename D3::Scalar, 3, 1> > dp_p ( & d_pert(0) ); - Map<Quaternion<typename D3::Scalar> > dq_p ( & d_pert(3) ); - Map<Matrix<typename D3::Scalar, 3, 1> > dv_p ( & d_pert(7) ); + Map<Matrix<typename D3::Scalar, 3, 1> > dp ( & d (0) ); + Map<Quaternion<typename D3::Scalar> > dq ( & d (3) ); + Map<Matrix<typename D3::Scalar, 3, 1> > dv ( & d (7) ); - plus(dp1, dq1, dv1, dp2, do2, dv2, dp_p, dq_p, dv_p); + plus(dp1, dq1, dv1, dp2, do2, dv2, dp, dq, dv); } template<typename D1, typename D2> diff --git a/include/imu/processor/processor_compass.h b/include/imu/processor/processor_compass.h index 690755716de4029d257ae0807bf947bc2b511acb..71f572e6317be94c99a22d1431ef73be8d7a08cd 100644 --- a/include/imu/processor/processor_compass.h +++ b/include/imu/processor/processor_compass.h @@ -1,3 +1,24 @@ +//--------LICENSE_START-------- +// +// Copyright (C) 2020,2021,2022 Institut de Robòtica i Informà tica Industrial, CSIC-UPC. +// Authors: Joan Solà Ortega (jsola@iri.upc.edu) +// All rights reserved. +// +// This file is part of WOLF +// WOLF is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see <http://www.gnu.org/licenses/>. +// +//--------LICENSE_END-------- #ifndef INCLUDE_IMU_PROCESSOR_PROCESSORCOMPASS_H_ #define INCLUDE_IMU_PROCESSOR_PROCESSORCOMPASS_H_ @@ -38,11 +59,11 @@ class ProcessorCompass : public ProcessorBase protected: void processCapture(CaptureBasePtr) override; - void processKeyFrame(FrameBasePtr, const double&) override; + void processKeyFrame(FrameBasePtr _frm) override; void processMatch(FrameBasePtr, CaptureBasePtr); bool triggerInCapture(CaptureBasePtr _cap) const override { return true;}; - bool triggerInKeyFrame(FrameBasePtr _frm, const double& _time_tol) const override { return true;}; + bool triggerInKeyFrame(FrameBasePtr _frm) const override { return true;}; bool storeKeyFrame(FrameBasePtr _frm) override { return false;}; bool storeCapture(CaptureBasePtr _cap) override { return false;}; diff --git a/include/imu/processor/processor_imu.h b/include/imu/processor/processor_imu.h index 502120cc1400bcd2da109903adc72c219e7a6efe..12676c83d8536bc8f2ccbcc78eb288dfe74804cd 100644 --- a/include/imu/processor/processor_imu.h +++ b/include/imu/processor/processor_imu.h @@ -1,3 +1,24 @@ +//--------LICENSE_START-------- +// +// Copyright (C) 2020,2021,2022 Institut de Robòtica i Informà tica Industrial, CSIC-UPC. +// Authors: Joan Solà Ortega (jsola@iri.upc.edu) +// All rights reserved. +// +// This file is part of WOLF +// WOLF is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see <http://www.gnu.org/licenses/>. +// +//--------LICENSE_END-------- #ifndef PROCESSOR_IMU_H #define PROCESSOR_IMU_H @@ -77,8 +98,6 @@ class ProcessorImu : public ProcessorMotion{ protected: ParamsProcessorImuPtr params_motion_Imu_; - Eigen::Matrix<double, 9, 9> unmeasured_perturbation_cov_; - }; } diff --git a/include/imu/processor/processor_imu2d.h b/include/imu/processor/processor_imu2d.h index bda61341dad3165764aaf78e1a6a5a7efdf8d373..433ccf6b92724169420813bdea8692cf5bc6777e 100644 --- a/include/imu/processor/processor_imu2d.h +++ b/include/imu/processor/processor_imu2d.h @@ -1,3 +1,24 @@ +//--------LICENSE_START-------- +// +// Copyright (C) 2020,2021,2022 Institut de Robòtica i Informà tica Industrial, CSIC-UPC. +// Authors: Joan Solà Ortega (jsola@iri.upc.edu) +// All rights reserved. +// +// This file is part of WOLF +// WOLF is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see <http://www.gnu.org/licenses/>. +// +//--------LICENSE_END-------- #ifndef PROCESSOR_IMU2D_H #define PROCESSOR_IMU2D_H @@ -77,8 +98,6 @@ class ProcessorImu2d : public ProcessorMotion{ protected: ParamsProcessorImu2dPtr params_motion_Imu_; - Eigen::Matrix<double, 5, 5> unmeasured_perturbation_cov_; - }; } diff --git a/include/imu/sensor/sensor_compass.h b/include/imu/sensor/sensor_compass.h index e21bb028d1daf45e662698e4e21b2055fa5c69df..a446b8acabf40ace81f7280d931d14eb8faedb32 100644 --- a/include/imu/sensor/sensor_compass.h +++ b/include/imu/sensor/sensor_compass.h @@ -1,3 +1,24 @@ +//--------LICENSE_START-------- +// +// Copyright (C) 2020,2021,2022 Institut de Robòtica i Informà tica Industrial, CSIC-UPC. +// Authors: Joan Solà Ortega (jsola@iri.upc.edu) +// All rights reserved. +// +// This file is part of WOLF +// WOLF is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see <http://www.gnu.org/licenses/>. +// +//--------LICENSE_END-------- #ifndef SENSOR_SENSOR_COMPASS_H_ #define SENSOR_SENSOR_COMPASS_H_ diff --git a/include/imu/sensor/sensor_imu.h b/include/imu/sensor/sensor_imu.h index 07b289c0ac0e21451dbe682774d3aeddc79ffa7b..dd21d8859880c52758152a445996298cdad08d48 100644 --- a/include/imu/sensor/sensor_imu.h +++ b/include/imu/sensor/sensor_imu.h @@ -1,3 +1,24 @@ +//--------LICENSE_START-------- +// +// Copyright (C) 2020,2021,2022 Institut de Robòtica i Informà tica Industrial, CSIC-UPC. +// Authors: Joan Solà Ortega (jsola@iri.upc.edu) +// All rights reserved. +// +// This file is part of WOLF +// WOLF is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see <http://www.gnu.org/licenses/>. +// +//--------LICENSE_END-------- #ifndef SENSOR_IMU_H #define SENSOR_IMU_H diff --git a/include/imu/sensor/sensor_imu2d.h b/include/imu/sensor/sensor_imu2d.h index 21485c43168141ac29e5df325a26d9d8d4aa90da..a46b5ccae3cdbd341ad36540d366ab71ee6803d6 100644 --- a/include/imu/sensor/sensor_imu2d.h +++ b/include/imu/sensor/sensor_imu2d.h @@ -1,3 +1,24 @@ +//--------LICENSE_START-------- +// +// Copyright (C) 2020,2021,2022 Institut de Robòtica i Informà tica Industrial, CSIC-UPC. +// Authors: Joan Solà Ortega (jsola@iri.upc.edu) +// All rights reserved. +// +// This file is part of WOLF +// WOLF is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see <http://www.gnu.org/licenses/>. +// +//--------LICENSE_END-------- #ifndef SENSOR_IMU2D_H #define SENSOR_IMU2D_H diff --git a/license_header_2022.txt b/license_header_2022.txt new file mode 100644 index 0000000000000000000000000000000000000000..0c987025f9dba3e7af993051b9bdf4b5ff400e0d --- /dev/null +++ b/license_header_2022.txt @@ -0,0 +1,17 @@ +// Copyright (C) 2020,2021,2022 Institut de Robòtica i Informà tica Industrial, CSIC-UPC. +// Authors: Joan Solà Ortega (jsola@iri.upc.edu) +// All rights reserved. +// +// This file is part of WOLF +// WOLF is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see <http://www.gnu.org/licenses/>. diff --git a/src/capture/capture_imu.cpp b/src/capture/capture_imu.cpp index 75230fafd5663ca7a422497fbd834e4a97e31fe3..f8a4b0b4118c299fda57c59e77df1b922b2e292a 100644 --- a/src/capture/capture_imu.cpp +++ b/src/capture/capture_imu.cpp @@ -1,3 +1,24 @@ +//--------LICENSE_START-------- +// +// Copyright (C) 2020,2021,2022 Institut de Robòtica i Informà tica Industrial, CSIC-UPC. +// Authors: Joan Solà Ortega (jsola@iri.upc.edu) +// All rights reserved. +// +// This file is part of WOLF +// WOLF is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see <http://www.gnu.org/licenses/>. +// +//--------LICENSE_END-------- #include "imu/capture/capture_imu.h" #include "imu/sensor/sensor_imu.h" #include "core/state_block/state_quaternion.h" diff --git a/src/feature/feature_imu.cpp b/src/feature/feature_imu.cpp index d3547a52c2c6794ed2d795af780ca2063ef14e36..3dfb28f79cff470aa22a1a468c4ab4c48dc09c5e 100644 --- a/src/feature/feature_imu.cpp +++ b/src/feature/feature_imu.cpp @@ -1,3 +1,24 @@ +//--------LICENSE_START-------- +// +// Copyright (C) 2020,2021,2022 Institut de Robòtica i Informà tica Industrial, CSIC-UPC. +// Authors: Joan Solà Ortega (jsola@iri.upc.edu) +// All rights reserved. +// +// This file is part of WOLF +// WOLF is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see <http://www.gnu.org/licenses/>. +// +//--------LICENSE_END-------- #include "imu/feature/feature_imu.h" namespace wolf { diff --git a/src/feature/feature_imu2d.cpp b/src/feature/feature_imu2d.cpp index 1a5e61a0d0a88629f37d84f96e3605933636ce3e..9fee0928794000dc527029cdf13cc1e51bef0875 100644 --- a/src/feature/feature_imu2d.cpp +++ b/src/feature/feature_imu2d.cpp @@ -1,3 +1,24 @@ +//--------LICENSE_START-------- +// +// Copyright (C) 2020,2021,2022 Institut de Robòtica i Informà tica Industrial, CSIC-UPC. +// Authors: Joan Solà Ortega (jsola@iri.upc.edu) +// All rights reserved. +// +// This file is part of WOLF +// WOLF is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see <http://www.gnu.org/licenses/>. +// +//--------LICENSE_END-------- #include "imu/feature/feature_imu2d.h" namespace wolf { diff --git a/src/processor/processor_compass.cpp b/src/processor/processor_compass.cpp index 972c26c572e51296a556f8c48c6daee941770bd8..a0231bd6e9c01e178ba034efc9e14698ca9583d8 100644 --- a/src/processor/processor_compass.cpp +++ b/src/processor/processor_compass.cpp @@ -1,3 +1,24 @@ +//--------LICENSE_START-------- +// +// Copyright (C) 2020,2021,2022 Institut de Robòtica i Informà tica Industrial, CSIC-UPC. +// Authors: Joan Solà Ortega (jsola@iri.upc.edu) +// All rights reserved. +// +// This file is part of WOLF +// WOLF is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see <http://www.gnu.org/licenses/>. +// +//--------LICENSE_END-------- #include "imu/processor/processor_compass.h" #include "imu/capture/capture_compass.h" #include "imu/factor/factor_compass_3d.h" @@ -18,24 +39,24 @@ ProcessorCompass::~ProcessorCompass() void ProcessorCompass::processCapture(CaptureBasePtr _capture) { // Search for any stored frame within time tolerance of capture - auto frame_pack = buffer_pack_kf_.select(_capture->getTimeStamp(), params_->time_tolerance); - if (frame_pack) + auto keyframe = buffer_frame_.select(_capture->getTimeStamp(), params_->time_tolerance); + if (keyframe) { - processMatch(frame_pack->key_frame, _capture); + processMatch(keyframe, _capture); // remove the frame and older frames - buffer_pack_kf_.removeUpTo(frame_pack->key_frame->getTimeStamp()); + buffer_frame_.removeUpTo(keyframe->getTimeStamp()); } // Otherwise: store capture // Note that more than one processor can be emplacing frames, so an older frame can arrive later than this one. else - buffer_capture_.add(_capture->getTimeStamp(), _capture); + buffer_capture_.emplace(_capture->getTimeStamp(), _capture); } -void ProcessorCompass::processKeyFrame(FrameBasePtr _frame, const double& _time_tolerance) +void ProcessorCompass::processKeyFrame(FrameBasePtr _frame) { // Search for any stored capture within time tolerance of frame - auto capture = buffer_capture_.select(_frame->getTimeStamp(), _time_tolerance); + auto capture = buffer_capture_.select(_frame->getTimeStamp(), getTimeTolerance()); if (capture) { processMatch(_frame, capture); @@ -44,10 +65,10 @@ void ProcessorCompass::processKeyFrame(FrameBasePtr _frame, const double& _time_ buffer_capture_.removeUpTo(_frame->getTimeStamp() - 10); } // Otherwise: If frame is more recent than any capture in buffer -> store frame to be processed later in processCapture - else if (buffer_capture_.selectLastAfter(_frame->getTimeStamp(), _time_tolerance) == nullptr) + else if (buffer_capture_.selectLastAfter(_frame->getTimeStamp(), getTimeTolerance()) == nullptr) { // store frame - buffer_pack_kf_.add(_frame, _time_tolerance); + buffer_frame_.emplace(_frame->getTimeStamp(), _frame); } // Otherwise: There are captures more recent than the frame but none that match with it -> discard frame } diff --git a/src/processor/processor_imu.cpp b/src/processor/processor_imu.cpp index 6eb0edced109dec6bc58e2bb3e9a400805c49730..69dbf111bc7a5bbcd4ad11796633338c5e877083 100644 --- a/src/processor/processor_imu.cpp +++ b/src/processor/processor_imu.cpp @@ -1,3 +1,24 @@ +//--------LICENSE_START-------- +// +// Copyright (C) 2020,2021,2022 Institut de Robòtica i Informà tica Industrial, CSIC-UPC. +// Authors: Joan Solà Ortega (jsola@iri.upc.edu) +// All rights reserved. +// +// This file is part of WOLF +// WOLF is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see <http://www.gnu.org/licenses/>. +// +//--------LICENSE_END-------- // imu #include "imu/processor/processor_imu.h" #include "imu/factor/factor_imu.h" @@ -12,11 +33,7 @@ ProcessorImu::ProcessorImu(ParamsProcessorImuPtr _params_motion_imu) : ProcessorMotion("ProcessorImu", "POV", 3, 10, 10, 9, 6, 6, _params_motion_imu), params_motion_Imu_(std::make_shared<ParamsProcessorImu>(*_params_motion_imu)) { - // Set constant parts of Jacobians - jacobian_delta_preint_.setIdentity(9,9); // dDp'/dDp, dDv'/dDv, all zeros - jacobian_delta_.setIdentity(9,9); // - jacobian_calib_.setZero(9,6); - unmeasured_perturbation_cov_ = pow(params_motion_Imu_->unmeasured_perturbation_std, 2.0) * Eigen::Matrix<double, 9, 9>::Identity(); + // } ProcessorImu::~ProcessorImu() diff --git a/src/processor/processor_imu2d.cpp b/src/processor/processor_imu2d.cpp index b0bfed05b4ce5d86bd095ff7aa57193e04989c34..1fcf8f5d782634b821daa013ada05426a92d0aa3 100644 --- a/src/processor/processor_imu2d.cpp +++ b/src/processor/processor_imu2d.cpp @@ -1,3 +1,24 @@ +//--------LICENSE_START-------- +// +// Copyright (C) 2020,2021,2022 Institut de Robòtica i Informà tica Industrial, CSIC-UPC. +// Authors: Joan Solà Ortega (jsola@iri.upc.edu) +// All rights reserved. +// +// This file is part of WOLF +// WOLF is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see <http://www.gnu.org/licenses/>. +// +//--------LICENSE_END-------- // imu #include "imu/processor/processor_imu2d.h" #include "imu/factor/factor_imu2d.h" @@ -13,11 +34,7 @@ namespace wolf { ProcessorMotion("ProcessorImu2d", "POV", 2, 5, 5, 5, 6, 3, _params_motion_imu), params_motion_Imu_(std::make_shared<ParamsProcessorImu2d>(*_params_motion_imu)) { - // Set constant parts of Jacobians - jacobian_delta_preint_.setIdentity(5,5); // dDp'/dDp, dDv'/dDv, all zeros - jacobian_delta_.setIdentity(5,5); // - jacobian_calib_.setZero(5,3); - unmeasured_perturbation_cov_ = pow(params_motion_Imu_->unmeasured_perturbation_std, 2.0) * Eigen::Matrix<double, 5, 5>::Identity(); + // } ProcessorImu2d::~ProcessorImu2d() diff --git a/src/sensor/sensor_compass.cpp b/src/sensor/sensor_compass.cpp index d81f52926e3633cc31d248a88e8f119bc6f2012b..43171641af0110385be84e72f40251bc5797b5cc 100644 --- a/src/sensor/sensor_compass.cpp +++ b/src/sensor/sensor_compass.cpp @@ -1,3 +1,24 @@ +//--------LICENSE_START-------- +// +// Copyright (C) 2020,2021,2022 Institut de Robòtica i Informà tica Industrial, CSIC-UPC. +// Authors: Joan Solà Ortega (jsola@iri.upc.edu) +// All rights reserved. +// +// This file is part of WOLF +// WOLF is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see <http://www.gnu.org/licenses/>. +// +//--------LICENSE_END-------- #include "imu/sensor/sensor_compass.h" #include "core/state_block/state_block.h" #include "core/state_block/state_quaternion.h" diff --git a/src/sensor/sensor_imu.cpp b/src/sensor/sensor_imu.cpp index 8f12c8188ea85bdfff31e1a524a667dddd3cd178..bb6ec35e0061202819385fe04b5b2c58c54a3160 100644 --- a/src/sensor/sensor_imu.cpp +++ b/src/sensor/sensor_imu.cpp @@ -1,3 +1,24 @@ +//--------LICENSE_START-------- +// +// Copyright (C) 2020,2021,2022 Institut de Robòtica i Informà tica Industrial, CSIC-UPC. +// Authors: Joan Solà Ortega (jsola@iri.upc.edu) +// All rights reserved. +// +// This file is part of WOLF +// WOLF is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see <http://www.gnu.org/licenses/>. +// +//--------LICENSE_END-------- #include "imu/sensor/sensor_imu.h" #include "core/state_block/state_block.h" #include "core/state_block/state_quaternion.h" diff --git a/src/sensor/sensor_imu2d.cpp b/src/sensor/sensor_imu2d.cpp index 4db7e8fab11258f3197bc238d54d8eb6dfe4802a..f74b3baa23383ea5265d7d288abc8d97d225a0ff 100644 --- a/src/sensor/sensor_imu2d.cpp +++ b/src/sensor/sensor_imu2d.cpp @@ -1,3 +1,24 @@ +//--------LICENSE_START-------- +// +// Copyright (C) 2020,2021,2022 Institut de Robòtica i Informà tica Industrial, CSIC-UPC. +// Authors: Joan Solà Ortega (jsola@iri.upc.edu) +// All rights reserved. +// +// This file is part of WOLF +// WOLF is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see <http://www.gnu.org/licenses/>. +// +//--------LICENSE_END-------- #include <imu/sensor/sensor_imu2d.h> #include <core/state_block/state_block.h> #include <core/state_block/state_angle.h> diff --git a/src/yaml/processor_imu2d_yaml.cpp b/src/yaml/processor_imu2d_yaml.cpp index 5d8e528cf6d1a12d0f31e2dee03bb2d9d9874ee9..b1d1e282e4991d7ad991d5e6f5a70bb31984c187 100644 --- a/src/yaml/processor_imu2d_yaml.cpp +++ b/src/yaml/processor_imu2d_yaml.cpp @@ -1,3 +1,24 @@ +//--------LICENSE_START-------- +// +// Copyright (C) 2020,2021,2022 Institut de Robòtica i Informà tica Industrial, CSIC-UPC. +// Authors: Joan Solà Ortega (jsola@iri.upc.edu) +// All rights reserved. +// +// This file is part of WOLF +// WOLF is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see <http://www.gnu.org/licenses/>. +// +//--------LICENSE_END-------- /** * \file processor_imu2d_yaml.cpp * diff --git a/src/yaml/processor_imu_yaml.cpp b/src/yaml/processor_imu_yaml.cpp index 4d75aa8f13069a7a22404de29fe90462196b394e..30221d8e0350f1bcf840acd0fddcba2f2f845e8e 100644 --- a/src/yaml/processor_imu_yaml.cpp +++ b/src/yaml/processor_imu_yaml.cpp @@ -1,3 +1,24 @@ +//--------LICENSE_START-------- +// +// Copyright (C) 2020,2021,2022 Institut de Robòtica i Informà tica Industrial, CSIC-UPC. +// Authors: Joan Solà Ortega (jsola@iri.upc.edu) +// All rights reserved. +// +// This file is part of WOLF +// WOLF is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see <http://www.gnu.org/licenses/>. +// +//--------LICENSE_END-------- /** * \file processor_imu_yaml.cpp * diff --git a/src/yaml/sensor_imu2d_yaml.cpp b/src/yaml/sensor_imu2d_yaml.cpp index 548168791dde3afb2d2df5a6f415f7047313b9f5..a138b56bf11564a794893c872eecb297d10a1634 100644 --- a/src/yaml/sensor_imu2d_yaml.cpp +++ b/src/yaml/sensor_imu2d_yaml.cpp @@ -1,3 +1,24 @@ +//--------LICENSE_START-------- +// +// Copyright (C) 2020,2021,2022 Institut de Robòtica i Informà tica Industrial, CSIC-UPC. +// Authors: Joan Solà Ortega (jsola@iri.upc.edu) +// All rights reserved. +// +// This file is part of WOLF +// WOLF is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see <http://www.gnu.org/licenses/>. +// +//--------LICENSE_END-------- /** * \file sensor_imu2d_yaml.cpp * diff --git a/src/yaml/sensor_imu_yaml.cpp b/src/yaml/sensor_imu_yaml.cpp index 87201a4699e047e1873fe12de0ce121bcd96d1db..fbee701af0d92988fd0833da9aac2dbbee5927c4 100644 --- a/src/yaml/sensor_imu_yaml.cpp +++ b/src/yaml/sensor_imu_yaml.cpp @@ -1,3 +1,24 @@ +//--------LICENSE_START-------- +// +// Copyright (C) 2020,2021,2022 Institut de Robòtica i Informà tica Industrial, CSIC-UPC. +// Authors: Joan Solà Ortega (jsola@iri.upc.edu) +// All rights reserved. +// +// This file is part of WOLF +// WOLF is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see <http://www.gnu.org/licenses/>. +// +//--------LICENSE_END-------- /** * \file sensor_imu_yaml.cpp * @@ -28,7 +49,6 @@ static ParamsSensorBasePtr createParamsSensorImu(const std::string & _filename_d if (config["type"].as<std::string>() == "SensorImu") { YAML::Node variances = config["motion_variances"]; - YAML::Node kf_vote = config["keyframe_vote"]; ParamsSensorImuPtr params = std::make_shared<ParamsSensorImu>(); diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 8c95cfe4aea8d11b9fecd28135ec25630b174353..bc10d2bf34366c9dbd624d62a8fffa92b1fb2598 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -14,48 +14,54 @@ target_link_libraries(gtest_example ${PLUGIN_NAME}) # ########################################################### wolf_add_gtest(gtest_processor_imu gtest_processor_imu.cpp) -target_link_libraries(gtest_processor_imu ${PLUGIN_NAME} ${wolf_LIBRARY}) +target_link_libraries(gtest_processor_imu ${PLUGIN_NAME}) wolf_add_gtest(gtest_processor_imu2d gtest_processor_imu2d.cpp) -target_link_libraries(gtest_processor_imu2d ${PLUGIN_NAME} ${wolf_LIBRARY}) +target_link_libraries(gtest_processor_imu2d ${PLUGIN_NAME}) wolf_add_gtest(gtest_processor_imu2d_with_gravity gtest_processor_imu2d_with_gravity.cpp) target_link_libraries(gtest_processor_imu2d_with_gravity ${PLUGIN_NAME} ${wolf_LIBRARY}) wolf_add_gtest(gtest_imu gtest_imu.cpp) -target_link_libraries(gtest_imu ${PLUGIN_NAME} ${wolf_LIBRARY}) +target_link_libraries(gtest_imu ${PLUGIN_NAME}) wolf_add_gtest(gtest_imu_tools gtest_imu_tools.cpp) -target_link_libraries(gtest_imu_tools ${PLUGIN_NAME} ${wolf_LIBRARY}) +target_link_libraries(gtest_imu_tools ${PLUGIN_NAME}) wolf_add_gtest(gtest_imu2d_tools gtest_imu2d_tools.cpp) -target_link_libraries(gtest_imu2d_tools ${PLUGIN_NAME} ${wolf_LIBRARY}) +target_link_libraries(gtest_imu2d_tools ${PLUGIN_NAME}) wolf_add_gtest(gtest_processor_imu_jacobians gtest_processor_imu_jacobians.cpp) -target_link_libraries(gtest_processor_imu_jacobians ${PLUGIN_NAME} ${wolf_LIBRARY}) +target_link_libraries(gtest_processor_imu_jacobians ${PLUGIN_NAME}) wolf_add_gtest(gtest_feature_imu gtest_feature_imu.cpp) -target_link_libraries(gtest_feature_imu ${PLUGIN_NAME} ${wolf_LIBRARY}) +target_link_libraries(gtest_feature_imu ${PLUGIN_NAME}) wolf_add_gtest(gtest_factor_imu2d gtest_factor_imu2d.cpp) -target_link_libraries(gtest_factor_imu2d ${PLUGIN_NAME} ${wolf_LIBRARY}) +target_link_libraries(gtest_factor_imu2d ${PLUGIN_NAME}) + +wolf_add_gtest(gtest_imu_static_init gtest_imu_static_init.cpp) +target_link_libraries(gtest_imu_static_init ${PLUGIN_NAME}) + +wolf_add_gtest(gtest_imu2d_static_init gtest_imu2d_static_init.cpp) +target_link_libraries(gtest_imu2d_static_init ${PLUGIN_NAME}) wolf_add_gtest(gtest_factor_imu2d_with_gravity gtest_factor_imu2d_with_gravity.cpp) target_link_libraries(gtest_factor_imu2d_with_gravity ${PLUGIN_NAME} ${wolf_LIBRARY}) wolf_add_gtest(gtest_imu_mocap_fusion gtest_imu_mocap_fusion.cpp) -target_link_libraries(gtest_imu_mocap_fusion ${PLUGIN_NAME} ${wolf_LIBRARY}) +target_link_libraries(gtest_imu_mocap_fusion ${PLUGIN_NAME}) wolf_add_gtest(gtest_factor_compass_3d gtest_factor_compass_3d.cpp) -target_link_libraries(gtest_factor_compass_3d ${PLUGIN_NAME} ${wolf_LIBRARY}) +target_link_libraries(gtest_factor_compass_3d ${PLUGIN_NAME}) # Has been excluded from tests for god knows how long, so thing is broken. # Maybe call an archeologist to fix this thing? # wolf_add_gtest(gtest_factor_imu gtest_factor_imu.cpp) -# target_link_libraries(gtest_factor_imu ${PLUGIN_NAME} ${wolf_LIBRARY}) +# target_link_libraries(gtest_factor_imu ${PLUGIN_NAME}) wolf_add_gtest(gtest_processor_motion_intrinsics_update gtest_processor_motion_intrinsics_update.cpp) -target_link_libraries(gtest_processor_motion_intrinsics_update ${PLUGIN_NAME} ${wolf_LIBRARY}) +target_link_libraries(gtest_processor_motion_intrinsics_update ${PLUGIN_NAME}) wolf_add_gtest(gtest_sensor_compass gtest_sensor_compass.cpp) -target_link_libraries(gtest_sensor_compass ${PLUGIN_NAME} ${wolf_LIBRARY}) +target_link_libraries(gtest_sensor_compass ${PLUGIN_NAME}) diff --git a/test/gtest_example.cpp b/test/gtest_example.cpp index 140792d538ab5ae568ba7743fbc49bce0bb6d9f2..c73292612597de2fb22c677ffd5bedf92c62daa4 100644 --- a/test/gtest_example.cpp +++ b/test/gtest_example.cpp @@ -1,3 +1,24 @@ +//--------LICENSE_START-------- +// +// Copyright (C) 2020,2021,2022 Institut de Robòtica i Informà tica Industrial, CSIC-UPC. +// Authors: Joan Solà Ortega (jsola@iri.upc.edu) +// All rights reserved. +// +// This file is part of WOLF +// WOLF is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see <http://www.gnu.org/licenses/>. +// +//--------LICENSE_END-------- #include <core/utils/utils_gtest.h> TEST(TestTest, DummyTestExample) diff --git a/test/gtest_factor_compass_3d.cpp b/test/gtest_factor_compass_3d.cpp index f438aa03fbc5c18ed3d6f0d87c26ed568c535a6d..c368b7691e2012691ab2ec5c35dbe6bdb251b640 100644 --- a/test/gtest_factor_compass_3d.cpp +++ b/test/gtest_factor_compass_3d.cpp @@ -1,3 +1,24 @@ +//--------LICENSE_START-------- +// +// Copyright (C) 2020,2021,2022 Institut de Robòtica i Informà tica Industrial, CSIC-UPC. +// Authors: Joan Solà Ortega (jsola@iri.upc.edu) +// All rights reserved. +// +// This file is part of WOLF +// WOLF is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see <http://www.gnu.org/licenses/>. +// +//--------LICENSE_END-------- #include "core/utils/utils_gtest.h" #include "imu/internal/config.h" diff --git a/test/gtest_factor_imu.cpp b/test/gtest_factor_imu.cpp index c22ac6eafd00cb4c0cf480f70ffa64c0c8a88676..b6fe81776f2fb7db6ef7aaba0e4f130d7a6c2637 100644 --- a/test/gtest_factor_imu.cpp +++ b/test/gtest_factor_imu.cpp @@ -1,3 +1,24 @@ +//--------LICENSE_START-------- +// +// Copyright (C) 2020,2021,2022 Institut de Robòtica i Informà tica Industrial, CSIC-UPC. +// Authors: Joan Solà Ortega (jsola@iri.upc.edu) +// All rights reserved. +// +// This file is part of WOLF +// WOLF is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see <http://www.gnu.org/licenses/>. +// +//--------LICENSE_END-------- /** * \file gtest_factor_imu.cpp * @@ -89,7 +110,7 @@ class FactorImu_biasTest_Static_NullBias : public testing::Test expected_final_state = x_origin; //null bias + static //set origin of the problem - KF0 = problem->setPrior(x_origin, P_origin, t, 0.005); + KF0 = problem->setPrior(x_origin, P_origin, t); // KF0 = processor_imu->setOrigin(x_origin, t); //===================================================== END{INITIALIZATION} @@ -1220,7 +1241,7 @@ class FactorImu_ODOM_biasTest_Move_NonNullBiasRotXY : public testing::Test Eigen::Quaterniond current_quatState(Eigen::Quaterniond::Identity()); //set origin of the problem - origin_KF = problem->setPrior(x_origin, P_origin, t, 0.005); + origin_KF = problem->setPrior(x_origin, P_origin, t); // origin_KF = processor_imu->setOrigin(x_origin, t); // processor_odom3d->setOrigin(origin_KF); diff --git a/test/gtest_factor_imu2d.cpp b/test/gtest_factor_imu2d.cpp index 037783f6966b9c96f7016371469c7b522a6ded14..7dd71060608bd87f8b3188f9827f213d181322e6 100644 --- a/test/gtest_factor_imu2d.cpp +++ b/test/gtest_factor_imu2d.cpp @@ -1,3 +1,24 @@ +//--------LICENSE_START-------- +// +// Copyright (C) 2020,2021,2022 Institut de Robòtica i Informà tica Industrial, CSIC-UPC. +// Authors: Joan Solà Ortega (jsola@iri.upc.edu) +// All rights reserved. +// +// This file is part of WOLF +// WOLF is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see <http://www.gnu.org/licenses/>. +// +//--------LICENSE_END-------- #include <core/ceres_wrapper/solver_ceres.h> #include <core/utils/utils_gtest.h> diff --git a/test/gtest_feature_imu.cpp b/test/gtest_feature_imu.cpp index 6d2403b6827319b85236fbf444bc3af8987dbc27..d634807aec2b5b6b4f4243ea106c6b5363ffa10f 100644 --- a/test/gtest_feature_imu.cpp +++ b/test/gtest_feature_imu.cpp @@ -1,3 +1,24 @@ +//--------LICENSE_START-------- +// +// Copyright (C) 2020,2021,2022 Institut de Robòtica i Informà tica Industrial, CSIC-UPC. +// Authors: Joan Solà Ortega (jsola@iri.upc.edu) +// All rights reserved. +// +// This file is part of WOLF +// WOLF is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see <http://www.gnu.org/licenses/>. +// +//--------LICENSE_END-------- //Wolf #include "imu/capture/capture_imu.h" #include "imu/processor/processor_imu.h" @@ -57,7 +78,7 @@ class FeatureImu_test : public testing::Test // Set the origin VectorComposite x0("POV", {Vector3d::Zero(), Quaterniond::Identity().coeffs(), Vector3d::Zero()}); VectorComposite s0("POV", {Vector3d(1,1,1), Vector3d(1,1,1), Vector3d(1,1,1)}); - origin_frame = problem->setPriorFactor(x0, s0, t, 0.01); + origin_frame = problem->setPriorFactor(x0, s0, t); processor_motion_ptr_->setOrigin(origin_frame); // Emplace one capture to store the Imu data arriving from (sensor / callback / file / etc.) diff --git a/test/gtest_imu.cpp b/test/gtest_imu.cpp index 161157b8e079a5dd5f3dd4c873e754e021003c6f..6e63ec0bba182b5b0e163ed3c7ff094896f4a296 100644 --- a/test/gtest_imu.cpp +++ b/test/gtest_imu.cpp @@ -1,3 +1,24 @@ +//--------LICENSE_START-------- +// +// Copyright (C) 2020,2021,2022 Institut de Robòtica i Informà tica Industrial, CSIC-UPC. +// Authors: Joan Solà Ortega (jsola@iri.upc.edu) +// All rights reserved. +// +// This file is part of WOLF +// WOLF is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see <http://www.gnu.org/licenses/>. +// +//--------LICENSE_END-------- /* * gtest_Imu.cpp * @@ -328,7 +349,7 @@ class Process_Factor_Imu : public testing::Test // wolf objects WOLF_INFO("x0c: ", x0c); WOLF_INFO("s0c: ", s0c); - KF_0 = problem->setPriorFactor(x0c, s0c, t0, dt/2); + KF_0 = problem->setPriorFactor(x0c, s0c, t0); processor_imu->setOrigin(KF_0); WOLF_INFO("prior set"); @@ -475,28 +496,10 @@ class Process_Factor_Imu : public testing::Test { // This perturbs states to estimate around the exact value, then assigns to the keyframe // Perturbations are applied only if the state block is unfixed - - VectorXd x_pert(10); - - // KF 0 - x_pert = x0; - if (!p0_fixed) - x_pert.head(3) += Vector3d::Random() * 0.01; - if (!q0_fixed) - x_pert.segment(3,4) = (Quaterniond(x_pert.data() + 3) * exp_q(Vector3d::Random() * 0.01)).coeffs().normalized(); - if (!v0_fixed) - x_pert.tail(3) += Vector3d::Random() * 0.01; - KF_0->setState(x_pert); - - // KF 1 - x_pert = x1_exact; - if (!p1_fixed) - x_pert.head(3) += Vector3d::Random() * 0.01; - if (!q1_fixed) - x_pert.segment(3,4) = (Quaterniond(x_pert.data() + 3) * exp_q(Vector3d::Random() * 0.01)).coeffs().normalized(); - if (!v1_fixed) - x_pert.tail(3) += Vector3d::Random() * 0.01; - KF_1->setState(x_pert); + KF_0->setState(x0); + KF_0->perturb(); + KF_1->setState(x1_exact); + KF_1->perturb(); } virtual void buildProblem() @@ -505,7 +508,7 @@ class Process_Factor_Imu : public testing::Test FrameBasePtr KF = problem->emplaceFrame(t, x1_exact); // ===================================== Imu CALLBACK - problem->keyFrameCallback(KF, nullptr, dt/2); + problem->keyFrameCallback(KF, nullptr); // Process Imu for the callback to take effect data = Vector6d::Zero(); diff --git a/test/gtest_imu2d_static_init.cpp b/test/gtest_imu2d_static_init.cpp new file mode 100644 index 0000000000000000000000000000000000000000..ddf1624c4a9c7c9d44c6ce43c35d8f975c8d2494 --- /dev/null +++ b/test/gtest_imu2d_static_init.cpp @@ -0,0 +1,555 @@ +//--------LICENSE_START-------- +// +// Copyright (C) 2020,2021,2022 Institut de Robòtica i Informà tica Industrial, CSIC-UPC. +// Authors: Joan Solà Ortega (jsola@iri.upc.edu) +// All rights reserved. +// +// This file is part of WOLF +// WOLF is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see <http://www.gnu.org/licenses/>. +// +//--------LICENSE_END-------- +/* + * gtest_imu2d_static_init.cpp + * + * Created on: Sept 2021 + * Author: igeer + */ + +#include <fstream> +#include <core/ceres_wrapper/solver_ceres.h> +#include <core/utils/utils_gtest.h> +#include "imu/internal/config.h" + +#include "imu/factor/factor_imu2d.h" +#include "imu/math/imu2d_tools.h" +#include "imu/sensor/sensor_imu2d.h" +#include "core/capture/capture_void.h" +#include <core/factor/factor_relative_pose_2d.h> + +using namespace Eigen; +using namespace wolf; + +class ProcessorImu2dStaticInitTest : public testing::Test +{ + + public: //These can be accessed in fixtures + wolf::ProblemPtr problem_ptr_; + wolf::SensorBasePtr sensor_ptr_; + wolf::ProcessorMotionPtr processor_motion_; + wolf::TimeStamp t; + wolf::TimeStamp t0; + double dt; + Vector6d data; + Matrix6d data_cov; + FrameBasePtr KF0_; + FrameBasePtr first_frame_; + FrameBasePtr last_frame_; + SolverCeresPtr solver_; + + //a new of this will be created for each new test + void SetUp() override + { + WOLF_INFO("Doing setup..."); + using namespace Eigen; + using std::shared_ptr; + using std::make_shared; + using std::static_pointer_cast; + using namespace wolf::Constants; + + std::string wolf_root = _WOLF_IMU_ROOT_DIR; + + // Wolf problem + problem_ptr_ = Problem::create("POV", 2); + Vector3d extrinsics = (Vector3d() << 0,0,0).finished(); + sensor_ptr_ = problem_ptr_->installSensor("SensorImu2d", "Main Imu", extrinsics, wolf_root + "/test/yaml/sensor_imu2d_static_init.yaml"); + ProcessorBasePtr processor_ptr = problem_ptr_->installProcessor("ProcessorImu2d", "Imu pre-integrator", "Main Imu", wolf_root + "/test/yaml/imu2d_static_init.yaml"); + processor_motion_ = std::static_pointer_cast<ProcessorMotion>(processor_ptr); + + // Time and data variables + dt = 0.1; + t0.set(0); + t = t0; + data = Vector6d::Random(); + data_cov = Matrix6d::Identity(); + last_frame_ = nullptr; + first_frame_ = nullptr; + + // Create the solver + solver_ = make_shared<SolverCeres>(problem_ptr_); + + // Set the origin + VectorComposite x_origin("POV", {Vector2d::Zero(), Vector1d::Zero(), Vector2d::Zero()}); + VectorComposite std_origin("POV", {0.001*Vector2d::Ones(), 0.001*Vector1d::Ones(), 0.001*Vector2d::Ones()}); + //KF0_ = problem_ptr_->setPriorFix(x_origin, t0); + KF0_ = problem_ptr_->setPriorFactor(x_origin, std_origin, 0); + + } + + void TestStatic(const Vector3d& body_magnitudes, const Vector3d& bias_groundtruth, const Vector3d& bias_initial_guess, const string& test_name, int testing_var, bool small_tol) + { + //Data + data.head(2) = body_magnitudes.head(2); + data(5) = body_magnitudes(2); + data.head(2) += bias_groundtruth.head(2); + data(5) += bias_groundtruth(2); + + //Set bias initial guess + sensor_ptr_->getIntrinsic(t0)->setState(bias_initial_guess); + processor_motion_->setOrigin(KF0_); + +#if WRITE_CSV_FILE + std::fstream file_est; + file_est.open("./est2d-"+test_name+".csv", std::fstream::out); + // std::string header_est = "t,px,py,pz,qx,qy,qz,qw,vx,vy,vz,bax_est,bax_preint\n"; + std::string header_est; + if(testing_var == 0) header_est = "t;px;vx;o;bax_est;bg_est;bax_preint;bg_preint\n"; + if(testing_var == 1) header_est = "t;py;vy;o;bay_est;bg_est;bay_preint;bg_preint\n"; + //if(testing_var == 2) header_est = "t;pz;vz;oz:baz_est;bgz_est;baz_preint;bgz_preint\n"; + if(testing_var == 3) header_est = "t;pnorm;vnorm;o;banorm_est;bg_est;banorm_preint;bg_preint\n"; + file_est << header_est; +#endif + + + int n_frames = 0; + for(t = t0; t <= t0 + 9.9 + dt/2; t+=dt){ + WOLF_INFO("\n------------------------------------------------------------------------"); + + //Create and process capture + auto C = std::make_shared<CaptureImu>(t, sensor_ptr_, data, data_cov, KF0_->getCaptureList().front()); + C->process(); + + auto state = problem_ptr_->getState(); + auto bias_est = sensor_ptr_->getIntrinsic()->getState(); + auto bias_preint = processor_motion_->getLast()->getCalibrationPreint(); + +#if WRITE_CSV_FILE + // pre-solve print to CSV + if(testing_var == 3){ + file_est << std::fixed << t << ";" + << state['P'].norm() << ";" + << state['V'].norm() << ";" + << state['O'] << ";" + << bias_est.head(2).norm() << ";" + << bias_est(2) << ";" + << bias_preint.head(2).norm() << ";" + << bias_preint(2) << "\n"; + } + else + { + file_est << std::fixed << t << ";" + << state['P'](testing_var) << ";" + << state['V'](testing_var) << ";" + << state['O'] << ";" + << bias_est(testing_var) << ";" + << bias_est(2) << ";" + << bias_preint(testing_var) << ";" + << bias_preint(2) << "\n"; + + } +#endif + + // new frame + if (last_frame_ != processor_motion_->getOrigin()->getFrame()) + { + n_frames++; + last_frame_ = processor_motion_->getOrigin()->getFrame(); + + // impose static + last_frame_->getP()->setState(KF0_->getP()->getState()); + last_frame_->getO()->setState(KF0_->getO()->getState()); + last_frame_->getV()->setZero(); + + //Fix frame + last_frame_->fix(); + + //Solve + if(n_frames > 0) + { + std::string report = solver_->solve(SolverManager::ReportVerbosity::FULL); + //WOLF_INFO("Solver Report: ", report); + + state = problem_ptr_->getState(); + bias_est = sensor_ptr_->getIntrinsic()->getState(); + bias_preint = processor_motion_->getLast()->getCalibrationPreint(); + + WOLF_INFO("The current problem is:"); + problem_ptr_->print(4); + +#if WRITE_CSV_FILE + // post-solve print to CSV with time-stamp shifted by dt/2 to separate from pre-solve result + if(testing_var == 3){ + file_est << std::fixed << t+dt/2 << ";" + << state['P'].norm() << ";" + << state['V'].norm() << ";" + << state['O'] << ";" + << bias_est.head(2).norm() << ";" + << bias_est(2) << ";" + << bias_preint.head(2).norm() << ";" + << bias_preint(2) << "\n"; + } + else + { + file_est << std::fixed << t+dt/2 << ";" + << state['P'](testing_var) << ";" + << state['V'](testing_var) << ";" + << state['O'] << ";" + << bias_est(testing_var) << ";" + << bias_est(2) << ";" + << bias_preint(testing_var) << ";" + << bias_preint(2) << "\n"; + + } +#endif + } + + } + + + WOLF_INFO("Number of frames is ", n_frames); + WOLF_INFO("The state is: ", state); + WOLF_INFO("The estimated bias is: ", bias_est.transpose()); + WOLF_INFO("The preintegrated bias is: ", bias_preint.transpose()); + if(small_tol) + { + if(n_frames == 2) + { + EXPECT_MATRIX_APPROX(state.vector("POV"), KF0_->getState().vector("POV"), 1e-6); + EXPECT_MATRIX_APPROX(bias_est, bias_groundtruth, 1e-6); + } + else if (n_frames > 2) + { + EXPECT_MATRIX_APPROX(state.vector("POV"), KF0_->getState().vector("POV"), 1e-6); + EXPECT_MATRIX_APPROX(bias_est, bias_groundtruth, 1e-6); + EXPECT_MATRIX_APPROX(bias_preint, bias_groundtruth, 1e-6); + } + } + else + { + if(n_frames == 2) + { + EXPECT_MATRIX_APPROX(state.vector("POV"), KF0_->getState().vector("POV"), 1e-3); + EXPECT_MATRIX_APPROX(bias_est, bias_groundtruth, 1e-3); + } + else if (n_frames > 2) + { + EXPECT_MATRIX_APPROX(state.vector("POV"), KF0_->getState().vector("POV"), 1e-3); + EXPECT_MATRIX_APPROX(bias_est, bias_groundtruth, 1e-3); + EXPECT_MATRIX_APPROX(bias_preint, bias_groundtruth, 1e-3); + } + } + } + +#if WRITE_CSV_FILE + file_est.close(); +#endif + + } + + void TestStaticZeroOdom(const Vector3d& body_magnitudes, const Vector3d& bias_groundtruth, const Vector3d& bias_initial_guess, const string& test_name, int testing_var, bool small_tol) + { + //Data + data.head(2) = body_magnitudes.head(2); + data(5) = body_magnitudes(2); + data.head(2) += bias_groundtruth.head(2); + data(5) += bias_groundtruth(2); + + //Set bias initial guess + sensor_ptr_->getIntrinsic(t0)->setState(bias_initial_guess); + processor_motion_->setOrigin(KF0_); + +#if WRITE_CSV_FILE + std::fstream file_est; + file_est.open("./est2dzeroodom-"+test_name+".csv", std::fstream::out); + // std::string header_est = "t,px,py,pz,qx,qy,qz,qw,vx,vy,vz,bax_est,bax_preint\n"; + std::string header_est; + if(testing_var == 0) header_est = "t;px;vx;o;bax_est;bg_est;bax_preint;bg_preint\n"; + if(testing_var == 1) header_est = "t;py;vy;o;bay_est;bg_est;bay_preint;bg_preint\n"; + //if(testing_var == 2) header_est = "t;pz;vz;oz:baz_est;bgz_est;baz_preint;bgz_preint\n"; + if(testing_var == 3) header_est = "t;pnorm;vnorm;o;banorm_est;bg_est;banorm_preint;bg_preint\n"; + file_est << header_est; +#endif + + int n_frames = 0; + for(t = t0; t <= t0 + 9.9 + dt/2; t+=dt){ + WOLF_INFO("\n------------------------------------------------------------------------"); + + //Create and process capture + auto C = std::make_shared<CaptureImu>(t, sensor_ptr_, data, data_cov, KF0_->getCaptureList().front()); + C->process(); + + auto state = problem_ptr_->getState(); + auto bias_est = sensor_ptr_->getIntrinsic()->getState(); + auto bias_preint = processor_motion_->getLast()->getCalibrationPreint(); + +#if WRITE_CSV_FILE + // pre-solve print to CSV + if(testing_var == 3){ + file_est << std::fixed << t << ";" + << state['P'].norm() << ";" + << state['V'].norm() << ";" + << state['O'] << ";" + << bias_est.head(2).norm() << ";" + << bias_est(2) << ";" + << bias_preint.head(2).norm() << ";" + << bias_preint(2) << "\n"; + } + else + { + file_est << std::fixed << t << ";" + << state['P'](testing_var) << ";" + << state['V'](testing_var) << ";" + << state['O'] << ";" + << bias_est(testing_var) << ";" + << bias_est(2) << ";" + << bias_preint(testing_var) << ";" + << bias_preint(2) << "\n"; + + } +#endif + + // new frame + if (last_frame_ != processor_motion_->getOrigin()->getFrame()) + { + n_frames++; + last_frame_ = processor_motion_->getOrigin()->getFrame(); + + // impose zero odometry + processor_motion_->setOdometry(sensor_ptr_->getProblem()->stateZero(processor_motion_->getStateStructure())); + + // add zero displacement and rotation capture & feature & factor with all previous frames + assert(sensor_ptr_->getProblem()); + for (auto frm_pair = sensor_ptr_->getProblem()->getTrajectory()->begin(); + frm_pair != sensor_ptr_->getProblem()->getTrajectory()->end(); + frm_pair++) + { + if (frm_pair->second == last_frame_) + break; + auto capture_zero = CaptureBase::emplace<CaptureVoid>(last_frame_, last_frame_->getTimeStamp(), nullptr); + + auto feature_zero = FeatureBase::emplace<FeatureBase>(capture_zero, + "FeatureZeroOdom", + Vector3d::Zero(), + Eigen::MatrixXd::Identity(3,3) * 0.01); + + FactorBase::emplace<FactorRelativePose2d>(feature_zero, + feature_zero, + frm_pair->second, + nullptr, + false, + TOP_MOTION); + + } + + // impose static + last_frame_->getV()->setZero(); + + //Fix frame + last_frame_->getV()->fix(); + + //Solve + if(n_frames > 0) + { + std::string report = solver_->solve(SolverManager::ReportVerbosity::FULL); + //WOLF_INFO("Solver Report: ", report); + + state = problem_ptr_->getState(); + bias_est = sensor_ptr_->getIntrinsic()->getState(); + bias_preint = processor_motion_->getLast()->getCalibrationPreint(); + + WOLF_INFO("The current problem is:"); + problem_ptr_->print(4); + +#if WRITE_CSV_FILE + // post-solve print to CSV with time-stamp shifted by dt/2 to separate from pre-solve result + if(testing_var == 3){ + file_est << std::fixed << t+dt/2 << ";" + << state['P'].norm() << ";" + << state['V'].norm() << ";" + << state['O'] << ";" + << bias_est.head(2).norm() << ";" + << bias_est(2) << ";" + << bias_preint.head(2).norm() << ";" + << bias_preint(2) << "\n"; + } + else + { + file_est << std::fixed << t+dt/2 << ";" + << state['P'](testing_var) << ";" + << state['V'](testing_var) << ";" + << state['O'] << ";" + << bias_est(testing_var) << ";" + << bias_est(2) << ";" + << bias_preint(testing_var) << ";" + << bias_preint(2) << "\n"; + + } +#endif + } + + } + + + + WOLF_INFO("Number of frames is ", n_frames); + WOLF_INFO("The state is: ", state); + WOLF_INFO("The estimated bias is: ", bias_est.transpose()); + WOLF_INFO("The preintegrated bias is: ", bias_preint.transpose()); + if(small_tol) + { + if(n_frames == 2) + { + EXPECT_MATRIX_APPROX(state.vector("POV"), KF0_->getState().vector("POV"), 1e-6); + EXPECT_MATRIX_APPROX(bias_est, bias_groundtruth, 1e-6); + } + else if (n_frames > 2) + { + EXPECT_MATRIX_APPROX(state.vector("POV"), KF0_->getState().vector("POV"), 1e-6); + EXPECT_MATRIX_APPROX(bias_est, bias_groundtruth, 1e-6); + EXPECT_MATRIX_APPROX(bias_preint, bias_groundtruth, 1e-6); + } + } + else + { + if(n_frames == 2) + { + EXPECT_MATRIX_APPROX(state.vector("POV"), KF0_->getState().vector("POV"), 1e-3); + EXPECT_MATRIX_APPROX(bias_est, bias_groundtruth, 1e-3); + } + else if (n_frames > 2) + { + EXPECT_MATRIX_APPROX(state.vector("POV"), KF0_->getState().vector("POV"), 1e-3); + EXPECT_MATRIX_APPROX(bias_est, bias_groundtruth, 1e-3); + EXPECT_MATRIX_APPROX(bias_preint, bias_groundtruth, 1e-3); + } + } + } + +#if WRITE_CSV_FILE + file_est.close(); +#endif + + } +}; + + + +TEST_F(ProcessorImu2dStaticInitTest, static_bias_aX_initial_guess_zero) +{ + Vector3d body_magnitudes = Vector3d::Zero(); + Vector3d bias_groundtruth = (Vector3d() << 0.42, 0, 0).finished(); + Vector3d bias_initial_guess = Vector3d::Zero(); + + TestStatic(body_magnitudes, bias_groundtruth, bias_initial_guess, "static_bias_aX_initial_guess_zero", 0, true); +} + +TEST_F(ProcessorImu2dStaticInitTest, static_bias_zero_initial_guess_aX) +{ + Vector3d body_magnitudes = Vector3d::Zero(); + Vector3d bias_groundtruth = Vector3d::Zero(); + Vector3d bias_initial_guess = (Vector3d() << 0.42, 0, 0).finished(); + + TestStatic(body_magnitudes, bias_groundtruth, bias_initial_guess, "static_bias_zero_initial_guess_aX", 0, true); +} + +TEST_F(ProcessorImu2dStaticInitTest, static_bias_gX_initial_guess_zero) +{ + Vector3d body_magnitudes = Vector3d::Zero(); + Vector3d bias_groundtruth = (Vector3d() << 0, 0, 0.01).finished(); + Vector3d bias_initial_guess = Vector3d::Zero(); + + TestStatic(body_magnitudes, bias_groundtruth, bias_initial_guess, "static_bias_gX_initial_guess_zero", 0, false); +} + +TEST_F(ProcessorImu2dStaticInitTest, static_bias_zero_initial_guess_gX) +{ + Vector3d body_magnitudes = Vector3d::Zero(); + Vector3d bias_groundtruth = Vector3d::Zero(); + Vector3d bias_initial_guess = (Vector3d() << 0, 0, 0.01).finished(); + + TestStatic(body_magnitudes, bias_groundtruth, bias_initial_guess, "static_bias_zero_initial_guess_gX", 0, false); +} + +TEST_F(ProcessorImu2dStaticInitTest, static_bias_aX_initial_guess_zero_zeroodom) +{ + Vector3d body_magnitudes = Vector3d::Zero(); + Vector3d bias_groundtruth = (Vector3d() << 0.42, 0, 0).finished(); + Vector3d bias_initial_guess = Vector3d::Zero(); + + TestStaticZeroOdom(body_magnitudes, bias_groundtruth, bias_initial_guess, "static_bias_aX_initial_guess_zero", 0, true); +} + +TEST_F(ProcessorImu2dStaticInitTest, static_bias_zero_initial_guess_aX_zeroodom) +{ + Vector3d body_magnitudes = Vector3d::Zero(); + Vector3d bias_groundtruth = Vector3d::Zero(); + Vector3d bias_initial_guess = (Vector3d() << 0.42, 0, 0).finished(); + + TestStaticZeroOdom(body_magnitudes, bias_groundtruth, bias_initial_guess, "static_bias_zero_initial_guess_aX", 0, true); +} + +TEST_F(ProcessorImu2dStaticInitTest, static_bias_gX_initial_guess_zero_zeroodom) +{ + Vector3d body_magnitudes = Vector3d::Zero(); + Vector3d bias_groundtruth = (Vector3d() << 0, 0, 0.01).finished(); + Vector3d bias_initial_guess = Vector3d::Zero(); + + TestStaticZeroOdom(body_magnitudes, bias_groundtruth, bias_initial_guess, "static_bias_gX_initial_guess_zero", 0, false); +} + +TEST_F(ProcessorImu2dStaticInitTest, static_bias_zero_initial_guess_gX_zeroodom) +{ + Vector3d body_magnitudes = Vector3d::Zero(); + Vector3d bias_groundtruth = Vector3d::Zero(); + Vector3d bias_initial_guess = (Vector3d() << 0, 0, 0.01).finished(); + + TestStaticZeroOdom(body_magnitudes, bias_groundtruth, bias_initial_guess, "static_bias_zero_initial_guess_gX", 0, false); +} + + +TEST_F(ProcessorImu2dStaticInitTest, static_bias_zero_initial_guess_a_random) +{ + Vector3d body_magnitudes = Vector3d::Zero(); + Vector3d bias_groundtruth = Vector3d::Zero(); + Vector3d bias_initial_guess = Vector3d::Random()*100; + bias_initial_guess(2) = 0; + + TestStatic(body_magnitudes, bias_groundtruth, bias_initial_guess, "static_bias_zero_initial_guess_a_random", 3, true); +} + +TEST_F(ProcessorImu2dStaticInitTest, static_bias_zero_initial_guess_random) +{ + Vector3d body_magnitudes = Vector3d::Zero(); + Vector3d bias_groundtruth = Vector3d::Zero(); + Vector3d bias_initial_guess = Vector3d::Random()*0.01; + + TestStatic(body_magnitudes, bias_groundtruth, bias_initial_guess, "static_bias_zero_initial_guess_random", 3, false); +} + +TEST_F(ProcessorImu2dStaticInitTest, realistic_test) +{ + Vector3d body_magnitudes = Vector3d::Zero(); + Vector3d bias_groundtruth = (Vector3d() << -0.529550648247, + 0.278316717683, + -0.00122491355676).finished(); + Vector3d bias_initial_guess = Vector3d::Zero(); + + TestStatic(body_magnitudes, bias_groundtruth, bias_initial_guess, "static_bias_zero_initial_guess_random", 3, false); +} + +int main(int argc, char **argv) +{ + testing::InitGoogleTest(&argc, argv); + // ::testing::GTEST_FLAG(filter) = "FactorImu2d.no_bias_fixed"; // Test only this one + return RUN_ALL_TESTS(); +} diff --git a/test/gtest_imu2d_tools.cpp b/test/gtest_imu2d_tools.cpp index c1e727ccac84397b47f4902cb6c6b808df4ca9f3..964cdbee899e1e83760b062a2caf531614c545e4 100644 --- a/test/gtest_imu2d_tools.cpp +++ b/test/gtest_imu2d_tools.cpp @@ -1,3 +1,24 @@ +//--------LICENSE_START-------- +// +// Copyright (C) 2020,2021,2022 Institut de Robòtica i Informà tica Industrial, CSIC-UPC. +// Authors: Joan Solà Ortega (jsola@iri.upc.edu) +// All rights reserved. +// +// This file is part of WOLF +// WOLF is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see <http://www.gnu.org/licenses/>. +// +//--------LICENSE_END-------- /* * gtest_imu2d_tools.cpp * diff --git a/test/gtest_imu_mocap_fusion.cpp b/test/gtest_imu_mocap_fusion.cpp index bb668f2b85062e100ad80dbd92ce29411dd19458..34cf4948419a04b2b8f0648fe75b020495509b70 100644 --- a/test/gtest_imu_mocap_fusion.cpp +++ b/test/gtest_imu_mocap_fusion.cpp @@ -1,3 +1,24 @@ +//--------LICENSE_START-------- +// +// Copyright (C) 2020,2021,2022 Institut de Robòtica i Informà tica Industrial, CSIC-UPC. +// Authors: Joan Solà Ortega (jsola@iri.upc.edu) +// All rights reserved. +// +// This file is part of WOLF +// WOLF is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see <http://www.gnu.org/licenses/>. +// +//--------LICENSE_END-------- /** * \file gtest_imu_mocap_fusion.cpp * @@ -92,7 +113,7 @@ class ImuMocapFusion_Test : public testing::Test solver_->getSolverOptions().max_num_iterations = 500; // initial guess VectorComposite x_origin("POV", {w_p_wb, w_q_b.coeffs(), w_v_wb}); - FrameBasePtr KF1 = problem_->setPriorInitialGuess(x_origin, 0, 0.0005); // if mocap used + FrameBasePtr KF1 = problem_->setPriorInitialGuess(x_origin, 0); // if mocap used // pose sensor and proc (to get extrinsics in the prb) auto intr_sp = std::make_shared<ParamsSensorPose>(); @@ -279,4 +300,4 @@ int main(int argc, char **argv) { testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); -} \ No newline at end of file +} diff --git a/test/gtest_imu_static_init.cpp b/test/gtest_imu_static_init.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e0c769b4a30a4d1dc122be4ebe88622634186e1a --- /dev/null +++ b/test/gtest_imu_static_init.cpp @@ -0,0 +1,554 @@ +//--------LICENSE_START-------- +// +// Copyright (C) 2020,2021,2022 Institut de Robòtica i Informà tica Industrial, CSIC-UPC. +// Authors: Joan Solà Ortega (jsola@iri.upc.edu) +// All rights reserved. +// +// This file is part of WOLF +// WOLF is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see <http://www.gnu.org/licenses/>. +// +//--------LICENSE_END-------- +/* + * gtest_imu_static_init.cpp + * + * Created on: Sept 2021 + * Author: igeer + */ +#include <fstream> + +#include <core/ceres_wrapper/solver_ceres.h> +#include <core/utils/utils_gtest.h> +#include "imu/internal/config.h" + +#include "imu/factor/factor_imu.h" +#include "imu/math/imu_tools.h" +#include "imu/sensor/sensor_imu.h" +#include "core/capture/capture_void.h" +#include <core/factor/factor_relative_pose_3d.h> + +using namespace Eigen; +using namespace wolf; + +/** + * SET TO TRUE TO PRODUCE CSV FILE + * SET TO FALSE TO STOP PRODUCING CSV FILE + */ +#define WRITE_CSV_FILE true + +class ProcessorImuStaticInitTest : public testing::Test +{ + + public: //These can be accessed in fixtures + wolf::ProblemPtr problem_ptr_; + wolf::SensorBasePtr sensor_ptr_; + wolf::ProcessorMotionPtr processor_motion_; + wolf::TimeStamp t; + wolf::TimeStamp t0; + double dt; + Vector6d data; + Matrix6d data_cov; + FrameBasePtr KF0_; + FrameBasePtr first_frame_; + FrameBasePtr last_frame_; + SolverCeresPtr solver_; + + //a new of this will be created for each new test + void SetUp() override + { + WOLF_INFO("Doing setup..."); + using namespace Eigen; + using std::shared_ptr; + using std::make_shared; + using std::static_pointer_cast; + using namespace wolf::Constants; + + std::string wolf_root = _WOLF_IMU_ROOT_DIR; + + // Wolf problem + problem_ptr_ = Problem::create("POV", 3); + Vector7d extrinsics = (Vector7d() << 0,0,0,0,0,0,1).finished(); + sensor_ptr_ = problem_ptr_->installSensor("SensorImu", "Main Imu", extrinsics, wolf_root + "/test/yaml/sensor_imu_static_init.yaml"); + ProcessorBasePtr processor_ptr = problem_ptr_->installProcessor("ProcessorImu", "Imu pre-integrator", "Main Imu", wolf_root + "/test/yaml/imu_static_init.yaml"); + processor_motion_ = std::static_pointer_cast<ProcessorMotion>(processor_ptr); + + // Time and data variables + dt = 0.1; + t0.set(0); + t = t0; + data = Vector6d::Random(); + data_cov = Matrix6d::Identity(); + last_frame_ = nullptr; + first_frame_ = nullptr; + + // Create the solver + solver_ = make_shared<SolverCeres>(problem_ptr_); + + // Set the origin + VectorComposite x0c("POV", {Vector3d::Zero(), (Vector4d() << 0,0,0,1).finished(), Vector3d::Zero()}); + WOLF_INFO("x0c is: \n", x0c); + //KF0_ = problem_ptr_->setPriorFix(x0c, t0); + + Vector4d q_init; q_init << 0,0,0,1; + VectorComposite x_origin("POV", {Vector3d::Zero(), q_init, Vector3d::Zero()}); + VectorComposite std_origin("POV", {0.001*Vector3d::Ones(), 0.001*Vector3d::Ones(), 0.001*Vector3d::Ones()}); + KF0_ = problem_ptr_->setPriorFactor(x_origin, std_origin, 0); + + } + + void TestStatic(const Vector6d& body_magnitudes, const Vector6d& bias_groundtruth, const Vector6d& bias_initial_guess, const string& test_name, int testing_var, bool small_tol) + { + //Data + data = body_magnitudes; + data.head(3) -= Quaterniond(Vector4d(KF0_->getO()->getState())).conjugate() * wolf::gravity(); + data += bias_groundtruth; + + //Set bias initial guess + sensor_ptr_->getIntrinsic(t0)->setState(bias_initial_guess); + processor_motion_->setOrigin(KF0_); + +#if WRITE_CSV_FILE + std::fstream file_est; + file_est.open("./est-"+test_name+".csv", std::fstream::out); + // std::string header_est = "t,px,py,pz,qx,qy,qz,qw,vx,vy,vz,bax_est,bax_preint\n"; + std::string header_est; + if(testing_var == 0) header_est = "t;px;vx;ox;bax_est;bgx_est;bax_preint;bgx_preint\n"; + if(testing_var == 1) header_est = "t;py;vy;oy;bay_est;bgy_est;bay_preint;bgy_preint\n"; + if(testing_var == 2) header_est = "t;pz;vz;oz:baz_est;bgz_est;baz_preint;bgz_preint\n"; + if(testing_var == 3) header_est = "t;pnorm;vnorm;onorm;banorm_est;bgnorm_est;banorm_preint;bgnorm_preint\n"; + file_est << header_est; +#endif + + + int n_frames = 0; + for(t = t0; t <= t0 + 9.9 + dt/2; t+=dt){ + WOLF_INFO("\n------------------------------------------------------------------------"); + + //Create and process capture + auto C = std::make_shared<CaptureImu>(t, sensor_ptr_, data, data_cov, KF0_->getCaptureList().front()); + C->process(); + + auto state = problem_ptr_->getState(); + auto bias_est = sensor_ptr_->getIntrinsic()->getState(); + auto bias_preint = processor_motion_->getLast()->getCalibrationPreint(); + +#if WRITE_CSV_FILE + // pre-solve print to CSV + if(testing_var == 3){ + file_est << std::fixed << t << ";" + << state['P'].norm() << ";" + << state['V'].norm() << ";" + << state['O'].norm() << ";" + << bias_est.head(3).norm() << ";" + << bias_est.tail(3).norm() << ";" + << bias_preint.head(3).norm() << ";" + << bias_preint.tail(3).norm() << "\n"; + } + else + { + file_est << std::fixed << t << ";" + << state['P'](testing_var) << ";" + << state['V'](testing_var) << ";" + << state['O'](testing_var) << ";" + << bias_est(testing_var) << ";" + << bias_est(testing_var+3) << ";" + << bias_preint(testing_var) << ";" + << bias_preint(testing_var+3) << "\n"; + + } +#endif + + // new frame + if (last_frame_ != processor_motion_->getOrigin()->getFrame()) + { + n_frames++; + last_frame_ = processor_motion_->getOrigin()->getFrame(); + + // impose static + last_frame_->getP()->setState(KF0_->getP()->getState()); + last_frame_->getO()->setState(KF0_->getO()->getState()); + last_frame_->getV()->setZero(); + + //Fix frame + last_frame_->fix(); + + //Solve + if(n_frames > 0) + { + std::string report = solver_->solve(SolverManager::ReportVerbosity::FULL); + //WOLF_INFO("Solver Report: ", report); + + state = problem_ptr_->getState(); + bias_est = sensor_ptr_->getIntrinsic()->getState(); + bias_preint = processor_motion_->getLast()->getCalibrationPreint(); + + WOLF_INFO("The current problem is:"); + problem_ptr_->print(4); + +#if WRITE_CSV_FILE + // post-solve print to CSV with time-stamp shifted by dt/2 to separate from pre-solve result + if(testing_var == 3){ + file_est << std::fixed << t+dt/2 << ";" + << state['P'].norm() << ";" + << state['V'].norm() << ";" + << state['O'].norm() << ";" + << bias_est.head(3).norm() << ";" + << bias_est.tail(3).norm() << ";" + << bias_preint.head(3).norm() << ";" + << bias_preint.tail(3).norm() << "\n"; + } + else + { + file_est << std::fixed << t+dt/2 << ";" + << state['P'](testing_var) << ";" + << state['V'](testing_var) << ";" + << state['O'](testing_var) << ";" + << bias_est(testing_var) << ";" + << bias_est(testing_var+3) << ";" + << bias_preint(testing_var) << ";" + << bias_preint(testing_var+3) << "\n"; + + } +#endif + } + + } + + + + WOLF_INFO("Number of frames is ", n_frames); + WOLF_INFO("The state is: ", state); + WOLF_INFO("The estimated bias is: ", bias_est.transpose()); + WOLF_INFO("The preintegrated bias is: ", bias_preint.transpose()); + if(small_tol) + { + if(n_frames == 2) + { + EXPECT_MATRIX_APPROX(state.vector("POV"), KF0_->getState().vector("POV"), 1e-6); + EXPECT_MATRIX_APPROX(bias_est, bias_groundtruth, 1e-6); + } + else if (n_frames > 2) + { + EXPECT_MATRIX_APPROX(state.vector("POV"), KF0_->getState().vector("POV"), 1e-6); + EXPECT_MATRIX_APPROX(bias_est, bias_groundtruth, 1e-6); + EXPECT_MATRIX_APPROX(bias_preint, bias_groundtruth, 1e-6); + } + } + else + { + if(n_frames == 2) + { + EXPECT_MATRIX_APPROX(state.vector("POV"), KF0_->getState().vector("POV"), 1e-3); + EXPECT_MATRIX_APPROX(bias_est, bias_groundtruth, 1e-3); + } + else if (n_frames > 2) + { + EXPECT_MATRIX_APPROX(state.vector("POV"), KF0_->getState().vector("POV"), 1e-3); + EXPECT_MATRIX_APPROX(bias_est, bias_groundtruth, 1e-3); + EXPECT_MATRIX_APPROX(bias_preint, bias_groundtruth, 1e-3); + } + } + } + +#if WRITE_CSV_FILE + file_est.close(); +#endif + + } + + void TestStaticZeroOdom(const Vector6d& body_magnitudes, const Vector6d& bias_groundtruth, const Vector6d& bias_initial_guess, const string& test_name, int testing_var, bool small_tol) + { + //Data + data = body_magnitudes; + data.head(3) -= Quaterniond(Vector4d(KF0_->getO()->getState())).conjugate() * wolf::gravity(); + data += bias_groundtruth; + + //Set bias initial guess + sensor_ptr_->getIntrinsic(t0)->setState(bias_initial_guess); + processor_motion_->setOrigin(KF0_); + +#if WRITE_CSV_FILE + std::fstream file_est; + file_est.open("./estzeroodom-"+test_name+".csv", std::fstream::out); + // std::string header_est = "t,px,py,pz,qx,qy,qz,qw,vx,vy,vz,bax_est,bax_preint\n"; + std::string header_est; + if(testing_var == 0) header_est = "t;px;vx;ox;bax_est;bgx_est;bax_preint;bgx_preint\n"; + if(testing_var == 1) header_est = "t;py;vy;oy;bay_est;bgy_est;bay_preint;bgy_preint\n"; + if(testing_var == 2) header_est = "t;pz;vz;oz:baz_est;bgz_est;baz_preint;bgz_preint\n"; + if(testing_var == 3) header_est = "t;pnorm;vnorm;onorm;banorm_est;bgnorm_est;banorm_preint;bgnorm_preint\n"; + file_est << header_est; +#endif + + + int n_frames = 0; + for(t = t0; t <= t0 + 9.9 + dt/2; t+=dt){ + WOLF_INFO("\n------------------------------------------------------------------------"); + + //Create and process capture + auto C = std::make_shared<CaptureImu>(t, sensor_ptr_, data, data_cov, KF0_->getCaptureList().front()); + C->process(); + + auto state = problem_ptr_->getState(); + auto bias_est = sensor_ptr_->getIntrinsic()->getState(); + auto bias_preint = processor_motion_->getLast()->getCalibrationPreint(); + +#if WRITE_CSV_FILE + // pre-solve print to CSV + if(testing_var == 3){ + file_est << std::fixed << t << ";" + << state['P'].norm() << ";" + << state['V'].norm() << ";" + << state['O'].norm() << ";" + << bias_est.head(3).norm() << ";" + << bias_est.tail(3).norm() << ";" + << bias_preint.head(3).norm() << ";" + << bias_preint.tail(3).norm() << "\n"; + } + else + { + file_est << std::fixed << t << ";" + << state['P'](testing_var) << ";" + << state['V'](testing_var) << ";" + << state['O'](testing_var) << ";" + << bias_est(testing_var) << ";" + << bias_est(testing_var+3) << ";" + << bias_preint(testing_var) << ";" + << bias_preint(testing_var+3) << "\n"; + + } +#endif + + // new frame + if (last_frame_ != processor_motion_->getOrigin()->getFrame()) + { + n_frames++; + last_frame_ = processor_motion_->getOrigin()->getFrame(); + + // impose zero odometry + processor_motion_->setOdometry(sensor_ptr_->getProblem()->stateZero(processor_motion_->getStateStructure())); + + // add zero displacement and rotation capture & feature & factor with all previous frames + assert(sensor_ptr_->getProblem()); + for (auto frm_pair = sensor_ptr_->getProblem()->getTrajectory()->begin(); + frm_pair != sensor_ptr_->getProblem()->getTrajectory()->end(); + frm_pair++) + { + if (frm_pair->second == last_frame_) + break; + auto capture_zero = CaptureBase::emplace<CaptureVoid>(last_frame_, last_frame_->getTimeStamp(), nullptr); + + auto feature_zero = FeatureBase::emplace<FeatureBase>(capture_zero, + "FeatureZeroOdom", + Vector7d::Zero(), + Eigen::MatrixXd::Identity(6,6) * 0.01); + + FactorBase::emplace<FactorRelativePose3d>(feature_zero, + feature_zero, + frm_pair->second, + nullptr, + false, + TOP_MOTION); + + } + + // impose static + last_frame_->getV()->setZero(); + + //Fix frame + last_frame_->getV()->fix(); + + //Solve + if(n_frames > 0) + { + std::string report = solver_->solve(SolverManager::ReportVerbosity::FULL); + //WOLF_INFO("Solver Report: ", report); + + state = problem_ptr_->getState(); + bias_est = sensor_ptr_->getIntrinsic()->getState(); + bias_preint = processor_motion_->getLast()->getCalibrationPreint(); + + WOLF_INFO("The current problem is:"); + problem_ptr_->print(4); + +#if WRITE_CSV_FILE + // post-solve print to CSV with time-stamp shifted by dt/2 to separate from pre-solve result + if(testing_var == 3){ + file_est << std::fixed << t+dt/2 << ";" + << state['P'].norm() << ";" + << state['V'].norm() << ";" + << state['O'].norm() << ";" + << bias_est.head(3).norm() << ";" + << bias_est.tail(3).norm() << ";" + << bias_preint.head(3).norm() << ";" + << bias_preint.tail(3).norm() << "\n"; + } + else + { + file_est << std::fixed << t+dt/2 << ";" + << state['P'](testing_var) << ";" + << state['V'](testing_var) << ";" + << state['O'](testing_var) << ";" + << bias_est(testing_var) << ";" + << bias_est(testing_var+3) << ";" + << bias_preint(testing_var) << ";" + << bias_preint(testing_var+3) << "\n"; + + } +#endif + } + + } + + + + WOLF_INFO("Number of frames is ", n_frames); + WOLF_INFO("The state is: ", state); + WOLF_INFO("The estimated bias is: ", bias_est.transpose()); + WOLF_INFO("The preintegrated bias is: ", bias_preint.transpose()); + if(small_tol) + { + if(n_frames == 2) + { + EXPECT_MATRIX_APPROX(state.vector("POV"), KF0_->getState().vector("POV"), 1e-6); + EXPECT_MATRIX_APPROX(bias_est, bias_groundtruth, 1e-6); + } + else if (n_frames > 2) + { + EXPECT_MATRIX_APPROX(state.vector("POV"), KF0_->getState().vector("POV"), 1e-6); + EXPECT_MATRIX_APPROX(bias_est, bias_groundtruth, 1e-6); + EXPECT_MATRIX_APPROX(bias_preint, bias_groundtruth, 1e-6); + } + } + else + { + if(n_frames == 2) + { + EXPECT_MATRIX_APPROX(state.vector("POV"), KF0_->getState().vector("POV"), 1e-3); + EXPECT_MATRIX_APPROX(bias_est, bias_groundtruth, 1e-3); + } + else if (n_frames > 2) + { + EXPECT_MATRIX_APPROX(state.vector("POV"), KF0_->getState().vector("POV"), 1e-3); + EXPECT_MATRIX_APPROX(bias_est, bias_groundtruth, 1e-3); + EXPECT_MATRIX_APPROX(bias_preint, bias_groundtruth, 1e-3); + } + } + } + +#if WRITE_CSV_FILE + file_est.close(); +#endif + + } +}; + + + +TEST_F(ProcessorImuStaticInitTest, static_bias_aX_initial_guess_zero) +{ + Vector6d body_magnitudes = Vector6d::Zero(); + Vector6d bias_groundtruth = (Vector6d() << 0.42, 0, 0, 0, 0, 0).finished(); + Vector6d bias_initial_guess = Vector6d::Zero(); + + TestStatic(body_magnitudes, bias_groundtruth, bias_initial_guess, "static_bias_aX_initial_guess_zero", 0, true); +} + +TEST_F(ProcessorImuStaticInitTest, static_bias_zero_initial_guess_aX) +{ + Vector6d body_magnitudes = Vector6d::Zero(); + Vector6d bias_groundtruth = Vector6d::Zero(); + Vector6d bias_initial_guess = (Vector6d() << 0.42, 0, 0, 0, 0, 0).finished(); + + TestStatic(body_magnitudes, bias_groundtruth, bias_initial_guess, "static_bias_zero_initial_guess_aX", 0, true); +} + +TEST_F(ProcessorImuStaticInitTest, static_bias_gX_initial_guess_zero) +{ + Vector6d body_magnitudes = Vector6d::Zero(); + Vector6d bias_groundtruth = (Vector6d() << 0, 0, 0, 0.01, 0, 0).finished(); + Vector6d bias_initial_guess = Vector6d::Zero(); + + TestStatic(body_magnitudes, bias_groundtruth, bias_initial_guess, "static_bias_gX_initial_guess_zero", 0, false); +} + +TEST_F(ProcessorImuStaticInitTest, static_bias_zero_initial_guess_gX) +{ + Vector6d body_magnitudes = Vector6d::Zero(); + Vector6d bias_groundtruth = Vector6d::Zero(); + Vector6d bias_initial_guess = (Vector6d() << 0, 0, 0, 0.01, 0, 0).finished(); + + TestStatic(body_magnitudes, bias_groundtruth, bias_initial_guess, "static_bias_zero_initial_guess_gX", 0, false); +} + +TEST_F(ProcessorImuStaticInitTest, static_bias_aX_initial_guess_zero_zeroodom) +{ + Vector6d body_magnitudes = Vector6d::Zero(); + Vector6d bias_groundtruth = (Vector6d() << 0.42, 0, 0, 0, 0, 0).finished(); + Vector6d bias_initial_guess = Vector6d::Zero(); + + TestStaticZeroOdom(body_magnitudes, bias_groundtruth, bias_initial_guess, "static_bias_aX_initial_guess_zero", 0, true); +} + +TEST_F(ProcessorImuStaticInitTest, static_bias_zero_initial_guess_aX_zeroodom) +{ + Vector6d body_magnitudes = Vector6d::Zero(); + Vector6d bias_groundtruth = Vector6d::Zero(); + Vector6d bias_initial_guess = (Vector6d() << 0.42, 0, 0, 0, 0, 0).finished(); + + TestStaticZeroOdom(body_magnitudes, bias_groundtruth, bias_initial_guess, "static_bias_zero_initial_guess_aX", 0, true); +} + +TEST_F(ProcessorImuStaticInitTest, static_bias_gX_initial_guess_zero_zeroodom) +{ + Vector6d body_magnitudes = Vector6d::Zero(); + Vector6d bias_groundtruth = (Vector6d() << 0, 0, 0, 0.01, 0, 0).finished(); + Vector6d bias_initial_guess = Vector6d::Zero(); + + TestStaticZeroOdom(body_magnitudes, bias_groundtruth, bias_initial_guess, "static_bias_gX_initial_guess_zero", 0, false); +} + +TEST_F(ProcessorImuStaticInitTest, static_bias_zero_initial_guess_gX_zeroodom) +{ + Vector6d body_magnitudes = Vector6d::Zero(); + Vector6d bias_groundtruth = Vector6d::Zero(); + Vector6d bias_initial_guess = (Vector6d() << 0, 0, 0, 0.01, 0, 0).finished(); + + TestStaticZeroOdom(body_magnitudes, bias_groundtruth, bias_initial_guess, "static_bias_zero_initial_guess_gX", 0, false); +} + + +TEST_F(ProcessorImuStaticInitTest, static_bias_zero_initial_guess_a_random) +{ + Vector6d body_magnitudes = Vector6d::Zero(); + Vector6d bias_groundtruth = Vector6d::Zero(); + Vector6d bias_initial_guess = Vector6d::Random()*100; + bias_initial_guess.tail(3) = Vector3d::Zero(); + + TestStatic(body_magnitudes, bias_groundtruth, bias_initial_guess, "static_bias_zero_initial_guess_a_random", 3, true); +} + +TEST_F(ProcessorImuStaticInitTest, static_bias_zero_initial_guess_random) +{ + Vector6d body_magnitudes = Vector6d::Zero(); + Vector6d bias_groundtruth = Vector6d::Zero(); + Vector6d bias_initial_guess = Vector6d::Random()*0.01; + + TestStatic(body_magnitudes, bias_groundtruth, bias_initial_guess, "static_bias_zero_initial_guess_random", 3, false); +} + + +int main(int argc, char **argv) +{ + testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} diff --git a/test/gtest_imu_tools.cpp b/test/gtest_imu_tools.cpp index c2e8306ce5b7d0c6cacafc1ac30f8be0474cf0e9..4053b15f912ef7e5cb4b39181e7a5b81395d0c6a 100644 --- a/test/gtest_imu_tools.cpp +++ b/test/gtest_imu_tools.cpp @@ -1,3 +1,24 @@ +//--------LICENSE_START-------- +// +// Copyright (C) 2020,2021,2022 Institut de Robòtica i Informà tica Industrial, CSIC-UPC. +// Authors: Joan Solà Ortega (jsola@iri.upc.edu) +// All rights reserved. +// +// This file is part of WOLF +// WOLF is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see <http://www.gnu.org/licenses/>. +// +//--------LICENSE_END-------- /* * gtest_imu_tools.cpp * diff --git a/test/gtest_processor_imu.cpp b/test/gtest_processor_imu.cpp index 79db6e39e80ca013f5ea4bc833844984fa69d5c3..6255fa38517be1218fcd6e39647c18e2151974c6 100644 --- a/test/gtest_processor_imu.cpp +++ b/test/gtest_processor_imu.cpp @@ -1,3 +1,24 @@ +//--------LICENSE_START-------- +// +// Copyright (C) 2020,2021,2022 Institut de Robòtica i Informà tica Industrial, CSIC-UPC. +// Authors: Joan Solà Ortega (jsola@iri.upc.edu) +// All rights reserved. +// +// This file is part of WOLF +// WOLF is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see <http://www.gnu.org/licenses/>. +// +//--------LICENSE_END-------- /** * \file gtest_processor_imu.cpp * @@ -144,7 +165,7 @@ TEST(ProcessorImu, voteForKeyFrame) TimeStamp t(0); VectorComposite x0("POV", {Vector3d::Zero(), Quaterniond::Identity().coeffs(), Vector3d::Zero()}); VectorComposite s0("POV", {Vector3d(1,1,1), Vector3d(1,1,1), Vector3d(1,1,1)}); - problem->setPriorFactor(x0, s0, t, 0.01); + problem->setPriorFactor(x0, s0, t); //data variable and covariance matrix // since we integrate only a few times, give the capture a big covariance, otherwise it will be so small that it won't pass following assertions @@ -212,7 +233,7 @@ TEST_F(ProcessorImut, acc_x) MatrixXd P0(9,9); P0.setIdentity(); x0c = VectorComposite("POV", {Vector3d::Zero(), Quaterniond::Identity().coeffs(), Vector3d::Zero()}); s0c = VectorComposite("POV", {Vector3d(1,1,1), Vector3d(1,1,1), Vector3d(1,1,1)}); - problem->setPriorFactor(x0c, s0c, t, 0.01); + problem->setPriorFactor(x0c, s0c, t); // process this capture for joining prior KF (t=0) and set it as origin KF cap_imu_ptr->setTimeStamp(t); cap_imu_ptr->process(); @@ -243,7 +264,7 @@ TEST_F(ProcessorImut, acc_y) MatrixXd P0(9,9); P0.setIdentity(); x0c = VectorComposite("POV", {Vector3d::Zero(), Quaterniond::Identity().coeffs(), Vector3d::Zero()}); s0c = VectorComposite("POV", {Vector3d(1,1,1), Vector3d(1,1,1), Vector3d(1,1,1)}); - problem->setPriorFactor(x0c, s0c, t, 0.01); + problem->setPriorFactor(x0c, s0c, t); // process this capture for joining prior KF (t=0) and set it as origin KF cap_imu_ptr->setTimeStamp(t); cap_imu_ptr->process(); @@ -285,7 +306,7 @@ TEST_F(ProcessorImut, acc_z) MatrixXd P0(9,9); P0.setIdentity(); x0c = VectorComposite("POV", {Vector3d::Zero(), Quaterniond::Identity().coeffs(), Vector3d::Zero()}); s0c = VectorComposite("POV", {Vector3d(1,1,1), Vector3d(1,1,1), Vector3d(1,1,1)}); - problem->setPriorFactor(x0c, s0c, t, 0.01); + problem->setPriorFactor(x0c, s0c, t); // process this capture for joining prior KF (t=0) and set it as origin KF cap_imu_ptr->setTimeStamp(t); cap_imu_ptr->process(); @@ -327,7 +348,7 @@ TEST_F(ProcessorImut, check_Covariance) MatrixXd P0(9,9); P0.setIdentity(); x0c = VectorComposite("POV", {Vector3d::Zero(), Quaterniond::Identity().coeffs(), Vector3d::Zero()}); s0c = VectorComposite("POV", {Vector3d(1,1,1), Vector3d(1,1,1), Vector3d(1,1,1)}); - problem->setPriorFactor(x0c, s0c, t, 0.01); + problem->setPriorFactor(x0c, s0c, t); // process this capture for joining prior KF (t=0) and set it as origin KF cap_imu_ptr->setTimeStamp(t); cap_imu_ptr->process(); @@ -353,7 +374,7 @@ TEST_F(ProcessorImut, gyro_x) MatrixXd P0(9,9); P0.setIdentity(); x0c = VectorComposite("POV", {Vector3d::Zero(), Quaterniond::Identity().coeffs(), Vector3d::Zero()}); s0c = VectorComposite("POV", {Vector3d(1,1,1), Vector3d(1,1,1), Vector3d(1,1,1)}); - problem->setPriorFactor(x0c, s0c, t, 0.01); + problem->setPriorFactor(x0c, s0c, t); // process this capture for joining prior KF (t=0) and set it as origin KF cap_imu_ptr->setTimeStamp(t); cap_imu_ptr->process(); @@ -410,7 +431,7 @@ TEST_F(ProcessorImut, gyro_x_biasedAbx) // init things x0c = VectorComposite("POV", {Vector3d::Zero(), Quaterniond::Identity().coeffs(), Vector3d::Zero()}); s0c = VectorComposite("POV", {Vector3d(1,1,1), Vector3d(1,1,1), Vector3d(1,1,1)}); - problem->setPriorFactor(x0c, s0c, t, 0.01); + problem->setPriorFactor(x0c, s0c, t); // process this capture for joining prior KF (t=0) and set it as origin KF cap_imu_ptr->setTimeStamp(t); cap_imu_ptr->process(); @@ -468,7 +489,7 @@ TEST_F(ProcessorImut, gyro_xy_biasedAbxy) MatrixXd P0(9,9); P0.setIdentity(); x0c = VectorComposite("POV", {Vector3d::Zero(), Quaterniond::Identity().coeffs(), Vector3d::Zero()}); s0c = VectorComposite("POV", {Vector3d(1,1,1), Vector3d(1,1,1), Vector3d(1,1,1)}); - problem->setPriorFactor(x0c, s0c, t, 0.01); + problem->setPriorFactor(x0c, s0c, t); // process this capture for joining prior KF (t=0) and set it as origin KF cap_imu_ptr->setTimeStamp(t); cap_imu_ptr->process(); @@ -524,7 +545,7 @@ TEST_F(ProcessorImut, gyro_z) MatrixXd P0(9,9); P0.setIdentity(); x0c = VectorComposite("POV", {Vector3d::Zero(), Quaterniond::Identity().coeffs(), Vector3d::Zero()}); s0c = VectorComposite("POV", {Vector3d(1,1,1), Vector3d(1,1,1), Vector3d(1,1,1)}); - problem->setPriorFactor(x0c, s0c, t, 0.01); + problem->setPriorFactor(x0c, s0c, t); // process this capture for joining prior KF (t=0) and set it as origin KF cap_imu_ptr->setTimeStamp(t); cap_imu_ptr->process(); @@ -567,7 +588,7 @@ TEST_F(ProcessorImut, gyro_xyz) MatrixXd P0(9,9); P0.setIdentity(); x0c = VectorComposite("POV", {Vector3d::Zero(), Quaterniond::Identity().coeffs(), Vector3d::Zero()}); s0c = VectorComposite("POV", {Vector3d(1,1,1), Vector3d(1,1,1), Vector3d(1,1,1)}); - problem->setPriorFactor(x0c, s0c, t, 0.01); + problem->setPriorFactor(x0c, s0c, t); // process this capture for joining prior KF (t=0) and set it as origin KF cap_imu_ptr->setTimeStamp(t); cap_imu_ptr->process(); @@ -659,7 +680,7 @@ TEST_F(ProcessorImut, gyro_z_ConstVelocity) MatrixXd P0(9,9); P0.setIdentity(); x0c = VectorComposite("POV", {Vector3d::Zero(), Quaterniond::Identity().coeffs(), Vector3d(2,0,0)}); s0c = VectorComposite("POV", {Vector3d(1,1,1), Vector3d(1,1,1), Vector3d(1,1,1)}); - problem->setPriorFactor(x0c, s0c, t, 0.01); + problem->setPriorFactor(x0c, s0c, t); // process this capture for joining prior KF (t=0) and set it as origin KF cap_imu_ptr->setTimeStamp(t); cap_imu_ptr->process(); @@ -703,7 +724,7 @@ TEST_F(ProcessorImut, gyro_x_ConstVelocity) MatrixXd P0(9,9); P0.setIdentity(); x0c = VectorComposite("POV", {Vector3d::Zero(), Quaterniond::Identity().coeffs(), Vector3d(2,0,0)}); s0c = VectorComposite("POV", {Vector3d(1,1,1), Vector3d(1,1,1), Vector3d(1,1,1)}); - problem->setPriorFactor(x0c, s0c, t, 0.01); + problem->setPriorFactor(x0c, s0c, t); // process this capture for joining prior KF (t=0) and set it as origin KF cap_imu_ptr->setTimeStamp(t); cap_imu_ptr->process(); @@ -752,7 +773,7 @@ TEST_F(ProcessorImut, gyro_xy_ConstVelocity) MatrixXd P0(9,9); P0.setIdentity(); x0c = VectorComposite("POV", {Vector3d::Zero(), Quaterniond::Identity().coeffs(), Vector3d(2,0,0)}); s0c = VectorComposite("POV", {Vector3d(1,1,1), Vector3d(1,1,1), Vector3d(1,1,1)}); - problem->setPriorFactor(x0c, s0c, t, 0.01); + problem->setPriorFactor(x0c, s0c, t); // process this capture for joining prior KF (t=0) and set it as origin KF cap_imu_ptr->setTimeStamp(t); cap_imu_ptr->process(); @@ -801,7 +822,7 @@ TEST_F(ProcessorImut, gyro_y_ConstVelocity) MatrixXd P0(9,9); P0.setIdentity(); x0c = VectorComposite("POV", {Vector3d::Zero(), Quaterniond::Identity().coeffs(), Vector3d(2,0,0)}); s0c = VectorComposite("POV", {Vector3d(1,1,1), Vector3d(1,1,1), Vector3d(1,1,1)}); - problem->setPriorFactor(x0c, s0c, t, 0.01); + problem->setPriorFactor(x0c, s0c, t); // process this capture for joining prior KF (t=0) and set it as origin KF cap_imu_ptr->setTimeStamp(t); cap_imu_ptr->process(); @@ -849,7 +870,7 @@ TEST_F(ProcessorImut, gyro_xyz_ConstVelocity) MatrixXd P0(9,9); P0.setIdentity(); x0c = VectorComposite("POV", {Vector3d::Zero(), Quaterniond::Identity().coeffs(), Vector3d(2,0,0)}); s0c = VectorComposite("POV", {Vector3d(1,1,1), Vector3d(1,1,1), Vector3d(1,1,1)}); - problem->setPriorFactor(x0c, s0c, t, 0.01); + problem->setPriorFactor(x0c, s0c, t); // process this capture for joining prior KF (t=0) and set it as origin KF cap_imu_ptr->setTimeStamp(t); cap_imu_ptr->process(); @@ -943,7 +964,7 @@ TEST_F(ProcessorImut, gyro_x_acc_x) MatrixXd P0(9,9); P0.setIdentity(); x0c = VectorComposite("POV", {Vector3d::Zero(), Quaterniond::Identity().coeffs(), Vector3d(0,0,0)}); s0c = VectorComposite("POV", {Vector3d(1,1,1), Vector3d(1,1,1), Vector3d(1,1,1)}); - problem->setPriorFactor(x0c, s0c, t, 0.01); + problem->setPriorFactor(x0c, s0c, t); // process this capture for joining prior KF (t=0) and set it as origin KF cap_imu_ptr->setTimeStamp(t); cap_imu_ptr->process(); @@ -997,7 +1018,7 @@ TEST_F(ProcessorImut, gyro_y_acc_y) MatrixXd P0(9,9); P0.setIdentity(); x0c = VectorComposite("POV", {Vector3d::Zero(), Quaterniond::Identity().coeffs(), Vector3d(0,0,0)}); s0c = VectorComposite("POV", {Vector3d(1,1,1), Vector3d(1,1,1), Vector3d(1,1,1)}); - problem->setPriorFactor(x0c, s0c, t, 0.01); + problem->setPriorFactor(x0c, s0c, t); // process this capture for joining prior KF (t=0) and set it as origin KF cap_imu_ptr->setTimeStamp(t); cap_imu_ptr->process(); @@ -1051,7 +1072,7 @@ TEST_F(ProcessorImut, gyro_z_acc_z) MatrixXd P0(9,9); P0.setIdentity(); x0c = VectorComposite("POV", {Vector3d::Zero(), Quaterniond::Identity().coeffs(), Vector3d(0,0,0)}); s0c = VectorComposite("POV", {Vector3d(1,1,1), Vector3d(1,1,1), Vector3d(1,1,1)}); - problem->setPriorFactor(x0c, s0c, t, 0.01); + problem->setPriorFactor(x0c, s0c, t); // process this capture for joining prior KF (t=0) and set it as origin KF cap_imu_ptr->setTimeStamp(t); cap_imu_ptr->process(); diff --git a/test/gtest_processor_imu2d.cpp b/test/gtest_processor_imu2d.cpp index 4e0084f3002024e2bd04cd9896bcb49e798b8cd7..87c3619d3fbe37425bfc62bb6c0e2b17cfc40d9c 100644 --- a/test/gtest_processor_imu2d.cpp +++ b/test/gtest_processor_imu2d.cpp @@ -1,3 +1,24 @@ +//--------LICENSE_START-------- +// +// Copyright (C) 2020,2021,2022 Institut de Robòtica i Informà tica Industrial, CSIC-UPC. +// Authors: Joan Solà Ortega (jsola@iri.upc.edu) +// All rights reserved. +// +// This file is part of WOLF +// WOLF is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see <http://www.gnu.org/licenses/>. +// +//--------LICENSE_END-------- /** * \file gtest_processor_imu2d.cpp * @@ -113,7 +134,7 @@ TEST_F(ProcessorImu2dTest, Prior) x0c['P'] = Vector2d(1,2); x0c['O'] = Vector1d(0); x0c['V'] = Vector2d(4,5); - auto KF0 = problem->setPriorFix(x0c, t0, dt/2); + auto KF0 = problem->setPriorFix(x0c, t0); processor_motion->setOrigin(KF0); //WOLF_DEBUG("x0 =", x0c); //WOLF_DEBUG("KF0 state =", problem->getTrajectory()->getFrameMap().at(t)->getState("POV")); @@ -127,7 +148,7 @@ TEST_F(ProcessorImu2dTest, MRUA) x0c['P'] = Vector2d(1,2); x0c['O'] = Vector1d(0); x0c['V'] = Vector2d(4,5); - auto KF0 = problem->setPriorFix(x0c, t0, dt/2); + auto KF0 = problem->setPriorFix(x0c, t0); processor_motion->setOrigin(KF0); //WOLF_DEBUG("Current State: ", problem->getState()); @@ -154,7 +175,7 @@ TEST_F(ProcessorImu2dTest, parabola) x0c['V'] = Vector2d(v0, 0); data_cov *= 1e-3; - auto KF0 = problem->setPriorFix(x0c, t0, dt/2); + auto KF0 = problem->setPriorFix(x0c, t0); processor_motion->setOrigin(KF0); for(t = t0+dt; t <= t0 + 0.5 + dt/2; t+=dt){ @@ -184,7 +205,7 @@ TEST_F(ProcessorImu2dTest, parabola_deluxe) x0c['V'] = v0; data_cov *= 1e-3; - auto KF0 = problem->setPriorFix(x0c, t0, dt/2); + auto KF0 = problem->setPriorFix(x0c, t0); processor_motion->setOrigin(KF0); for(t = t0+dt; t <= t0 + 0.5 + dt/2; t+=dt){ @@ -216,7 +237,7 @@ TEST_F(ProcessorImu2dTest, Circular_move) data_cov *= 1e-3; //dt = 0.0001; - auto KF0 = problem->setPriorFix(x0c, t0, dt/2); + auto KF0 = problem->setPriorFix(x0c, t0); processor_motion->setOrigin(KF0); WOLF_DEBUG("Current State: ", problem->getState()); diff --git a/test/gtest_processor_imu_jacobians.cpp b/test/gtest_processor_imu_jacobians.cpp index bc4ff1533c993e8be1b530433527a2e2cb7783d2..929b92569f363af49e92a39a28428f23df500e10 100644 --- a/test/gtest_processor_imu_jacobians.cpp +++ b/test/gtest_processor_imu_jacobians.cpp @@ -1,3 +1,24 @@ +//--------LICENSE_START-------- +// +// Copyright (C) 2020,2021,2022 Institut de Robòtica i Informà tica Industrial, CSIC-UPC. +// Authors: Joan Solà Ortega (jsola@iri.upc.edu) +// All rights reserved. +// +// This file is part of WOLF +// WOLF is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see <http://www.gnu.org/licenses/>. +// +//--------LICENSE_END-------- /** * \file gtest_imu_preintegration_jacobians.cpp * diff --git a/test/gtest_processor_motion_intrinsics_update.cpp b/test/gtest_processor_motion_intrinsics_update.cpp index 4dbac962133c7d8da9f76e152a09e0749c1f2e71..93ba8561b5b4fea55e814cc9d3b68501ae2439ac 100644 --- a/test/gtest_processor_motion_intrinsics_update.cpp +++ b/test/gtest_processor_motion_intrinsics_update.cpp @@ -1,3 +1,24 @@ +//--------LICENSE_START-------- +// +// Copyright (C) 2020,2021,2022 Institut de Robòtica i Informà tica Industrial, CSIC-UPC. +// Authors: Joan Solà Ortega (jsola@iri.upc.edu) +// All rights reserved. +// +// This file is part of WOLF +// WOLF is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see <http://www.gnu.org/licenses/>. +// +//--------LICENSE_END-------- #include <fstream> #include "imu/internal/config.h" @@ -77,7 +98,7 @@ class ProcessorImuTest : public testing::Test params_->time_tolerance = 0.0025; processor_ = std::static_pointer_cast<ProcessorImu>(problem_->installProcessor("ProcessorImu", "processor imu", sensor_, params_)); - KF0_ = problem_->setPriorFactor(x_origin, std_origin, 0, 0.01); + KF0_ = problem_->setPriorFactor(x_origin, std_origin, 0); Vector6d bias; bias << 0.42,0,0, 0,0,0; // Vector6d bias; bias << 0.0,0,0, 0.42,0,0; @@ -155,7 +176,7 @@ TEST_F(ProcessorImuTest, test1) * SET TO TRUE TO PRODUCE CSV FILE * SET TO FALSE TO STOP PRODUCING CSV FILE */ -#define WRITE_CSV_FILE false +#define WRITE_CSV_FILE true TEST_F(ProcessorImuTest, getState) { diff --git a/test/gtest_sensor_compass.cpp b/test/gtest_sensor_compass.cpp index 8b404d2ad88ea63c0d6a6beac32f2a7b31377299..0200128bad102e5b4c50015a4428050bd957d5a7 100644 --- a/test/gtest_sensor_compass.cpp +++ b/test/gtest_sensor_compass.cpp @@ -1,3 +1,24 @@ +//--------LICENSE_START-------- +// +// Copyright (C) 2020,2021,2022 Institut de Robòtica i Informà tica Industrial, CSIC-UPC. +// Authors: Joan Solà Ortega (jsola@iri.upc.edu) +// All rights reserved. +// +// This file is part of WOLF +// WOLF is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see <http://www.gnu.org/licenses/>. +// +//--------LICENSE_END-------- #include "core/utils/utils_gtest.h" #include "imu/internal/config.h" diff --git a/test/processor_imu2d_UnitTester.cpp b/test/processor_imu2d_UnitTester.cpp index 6611c9b1461993fb9fb09268a756d7f13c93f4ec..3412389aa7c251d37aa1f98afe3891e9b9b7374e 100644 --- a/test/processor_imu2d_UnitTester.cpp +++ b/test/processor_imu2d_UnitTester.cpp @@ -1,3 +1,24 @@ +//--------LICENSE_START-------- +// +// Copyright (C) 2020,2021,2022 Institut de Robòtica i Informà tica Industrial, CSIC-UPC. +// Authors: Joan Solà Ortega (jsola@iri.upc.edu) +// All rights reserved. +// +// This file is part of WOLF +// WOLF is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see <http://www.gnu.org/licenses/>. +// +//--------LICENSE_END-------- #include "processor_imu2d_UnitTester.h" namespace wolf { diff --git a/test/processor_imu2d_UnitTester.h b/test/processor_imu2d_UnitTester.h index 30cd61fed36b4b2e74609c7cfc2af748f0f51f38..8dd65887a91947890e6f83aa48c797f5c39cd522 100644 --- a/test/processor_imu2d_UnitTester.h +++ b/test/processor_imu2d_UnitTester.h @@ -1,3 +1,24 @@ +//--------LICENSE_START-------- +// +// Copyright (C) 2020,2021,2022 Institut de Robòtica i Informà tica Industrial, CSIC-UPC. +// Authors: Joan Solà Ortega (jsola@iri.upc.edu) +// All rights reserved. +// +// This file is part of WOLF +// WOLF is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see <http://www.gnu.org/licenses/>. +// +//--------LICENSE_END-------- #ifndef PROCESSOR_IMU2D_UNITTESTER_H #define PROCESSOR_IMU2D_UNITTESTER_H diff --git a/test/processor_imu_UnitTester.cpp b/test/processor_imu_UnitTester.cpp index 71b68efe982fa4c635b1bbf4f068a2101e07fc70..8b6f10f272a0923c67b709ba3676a4b21c95719b 100644 --- a/test/processor_imu_UnitTester.cpp +++ b/test/processor_imu_UnitTester.cpp @@ -1,3 +1,24 @@ +//--------LICENSE_START-------- +// +// Copyright (C) 2020,2021,2022 Institut de Robòtica i Informà tica Industrial, CSIC-UPC. +// Authors: Joan Solà Ortega (jsola@iri.upc.edu) +// All rights reserved. +// +// This file is part of WOLF +// WOLF is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see <http://www.gnu.org/licenses/>. +// +//--------LICENSE_END-------- #include "processor_imu_UnitTester.h" namespace wolf { diff --git a/test/processor_imu_UnitTester.h b/test/processor_imu_UnitTester.h index f9990707cb56f5ec6d1357683aa749503343ca1b..398b69bc28c4be496b3d742750621b4b5e18ea90 100644 --- a/test/processor_imu_UnitTester.h +++ b/test/processor_imu_UnitTester.h @@ -1,3 +1,24 @@ +//--------LICENSE_START-------- +// +// Copyright (C) 2020,2021,2022 Institut de Robòtica i Informà tica Industrial, CSIC-UPC. +// Authors: Joan Solà Ortega (jsola@iri.upc.edu) +// All rights reserved. +// +// This file is part of WOLF +// WOLF is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with this program. If not, see <http://www.gnu.org/licenses/>. +// +//--------LICENSE_END-------- #ifndef PROCESSOR_IMU_UNITTESTER_H #define PROCESSOR_IMU_UNITTESTER_H @@ -108,16 +129,16 @@ namespace wolf { jacobian_delta_ = Eigen::MatrixXd::Zero(9,9); } - Imu_jac_deltas(Imu_jac_deltas const & toCopy){ - - Delta_noisy_vect_ = toCopy.Delta_noisy_vect_; - delta_noisy_vect_ = toCopy.delta_noisy_vect_; - - Delta0_ = toCopy.Delta0_; - delta0_ = toCopy.delta0_; - jacobian_delta_preint_ = toCopy.jacobian_delta_preint_; - jacobian_delta_ = toCopy.jacobian_delta_; - } +// Imu_jac_deltas(Imu_jac_deltas const & toCopy){ +// +// Delta_noisy_vect_ = toCopy.Delta_noisy_vect_; +// delta_noisy_vect_ = toCopy.delta_noisy_vect_; +// +// Delta0_ = toCopy.Delta0_; +// delta0_ = toCopy.delta0_; +// jacobian_delta_preint_ = toCopy.jacobian_delta_preint_; +// jacobian_delta_ = toCopy.jacobian_delta_; +// } public: /*The following vectors will contain all the matrices and deltas needed to compute the finite differences. diff --git a/test/yaml/imu2d_static_init.yaml b/test/yaml/imu2d_static_init.yaml new file mode 100644 index 0000000000000000000000000000000000000000..4978c8e2863908df72a336da1225667411d3022a --- /dev/null +++ b/test/yaml/imu2d_static_init.yaml @@ -0,0 +1,12 @@ +type: "ProcessorImu2d" # This must match the KEY used in the SensorFactory. Otherwise it is an error. + +time_tolerance: 0.0025 # Time tolerance for joining KFs +unmeasured_perturbation_std: 0.0001 + +keyframe_vote: + voting_active: true + voting_aux_active: false + max_time_span: 0.9999 # seconds + max_buff_length: 1000000000 # motion deltas + dist_traveled: 100000000000 # meters + angle_turned: 10000000000 # radians (1 rad approx 57 deg, approx 60 deg) diff --git a/test/yaml/imu_static_init.yaml b/test/yaml/imu_static_init.yaml new file mode 100644 index 0000000000000000000000000000000000000000..46393f30b8f24bf645bfb1272764e6c8915e5dc2 --- /dev/null +++ b/test/yaml/imu_static_init.yaml @@ -0,0 +1,12 @@ +type: "ProcessorImu" # This must match the KEY used in the SensorFactory. Otherwise it is an error. + +time_tolerance: 0.0025 # Time tolerance for joining KFs +unmeasured_perturbation_std: 0.0001 + +keyframe_vote: + voting_active: true + voting_aux_active: false + max_time_span: 0.9999 # seconds + max_buff_length: 1000000000 # motion deltas + dist_traveled: 100000000000 # meters + angle_turned: 10000000000 # radians (1 rad approx 57 deg, approx 60 deg) diff --git a/test/yaml/sensor_imu.yaml b/test/yaml/sensor_imu.yaml new file mode 100644 index 0000000000000000000000000000000000000000..3c78a00d35c785fe73381d8f6ce99a705d27ce77 --- /dev/null +++ b/test/yaml/sensor_imu.yaml @@ -0,0 +1,9 @@ +type: "SensorImu" # This must match the KEY used in the SensorFactory. Otherwise it is an error. + +motion_variances: + a_noise: 0.053 # standard deviation of Acceleration noise (same for all the axis) in m/s2 + w_noise: 0.0011 # standard deviation of Gyroscope noise (same for all the axis) in rad/sec + ab_initial_stdev: 0.800 # m/s2 - initial bias + wb_initial_stdev: 0.350 # rad/sec - initial bias + ab_rate_stdev: 0.1 # m/s2/sqrt(s) + wb_rate_stdev: 0.0400 # rad/s/sqrt(s) diff --git a/test/yaml/sensor_imu2d_static_init.yaml b/test/yaml/sensor_imu2d_static_init.yaml new file mode 100644 index 0000000000000000000000000000000000000000..ce810d4f5f397a7bcb8647e086c026b125fbc936 --- /dev/null +++ b/test/yaml/sensor_imu2d_static_init.yaml @@ -0,0 +1,9 @@ +type: "SensorImu2d" # This must match the KEY used in the SensorFactory. Otherwise it is an error. + +motion_variances: + a_noise: 0.053 # standard deviation of Acceleration noise (same for all the axis) in m/s2 + w_noise: 0.0011 # standard deviation of Gyroscope noise (same for all the axis) in rad/sec + ab_initial_stdev: 0.800 # m/s2 - initial bias + wb_initial_stdev: 0.350 # rad/sec - initial bias + ab_rate_stdev: 0.1 # m/s2/sqrt(s) + wb_rate_stdev: 0.0400 # rad/s/sqrt(s) diff --git a/test/yaml/sensor_imu_static_init.yaml b/test/yaml/sensor_imu_static_init.yaml new file mode 100644 index 0000000000000000000000000000000000000000..700b8d6762b91b38e96391f6032b2c7c4221eabc --- /dev/null +++ b/test/yaml/sensor_imu_static_init.yaml @@ -0,0 +1,9 @@ +type: "SensorImu" # This must match the KEY used in the SensorFactory. Otherwise it is an error. + +motion_variances: + a_noise: 0.001 # standard deviation of Acceleration noise (same for all the axis) in m/s2 + w_noise: 0.001 # standard deviation of Gyroscope noise (same for all the axis) in rad/sec + ab_initial_stdev: 0.001 # m/s2 - initial bias + wb_initial_stdev: 0.001 # rad/sec - initial bias + ab_rate_stdev: 0.001 # m/s2/sqrt(s) + wb_rate_stdev: 0.001 # rad/s/sqrt(s)