47 std::vector<std::shared_ptr<Cal3_S2Stereo>>
K_all_;
68 typedef Eigen::Matrix<double, ZDim, DimBlock> MatrixZD;
69 typedef std::vector<MatrixZD, Eigen::aligned_allocator<MatrixZD> > FBlocks;
77 const SmartStereoProjectionParams& params =
78 SmartStereoProjectionParams());
89 const Key& body_P_cam_key,
90 const std::shared_ptr<Cal3_S2Stereo>& K);
101 void add(
const std::vector<StereoPoint2>& measurements,
103 const std::vector<std::shared_ptr<Cal3_S2Stereo>>& Ks);
115 void add(
const std::vector<StereoPoint2>& measurements,
117 const std::shared_ptr<Cal3_S2Stereo>& K);
138 double error(
const Values& values)
const override;
141 inline std::vector<std::shared_ptr<Cal3_S2Stereo>>
calibration()
const {
152 Base::Cameras cameras(
const Values& values)
const override;
163 FBlocks& Fs, Matrix& E, Vector& b,
const Values& values)
const {
165 throw(
"computeJacobiansWithTriangulatedPoint");
168 E = Matrix::Zero(3 * numViews, 3);
169 b = Vector::Zero(3 * numViews);
170 Matrix dPoseCam_dPoseBody_i, dPoseCam_dPoseExt_i, dProject_dPoseCam_i, Ei;
172 for (
size_t i = 0; i < numViews; i++) {
176 w_P_body.compose(body_P_cam, dPoseCam_dPoseBody_i, dPoseCam_dPoseExt_i),
181 Eigen::Matrix<double, ZDim, DimBlock> J;
182 J.block<
ZDim, 6>(0, 0) = dProject_dPoseCam_i * dPoseCam_dPoseBody_i;
183 J.block<
ZDim, 6>(0, 6) = dProject_dPoseCam_i * dPoseCam_dPoseExt_i;
187 J.block<1, 12>(1, 0) = Matrix::Zero(1, 12);
188 Ei.block<1, 3>(1, 0) = Matrix::Zero(1, 3);
190 reprojectionError_i.
v());
195 b.segment<
ZDim>(row) = -reprojectionError_i.
vector();
196 E.block<3, 3>(row, 0) = Ei;
203 const Values& values,
const double lambda = 0.0,
204 bool diagonalDamping =
false)
const {
208 size_t nrUniqueKeys =
keys_.size();
212 std::vector<Matrix> Gs(nrUniqueKeys * (nrUniqueKeys + 1) / 2);
213 std::vector<Vector> gs(nrUniqueKeys);
216 throw std::runtime_error(
"SmartStereoProjectionHessianFactor: this->"
217 "measured_.size() inconsistent with input");
225 for (Vector& v : gs) v = Vector::Zero(
DimPose);
226 return std::make_shared<RegularHessianFactor<DimPose>>(
keys_, Gs, gs,
238 for (
size_t i = 0; i < Fs.size(); i++) {
254 Base::Cameras::template SchurComplementAndRearrangeBlocks<3,
DimBlock,
256 Fs, E, P, b, nonuniqueKeys,
keys_);
258 return std::make_shared<RegularHessianFactor<DimPose>>(
259 keys_, augmentedHessianUniqueKeys);
268 const Values& values,
const double lambda = 0.0)
const {
270 switch (params_.linearizationMode) {
274 throw std::runtime_error(
275 "SmartStereoProjectionFactorPP: unknown linearization mode");
286#if GTSAM_ENABLE_BOOST_SERIALIZATION
288 friend class boost::serialization::access;
289 template<
class ARCHIVE>
290 void serialize(ARCHIVE& ar,
const unsigned int ) {
291 ar& BOOST_SERIALIZATION_BASE_OBJECT_NVP(Base);
292 ar & BOOST_SERIALIZATION_NVP(K_all_);
301 SmartStereoProjectionFactorPP> {
Smart stereo factor on StereoCameras (pose).
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
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
This class stores a dense matrix and allows it to be accessed as a collection of blocks.
Definition SymmetricBlockMatrix.h:80
A helper that implements the traits interface for GTSAM types.
Definition Testable.h:152
static void ComputePointCovariance(Eigen::Matrix< double, N, N > &P, const Matrix &E, double lambda, bool diagonalDamping=false)
Definition CameraSet.h:344
A 3D pose (R,t) : (Rot3,Point3).
Definition Pose3.h:42
A stereo camera class, parameterize by left camera pose and stereo calibration.
Definition StereoCamera.h:47
StereoPoint2 project(const Point3 &point) const
Project 3D point to StereoPoint2 (uL,uR,v).
Definition StereoCamera.cpp:32
A 2D stereo point, v will be same for rectified images.
Definition StereoPoint2.h:34
Vector3 vector() const
convert to vector
Definition StereoPoint2.h:119
double uL() const
get uL
Definition StereoPoint2.h:110
double v() const
get v
Definition StereoPoint2.h:116
KeyVector keys_
The keys involved in this factor.
Definition Factor.h:88
size_t size() const
Definition Factor.h:160
Nonlinear factor base class.
Definition NonlinearFactor.h:70
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
SharedIsotropic noiseModel_
Definition SmartFactorBase.h:73
ZVector measured_
Definition SmartFactorBase.h:80
const ZVector & measured() const
Definition SmartFactorBase.h:162
TriangulationResult triangulateSafe(const Cameras &cameras) const
triangulateSafe
Definition SmartStereoProjectionFactor.h:167
TriangulationResult result_
result from triangulateSafe
Definition SmartStereoProjectionFactor.h:70
SmartStereoProjectionFactor(const SharedNoiseModel &sharedNoiseModel, const SmartStereoProjectionParams ¶ms=SmartStereoProjectionParams(), const std::optional< Pose3 > body_P_sensor={})
Constructor.
Definition SmartStereoProjectionFactor.h:91
If you are using the factor, please cite: L.
Definition SmartStereoProjectionFactorPP.h:44
static const int DimBlock
Camera dimension: 6 for body pose, 6 for extrinsic pose.
Definition SmartStereoProjectionFactorPP.h:65
SmartStereoProjectionFactorPP This
shorthand for this class
Definition SmartStereoProjectionFactorPP.h:60
std::vector< std::shared_ptr< Cal3_S2Stereo > > K_all_
shared pointer to calibration object (one for each camera)
Definition SmartStereoProjectionFactorPP.h:47
static const int ZDim
Measurement dimension (for a StereoPoint2 measurement).
Definition SmartStereoProjectionFactorPP.h:67
std::shared_ptr< This > shared_ptr
shorthand for a smart pointer to a factor
Definition SmartStereoProjectionFactorPP.h:63
bool equals(const NonlinearFactor &p, double tol=1e-9) const override
equals
Definition SmartStereoProjectionFactorPP.cpp:96
std::shared_ptr< GaussianFactor > linearize(const Values &values) const override
linearize
Definition SmartStereoProjectionFactorPP.h:280
SmartStereoProjectionFactorPP(const SharedNoiseModel &sharedNoiseModel, const SmartStereoProjectionParams ¶ms=SmartStereoProjectionParams())
Constructor.
Definition SmartStereoProjectionFactorPP.cpp:25
void add(const StereoPoint2 &measured, const Key &world_P_body_key, const Key &body_P_cam_key, const std::shared_ptr< Cal3_S2Stereo > &K)
add a new measurement, with a pose key, and an extrinsic pose key
Definition SmartStereoProjectionFactorPP.cpp:30
const KeyVector & getExtrinsicPoseKeys() const
equals
Definition SmartStereoProjectionFactorPP.h:131
std::vector< std::shared_ptr< Cal3_S2Stereo > > calibration() const
return the calibration object
Definition SmartStereoProjectionFactorPP.h:141
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)
Definition SmartStereoProjectionFactorPP.h:202
KeyVector world_P_body_keys_
The keys corresponding to the pose of the body (with respect to an external world frame) for each vie...
Definition SmartStereoProjectionFactorPP.h:50
void computeJacobiansAndCorrectForMissingMeasurements(FBlocks &Fs, Matrix &E, Vector &b, const Values &values) const
Compute jacobian F, E and error vector at a given linearization point.
Definition SmartStereoProjectionFactorPP.h:162
KeyVector body_P_cam_keys_
The keys corresponding to the extrinsic pose calibration for each view (pose that transform from came...
Definition SmartStereoProjectionFactorPP.h:53
std::shared_ptr< GaussianFactor > linearizeDamped(const Values &values, const double lambda=0.0) const
Linearize to Gaussian Factor (possibly adding a damping factor Lambda for LM).
Definition SmartStereoProjectionFactorPP.h:267
Base::Cameras cameras(const Values &values) const override
Collect all cameras involved in this factor.
Definition SmartStereoProjectionFactorPP.cpp:114
void print(const std::string &s="", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const override
print
Definition SmartStereoProjectionFactorPP.cpp:86
SmartStereoProjectionFactor Base
shorthand for base class type
Definition SmartStereoProjectionFactorPP.h:57
static const int DimPose
Pose3 dimension.
Definition SmartStereoProjectionFactorPP.h:66