21 #include <gtsam/nonlinear/ExpressionFactor.h> 26 template <
typename A1,
typename A2>
34 template <
typename A1,
typename A2 = A1,
typename T =
double>
45 : Base({key1, key2}, model,
measured) {
50 gtsam::NonlinearFactor::shared_ptr
clone()
const override {
52 gtsam::NonlinearFactor::shared_ptr(
new This(*
this)));
62 Vector evaluateError(
const A1& a1,
const A2& a2,
65 std::vector<Matrix> Hs(2);
76 void print(
const std::string& s =
"",
77 const KeyFormatter& kf = DefaultKeyFormatter)
const override {
78 std::cout << s <<
"RangeFactor" << std::endl;
83 #ifdef GTSAM_ENABLE_BOOST_SERIALIZATION 84 friend class boost::serialization::access;
85 template <
class ARCHIVE>
86 void serialize(ARCHIVE& ar,
const unsigned int ) {
87 ar& boost::serialization::make_nvp(
88 "Base", boost::serialization::base_object<Base>(*
this));
94 template <
typename A1,
typename A2,
typename T>
96 :
public Testable<RangeFactor<A1, A2, T> > {};
102 template <
typename A1,
typename A2 = A1,
117 const A1& body_T_sensor)
118 : Base({key1, key2}, model,
measured), body_T_sensor_(body_T_sensor) {
125 gtsam::NonlinearFactor::shared_ptr
clone()
const override {
127 gtsam::NonlinearFactor::shared_ptr(
new This(*
this)));
140 Vector evaluateError(
const A1& a1,
const A2& a2,
142 std::vector<Matrix> Hs(2);
154 Vector evaluateError(
const A1& a1,
const A2& a2, Matrix& H1, Matrix& H2)
const {
155 return evaluateError(a1, a2, &H1, &H2);
159 void print(
const std::string& s =
"",
160 const KeyFormatter& keyFormatter = DefaultKeyFormatter)
const override {
161 std::cout << s <<
"RangeFactorWithTransform" << std::endl;
162 this->body_T_sensor_.print(
" sensor pose in body frame: ");
167 #ifdef GTSAM_ENABLE_BOOST_SERIALIZATION 168 friend class boost::serialization::access;
170 template <
typename ARCHIVE>
171 void serialize(ARCHIVE& ar,
const unsigned int ) {
175 ar& BOOST_SERIALIZATION_NVP(body_T_sensor_);
176 ar& boost::serialization::make_nvp(
177 "Base", boost::serialization::base_object<Base>(*
this));
183 template <
typename A1,
typename A2,
typename T>
185 :
public Testable<RangeFactorWithTransform<A1, A2, T> > {};
double error(const Values &c) const override
gtsam::NonlinearFactor::shared_ptr clone() const override
Definition: RangeFactor.h:50
std::string serialize(const T &input)
serializes to a string
Definition: serialization.h:113
void print(const std::string &s="", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const override
print relies on Testable traits being defined for T
Definition: ExpressionFactor.h:85
void print(const std::string &s="", const KeyFormatter &kf=DefaultKeyFormatter) const override
print
Definition: RangeFactor.h:76
Definition: Testable.h:152
Definition: NonlinearFactor.h:68
void initialize(const Expression< T > &expression)
Initialize with constructor arguments.
Definition: ExpressionFactor.h:172
Definition: Expression.h:47
Definition: RangeFactor.h:35
const T & measured() const
Definition: ExpressionFactor.h:82
#define OptionalNone
Definition: NonlinearFactor.h:49
Matrix * OptionalMatrixType
Definition: NonlinearFactor.h:55
Vector unwhitenedError(const Values &x, OptionalMatrixVecType H=nullptr) const override
Definition: ExpressionFactor.h:104
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: BearingRange.h:41
Definition: chartTesting.h:28
GenericValue< T > genericValue(const T &v)
Definition: GenericValue.h:211
RangeFactor()
default constructor
Definition: RangeFactor.h:42
const KeyVector & keys() const
Access the factor's involved variable keys.
Definition: Factor.h:142
Definition: ExpressionFactor.h:249
std::uint64_t Key
Integer nonlinear key type.
Definition: types.h:102
noiseModel::Base::shared_ptr SharedNoiseModel
Definition: NoiseModel.h:741