Testable and default constructor
parent
022af8f9bc
commit
f44e39eb21
|
|
@ -29,19 +29,18 @@ namespace gtsam {
|
||||||
/**
|
/**
|
||||||
* Factor that supports arbitrary expressions via AD
|
* Factor that supports arbitrary expressions via AD
|
||||||
*/
|
*/
|
||||||
template<class T>
|
template<typename T>
|
||||||
class ExpressionFactor: public NoiseModelFactor {
|
class ExpressionFactor: public NoiseModelFactor {
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
typedef ExpressionFactor<T> This;
|
typedef ExpressionFactor<T> This;
|
||||||
|
static const int Dim = traits<T>::dimension;
|
||||||
|
|
||||||
T measurement_; ///< the measurement to be compared with the expression
|
T measurement_; ///< the measurement to be compared with the expression
|
||||||
Expression<T> expression_; ///< the expression that is AD enabled
|
Expression<T> expression_; ///< the expression that is AD enabled
|
||||||
FastVector<int> dims_; ///< dimensions of the Jacobian matrices
|
FastVector<int> dims_; ///< dimensions of the Jacobian matrices
|
||||||
|
|
||||||
static const int Dim = traits<T>::dimension;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
typedef boost::shared_ptr<ExpressionFactor<T> > shared_ptr;
|
typedef boost::shared_ptr<ExpressionFactor<T> > shared_ptr;
|
||||||
|
|
@ -62,6 +61,19 @@ public:
|
||||||
boost::tie(keys_, dims_) = expression_.keysAndDims();
|
boost::tie(keys_, dims_) = expression_.keysAndDims();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// print relies on Testable traits being defined for T
|
||||||
|
void print(const std::string& s, const KeyFormatter& keyFormatter) const {
|
||||||
|
NoiseModelFactor::print(s, keyFormatter);
|
||||||
|
traits<T>::Print(measurement_, s + ".measurement_");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// equals relies on Testable traits being defined for T
|
||||||
|
bool equals(const NonlinearFactor& f, double tol) const {
|
||||||
|
const ExpressionFactor* p = dynamic_cast<const ExpressionFactor*>(&f);
|
||||||
|
return p && NoiseModelFactor::equals(f, tol) &&
|
||||||
|
traits<T>::Equals(measurement_, p->measurement_, tol);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Error function *without* the NoiseModel, \f$ h(x)-z \f$.
|
* Error function *without* the NoiseModel, \f$ h(x)-z \f$.
|
||||||
* We override this method to provide
|
* We override this method to provide
|
||||||
|
|
@ -119,8 +131,17 @@ public:
|
||||||
return boost::static_pointer_cast<gtsam::NonlinearFactor>(
|
return boost::static_pointer_cast<gtsam::NonlinearFactor>(
|
||||||
gtsam::NonlinearFactor::shared_ptr(new This(*this)));
|
gtsam::NonlinearFactor::shared_ptr(new This(*this)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
/// Default constructor, for serialization
|
||||||
|
ExpressionFactor() {}
|
||||||
|
|
||||||
};
|
};
|
||||||
// ExpressionFactor
|
// ExpressionFactor
|
||||||
|
|
||||||
|
/// traits
|
||||||
|
template <typename T>
|
||||||
|
struct traits<ExpressionFactor<T> > : public Testable<ExpressionFactor<T> > {};
|
||||||
|
|
||||||
}// \ namespace gtsam
|
}// \ namespace gtsam
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue