21#include <gtsam/nonlinear/ExpressionFactor.h>
26template <
typename A1,
typename A2>
34template <
typename A1,
typename A2 = A1,
typename T =
double>
45 : Base({key1, key2}, model,
measured) {
50 gtsam::NonlinearFactor::shared_ptr
clone()
const override {
51 return boost::static_pointer_cast<gtsam::NonlinearFactor>(
52 gtsam::NonlinearFactor::shared_ptr(
new This(*
this)));
62 Vector evaluateError(
const A1& a1,
const A2& a2,
63 boost::optional<Matrix&> H1 = boost::none,
64 boost::optional<Matrix&> H2 = boost::none)
const
66 std::vector<Matrix> Hs(2);
77 void print(
const std::string& s =
"",
78 const KeyFormatter& kf = DefaultKeyFormatter)
const override {
79 std::cout << s <<
"RangeFactor" << std::endl;
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));
93template <
typename A1,
typename A2,
typename T>
95 :
public Testable<RangeFactor<A1, A2, T> > {};
101template <
typename A1,
typename A2 = A1,
116 const A1& body_T_sensor)
117 :
Base({key1, key2}, model,
measured), body_T_sensor_(body_T_sensor) {
124 gtsam::NonlinearFactor::shared_ptr
clone()
const override {
125 return boost::static_pointer_cast<gtsam::NonlinearFactor>(
126 gtsam::NonlinearFactor::shared_ptr(
new This(*
this)));
139 Vector evaluateError(
const A1& a1,
const A2& a2,
140 boost::optional<Matrix&> H1 = boost::none,
141 boost::optional<Matrix&> H2 = boost::none)
const
143 std::vector<Matrix> Hs(2);
154 void print(
const std::string& s =
"",
155 const KeyFormatter& keyFormatter = DefaultKeyFormatter)
const override {
156 std::cout << s <<
"RangeFactorWithTransform" << std::endl;
157 this->body_T_sensor_.print(
" sensor pose in body frame: ");
164 template <
typename ARCHIVE>
165 void serialize(ARCHIVE& ar,
const unsigned int ) {
169 ar& BOOST_SERIALIZATION_NVP(body_T_sensor_);
170 ar& boost::serialization::make_nvp(
171 "Base", boost::serialization::base_object<Base>(*
this));
176template <
typename A1,
typename A2,
typename T>
178 :
public Testable<RangeFactorWithTransform<A1, A2, T> > {};
Global functions in a separate testing namespace.
Definition: chartTesting.h:28
noiseModel::Base::shared_ptr SharedNoiseModel
Note, deliberately not in noiseModel namespace.
Definition: NoiseModel.h:736
std::uint64_t Key
Integer nonlinear key type.
Definition: types.h:69
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
GenericValue< T > genericValue(const T &v)
Functional constructor of GenericValue<T> so T can be automatically deduced.
Definition: GenericValue.h:212
A manifold defines a space in which there is a notion of a linear tangent space that can be centered ...
Definition: concepts.h:30
A helper that implements the traits interface for GTSAM types.
Definition: Testable.h:151
Definition: BearingRange.h:39
This is the base class for all factor types.
Definition: Factor.h:56
const KeyVector & keys() const
Access the factor's involved variable keys.
Definition: Factor.h:125
Vector unwhitenedError(const Values &x, boost::optional< std::vector< Matrix > & > H=boost::none) const override
Error function without the NoiseModel, .
Definition: ExpressionFactor.h:99
void print(const std::string &s="", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const override
print relies on Testable traits being defined for T
Definition: ExpressionFactor.h:80
const double & measured() const
return the measurement
Definition: ExpressionFactor.h:77
void initialize(const Expression< double > &expression)
Initialize with constructor arguments.
Definition: ExpressionFactor.h:167
Expression class that supports automatic differentiation.
Definition: Expression.h:48
N-ary variadic template for ExpressionFactor meant as a base class for N-ary factors.
Definition: ExpressionFactor.h:242
double error(const Values &c) const override
Calculate the error of the factor.
Definition: NonlinearFactor.cpp:127
Definition: RangeFactor.h:35
gtsam::NonlinearFactor::shared_ptr clone() const override
Definition: RangeFactor.h:50
void print(const std::string &s="", const KeyFormatter &kf=DefaultKeyFormatter) const override
print
Definition: RangeFactor.h:77
RangeFactor()
default constructor
Definition: RangeFactor.h:42
Definition: RangeFactor.h:103
gtsam::NonlinearFactor::shared_ptr clone() const override
Definition: RangeFactor.h:124
friend class boost::serialization::access
Serialization function.
Definition: RangeFactor.h:163
void print(const std::string &s="", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const override
print contents
Definition: RangeFactor.h:154