24 #include <boost/bind.hpp> 92 j), feasible_(feasible), allow_error_(false), error_gain_(0.0),
102 j), feasible_(feasible), allow_error_(true), error_gain_(error_gain),
112 std::cout <<
s <<
"Constraint: on [" << keyFormatter(this->
key()) <<
"]\n";
119 const This*
e =
dynamic_cast<const This*
>(&
f);
130 const T& xj = c.
at<T>(this->
key());
132 if (allow_error_ || !
compare_(xj, feasible_)) {
133 return error_gain_ *
dot(e, e);
141 boost::optional<Matrix&>
H = boost::none)
const override {
145 *
H = Matrix::Identity(nj,nj);
147 }
else if (
compare_(feasible_, xj)) {
149 *
H = Matrix::Identity(nj,nj);
150 return Vector::Zero(nj);
153 throw std::invalid_argument(
154 "Linearization point not feasible for " 156 return Vector::Constant(nj, std::numeric_limits<double>::infinity());
162 const T& xj = x.
at<T>(this->
key());
184 template<
class ARCHIVE>
187 & boost::serialization::make_nvp(
"NoiseModelFactor1",
188 boost::serialization::base_object<Base>(*
this));
189 ar & BOOST_SERIALIZATION_NVP(feasible_);
190 ar & BOOST_SERIALIZATION_NVP(allow_error_);
191 ar & BOOST_SERIALIZATION_NVP(error_gain_);
197 template<
typename VALUE>
205 template<
class VALUE>
238 std::
abs(
mu)), key), value_(value) {
252 boost::optional<Matrix&>
H = boost::none)
const override {
262 std::cout <<
s <<
": NonlinearEquality1(" << keyFormatter(this->
key())
273 friend class boost::serialization::access;
274 template<
class ARCHIVE>
277 & boost::serialization::make_nvp(
"NoiseModelFactor1",
278 boost::serialization::base_object<Base>(*
this));
279 ar & BOOST_SERIALIZATION_NVP(value_);
284 template<
typename VALUE>
293 template<
class VALUE>
310 typedef boost::shared_ptr<NonlinearEquality2<VALUE> >
shared_ptr;
327 boost::none, boost::optional<Matrix&> H2 = boost::none)
const override {
329 if (H1) *H1 = -Matrix::Identity(p,p);
330 if (H2) *H2 = Matrix::Identity(p,p);
339 friend class boost::serialization::access;
340 template<
class ARCHIVE>
343 & boost::serialization::make_nvp(
"NoiseModelFactor2",
344 boost::serialization::base_object<Base>(*
this));
349 template<
typename VALUE>
~NonlinearEquality2() override
bool equals(const NonlinearFactor &f, double tol=1e-9) const override
Concept check for values that can be used in unit tests.
gtsam::NonlinearFactor::shared_ptr clone() const override
double dot(const V1 &a, const V2 &b)
noiseModel::Diagonal::shared_ptr model
gtsam::NonlinearFactor::shared_ptr clone() const override
void serialize(ARCHIVE &ar, const unsigned int)
Pose3 x2(Rot3::Ypr(0.0, 0.0, 0.0), l2)
Vector evaluateError(const T &xj, boost::optional< Matrix & > H=boost::none) const override
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy y set format x g set format y g set format x2 g set format y2 g set format z g set angles radians set nogrid set key title set key left top Right noreverse box linetype linewidth samplen spacing width set nolabel set noarrow set nologscale set logscale x set set pointsize set encoding default set nopolar set noparametric set set set set surface set nocontour set clabel set mapping cartesian set nohidden3d set cntrparam order set cntrparam linear set cntrparam levels auto set cntrparam points set size set set xzeroaxis lt lw set x2zeroaxis lt lw set yzeroaxis lt lw set y2zeroaxis lt lw set tics in set ticslevel set tics set mxtics default set mytics default set mx2tics default set my2tics default set xtics border mirror norotate autofreq set ytics border mirror norotate autofreq set ztics border nomirror norotate autofreq set nox2tics set noy2tics set timestamp bottom norotate set rrange[*:*] noreverse nowriteback set trange[*:*] noreverse nowriteback set urange[*:*] noreverse nowriteback set vrange[*:*] noreverse nowriteback set xlabel matrix size set x2label set timefmt d m y n H
#define GTSAM_CONCEPT_TESTABLE_TYPE(T)
static const KeyFormatter DefaultKeyFormatter
const SharedNoiseModel & noiseModel() const
access to the noise model
NoiseModelFactor1< VALUE > Base
~NonlinearEquality() override
NoiseModelFactor1< VALUE > Base
const Symbol key1('v', 1)
GaussianFactor::shared_ptr linearize(const Values &x) const override
NonlinearEquality(Key j, const T &feasible, const CompareFunction &_compare=boost::bind(traits< T >::Equals, _1, _2, 1e-9))
gtsam::NonlinearFactor::shared_ptr clone() const override
Vector unwhitenedError(const Values &x, boost::optional< std::vector< Matrix > & > H=boost::none) const override
void print(const std::string &s="", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const override
print
const ValueType at(Key j) const
boost::function< bool(const T &, const T &)> CompareFunction
Vector evaluateError(const X &x1, boost::optional< Matrix & > H=boost::none) const override
Base class and basic functions for Manifold types.
friend class boost::serialization::access
NonlinearEquality(Key j, const T &feasible, double error_gain, const CompareFunction &_compare=boost::bind(traits< T >::Equals, _1, _2, 1e-9))
boost::shared_ptr< This > shared_ptr
std::function< std::string(Key)> KeyFormatter
Typedef for a function to format a key, i.e. to convert it to a string.
void serialize(ARCHIVE &ar, const unsigned int)
Point2(* f)(const Point3 &, OptionalJacobian< 2, 3 >)
boost::shared_ptr< NonlinearEquality2< VALUE > > shared_ptr
Array< double, 1, 3 > e(1./3., 0.5, 2.)
void print(const std::string &s="", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const override
NonlinearEquality2(Key key1, Key key2, double mu=1000.0)
TODO: comment.
boost::shared_ptr< This > shared_ptr
shared_ptr to this class
noiseModel::Diagonal::shared_ptr SharedDiagonal
boost::shared_ptr< Factor > shared_ptr
A shared_ptr to this class.
SharedNoiseModel noiseModel_
Non-linear factor base classes.
NoiseModelFactor2< VALUE, VALUE > Base
void serialize(ARCHIVE &ar, const unsigned int)
const Symbol key2('v', 2)
NonlinearEquality2< VALUE > This
#define GTSAM_CONCEPT_MANIFOLD_TYPE(T)
#define GTSAM_MAKE_ALIGNED_OPERATOR_NEW
NonlinearEquality< VALUE > This
double error(const Values &c) const override
Vector evaluateError(const X &x1, const X &x2, boost::optional< Matrix & > H1=boost::none, boost::optional< Matrix & > H2=boost::none) const override
NonlinearEquality1< VALUE > This
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy x
std::uint64_t Key
Integer nonlinear key type.
void Print(const CONTAINER &keys, const string &s, const KeyFormatter &keyFormatter)
~NonlinearEquality1() override
bool equals(const NonlinearFactor &f, double tol=1e-9) const override
static shared_ptr All(size_t dim)