Go to the documentation of this file.
75 template <
class CAMERA>
120 const std::shared_ptr<Cameras>&
cameraRig,
125 throw std::runtime_error(
126 "SmartProjectionRigFactor: "
127 "degeneracyMode must be set to ZERO_ON_DEGENERACY");
129 throw std::runtime_error(
130 "SmartProjectionRigFactor: "
131 "linearizationMode must be set to HESSIAN");
145 const size_t& cameraId = 0) {
148 this->nonUniqueKeys_.push_back(
poseKey);
152 if (std::find(this->
keys_.begin(),
this->keys_.end(), poseKey) ==
154 this->
keys_.push_back(poseKey);
174 throw std::runtime_error(
175 "SmartProjectionRigFactor: "
176 "trying to add inconsistent inputs");
179 throw std::runtime_error(
180 "SmartProjectionRigFactor: "
181 "camera rig includes multiple camera "
182 "but add did not input cameraIds");
206 const std::string&
s =
"",
208 std::cout <<
s <<
"SmartProjectionRigFactor: \n ";
210 std::cout <<
"-- Measurement nr " <<
i << std::endl;
212 std::cout <<
"cameraId: " <<
cameraIds_[
i] << std::endl;
213 (*cameraRig_)[
cameraIds_[
i]].print(
"camera in rig:\n");
220 const This*
e =
dynamic_cast<const This*
>(&
p);
224 e->cameraIds().begin());
238 const Pose3 world_P_sensor_i =
241 cameras.emplace_back(world_P_sensor_i,
242 make_shared<typename CAMERA::CalibrationType>(
243 camera_i.calibration()));
252 if (this->
active(values)) {
272 throw(
"computeJacobiansWithTriangulatedPoint");
275 for (
size_t i = 0;
i <
Fs.size();
i++) {
288 bool diagonalDamping =
false)
const {
292 size_t nrUniqueKeys =
299 std::vector<size_t> js;
300 std::vector<Matrix> Gs(nrUniqueKeys * (nrUniqueKeys + 1) / 2);
301 std::vector<Vector> gs(nrUniqueKeys);
303 if (this->
measured_.size() != cameras.size())
304 throw std::runtime_error(
305 "SmartProjectionRigFactor: "
306 "measured_.size() inconsistent with input");
315 return std::make_shared<RegularHessianFactor<DimPose> >(this->
keys_,
318 throw std::runtime_error(
319 "SmartProjectionRigFactor: "
320 "only supported degeneracy mode is ZERO_ON_DEGENERACY");
332 for (
size_t i = 0;
i <
Fs.size();
i++) {
336 const Matrix3
P = Base::Cameras::PointCov(
E,
lambda, diagonalDamping);
342 Base::Cameras::template SchurComplementAndRearrangeBlocks<3, 6, 6>(
345 return std::make_shared<RegularHessianFactor<DimPose> >(
346 this->
keys_, augmentedHessianUniqueKeys);
364 throw std::runtime_error(
365 "SmartProjectionRigFactor: unknown linearization mode");
376 #if GTSAM_ENABLE_BOOST_SERIALIZATION
377 friend class boost::serialization::access;
379 template <
class ARCHIVE>
380 void serialize(ARCHIVE& ar,
const unsigned int ) {
381 ar& BOOST_SERIALIZATION_BASE_OBJECT_NVP(
Base);
391 template <
class CAMERA>
393 :
public Testable<SmartProjectionRigFactor<CAMERA> > {};
bool equals(const NonlinearFactor &p, double tol=1e-9) const override
equals
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
std::shared_ptr< GaussianFactor > linearizeDamped(const Values &values, const double &lambda=0.0) const
Pose3 body_P_sensor() const
EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef CAMERA Camera
Array< double, 1, 3 > e(1./3., 0.5, 2.)
std::vector< T, typename internal::FastDefaultVectorAllocator< T >::type > FastVector
Smart factor on cameras (pose + calibration)
Class compose(const Class &g) const
bool equals(const NonlinearFactor &p, double tol=1e-9) const override
equals
const ZVector & measured() const
Return the 2D measurements (ZDim, in general).
SmartProjectionParams params_
const KeyVector & nonUniqueKeys() const
static const SmartProjectionParams params
double totalReprojectionError(const Cameras &cameras, std::optional< Point3 > externalPoint={}) const
SmartProjectionRigFactor()
Default constructor, only for serialization.
FastVector< Key > KeyVector
Define collection type once and for all - also used in wrappers.
TriangulationResult triangulateSafe(const Cameras &cameras) const
Call gtsam::triangulateSafe iff we need to re-triangulate.
void add(const MEASUREMENTS &measurements, const KeyVector &poseKeys, const FastVector< size_t > &cameraIds=FastVector< size_t >())
A set of cameras, all with their own calibration.
CameraSet< CAMERA > Cameras
const std::shared_ptr< Cameras > & cameraRig() const
return the calibration object
KeyFormatter DefaultKeyFormatter
Assign default key formatter.
CameraSet< CAMERA > Cameras
DegeneracyMode degeneracyMode
How to linearize the factor.
GenericMeasurement< Point2, Point2 > Measurement
std::shared_ptr< This > shared_ptr
shorthand for a smart pointer to a factor
LinearizationMode linearizationMode
How to linearize the factor.
TriangulationResult result_
result from triangulateSafe
SmartProjectionRigFactor< CAMERA > This
std::function< std::string(Key)> KeyFormatter
Typedef for a function to format a key, i.e. to convert it to a string.
SharedIsotropic noiseModel_
Pose3 inverse() const
inverse transformation with derivatives
CAMERA::MeasurementVector MEASUREMENTS
CAMERA::CalibrationType CALIBRATION
FastVector< size_t > cameraIds_
noiseModel::Base::shared_ptr SharedNoiseModel
#define EIGEN_MAKE_ALIGNED_OPERATOR_NEW
const FastVector< size_t > & cameraIds() const
return the calibration object
SmartProjectionFactor< CAMERA > Base
void print(const std::string &s="", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const override
std::vector< double > measurements
std::vector< MatrixZD, Eigen::aligned_allocator< MatrixZD > > FBlocks
SmartProjectionRigFactor(const SharedNoiseModel &sharedNoiseModel, const std::shared_ptr< Cameras > &cameraRig, const SmartProjectionParams ¶ms=SmartProjectionParams())
void computeJacobiansWithTriangulatedPoint(typename Base::FBlocks &Fs, Matrix &E, Vector &b, const Cameras &cameras) const
std::shared_ptr< GaussianFactor > linearize(const Values &values) const override
linearize
CAMERA::Measurement MEASUREMENT
std::shared_ptr< typename Base::Cameras > cameraRig_
cameras in the rig (fixed poses wrt body and intrinsics, for each camera)
KeyVector keys_
The keys involved in this factor.
void add(const MEASUREMENT &measured, const Key &poseKey, const size_t &cameraId=0)
KeyVector nonUniqueKeys_
vector of keys (one for each observation) with potentially repeated keys
Array< int, Dynamic, 1 > v
std::shared_ptr< RegularHessianFactor< DimPose > > createHessianFactor(const Values &values, const double &lambda=0.0, bool diagonalDamping=false) const
linearize and return a Hessianfactor that is an approximation of error(p)
CAMERA Camera
shorthand for a set of cameras
Base::Cameras cameras(const Values &values) const override
The matrix class, also used for vectors and row-vectors.
static const int ZDim
Measurement dimension.
double error(const Values &values) const override
std::uint64_t Key
Integer nonlinear key type.
static const int DimPose
Pose3 dimension.
virtual bool active(const Values &c) const
void print(const std::string &s="", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const override
bool equal(const T &obj1, const T &obj2, double tol)
gtsam
Author(s):
autogenerated on Wed May 28 2025 03:03:21