Skip to content

Commit

Permalink
[msvc] fix compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
FrancoisCarouge committed Jul 24, 2022
1 parent e752abd commit 8d0ceda
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 20 deletions.
23 changes: 10 additions & 13 deletions include/fcarouge/internal/kalman.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,9 @@ struct kalman<State, Output, void, Transpose, Symmetrize, Divide, Identity,
//! does the compiler/linker do it for us?
//! @todo Do we want to support extended custom y = output_difference(z,
//! observation(x))?
template <typename... Outputs>
inline constexpr void update(const UpdateTypes &...arguments,
const auto &...output_z)
const Outputs &...output_z)
{
const auto i{ identity.template operator()<estimate_uncertainty>() };

Expand All @@ -207,9 +208,10 @@ struct kalman<State, Output, void, Transpose, Symmetrize, Divide, Identity,
p = symmetrize(estimate_uncertainty{ f * p * transpose(f) + q });
}

template <typename... Outputs>
inline constexpr void
operator()(const PredictionTypes &...prediction_arguments,
const UpdateTypes &...update_arguments, const auto &...output_z)
const UpdateTypes &...update_arguments, const Outputs &...output_z)
{
update(update_arguments..., output_z...);
predict(prediction_arguments...);
Expand Down Expand Up @@ -341,8 +343,9 @@ struct kalman<State, Output, Input, Transpose, Symmetrize, Divide, Identity,
//! does the compiler/linker do it for us?
//! @todo Do we want to support extended custom y = output_difference(z,
//! observation(x))?
template <typename... Outputs>
inline constexpr void update(const UpdateTypes &...arguments,
const auto &...output_z)
const Outputs &...output_z)
{
const auto i{ identity.template operator()<estimate_uncertainty>() };

Expand All @@ -363,8 +366,9 @@ struct kalman<State, Output, Input, Transpose, Symmetrize, Divide, Identity,
//! input pack to the function?
//! @todo Should input U be passed to noise process Q compute? Probably?
//! @todo How to extended next state x = f * x + g * u?
template <typename... Inputs>
inline constexpr void predict(const PredictionTypes &...arguments,
const auto &...input_u)
const Inputs &...input_u)
{
u = input{ input_u... };
f = transition_state_f(x, arguments..., u);
Expand All @@ -374,17 +378,10 @@ struct kalman<State, Output, Input, Transpose, Symmetrize, Divide, Identity,
p = symmetrize(estimate_uncertainty{ f * p * transpose(f) + q });
}

inline constexpr void predict(const PredictionTypes &...arguments)
{
f = transition_state_f(x, arguments..., input{});
q = noise_process_q(x, arguments...);
x = transition(x, arguments...);
p = symmetrize(estimate_uncertainty{ f * p * transpose(f) + q });
}

template <typename... Inputs>
inline constexpr void
operator()(const PredictionTypes &...prediction_arguments,
const UpdateTypes &...update_arguments, const auto &...input_u,
const UpdateTypes &...update_arguments, const Inputs &...input_u,
const auto &...output_z)
{
update(update_arguments..., output_z...);
Expand Down
5 changes: 3 additions & 2 deletions test/f.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ namespace
kalman k;
const auto i5x5{ Eigen::Matrix<double, 5, 5>::Identity() };
const auto z5x5{ Eigen::Matrix<double, 5, 5>::Zero() };
const Eigen::Matrix<double, 3, 1> z3x1{ Eigen::Matrix<double, 3, 1>::Zero() };

assert(k.f() == i5x5);

Expand Down Expand Up @@ -152,7 +153,7 @@ namespace
} };
k.f(f);
assert(k.f() == z5x5);
k.predict(0, 0, 0.f, 0.);
k.predict(char(0), 0, 0.f, 0., z3x1);
assert(k.f() == i5x5);
}

Expand All @@ -170,7 +171,7 @@ namespace
} };
k.f(std::move(f));
assert(k.f() == i5x5);
k.predict(0, 0, 0.f, 0.);
k.predict(0, 0, 0.f, 0., z3x1);
assert(k.f() == z5x5);
}

Expand Down
11 changes: 6 additions & 5 deletions test/h.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ namespace
{
//! @test Verifies the observation transition matrix H management overloads for
//! the default filter type.
[[maybe_unused]] auto h111{ [] {
[[maybe_unused]] auto h110{ [] {
fcarouge::kalman k;
using kalman = decltype(k);

Expand Down Expand Up @@ -83,7 +83,7 @@ namespace
} };
k.h(h);
assert(k.h() == 5);
k.update(0.);
k.update();
assert(k.h() == 6);
}

Expand All @@ -94,7 +94,7 @@ namespace
} };
k.h(std::move(h));
assert(k.h() == 6);
k.update(0.);
k.update();
assert(k.h() == 7);
}

Expand All @@ -111,6 +111,7 @@ namespace
kalman k;
const auto i4x5{ Eigen::Matrix<double, 4, 5>::Identity() };
const auto z4x5{ Eigen::Matrix<double, 4, 5>::Zero() };
const Eigen::Matrix<double, 4, 1> z4x1{ Eigen::Matrix<double, 4, 1>::Zero() };

assert(k.h() == i4x5);

Expand Down Expand Up @@ -150,7 +151,7 @@ namespace
} };
k.h(h);
assert(k.h() == z4x5);
k.update(0., 0.f, 0, 0);
k.update(0., 0.f, 0, char(0), z4x1);
assert(k.h() == i4x5);
}

Expand All @@ -166,7 +167,7 @@ namespace
} };
k.h(std::move(h));
assert(k.h() == i4x5);
k.update(0., 0.f, 0, 0);
k.update(0., 0.f, 0, char(0), z4x1);
assert(k.h() == z4x5);
}

Expand Down

0 comments on commit 8d0ceda

Please sign in to comment.