Used template parameters in simulated2D to make it possible to template factors on a config type with typedefs for the previous usage so no other code needs to change
parent
040d45cb45
commit
af9f45ff24
|
|
@ -52,12 +52,13 @@ namespace gtsam {
|
||||||
/**
|
/**
|
||||||
* Unary factor encoding a soft prior on a vector
|
* Unary factor encoding a soft prior on a vector
|
||||||
*/
|
*/
|
||||||
struct Prior: public NonlinearFactor1<Config, PoseKey, Point2> {
|
template<class Cfg=Config>
|
||||||
|
struct GenericPrior: public NonlinearFactor1<Cfg, PoseKey, Point2> {
|
||||||
|
|
||||||
Point2 z_;
|
Point2 z_;
|
||||||
|
|
||||||
Prior(const Point2& z, const SharedGaussian& model, const PoseKey& key) :
|
GenericPrior(const Point2& z, const SharedGaussian& model, const PoseKey& key) :
|
||||||
NonlinearFactor1<Config, PoseKey, Point2> (model, key), z_(z) {
|
NonlinearFactor1<Cfg, PoseKey, Point2> (model, key), z_(z) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector evaluateError(const Point2& x, boost::optional<Matrix&> H =
|
Vector evaluateError(const Point2& x, boost::optional<Matrix&> H =
|
||||||
|
|
@ -70,13 +71,14 @@ namespace gtsam {
|
||||||
/**
|
/**
|
||||||
* Binary factor simulating "odometry" between two Vectors
|
* Binary factor simulating "odometry" between two Vectors
|
||||||
*/
|
*/
|
||||||
struct Odometry: public NonlinearFactor2<Config, PoseKey, Point2, PoseKey,
|
template<class Cfg=Config>
|
||||||
|
struct GenericOdometry: public NonlinearFactor2<Cfg, PoseKey, Point2, PoseKey,
|
||||||
Point2> {
|
Point2> {
|
||||||
Point2 z_;
|
Point2 z_;
|
||||||
|
|
||||||
Odometry(const Point2& z, const SharedGaussian& model, const PoseKey& j1,
|
GenericOdometry(const Point2& z, const SharedGaussian& model, const PoseKey& j1,
|
||||||
const PoseKey& j2) :
|
const PoseKey& j2) :
|
||||||
z_(z), NonlinearFactor2<Config, PoseKey, Point2, PoseKey, Point2> (
|
z_(z), NonlinearFactor2<Cfg, PoseKey, Point2, PoseKey, Point2> (
|
||||||
model, j1, j2) {
|
model, j1, j2) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -90,14 +92,16 @@ namespace gtsam {
|
||||||
/**
|
/**
|
||||||
* Binary factor simulating "measurement" between two Vectors
|
* Binary factor simulating "measurement" between two Vectors
|
||||||
*/
|
*/
|
||||||
struct Measurement: public NonlinearFactor2<Config, PoseKey, Point2,
|
template<class Cfg=Config>
|
||||||
|
class GenericMeasurement: public NonlinearFactor2<Cfg, PoseKey, Point2,
|
||||||
PointKey, Point2> {
|
PointKey, Point2> {
|
||||||
|
public:
|
||||||
|
|
||||||
Point2 z_;
|
Point2 z_;
|
||||||
|
|
||||||
Measurement(const Point2& z, const SharedGaussian& model,
|
GenericMeasurement(const Point2& z, const SharedGaussian& model,
|
||||||
const PoseKey& j1, const PointKey& j2) :
|
const PoseKey& j1, const PointKey& j2) :
|
||||||
z_(z), NonlinearFactor2<Config, PoseKey, Point2, PointKey, Point2> (
|
z_(z), NonlinearFactor2<Cfg, PoseKey, Point2, PointKey, Point2> (
|
||||||
model, j1, j2) {
|
model, j1, j2) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -108,5 +112,10 @@ namespace gtsam {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** Typedefs for regular use */
|
||||||
|
typedef GenericPrior<Config> Prior;
|
||||||
|
typedef GenericOdometry<Config> Odometry;
|
||||||
|
typedef GenericMeasurement<Config> Measurement;
|
||||||
|
|
||||||
} // namespace simulated2D
|
} // namespace simulated2D
|
||||||
} // namespace gtsam
|
} // namespace gtsam
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue