Skip to content

Commit

Permalink
[sample] start to generalize samples against linalg backend (#338)
Browse files Browse the repository at this point in the history
  • Loading branch information
FrancoisCarouge authored Jun 15, 2023
1 parent 1d385ea commit 8f0cc91
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 34 deletions.
41 changes: 19 additions & 22 deletions sample/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,6 @@ For more information, please refer to <https://unlicense.org> ]]

include(FetchContent)

FetchContent_Declare(
eigen
GIT_REPOSITORY "https://gitlab.com/libeigen/eigen"
FIND_PACKAGE_ARGS NAMES Eigen3)
FetchContent_MakeAvailable(eigen)

foreach(SAMPLE "kf_1x1x0_building_height.cpp" "kf_1x1x0_liquid_temperature.cpp"
"kf_1x1x1_dog_position.cpp")
get_filename_component(NAME ${SAMPLE} NAME_WE)
Expand All @@ -59,20 +53,23 @@ foreach(SAMPLE "kf_1x1x0_building_height.cpp" "kf_1x1x0_liquid_temperature.cpp"
$<TARGET_FILE:kalman_sample_${NAME}_driver>)
endforeach()

foreach(SAMPLE_EIGEN
"ekf_4x1x0_soaring.cpp" "kf_2x1x1_rocket_altitude.cpp"
"kf_6x2x0_vehicle_location.cpp" "kf_8x4x0_deep_sort_bounding_box.cpp")
get_filename_component(NAME ${SAMPLE_EIGEN} NAME_WE)
add_executable(kalman_sample_eigen_${NAME}_driver ${SAMPLE_EIGEN})
set_target_properties(kalman_sample_eigen_${NAME}_driver
PROPERTIES CXX_STANDARD 23)
set_target_properties(kalman_sample_eigen_${NAME}_driver
PROPERTIES CXX_EXTENSIONS OFF)
target_link_libraries(kalman_sample_eigen_${NAME}_driver
PRIVATE Eigen3::Eigen kalman kalman_main)
add_test(kalman_sample_eigen_${NAME} kalman_sample_eigen_${NAME}_driver)
add_test(
NAME kalman_valgrind_eigen_${NAME}
COMMAND valgrind --error-exitcode=1 --leak-check=full --track-origins=yes
$<TARGET_FILE:kalman_sample_eigen_${NAME}_driver>)
foreach(BACKEND IN ITEMS "eigen")
foreach(SAMPLE
"ekf_4x1x0_soaring.cpp" "kf_2x1x1_rocket_altitude.cpp"
"kf_6x2x0_vehicle_location.cpp" "kf_8x4x0_deep_sort_bounding_box.cpp")
get_filename_component(NAME ${SAMPLE} NAME_WE)
add_executable(kalman_sample_${BACKEND}_${NAME}_driver ${SAMPLE})
set_target_properties(kalman_sample_${BACKEND}_${NAME}_driver
PROPERTIES CXX_STANDARD 23)
set_target_properties(kalman_sample_${BACKEND}_${NAME}_driver
PROPERTIES CXX_EXTENSIONS OFF)
target_link_libraries(kalman_sample_${BACKEND}_${NAME}_driver
PRIVATE kalman kalman_main kalman_linalg_${BACKEND})
add_test(kalman_sample_${BACKEND}_${NAME}
kalman_sample_${BACKEND}_${NAME}_driver)
add_test(
NAME kalman_valgrind_${BACKEND}_${NAME}
COMMAND valgrind --error-exitcode=1 --leak-check=full --track-origins=yes
$<TARGET_FILE:kalman_sample_${BACKEND}_${NAME}_driver>)
endforeach()
endforeach()
5 changes: 2 additions & 3 deletions sample/ekf_4x1x0_soaring.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
#include "fcarouge/kalman.hpp"

#include <Eigen/Eigen>
#include "fcarouge/linalg.hpp"

#include <cassert>
#include <cmath>

namespace fcarouge::sample {
namespace {
template <auto Size> using vector = Eigen::Vector<float, Size>;
template <auto Size> using vector = column_vector<float, Size>;
using state = vector<4>;
using output = float;
using no_input = void;
Expand Down
5 changes: 2 additions & 3 deletions sample/kf_2x1x1_rocket_altitude.cpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
#include "fcarouge/kalman.hpp"

#include <Eigen/Eigen>
#include "fcarouge/linalg.hpp"

#include <cassert>
#include <chrono>
#include <cmath>

namespace fcarouge::sample {
namespace {
template <auto Size> using vector = Eigen::Vector<double, Size>;
template <auto Size> using vector = column_vector<double, Size>;
using state = vector<2>;
using output = double;
using input = double;
Expand Down
5 changes: 2 additions & 3 deletions sample/kf_6x2x0_vehicle_location.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include "fcarouge/kalman.hpp"

#include <Eigen/Eigen>
#include "fcarouge/linalg.hpp"

#include <cassert>
#include <cmath>
Expand All @@ -16,7 +15,7 @@ constexpr auto fcarouge::operator/(const Numerator &lhs, const Denominator &rhs)

namespace fcarouge::sample {
namespace {
template <auto Size> using vector = Eigen::Vector<double, Size>;
template <auto Size> using vector = column_vector<double, Size>;
using state = vector<6>;
using output = vector<2>;
using no_input = void;
Expand Down
5 changes: 2 additions & 3 deletions sample/kf_8x4x0_deep_sort_bounding_box.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include "fcarouge/kalman.hpp"

#include <Eigen/Eigen>
#include "fcarouge/linalg.hpp"

#include <cassert>
#include <cmath>
Expand All @@ -16,7 +15,7 @@ constexpr auto fcarouge::operator/(const Numerator &lhs, const Denominator &rhs)

namespace fcarouge::sample {
namespace {
template <auto Size> using vector = Eigen::Vector<float, Size>;
template <auto Size> using vector = column_vector<float, Size>;
using state = vector<8>;
using output = vector<4>;
using no_input = void;
Expand Down

0 comments on commit 8f0cc91

Please sign in to comment.