14 #ifndef PARKING_PLANNER__RUNGEKUTTA_HPP_ 15 #define PARKING_PLANNER__RUNGEKUTTA_HPP_ 30 namespace parking_planner
37 std::vector<T>
operator+(
const std::vector<T> & vector1,
const std::vector<T> & vector2)
39 std::vector<T> result = {};
40 result.reserve(vector1.size());
41 for (std::size_t k = 0; k < vector2.size(); k++) {
42 result.push_back(vector1[k] + vector2[k]);
48 std::vector<T>
operator*(
const T & scalar,
const std::vector<T> & vector)
50 std::vector<T> result = {};
51 result.reserve(vector.size());
52 for (std::size_t k = 0; k < vector.size(); k++) {
53 result.push_back(scalar * vector[k]);
61 template<
class X,
class U,
typename P>
62 X
RK4(X
x, U
u, P p, std::function<X(X, U, P)>
f,
const float64_t stepsize,
const std::size_t steps)
64 const auto dt = stepsize /
static_cast<float64_t>(steps);
65 for (std::size_t k = 0; k < steps; ++k) {
66 const auto k1 =
f(x, u, p);
67 const auto k2 =
f(x + (dt / 2.0) * k1, u, p);
68 const auto k3 =
f(x + (dt / 2.0) * k2, u, p);
69 const auto k4 =
f(x + dt * k3, u, p);
70 const auto xnext = x + (dt / 6.0) * (k1 + (2.0 * k2) + (2.0 * k3) + k4);
80 template<
class X,
class U>
81 X
RK4(X x, U u, std::function<X(X, U)>
f,
const float64_t stepsize,
const std::size_t steps)
84 const std::function<X(X, U, uint8_t)> shim = [&
f](X xx, U uu, uint8_t pp) {
85 (void)&pp;
return f(xx, uu);
88 return RK4(x, u, {}, shim, stepsize, steps);
96 #endif // PARKING_PLANNER__RUNGEKUTTA_HPP_ double float64_t
Definition: types.hpp:37
DifferentialEquation f
Definition: kinematic_bicycle.snippet.hpp:44
T
Definition: catr_diff.py:22
DifferentialState u
Definition: kinematic_bicycle.snippet.hpp:29
This file includes common type definition.
std::vector< T > operator*(const T &scalar, const std::vector< T > &vector)
Definition: rungekutta.hpp:48
DifferentialState x
Definition: kinematic_bicycle.snippet.hpp:28
Definition: controller_base.hpp:30
X RK4(X x, U u, P p, std::function< X(X, U, P)> f, const float64_t stepsize, const std::size_t steps)
Template for an explicit Runge-Kutta integrator. CasADi has its own, but it for some reason doesn't c...
Definition: rungekutta.hpp:62
std::vector< T > operator+(const std::vector< T > &vector1, const std::vector< T > &vector2)
Definition: rungekutta.hpp:37
This file defines the lanelet2_map_provider_node class.
Definition: quick_sort.hpp:24