36 typedef std::shared_ptr<BoundingConstraint1<VALUE> > shared_ptr;
45 bool isGreaterThan,
double mu = 1000.0) :
46 Base(
noiseModel::Constrained::All(1, mu), key),
47 threshold_(threshold), isGreaterThan_(isGreaterThan) {
52 inline double threshold()
const {
return threshold_; }
53 inline bool isGreaterThan()
const {
return isGreaterThan_; }
66 double x =
value(c.
at<X>(this->key()));
67 return (isGreaterThan_) ? x <= threshold_ : x >= threshold_;
74 if (isGreaterThan_) *H = D;
79 return (Vector(1) << error).finished();
81 return -1.0 * (Vector(1) <<
error).finished();
86 #ifdef GTSAM_ENABLE_BOOST_SERIALIZATION 88 friend class boost::serialization::access;
89 template<
class ARCHIVE>
90 void serialize(ARCHIVE & ar,
const unsigned int ) {
92 ar & boost::serialization::make_nvp(
"NoiseModelFactor1",
93 boost::serialization::base_object<Base>(*
this));
94 ar & BOOST_SERIALIZATION_NVP(threshold_);
95 ar & BOOST_SERIALIZATION_NVP(isGreaterThan_);
104 template<
class VALUE1,
class VALUE2>
110 typedef std::shared_ptr<BoundingConstraint2<VALUE1, VALUE2> > shared_ptr;
119 bool isGreaterThan,
double mu = 1000.0)
120 : Base(
noiseModel::Constrained::All(1, mu), key1, key2),
121 threshold_(threshold), isGreaterThan_(isGreaterThan) {}
125 inline double threshold()
const {
return threshold_; }
126 inline bool isGreaterThan()
const {
return isGreaterThan_; }
132 virtual double value(
const X1& x1,
const X2& x2,
139 double x =
value(c.
at<X1>(this->key1()), c.
at<X2>(this->key2()));
140 return (isGreaterThan_) ? x <= threshold_ : x >= threshold_;
143 Vector evaluateError(
const X1& x1,
const X2& x2,
146 double error =
value(x1, x2, &D1, &D2) - threshold_;
148 if (isGreaterThan_) *H1 = D1;
149 else *H1 = -1.0 * D1;
152 if (isGreaterThan_) *H2 = D2;
153 else *H2 = -1.0 * D2;
157 return (Vector(1) << error).finished();
159 return -1.0 * (Vector(1) <<
error).finished();
164 #ifdef GTSAM_ENABLE_BOOST_SERIALIZATION 166 friend class boost::serialization::access;
167 template<
class ARCHIVE>
168 void serialize(ARCHIVE & ar,
const unsigned int ) {
170 ar & boost::serialization::make_nvp(
"NoiseModelFactor2",
171 boost::serialization::base_object<Base>(*
this));
172 ar & BOOST_SERIALIZATION_NVP(threshold_);
173 ar & BOOST_SERIALIZATION_NVP(isGreaterThan_);
Definition: NonlinearFactor.h:431
double error(const Values &c) const override
Definition: BoundingConstraint.h:33
std::string serialize(const T &input)
serializes to a string
Definition: serialization.h:113
const ValueType at(Key j) const
Definition: Values-inl.h:204
BoundingConstraint1(Key key, double threshold, bool isGreaterThan, double mu=1000.0)
flag for greater/less than
Definition: BoundingConstraint.h:44
virtual Vector evaluateError(const ValueTypes &... x, OptionalMatrixTypeT< ValueTypes >... H) const=0
Key key() const
Definition: NonlinearFactor.h:582
Definition: BoundingConstraint.h:105
bool active(const Values &c) const override
Definition: BoundingConstraint.h:137
#define OptionalNone
Definition: NonlinearFactor.h:49
const SharedNoiseModel & noiseModel() const
access to the noise model
Definition: NonlinearFactor.h:245
Matrix * OptionalMatrixType
Definition: NonlinearFactor.h:55
Base class and basic functions for Lie types.
BoundingConstraint2(Key key1, Key key2, double threshold, bool isGreaterThan, double mu=1000.0)
flag for greater/less than
Definition: BoundingConstraint.h:118
Definition: chartTesting.h:28
virtual double value(const X &x, OptionalMatrixType H=OptionalNone) const =0
Non-linear factor base classes.
bool active(const Values &c) const override
Definition: BoundingConstraint.h:64
std::uint64_t Key
Integer nonlinear key type.
Definition: types.h:102