2009-08-22 06:23:24 +08:00
|
|
|
/**
|
|
|
|
* @file Ordering.h
|
|
|
|
* @brief Ordering of indices for eliminating a factor graph
|
|
|
|
* @author Frank Dellaert
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2009-10-31 23:24:22 +08:00
|
|
|
#include <list>
|
2009-08-22 06:23:24 +08:00
|
|
|
#include <string>
|
2010-01-07 16:00:54 +08:00
|
|
|
#include <map>
|
2009-10-31 23:24:22 +08:00
|
|
|
#include "Testable.h"
|
2009-08-22 06:23:24 +08:00
|
|
|
|
|
|
|
namespace gtsam {
|
|
|
|
|
|
|
|
/**
|
2009-10-07 02:01:40 +08:00
|
|
|
* @class Ordering
|
|
|
|
* @brief ordering of indices for eliminating a factor graph
|
2009-08-22 06:23:24 +08:00
|
|
|
*/
|
2009-10-31 23:24:22 +08:00
|
|
|
class Ordering: public std::list<std::string>, public Testable<Ordering> {
|
2009-10-07 02:01:40 +08:00
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* Default constructor creates empty ordering
|
|
|
|
*/
|
|
|
|
Ordering() {
|
|
|
|
}
|
|
|
|
|
2009-11-09 06:51:29 +08:00
|
|
|
/**
|
|
|
|
* Create from a single string
|
|
|
|
*/
|
|
|
|
Ordering(std::string key) {
|
|
|
|
push_back(key);
|
|
|
|
}
|
|
|
|
|
2009-10-07 02:01:40 +08:00
|
|
|
/**
|
|
|
|
* Copy constructor from string vector
|
|
|
|
*/
|
2009-10-31 23:24:22 +08:00
|
|
|
Ordering(const std::list<std::string>& strings_in) :
|
|
|
|
std::list<std::string>(strings_in) {
|
2009-10-07 02:01:40 +08:00
|
|
|
}
|
|
|
|
|
2010-01-07 16:00:54 +08:00
|
|
|
/**
|
|
|
|
* Generate the ordering from a spanning tree represented by its parent map
|
|
|
|
*/
|
Large gtsam refactoring
To support faster development *and* better performance Richard and I pushed through a large refactoring of NonlinearFactors.
The following are the biggest changes:
1) NonLinearFactor1 and NonLinearFactor2 are now templated on Config, Key type, and X type, where X is the argument to the measurement function.
2) The measurement itself is no longer kept in the nonlinear factor. Instead, a derived class (see testVSLAMFactor, testNonlinearEquality, testPose3Factor etc...) has to implement a function to compute the errors, "evaluateErrors". Instead of (h(x)-z), it needs to return (z-h(x)), so Ax-b is an approximation of the error. IMPORTANT: evaluateErrors needs - if asked - *combine* the calculation of the function value h(x) and the derivatives dh(x)/dx. This was a major performance issue. To do this, boost::optional<Matrix&> arguments are provided, and tin EvaluateErrors you just says something like
if (H) *H = Matrix_(3,6,....);
3) We are no longer using int or strings for nonlinear factors. Instead, the preferred key type is now Symbol, defined in Key.h. This is both fast and cool: you can construct it from an int, and cast it to a strong. It also does type checking: a Symbol<Pose3,'x'> will not match a Symbol<Pose2,'x'>
4) minor: take a look at LieConfig.h: it help you avoid writing a lot of code bu automatically creating configs for a certain type. See e.g. Pose3Config.h. A "double" LieConfig is on the way - Thanks Richard and Manohar !
2010-01-14 06:25:03 +08:00
|
|
|
//Ordering(const std::map<std::string, std::string>& p_map);
|
2010-01-07 16:00:54 +08:00
|
|
|
|
2009-11-29 02:35:36 +08:00
|
|
|
/**
|
|
|
|
* Remove a set of keys from an ordering
|
|
|
|
* @param keys to remove
|
|
|
|
* @return a new ordering without the selected keys
|
|
|
|
*/
|
|
|
|
Ordering subtract(const Ordering& keys) const;
|
|
|
|
|
2009-10-31 23:24:22 +08:00
|
|
|
void print(const std::string& s = "Ordering") const;
|
2009-10-07 02:01:40 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* check if two orderings are the same
|
|
|
|
* @param ordering
|
|
|
|
* @return bool
|
|
|
|
*/
|
2009-10-31 23:24:22 +08:00
|
|
|
bool equals(const Ordering &ord, double tol=0) const;
|
2009-12-12 05:34:08 +08:00
|
|
|
|
2009-10-07 02:01:40 +08:00
|
|
|
};
|
2009-08-22 06:23:24 +08:00
|
|
|
|
|
|
|
}
|