19 #include <boost/lexical_cast.hpp>
29 template<
class POSE,
class POINT>
34 boost::optional<POSE> body_P_sensor_;
43 GTSAM_CONCEPT_RANGE_MEASUREMENT_TYPE(POSE, POINT)
50 const SharedNoiseModel& model, boost::optional<POSE> body_P_sensor = boost::none) :
51 Base(model, poseKey, pointKey), measured_(measured), body_P_sensor_(body_P_sensor) {
57 virtual gtsam::NonlinearFactor::shared_ptr
clone()
const {
59 gtsam::NonlinearFactor::shared_ptr(
new This(*
this))); }
63 boost::optional<Matrix&> H1 = boost::none, boost::optional<Matrix&> H2 = boost::none)
const {
68 hx = pose.compose(*body_P_sensor_, H0).range(point, H1, H2);
71 hx = pose.compose(*body_P_sensor_).range(point, H1, H2);
74 hx = pose.range(point, H1, H2);
76 return (Vector(1) << hx - measured_);
86 const This *e =
dynamic_cast<const This*
> (&expected);
89 && fabs(this->measured_ - e->measured_) < tol
90 && ((!body_P_sensor_ && !e->body_P_sensor_) || (body_P_sensor_ && e->body_P_sensor_ && body_P_sensor_->equals(*e->body_P_sensor_)));
94 void print(
const std::string& s=
"",
const KeyFormatter& keyFormatter = DefaultKeyFormatter)
const {
95 std::cout << s <<
"RangeFactor, range = " << measured_ << std::endl;
96 if(this->body_P_sensor_)
97 this->body_P_sensor_->print(
" sensor pose in body frame: ");
105 template<
class ARCHIVE>
106 void serialize(ARCHIVE & ar,
const unsigned int version) {
107 ar & boost::serialization::make_nvp(
"NoiseModelFactor2",
108 boost::serialization::base_object<Base>(*
this));
109 ar & BOOST_SERIALIZATION_NVP(measured_);
110 ar & BOOST_SERIALIZATION_NVP(body_P_sensor_);
Non-linear factor base classes.
virtual bool equals(const NonlinearFactor &f, double tol=1e-9) const
Check if two factors are equal.
Definition: NonlinearFactor.h:239
double measured() const
return the measured
Definition: RangeFactor.h:80
friend class boost::serialization::access
Serialization function.
Definition: RangeFactor.h:104
A convenient base class for creating your own NoiseModelFactor with 2 variables.
Definition: NonlinearFactor.h:423
void print(const std::string &s="", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const
print contents
Definition: RangeFactor.h:94
This is the base class for all factor types.
Definition: Factor.h:51
Vector evaluateError(const POSE &pose, const POINT &point, boost::optional< Matrix & > H1=boost::none, boost::optional< Matrix & > H2=boost::none) const
h(x)-z
Definition: RangeFactor.h:62
Concept-checking macros for geometric objects Each macro instantiates a concept check structure...
size_t Key
Integer nonlinear key type.
Definition: types.h:59
virtual gtsam::NonlinearFactor::shared_ptr clone() const
Definition: RangeFactor.h:57
Definition: RangeFactor.h:30
virtual bool equals(const NonlinearFactor &expected, double tol=1e-9) const
equals specialized to this factor
Definition: RangeFactor.h:85
virtual void print(const std::string &s="", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const
Print.
Definition: NonlinearFactor.h:231
noiseModel::Base::shared_ptr SharedNoiseModel
Note, deliberately not in noiseModel namespace.
Definition: NoiseModel.h:884
Nonlinear factor base class.
Definition: NonlinearFactor.h:54
boost::function< std::string(Key)> KeyFormatter
Typedef for a function to format a key, i.e. to convert it to a string.
Definition: types.h:62