36 typedef boost::shared_ptr<BoundingConstraint1<VALUE> > shared_ptr;
42 bool isGreaterThan,
double mu = 1000.0) :
44 threshold_(threshold), isGreaterThan_(isGreaterThan) {
49 inline double threshold()
const {
return threshold_; }
50 inline bool isGreaterThan()
const {
return isGreaterThan_; }
57 virtual double value(
const X& x, boost::optional<Matrix&> H =
58 boost::none)
const = 0;
63 double x =
value(c.
at<X>(this->key()));
64 return (isGreaterThan_) ? x <= threshold_ : x >= threshold_;
68 boost::none)
const override {
72 if (isGreaterThan_) *H = D;
77 return (Vector(1) <<
error).finished();
79 return -1.0 * (Vector(1) <<
error).finished();
86 template<
class ARCHIVE>
87 void serialize(ARCHIVE & ar,
const unsigned int ) {
88 ar & boost::serialization::make_nvp(
"NoiseModelFactor1",
89 boost::serialization::base_object<Base>(*
this));
90 ar & BOOST_SERIALIZATION_NVP(threshold_);
91 ar & BOOST_SERIALIZATION_NVP(isGreaterThan_);
99template<
class VALUE1,
class VALUE2>
105 typedef boost::shared_ptr<BoundingConstraint2<VALUE1, VALUE2> > shared_ptr;
111 bool isGreaterThan,
double mu = 1000.0)
113 threshold_(threshold), isGreaterThan_(isGreaterThan) {}
117 inline double threshold()
const {
return threshold_; }
118 inline bool isGreaterThan()
const {
return isGreaterThan_; }
124 virtual double value(
const X1& x1,
const X2& x2,
125 boost::optional<Matrix&> H1 = boost::none,
126 boost::optional<Matrix&> H2 = boost::none)
const = 0;
131 double x =
value(c.
at<X1>(this->key1()), c.
at<X2>(this->key2()));
132 return (isGreaterThan_) ? x <= threshold_ : x >= threshold_;
136 boost::optional<Matrix&> H1 = boost::none,
137 boost::optional<Matrix&> H2 = boost::none)
const override {
139 double error =
value(x1, x2, D1, D2) - threshold_;
141 if (isGreaterThan_) *H1 = D1;
142 else *H1 = -1.0 * D1;
145 if (isGreaterThan_) *H2 = D2;
146 else *H2 = -1.0 * D2;
150 return (Vector(1) <<
error).finished();
152 return -1.0 * (Vector(1) <<
error).finished();
159 template<
class ARCHIVE>
160 void serialize(ARCHIVE & ar,
const unsigned int ) {
161 ar & boost::serialization::make_nvp(
"NoiseModelFactor2",
162 boost::serialization::base_object<Base>(*
this));
163 ar & BOOST_SERIALIZATION_NVP(threshold_);
164 ar & BOOST_SERIALIZATION_NVP(isGreaterThan_);
Base class and basic functions for Lie types.
Non-linear factor base classes.
Global functions in a separate testing namespace.
Definition: chartTesting.h:28
std::uint64_t Key
Integer nonlinear key type.
Definition: types.h:69
This is the base class for all factor types.
Definition: Factor.h:56
double error(const Values &c) const override
Calculate the error of the factor.
Definition: NonlinearFactor.cpp:127
const SharedNoiseModel & noiseModel() const
access to the noise model
Definition: NonlinearFactor.h:211
A convenient base class for creating your own NoiseModelFactor with 1 variable.
Definition: NonlinearFactor.h:285
A convenient base class for creating your own NoiseModelFactor with 2 variables.
Definition: NonlinearFactor.h:369
Key key1() const
methods to retrieve both keys
Definition: NonlinearFactor.h:401
A non-templated config holding any types of Manifold-group elements.
Definition: Values.h:63
const ValueType at(Key j) const
Retrieve a variable by key j.
Definition: Values-inl.h:346
Definition: BoundingConstraint.h:33
bool active(const Values &c) const override
active when constraint NOT met
Definition: BoundingConstraint.h:61
BoundingConstraint1(Key key, double threshold, bool isGreaterThan, double mu=1000.0)
flag for greater/less than
Definition: BoundingConstraint.h:41
friend class boost::serialization::access
Serialization function.
Definition: BoundingConstraint.h:85
virtual double value(const X &x, boost::optional< Matrix & > H=boost::none) const =0
function producing a scalar value to compare to the threshold Must have optional argument for derivat...
Vector evaluateError(const X &x, boost::optional< Matrix & > H=boost::none) const override
Override this method to finish implementing a unary factor.
Definition: BoundingConstraint.h:67
Binary scalar inequality constraint, with a similar value() function to implement for specific system...
Definition: BoundingConstraint.h:100
bool active(const Values &c) const override
active when constraint NOT met
Definition: BoundingConstraint.h:129
BoundingConstraint2(Key key1, Key key2, double threshold, bool isGreaterThan, double mu=1000.0)
flag for greater/less than
Definition: BoundingConstraint.h:110
Vector evaluateError(const X1 &x1, const X2 &x2, boost::optional< Matrix & > H1=boost::none, boost::optional< Matrix & > H2=boost::none) const override
Override this method to finish implementing a binary factor.
Definition: BoundingConstraint.h:135
friend class boost::serialization::access
Serialization function.
Definition: BoundingConstraint.h:158
virtual double value(const X1 &x1, const X2 &x2, boost::optional< Matrix & > H1=boost::none, boost::optional< Matrix & > H2=boost::none) const =0
function producing a scalar value to compare to the threshold Must have optional argument for derivat...