MCPcopy Create free account
hub / github.com/TUC-ProAut/libRSF / marginalizeStates

Method marginalizeStates

src/FactorGraph.cpp:242–350  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

240 }
241
242 bool FactorGraph::marginalizeStates(std::vector<StateID> States, const double Inflation)
243 {
244 /** time measurement */
245 Timer MargTimer;
246
247 /**check if state vector has been filled */
248 if (States.empty() == true)
249 {
250 PRINT_ERROR("Request for marginalization without any state.");
251 return false;
252 }
253
254 std::vector<double*> MarginalStates;
255 int MarginalSize = 0;
256 for (const StateID &State : States)
257 {
258 /** check if this is a set of valid states */
259 if (this->_StateData.checkElement(State.ID, State.Timestamp, State.Number) == false)
260 {
261 PRINT_ERROR("State doesn't exist at: ", State.Timestamp, " Type: ", State.ID, " Number: ", State.Number);
262 return false;
263 }
264
265 /** store pointer */
266 MarginalStates.push_back(_StateData.getElement(State.ID, State.Timestamp, State.Number).getMeanPointer());
267
268 /** compute size of the marginalized system */
269 MarginalSize += _Graph.ParameterBlockLocalSize(MarginalStates.back());
270 }
271
272 /** get connected states */
273 std::vector<double*> ConnectedStates;
274 std::vector<ceres::ResidualBlockId> Factors;
275 std::vector<int> GlobalSize;
276 std::vector<int> LocalSize;
277 std::vector<StateID> StateIDs;
278 std::vector<DataType> StateTypes;
279 _Structure.getMarginalizationInfo(MarginalStates, ConnectedStates, Factors, GlobalSize, LocalSize, StateIDs, StateTypes);
280
281 if (ConnectedStates.empty() == false)
282 {
283 /** calculate mean and uncertainty*/
284 ceres::Problem::EvaluateOptions Options;
285 Options.apply_loss_function = true;
286 Options.num_threads = std::thread::hardware_concurrency();
287
288 /** set which states should be evaluated (base + the connected ones) */
289 std::vector<double*> CombinedStates;
290 CombinedStates.insert(CombinedStates.end(), MarginalStates.begin(), MarginalStates.end());
291 CombinedStates.insert(CombinedStates.end(), ConnectedStates.begin(), ConnectedStates.end());
292 Options.parameter_blocks = CombinedStates;
293
294 /** set which factors should be evaluated */
295 Options.residual_blocks = Factors;
296
297 /** evaluate sub-problem */
298 ceres::CRSMatrix JacobianCRS;
299 std::vector<double> ResidualVec;

Callers 2

marginalizeStateMethod · 0.95

Calls 12

removeStateMethod · 0.95
CRSToMatrixFunction · 0.85
MarginalizeFunction · 0.85
emptyMethod · 0.80
getMeanPointerMethod · 0.80
getElementMethod · 0.80
endMethod · 0.80
beginMethod · 0.80
getSecondsMethod · 0.80
checkElementMethod · 0.45
EvaluateMethod · 0.45

Tested by

no test coverage detected