HumanSystemModel.cpp
Go to the documentation of this file.
1#include "HumanSystemModel.h"
2
4{
5
6 // ------------------------------ SO2xR2 -----------------------------------------
7
8 template <typename floatT>
11 {
12 ObsT observation;
13 observation.segment(0, 1) = state.orientation.log().coeffs();
14 observation.segment(1, 2) = state.position;
15 return observation;
16 }
17
18 template <typename floatT>
23 FloatT dt)
24 {
25 StateT new_state;
26 new_state.orientation = state.orientation.template rplus(control.angular_velocity * dt);
27 new_state.position = state.position + control.euclidean_velocity * dt;
28 //new_state.position =
29 // state.position + state.orientation.rotation() * control.euclidean_velocity * dt;
30 return new_state;
31 }
32
33 template <typename floatT>
36 const SystemModelSO2xR2::SigmaPointsT& sigmaPoints)
37 {
38 StateT new_state;
39 manif::SO2Tangent<FloatT> tan;
40 tan.coeffs() << sigmaPoints.segment(0, 1);
41 //new_state.orientation = state.orientation.lplus(tan);
42 new_state.orientation = state.orientation.rplus(tan);
43
44 new_state.position = state.position + sigmaPoints.segment(1, 2);
45 return new_state;
46 }
47
48 template <typename floatT>
51 const SystemModelSO2xR2::StateT& state2)
52 {
53 SigmaPointsT sigma;
54 // TODO: check if right order of substraction
55
56 //sigma.segment(0, 1) = state2.orientation.lminus(state1.orientation).coeffs();
57 sigma.segment(0, 1) = state1.orientation.lminus(state2.orientation).coeffs();
58
59 sigma.segment(1, 2) = state1.position - state2.position;
60 //sigma.segment(1, 2) = state2.position - state1.position;
61
62 return sigma;
63 }
64
65 template struct SystemModelSO2xR2<float>;
66 template struct SystemModelSO2xR2<double>;
67
68 // ------------------------------ SE2 -----------------------------------------
69
70 template <typename floatT>
73 {
74 ObsT observation = state.pose.log().coeffs();
75 return observation;
76 }
77
78 template <typename floatT>
83 FloatT dt)
84 {
85 StateT new_state;
86 new_state.pose = state.pose.template rplus(control.velocity * dt);
87 return new_state;
88 }
89
90 template <typename floatT>
93 const SystemModelSE2::SigmaPointsT& sigmaPoints)
94 {
95 StateT new_state;
96 manif::SE2Tangent<FloatT> tan;
97 tan.coeffs() << sigmaPoints;
98 new_state.pose = state.pose.lplus(tan);
99 return new_state;
100 }
101
102 template <typename floatT>
105 const SystemModelSE2::StateT& state2)
106 {
107 SigmaPointsT sigma;
108 sigma = state2.pose.lminus(state1.pose).coeffs();
109 return sigma;
111
112 template struct SystemModelSE2<float>;
113 template struct SystemModelSE2<double>;
114
115 // ------------------------------ SE2xV -----------------------------------------
116
117 template <typename floatT>
120 {
121 ObsT observation = state.pose.log().coeffs();
122 return observation;
123 }
124
125 template <typename floatT>
130 FloatT dt)
131 {
132 StateT new_state;
133 new_state.pose = state.pose.template rplus(state.velocity * dt);
134 new_state.velocity = state.velocity;
135 return new_state;
136 }
137
138 template <typename floatT>
141 const SystemModelSE2xV::SigmaPointsT& sigmaPoints)
142 {
143 StateT new_state;
144 manif::SE2Tangent<FloatT> tan;
145 tan.coeffs() << sigmaPoints.segment(0, 3);
146 new_state.pose = state.pose.lplus(tan);
147 tan.coeffs() << sigmaPoints.segment(3, 3);
148 // TODO: this is probably not correct, i.e. there needs to be some interaction between velocity and pose
149 new_state.velocity += tan;
150 return new_state;
151 }
152
153 template <typename floatT>
156 const SystemModelSE2xV::StateT& state2)
157 {
158 SigmaPointsT sigma;
159 sigma.template segment<3>(0) = state2.pose.lminus(state1.pose).coeffs();
160 // TODO: this is probably not correct; probably one cannot subtract two tangent vectors at two different poses
161 // from each other
162 sigma.template segment<3>(3) = (state2.velocity - state1.velocity).coeffs();
163 return sigma;
164 }
165
166 template struct SystemModelSE2xV<float>;
167 template struct SystemModelSE2xV<double>;
168
169} // namespace armarx::navigation::human::kalman_filter
constexpr T dt
This file is part of ArmarX.
static SigmaPointsT inverseRetraction(const StateT &state1, const StateT &state2)
static StateT retraction(const StateT &state, const SigmaPointsT &sigmaPoints)
static StateT propagationFunction(const StateT &state, const ControlT &control, const ControlNoiseT &noise, FloatT dt)
Eigen::Matrix< FloatT, dim::state, 1 > SigmaPointsT
Eigen:: Matrix< FloatT, dim::control, 1 > ControlNoiseT
static SigmaPointsT inverseRetraction(const StateT &state1, const StateT &state2)
static StateT retraction(const StateT &state, const SigmaPointsT &sigmaPoints)
static StateT propagationFunction(const StateT &state, const ControlT &control, const ControlNoiseT &noise, FloatT dt)
Eigen:: Matrix< FloatT, dim::control, 1 > ControlNoiseT
static SigmaPointsT inverseRetraction(const StateT &state1, const StateT &state2)
static StateT propagationFunction(const StateT &state, const ControlT &control, const ControlNoiseT &noise, FloatT dt)
static StateT retraction(const StateT &state, const SigmaPointsT &sigmaPoints)
Eigen:: Matrix< FloatT, dim::control, 1 > ControlNoiseT