55 static_assert(
N > 0,
"VectorNormFactor requires a fixed positive dimension");
58 typedef Eigen::Matrix<double, N, 1> VectorN;
87 : Base(model,
key), norm_(
norm) {}
92 NonlinearFactor::shared_ptr
clone()
const override {
93 return std::make_shared<This>(*
this);
98 void print(
const std::string& s =
"",
100 std::cout << (s.empty() ? s : s +
" ") <<
"VectorNormFactor on "
101 << keyFormatter(this->
template key<1>()) <<
", norm = " << norm_
103 this->noiseModel_->print(
" noise model: ");
107 const This* e =
dynamic_cast<const This*
>(&expected);
109 std::abs(norm_ - e->norm_) < tol;
114 double norm()
const {
return norm_; }
118 const double vnorm = v.norm();
121 *H = v.transpose() / vnorm;
128 return Vector1(vnorm - norm_);
132#if GTSAM_ENABLE_BOOST_SERIALIZATION
134 friend class boost::serialization::access;
135 template <
class ARCHIVE>
136 void serialize(ARCHIVE& ar,
const unsigned int ) {
137 ar& boost::serialization::make_nvp(
138 "NoiseModelFactor1", boost::serialization::base_object<Base>(*
this));
139 ar& BOOST_SERIALIZATION_NVP(norm_);
Non-linear factor base classes.
Global functions in a separate testing namespace.
Definition chartTesting.h:28
KeyFormatter DefaultKeyFormatter
Assign default key formatter.
Definition Key.cpp:30
Matrix * OptionalMatrixType
This typedef will be used everywhere boost::optional<Matrix&> reference was used previously.
Definition NonlinearFactor.h:57
NoiseModelFactorT< Vector, ValueTypes... > NoiseModelFactorN
Noise model factor with N value types and dynamic-sized error vector.
Definition NoiseModelFactorN.h:561
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
noiseModel::Base::shared_ptr SharedNoiseModel
Aliases.
Definition NoiseModel.h:846
std::uint64_t Key
Integer nonlinear key type.
Definition types.h:43
A manifold defines a space in which there is a notion of a linear tangent space that can be centered ...
Definition Group.h:37
A helper that implements the traits interface for GTSAM types.
Definition Testable.h:152
bool equals(const This &other, double tol=1e-9) const
check equality
Definition Factor.cpp:42
virtual Vector evaluateError(const ValueTypes &... x, OptionalMatrixTypeT< ValueTypes >... H) const=0
static constexpr auto N
Definition NoiseModelFactorN.h:158
Key key() const
Definition NoiseModelFactorN.h:307
Nonlinear factor base class.
Definition NonlinearFactor.h:70
Unary factor constraining the norm of an N-dimensional vector-space variable to a given value,...
Definition VectorNormFactor.h:54
Vector evaluateError(const VectorN &v, OptionalMatrixType H) const override
vector of errors: ||v|| - norm
Definition VectorNormFactor.h:117
void print(const std::string &s="", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const override
Print.
Definition VectorNormFactor.h:98
VectorNormFactor(Key key, double norm, const SharedNoiseModel &model)
Constructor.
Definition VectorNormFactor.h:86
NonlinearFactor::shared_ptr clone() const override
Definition VectorNormFactor.h:92
VectorNormFactor()
Default constructor - only use for serialization.
Definition VectorNormFactor.h:78
double norm() const
The desired norm.
Definition VectorNormFactor.h:114
bool equals(const NonlinearFactor &expected, double tol=1e-9) const override
Check if two factors are equal.
Definition VectorNormFactor.h:106
static constexpr double kMinNorm
Below this norm the error is treated as non-differentiable and the Jacobian is zero (see class warnin...
Definition VectorNormFactor.h:69
std::shared_ptr< This > shared_ptr
Shorthand for a smart pointer to a factor.
Definition VectorNormFactor.h:75