55 SharedGaussian model_;
58 GTSAM_CONCEPT_LIE_TYPE(T)
59 GTSAM_CONCEPT_TESTABLE_TYPE(T)
64 typedef typename std::shared_ptr<TransformBtwRobotsUnaryFactor>
shared_ptr;
72 const SharedGaussian& model) :
73 Base(
KeyVector{key}), key_(key), measured_(measured), keyA_(keyA), keyB_(keyB),
84 gtsam::NonlinearFactor::shared_ptr
clone()
const override {
return std::make_shared<This>(*
this); }
91 std::cout << s <<
"TransformBtwRobotsUnaryFactor("
92 << keyFormatter(key_) <<
")\n";
93 std::cout <<
"MR between factor keys: "
94 << keyFormatter(keyA_) <<
","
95 << keyFormatter(keyB_) <<
"\n";
96 measured_.print(
" measured: ");
97 model_->print(
" noise model: ");
103 const This *t =
dynamic_cast<const This*
> (&f);
106 return key_ == t->key_ && measured_.equals(t->measured_);
116 throw(
"something is wrong!");
132 return whitenedError(x).squaredNorm();
145 return std::shared_ptr<gtsam::JacobianFactor>();
149 std::vector<gtsam::Matrix> A(this->
size());
150 gtsam::Vector b = -whitenedError(x, A);
161 T orgA_T_currA = valA_.
at<T>(keyA_);
162 T orgB_T_currB = valB_.
at<T>(keyB_);
163 T orgA_T_orgB = x.
at<T>(key_);
165 T currA_T_currB_pred;
167 Matrix H_compose, H_between1;
168 T orgA_T_currB = orgA_T_orgB.compose(orgB_T_currB, H_compose, {});
169 currA_T_currB_pred = orgA_T_currA.between(orgA_T_currB, {}, H_between1);
170 (*H)[0] = H_compose * H_between1;
173 T orgA_T_currB = orgA_T_orgB.compose(orgB_T_currB);
174 currA_T_currB_pred = orgA_T_currA.between(orgA_T_currB);
177 const T& currA_T_currB_msr = measured_;
178 Vector error = currA_T_currB_msr.localCoordinates(currA_T_currB_pred);
181 model_->WhitenSystem(*H, error);
183 model_->whitenInPlace(error);
193 return whitenedError(x, &H);
198 gtsam::Vector unwhitenedError(
const gtsam::Values& x)
const {
200 T orgA_T_currA = valA_.
at<T>(keyA_);
201 T orgB_T_currB = valB_.
at<T>(keyB_);
202 T orgA_T_orgB = x.
at<T>(key_);
204 T orgA_T_currB = orgA_T_orgB.compose(orgB_T_currB);
205 T currA_T_currB_pred = orgA_T_currA.between(orgA_T_currB);
207 T currA_T_currB_msr = measured_;
208 return currA_T_currB_msr.localCoordinates(currA_T_currB_pred);
213 size_t dim()
const override {
214 return model_->R().rows() + model_->R().cols();
219#if GTSAM_ENABLE_BOOST_SERIALIZATION
221 friend class boost::serialization::access;
222 template<
class ARCHIVE>
223 void serialize(ARCHIVE & ar,
const unsigned int ) {
224 ar & boost::serialization::make_nvp(
"NonlinearFactor",
225 boost::serialization::base_object<Base>(*
this));
232 template<
class VALUE>
234 public Testable<TransformBtwRobotsUnaryFactor<VALUE> > {
Concept check for values that can be used in unit tests.
Base class and basic functions for Lie types.
A factor with a quadratic error function - a Gaussian.
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
FastVector< Key > KeyVector
Define collection type once and for all - also used in wrappers.
Definition Key.h:91
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
std::vector< Matrix > * OptionalMatrixVecType
The OptionalMatrixVecType is a pointer to a vector of matrices.
Definition NonlinearFactor.h:63
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
size_t size() const
Definition Factor.h:160
std::shared_ptr< This > shared_ptr
shared_ptr to this class
Definition GaussianFactor.h:42
A Gaussian factor in the squared-error form.
Definition JacobianFactor.h:92
static shared_ptr Create(size_t dim)
Create a unit covariance noise model.
Definition NoiseModel.h:673
Nonlinear factor base class.
Definition NonlinearFactor.h:70
virtual bool equals(const NonlinearFactor &f, double tol=1e-9) const
Check if two factors are equal.
Definition NonlinearFactor.cpp:55
NonlinearFactor()
Default constructor for I/O only.
Definition NonlinearFactor.h:86
virtual bool active(const Values &c) const
Checks whether a factor should be used based on a set of values.
Definition NonlinearFactor.h:143
A non-templated config holding any types of Manifold-group elements.
Definition Values.h:65
const ValueType at(Key j) const
Retrieve a variable by key j.
Definition Values-inl.h:260
bool exists(Key j) const
Check if a value exists with key j.
Definition Values.cpp:95
A class for a measurement predicted by "between(config[key1],config[key2])".
Definition TransformBtwRobotsUnaryFactor.h:35
void setValAValB(const gtsam::Values &valA, const gtsam::Values &valB)
implement functions needed to derive from Factor
Definition TransformBtwRobotsUnaryFactor.h:114
std::shared_ptr< gtsam::GaussianFactor > linearize(const gtsam::Values &x) const override
Linearize a non-linearFactorN to get a gtsam::GaussianFactor, Hence .
Definition TransformBtwRobotsUnaryFactor.h:142
bool equals(const NonlinearFactor &f, double tol=1e-9) const override
equals
Definition TransformBtwRobotsUnaryFactor.h:102
void print(const std::string &s, const KeyFormatter &keyFormatter=DefaultKeyFormatter) const override
implement functions needed for Testable
Definition TransformBtwRobotsUnaryFactor.h:90
size_t dim() const override
get the dimension of the factor (number of rows on linearization)
Definition TransformBtwRobotsUnaryFactor.h:213
TransformBtwRobotsUnaryFactor(Key key, const VALUE &measured, Key keyA, Key keyB, const gtsam::Values &valA, const gtsam::Values &valB, const SharedGaussian &model)
Constructor.
Definition TransformBtwRobotsUnaryFactor.h:70
gtsam::Vector whitenedError(const gtsam::Values &x, std::vector< Matrix > &H) const
A function overload to accept a vector<matrix> instead of a pointer to the said type.
Definition TransformBtwRobotsUnaryFactor.h:192
std::shared_ptr< TransformBtwRobotsUnaryFactor > shared_ptr
concept check by type
Definition TransformBtwRobotsUnaryFactor.h:64
TransformBtwRobotsUnaryFactor()
default constructor - only use for serialization
Definition TransformBtwRobotsUnaryFactor.h:67
gtsam::NonlinearFactor::shared_ptr clone() const override
Clone.
Definition TransformBtwRobotsUnaryFactor.h:84