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 
69  // ------------------------------ SE2 -----------------------------------------
70 
71  template <typename floatT>
74  {
75  ObsT observation = state.pose.log().coeffs();
76  return observation;
77  }
78 
79  template <typename floatT>
83  const SystemModelSE2::ControlNoiseT& noise,
84  FloatT dt)
85  {
86  StateT new_state;
87  new_state.pose = state.pose.template rplus(control.velocity * dt);
88  return new_state;
89  }
90 
91  template <typename floatT>
94  const SystemModelSE2::SigmaPointsT& sigmaPoints)
95  {
96  StateT new_state;
97  manif::SE2Tangent<FloatT> tan;
98  tan.coeffs() << sigmaPoints;
99  new_state.pose = state.pose.lplus(tan);
100  return new_state;
101  }
102 
103  template <typename floatT>
106  const SystemModelSE2::StateT& state2)
107  {
108  SigmaPointsT sigma;
109  sigma = state2.pose.lminus(state1.pose).coeffs();
110  return sigma;
111  }
112 
113  template struct SystemModelSE2<float>;
114  template struct SystemModelSE2<double>;
115 
116 
117  // ------------------------------ SE2xV -----------------------------------------
118 
119  template <typename floatT>
122  {
123  ObsT observation = state.pose.log().coeffs();
124  return observation;
125  }
126 
127  template <typename floatT>
131  const SystemModelSE2xV::ControlNoiseT& noise,
132  FloatT dt)
133  {
134  StateT new_state;
135  new_state.pose = state.pose.template rplus(state.velocity * dt);
136  new_state.velocity = state.velocity;
137  return new_state;
138  }
139 
140  template <typename floatT>
143  const SystemModelSE2xV::SigmaPointsT& sigmaPoints)
144  {
145  StateT new_state;
146  manif::SE2Tangent<FloatT> tan;
147  tan.coeffs() << sigmaPoints.segment(0, 3);
148  new_state.pose = state.pose.lplus(tan);
149  tan.coeffs() << sigmaPoints.segment(3, 3);
150  // TODO: this is probably not correct, i.e. there needs to be some interaction between velocity and pose
151  new_state.velocity += tan;
152  return new_state;
153  }
154 
155  template <typename floatT>
158  const SystemModelSE2xV::StateT& state2)
159  {
160  SigmaPointsT sigma;
161  sigma.segment(0, 3) = state2.pose.lminus(state1.pose).coeffs();
162  // TODO: this is probably not correct; probably one cannot subtract two tangent vectors at two different poses
163  // from each other
164  sigma.segment(3, 3) = (state2.velocity - state1.velocity).coeffs();
165  return sigma;
166  }
167 
168  template struct SystemModelSE2xV<float>;
169  template struct SystemModelSE2xV<double>;
170 
171 } // namespace armarx::navigation::human::kalman_filter
armarx::navigation::human::kalman_filter::StateSO2xR2
Definition: HumanSystemModel.h:32
armarx::navigation::human::kalman_filter::SystemModelSE2xV::propagationFunction
static StateT propagationFunction(const StateT &state, const ControlT &control, const ControlNoiseT &noise, FloatT dt)
Definition: HumanSystemModel.cpp:129
armarx::navigation::human::kalman_filter::SystemModelSE2
Definition: HumanSystemModel.h:93
armarx::navigation::human::kalman_filter::SystemModelSE2xV
Definition: HumanSystemModel.h:140
armarx::navigation::human::kalman_filter::StateSE2xV::pose
manif::SE2< floatT > pose
Definition: HumanSystemModel.h:130
armarx::navigation::human::kalman_filter::SystemModelSO2xR2::observationFunction
static ObsT observationFunction(const StateT &state)
Definition: HumanSystemModel.cpp:10
armarx::navigation::human::kalman_filter::SystemModelSE2xV::observationFunction
static ObsT observationFunction(const StateT &state)
Definition: HumanSystemModel.cpp:121
armarx::navigation::human::kalman_filter::SystemModelSE2::observationFunction
static ObsT observationFunction(const StateT &state)
Definition: HumanSystemModel.cpp:73
armarx::navigation::human::kalman_filter::SystemModelSO2xR2
Definition: HumanSystemModel.h:46
armarx::navigation::human::kalman_filter::StateSE2xV::velocity
manif::SE2< floatT >::Tangent velocity
Definition: HumanSystemModel.h:131
armarx::navigation::human::kalman_filter::SystemModelSE2xV::retraction
static StateT retraction(const StateT &state, const SigmaPointsT &sigmaPoints)
Definition: HumanSystemModel.cpp:142
armarx::navigation::human::kalman_filter::SystemModelSE2::propagationFunction
static StateT propagationFunction(const StateT &state, const ControlT &control, const ControlNoiseT &noise, FloatT dt)
Definition: HumanSystemModel.cpp:81
armarx::navigation::human::kalman_filter::SystemModelSE2::FloatT
floatT FloatT
Definition: HumanSystemModel.h:101
armarx::navigation::human::kalman_filter::StateSO2xR2::position
Eigen::Matrix< floatT, 2, 1 > position
Definition: HumanSystemModel.h:35
armarx::navigation::human::kalman_filter::StateSO2xR2::orientation
manif::SO2< floatT > orientation
Definition: HumanSystemModel.h:34
armarx::navigation::human::kalman_filter::SystemModelSE2xV::inverseRetraction
static SigmaPointsT inverseRetraction(const StateT &state1, const StateT &state2)
Definition: HumanSystemModel.cpp:157
armarx::navigation::human::kalman_filter::StateSE2xV
Definition: HumanSystemModel.h:128
armarx::navigation::human::kalman_filter::SystemModelSE2::retraction
static StateT retraction(const StateT &state, const SigmaPointsT &sigmaPoints)
Definition: HumanSystemModel.cpp:93
armarx::navigation::human::kalman_filter::SystemModelSO2xR2::propagationFunction
static StateT propagationFunction(const StateT &state, const ControlT &control, const ControlNoiseT &noise, FloatT dt)
Definition: HumanSystemModel.cpp:20
armarx::navigation::human::kalman_filter::StateSE2
Definition: HumanSystemModel.h:81
armarx::navigation::human::kalman_filter::SystemModelSE2xV::FloatT
floatT FloatT
Definition: HumanSystemModel.h:148
armarx::navigation::human::kalman_filter::ControlSE2xV
Definition: HumanSystemModel.h:135
armarx::navigation::human::kalman_filter::ControlSO2xR2
Definition: HumanSystemModel.h:39
armarx::navigation::human::kalman_filter::SystemModelSE2::inverseRetraction
static SigmaPointsT inverseRetraction(const StateT &state1, const StateT &state2)
Definition: HumanSystemModel.cpp:105
armarx::navigation::human::kalman_filter::ControlSE2
Definition: HumanSystemModel.h:87
armarx::navigation::human::kalman_filter::SystemModelSO2xR2::inverseRetraction
static SigmaPointsT inverseRetraction(const StateT &state1, const StateT &state2)
Definition: HumanSystemModel.cpp:50
armarx::navigation::human::kalman_filter::StateSE2::pose
manif::SE2< floatT > pose
Definition: HumanSystemModel.h:83
Eigen::Matrix
Definition: EigenForwardDeclarations.h:27
armarx::navigation::human::kalman_filter
This file is part of ArmarX.
Definition: HumanSystemModel.cpp:3
control
This file is part of ArmarX.
armarx::navigation::human::kalman_filter::SystemModelSO2xR2::FloatT
floatT FloatT
Definition: HumanSystemModel.h:54
HumanSystemModel.h
armarx::navigation::human::kalman_filter::SystemModelSO2xR2::retraction
static StateT retraction(const StateT &state, const SigmaPointsT &sigmaPoints)
Definition: HumanSystemModel.cpp:35
dt
constexpr T dt
Definition: UnscentedKalmanFilterTest.cpp:42