imu_model.cpp
Go to the documentation of this file.
1 //=================================================================================================
2 // Copyright (c) 2013, Johannes Meyer, TU Darmstadt
3 // All rights reserved.
4 
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are met:
7 // * Redistributions of source code must retain the above copyright
8 // notice, this list of conditions and the following disclaimer.
9 // * Redistributions in binary form must reproduce the above copyright
10 // notice, this list of conditions and the following disclaimer in the
11 // documentation and/or other materials provided with the distribution.
12 // * Neither the name of the Flight Systems and Automatic Control group,
13 // TU Darmstadt, nor the names of its contributors may be used to
14 // endorse or promote products derived from this software without
15 // specific prior written permission.
16 
17 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18 // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
21 // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 //=================================================================================================
28 
32 
33 namespace hector_pose_estimation {
34 
35 template class System_<GyroModel>;
36 template class System_<AccelerometerModel>;
37 
38 static const Matrix3 MinusIdentity = -Matrix3::Identity();
39 
41 {
42  rate_stddev_ = 1.0 * M_PI/180.0;
43  rate_drift_ = 1.0e-1 * M_PI/180.0;
44  parameters().add("stddev", rate_stddev_);
45  parameters().add("drift", rate_drift_);
46 }
47 
49 {}
50 
51 bool GyroModel::init(PoseEstimation& estimator, System &system, State& state)
52 {
53  bias_ = state.addSubState<3,3>(this, system.getName() + "_bias");
54  return (bias_.get() != 0);
55 }
56 
58 {
59  bias_->block(state.P()) = 3600./2. * pow(rate_drift_, 2) * SymmetricMatrix3::Identity();
60 }
61 
62 void GyroModel::getSystemNoise(NoiseVariance& Q, const State& state, bool init)
63 {
64  if (!init) return;
65  bias_->block(Q)(X,X) = bias_->block(Q)(Y,Y) = pow(rate_drift_, 2);
66  bias_->block(Q)(Z,Z) = pow(rate_drift_, 2);
67 }
68 
69 ColumnVector3 GyroModel::getRate(const ImuInput::RateType& imu_rate, const State& state) const
70 {
71  return imu_rate - bias_->getVector();
72 }
73 
74 void GyroModel::getRateJacobian(SystemMatrixBlock& C, const State& state, bool init)
75 {
76  if (!init) return;
77  bias_->cols(C) = MinusIdentity;
78 }
79 
80 void GyroModel::getRateNoise(CovarianceBlock Q, const State &, bool init)
81 {
82  if (!init) return;
83  Q(X,X) = Q(Y,Y) = Q(Z,Z) = pow(rate_stddev_, 2);
84 }
85 
86 //void GyroModel::getDerivative(StateVector &x_dot, const State &state)
87 //{
88 // x_dot.setZero();
89 // if (state.orientation() && !state.rate()) {
90 // state.orientation()->segment(x_dot).head(3) = state.R() * bias_->vector();
91 // }
92 //}
93 
94 //void GyroModel::getStateJacobian(SystemMatrix& A, const State& state)
95 //{
96 // A.setZero();
97 // if (state.orientation() && !state.rate()) {
98 // state.orientation()->block(A, *bias_) = state.R();
99 // }
100 //}
101 
103 {
104  acceleration_stddev_ = 1.0e-2;
105  acceleration_drift_ = 1.0e-2;
106  parameters().add("stddev", acceleration_stddev_);
107  parameters().add("drift", acceleration_drift_);
108 }
109 
111 {}
112 
113 bool AccelerometerModel::init(PoseEstimation& estimator, System &system, State& state)
114 {
115  bias_ = state.addSubState<3,3>(this, system.getName() + "_bias");
116  return (bias_.get() != 0);
117 }
118 
120 {
121  bias_->block(state.P()) = 3600./2. * pow(acceleration_drift_, 2) * SymmetricMatrix3::Identity();
122 }
123 
124 void AccelerometerModel::getSystemNoise(NoiseVariance& Q, const State&, bool init)
125 {
126  if (!init) return;
127  bias_->block(Q)(X,X) = bias_->block(Q)(Y,Y) = pow(acceleration_drift_, 2);
128  bias_->block(Q)(Z,Z) = pow(acceleration_drift_, 2);
129 }
130 
132 {
133  return imu_acceleration - bias_->getVector();
134 }
135 
136 void AccelerometerModel::getAccelerationJacobian(SystemMatrixBlock& C, const State&, bool init)
137 {
138  if (!init) return;
139  bias_->cols(C) = MinusIdentity;
140 }
141 
142 void AccelerometerModel::getAccelerationNoise(CovarianceBlock Q, const State &, bool init)
143 {
144  if (!init) return;
145  Q(X,X) = Q(Y,Y) = Q(Z,Z) = pow(acceleration_stddev_, 2);
146 }
147 
148 //void AccelerometerModel::getDerivative(StateVector &x_dot, const State &state)
149 //{
150 // x_dot.setZero();
151 // if (state.velocity() && !state.acceleration()) {
152 // if (state.getSystemStatus() & STATE_VELOCITY_XY) {
153 // state.velocity()->segment(x_dot)(X) = bias_nav_.x();
154 // state.velocity()->segment(x_dot)(Y) = bias_nav_.y();
155 // }
156 // if (state.getSystemStatus() & STATE_VELOCITY_Z) {
157 // state.velocity()->segment(x_dot)(Z) = bias_nav_.z();
158 // }
159 // }
160 //}
161 
162 //void AccelerometerModel::getStateJacobian(SystemMatrixBlock& A, const State& state)
163 //{
164 // A.setZero();
165 // if (state.velocity() && !state.acceleration()) {
166 // const State::RotationMatrix &R = state.R();
167 
168 // if (state.getSystemStatus() & STATE_VELOCITY_XY) {
169 // state.velocity()->block(A, *bias_).row(X) = R.row(X);
170 // state.velocity()->block(A, *bias_).row(Y) = R.row(Y);
171 // }
172 // if (state.getSystemStatus() & STATE_VELOCITY_Z) {
173 // state.velocity()->block(A, *bias_).row(Z) = R.row(Z);
174 // }
175 
176 // if (state.getSystemStatus() & STATE_VELOCITY_XY) {
177 // state.velocity()->block(A, *state.orientation())(X,X) = 0.0;
178 // state.velocity()->block(A, *state.orientation())(X,Y) = bias_nav_.z();
179 // state.velocity()->block(A, *state.orientation())(X,Z) = -bias_nav_.y();
180 
181 // state.velocity()->block(A, *state.orientation())(Y,X) = -bias_nav_.z();
182 // state.velocity()->block(A, *state.orientation())(Y,Y) = 0.0;
183 // state.velocity()->block(A, *state.orientation())(Y,Z) = bias_nav_.x();
184 // }
185 
186 // if (state.getSystemStatus() & STATE_VELOCITY_Z) {
187 // state.velocity()->block(A, *state.orientation())(Z,X) = bias_nav_.y();
188 // state.velocity()->block(A, *state.orientation())(Z,Y) = -bias_nav_.x();
189 // state.velocity()->block(A, *state.orientation())(Z,Z) = 0.0;
190 // }
191 // }
192 //}
193 
194 } // namespace hector_pose_estimation
boost::shared_ptr< SubState_< SubVectorDimension, SubCovarianceDimension > > addSubState(const std::string &name=std::string())
void getSystemNoise(NoiseVariance &Q, const State &state, bool init=true)
Definition: imu_model.cpp:62
void getRateNoise(CovarianceBlock Q, const State &state, bool init=true)
Definition: imu_model.cpp:80
ColumnVector3 getAcceleration(const ImuInput::AccelerationType &imu_acceleration, const State &state) const
Definition: imu_model.cpp:131
virtual const std::string & getName() const
Definition: system.h:52
void getAccelerationJacobian(SystemMatrixBlock &C, const State &state, bool init=true)
Definition: imu_model.cpp:136
bool init(PoseEstimation &estimator, System &system, State &state)
Definition: imu_model.cpp:113
void getAccelerationNoise(CovarianceBlock Q, const State &state, bool init=true)
Definition: imu_model.cpp:142
bool init(PoseEstimation &estimator, System &system, State &state)
Definition: imu_model.cpp:51
void getSystemNoise(NoiseVariance &Q, const State &state, bool init=true)
Definition: imu_model.cpp:124
ParameterList & add(const std::string &key, T &value, const T &default_value)
Definition: parameters.h:148
ParameterList & parameters()
Definition: model.h:47
Matrix_< 3, 3 >::type Matrix3
Definition: matrix.h:80
virtual Covariance & P()
Definition: state.h:93
Vector::ConstFixedSegmentReturnType< 3 >::Type AccelerationType
Definition: imu_input.h:50
static const Matrix3 MinusIdentity
Definition: imu_model.cpp:38
ColumnVector3 getRate(const ImuInput::RateType &imu_rate, const State &state) const
Definition: imu_model.cpp:69
void getRateJacobian(SystemMatrixBlock &C, const State &state, bool init=true)
Definition: imu_model.cpp:74
ColumnVector_< 3 >::type ColumnVector3
Definition: matrix.h:59
Vector::ConstFixedSegmentReturnType< 3 >::Type RateType
Definition: imu_input.h:51


hector_pose_estimation_core
Author(s): Johannes Meyer
autogenerated on Thu Feb 18 2021 03:29:30