21 #include <gtsam/geometry/concepts.h> 40 boost::optional<POSE> body_P_sensor_;
43 GTSAM_CONCEPT_TESTABLE_TYPE(POSE)
44 GTSAM_CONCEPT_POSE_TYPE(POSE)
48 typedef typename boost::shared_ptr<PoseBetweenFactor>
shared_ptr;
55 const SharedNoiseModel& model, boost::optional<POSE> body_P_sensor = boost::none) :
56 Base(model,
key1, key2), measured_(
measured), body_P_sensor_(body_P_sensor) {
62 virtual gtsam::NonlinearFactor::shared_ptr
clone()
const {
63 return boost::static_pointer_cast<gtsam::NonlinearFactor>(
64 gtsam::NonlinearFactor::shared_ptr(
new This(*
this))); }
69 virtual void print(
const std::string& s,
const KeyFormatter& keyFormatter = DefaultKeyFormatter)
const {
70 std::cout << s <<
"BetweenFactor(" 71 << keyFormatter(this->
key1()) <<
"," 72 << keyFormatter(this->key2()) <<
")\n";
73 measured_.print(
" measured: ");
74 if(this->body_P_sensor_)
75 this->body_P_sensor_->print(
" sensor pose in body frame: ");
76 this->noiseModel_->print(
" noise model: ");
81 const This *e = dynamic_cast<const This*> (&expected);
84 && this->measured_.equals(e->measured_, tol)
85 && ((!body_P_sensor_ && !e->body_P_sensor_) || (body_P_sensor_ && e->body_P_sensor_ && body_P_sensor_->
equals(*e->body_P_sensor_)));
92 boost::optional<Matrix&> H1 = boost::none,
93 boost::optional<Matrix&> H2 = boost::none)
const {
98 hx = p1.compose(*body_P_sensor_,H3).between(p2.compose(*body_P_sensor_), H1, H2);
102 hx = p1.compose(*body_P_sensor_).between(p2.compose(*body_P_sensor_));
105 return measured_.localCoordinates(hx);
107 POSE hx = p1.between(p2, H1, H2);
109 return measured_.localCoordinates(hx);
122 template<
class ARCHIVE>
123 void serialize(ARCHIVE & ar,
const unsigned int ) {
124 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(
Base);
125 ar & BOOST_SERIALIZATION_NVP(measured_);
This is the base class for all factor types.
Definition: Factor.h:54
A convenient base class for creating your own NoiseModelFactor with 2 variables.
Definition: NonlinearFactor.h:345
virtual void print(const std::string &s, const KeyFormatter &keyFormatter=DefaultKeyFormatter) const
implement functions needed for Testable
Definition: PoseBetweenFactor.h:69
virtual gtsam::NonlinearFactor::shared_ptr clone() const
Definition: PoseBetweenFactor.h:62
std::uint64_t Key
Integer nonlinear key type.
Definition: types.h:57
Definition: PoseBetweenFactor.h:32
boost::function< std::string(Key)> KeyFormatter
Typedef for a function to format a key, i.e. to convert it to a string.
Definition: Key.h:33
PoseBetweenFactor()
default constructor - only use for serialization
Definition: PoseBetweenFactor.h:51
Nonlinear factor base class.
Definition: NonlinearFactor.h:50
Key key1() const
methods to retrieve both keys
Definition: NonlinearFactor.h:377
friend class boost::serialization::access
Serialization function.
Definition: PoseBetweenFactor.h:121
const POSE & measured() const
return the measured
Definition: PoseBetweenFactor.h:114
Non-linear factor base classes.
Vector evaluateError(const POSE &p1, const POSE &p2, boost::optional< Matrix & > H1=boost::none, boost::optional< Matrix & > H2=boost::none) const
implement functions needed to derive from Factor
Definition: PoseBetweenFactor.h:91
PoseBetweenFactor(Key key1, Key key2, const POSE &measured, const SharedNoiseModel &model, boost::optional< POSE > body_P_sensor=boost::none)
Constructor.
Definition: PoseBetweenFactor.h:54
Global functions in a separate testing namespace.
Definition: chartTesting.h:28
Concept check for values that can be used in unit tests.
noiseModel::Base::shared_ptr SharedNoiseModel
Note, deliberately not in noiseModel namespace.
Definition: NoiseModel.h:1072
boost::shared_ptr< PoseBetweenFactor > shared_ptr
concept check by type
Definition: PoseBetweenFactor.h:48
virtual bool equals(const NonlinearFactor &expected, double tol=1e-9) const
equals
Definition: PoseBetweenFactor.h:80
virtual bool equals(const NonlinearFactor &f, double tol=1e-9) const
Check if two factors are equal.
Definition: NonlinearFactor.cpp:71
bool equals(const This &other, double tol=1e-9) const
check equality
Definition: Factor.cpp:42