21 #include <gtsam/geometry/concepts.h> 40 std::optional<POSE> body_P_sensor_;
43 GTSAM_CONCEPT_TESTABLE_TYPE(POSE)
44 GTSAM_CONCEPT_POSE_TYPE(POSE)
51 typedef typename std::shared_ptr<PoseBetweenFactor> shared_ptr;
59 Base(model, key1, key2), measured_(measured), body_P_sensor_(body_P_sensor) {
65 gtsam::NonlinearFactor::shared_ptr
clone()
const override {
67 gtsam::NonlinearFactor::shared_ptr(
new This(*
this))); }
72 void print(
const std::string& s,
const KeyFormatter& keyFormatter = DefaultKeyFormatter)
const override {
73 std::cout << s <<
"BetweenFactor(" 74 << keyFormatter(this->key1()) <<
"," 75 << keyFormatter(this->key2()) <<
")\n";
76 measured_.print(
" measured: ");
77 if(this->body_P_sensor_)
78 this->body_P_sensor_->print(
" sensor pose in body frame: ");
79 this->noiseModel_->print(
" noise model: ");
84 const This *e =
dynamic_cast<const This*
> (&expected);
87 && this->measured_.equals(e->measured_, tol)
88 && ((!body_P_sensor_ && !e->body_P_sensor_) || (body_P_sensor_ && e->body_P_sensor_ && body_P_sensor_->
equals(*e->body_P_sensor_)));
100 hx = p1.compose(*body_P_sensor_,H3).between(p2.compose(*body_P_sensor_), H1, H2);
104 hx = p1.compose(*body_P_sensor_).between(p2.compose(*body_P_sensor_));
107 return measured_.localCoordinates(hx);
109 POSE hx = p1.between(p2, H1, H2);
111 return measured_.localCoordinates(hx);
122 #ifdef GTSAM_ENABLE_BOOST_SERIALIZATION 124 friend class boost::serialization::access;
125 template<
class ARCHIVE>
126 void serialize(ARCHIVE & ar,
const unsigned int ) {
127 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Base);
128 ar & BOOST_SERIALIZATION_NVP(measured_);
Definition: NonlinearFactor.h:431
bool equals(const NonlinearFactor &f, double tol=1e-9) const override
Concept check for values that can be used in unit tests.
Definition: PoseBetweenFactor.h:32
std::string serialize(const T &input)
serializes to a string
Definition: serialization.h:113
virtual Vector evaluateError(const ValueTypes &... x, OptionalMatrixTypeT< ValueTypes >... H) const=0
Definition: NonlinearFactor.h:68
void print(const std::string &s, const KeyFormatter &keyFormatter=DefaultKeyFormatter) const override
Definition: PoseBetweenFactor.h:72
Vector evaluateError(const POSE &p1, const POSE &p2, OptionalMatrixType H1, OptionalMatrixType H2) const override
Definition: PoseBetweenFactor.h:94
const POSE & measured() const
Definition: PoseBetweenFactor.h:116
Matrix * OptionalMatrixType
Definition: NonlinearFactor.h:55
bool equals(const NonlinearFactor &expected, double tol=1e-9) const override
Definition: PoseBetweenFactor.h:83
std::function< std::string(Key)> KeyFormatter
Typedef for a function to format a key, i.e. to convert it to a string.
Definition: Key.h:35
Definition: chartTesting.h:28
gtsam::NonlinearFactor::shared_ptr clone() const override
Definition: PoseBetweenFactor.h:65
Non-linear factor base classes.
std::uint64_t Key
Integer nonlinear key type.
Definition: types.h:102
PoseBetweenFactor(Key key1, Key key2, const POSE &measured, const SharedNoiseModel &model, std::optional< POSE > body_P_sensor={})
Definition: PoseBetweenFactor.h:57
noiseModel::Base::shared_ptr SharedNoiseModel
Definition: NoiseModel.h:741
bool equals(const This &other, double tol=1e-9) const
check equality
PoseBetweenFactor()
Definition: PoseBetweenFactor.h:54