//************************************************************************* // slam //************************************************************************* namespace gtsam { #include #include #include // ###### #include template virtual class BetweenFactor : gtsam::NoiseModelFactor { BetweenFactor(size_t key1, size_t key2, const T& relativePose, const gtsam::noiseModel::Base* noiseModel); T measured() const; // enabling serialization functionality void serialize() const; }; #include template virtual class GenericProjectionFactor : gtsam::NoiseModelFactor { GenericProjectionFactor(const gtsam::Point2& measured, const gtsam::noiseModel::Base* noiseModel, size_t poseKey, size_t pointKey, const CALIBRATION* k); GenericProjectionFactor(const gtsam::Point2& measured, const gtsam::noiseModel::Base* noiseModel, size_t poseKey, size_t pointKey, const CALIBRATION* k, const POSE& body_P_sensor); GenericProjectionFactor(const gtsam::Point2& measured, const gtsam::noiseModel::Base* noiseModel, size_t poseKey, size_t pointKey, const CALIBRATION* k, bool throwCheirality, bool verboseCheirality); GenericProjectionFactor(const gtsam::Point2& measured, const gtsam::noiseModel::Base* noiseModel, size_t poseKey, size_t pointKey, const CALIBRATION* k, bool throwCheirality, bool verboseCheirality, const POSE& body_P_sensor); gtsam::Point2 measured() const; CALIBRATION* calibration() const; bool verboseCheirality() const; bool throwCheirality() const; // enabling serialization functionality void serialize() const; }; typedef gtsam::GenericProjectionFactor GenericProjectionFactorCal3_S2; typedef gtsam::GenericProjectionFactor GenericProjectionFactorCal3DS2; typedef gtsam::GenericProjectionFactor GenericProjectionFactorCal3Fisheye; typedef gtsam::GenericProjectionFactor GenericProjectionFactorCal3Unified; #include template virtual class GeneralSFMFactor : gtsam::NoiseModelFactor { GeneralSFMFactor(const gtsam::Point2& measured, const gtsam::noiseModel::Base* model, size_t cameraKey, size_t landmarkKey); gtsam::Point2 measured() const; }; typedef gtsam::GeneralSFMFactor, gtsam::Point3> GeneralSFMFactorCal3_S2; typedef gtsam::GeneralSFMFactor, gtsam::Point3> GeneralSFMFactorCal3DS2; typedef gtsam::GeneralSFMFactor, gtsam::Point3> GeneralSFMFactorCal3Bundler; typedef gtsam::GeneralSFMFactor, gtsam::Point3> GeneralSFMFactorCal3Fisheye; typedef gtsam::GeneralSFMFactor, gtsam::Point3> GeneralSFMFactorCal3Unified; template virtual class GeneralSFMFactor2 : gtsam::NoiseModelFactor { GeneralSFMFactor2(const gtsam::Point2& measured, const gtsam::noiseModel::Base* model, size_t poseKey, size_t landmarkKey, size_t calibKey); gtsam::Point2 measured() const; // enabling serialization functionality void serialize() const; }; #include /// Linearization mode: what factor to linearize to enum LinearizationMode { HESSIAN, IMPLICIT_SCHUR, JACOBIAN_Q, JACOBIAN_SVD }; /// How to manage degeneracy enum DegeneracyMode { IGNORE_DEGENERACY, ZERO_ON_DEGENERACY, HANDLE_INFINITY }; class SmartProjectionParams { SmartProjectionParams(); void setLinearizationMode(gtsam::LinearizationMode linMode); void setDegeneracyMode(gtsam::DegeneracyMode degMode); void setRankTolerance(double rankTol); void setEnableEPI(bool enableEPI); void setLandmarkDistanceThreshold(bool landmarkDistanceThreshold); void setDynamicOutlierRejectionThreshold(bool dynOutRejectionThreshold); }; #include template virtual class SmartProjectionPoseFactor : gtsam::NonlinearFactor { SmartProjectionPoseFactor(const gtsam::noiseModel::Base* noise, const CALIBRATION* K); SmartProjectionPoseFactor(const gtsam::noiseModel::Base* noise, const CALIBRATION* K, const gtsam::Pose3& body_P_sensor); SmartProjectionPoseFactor(const gtsam::noiseModel::Base* noise, const CALIBRATION* K, const gtsam::SmartProjectionParams& params); SmartProjectionPoseFactor(const gtsam::noiseModel::Base* noise, const CALIBRATION* K, const gtsam::Pose3& body_P_sensor, const gtsam::SmartProjectionParams& params); void add(const gtsam::Point2& measured_i, size_t poseKey_i); // enabling serialization functionality void serialize() const; }; typedef gtsam::SmartProjectionPoseFactor SmartProjectionPose3Factor; #include template virtual class GenericStereoFactor : gtsam::NoiseModelFactor { GenericStereoFactor(const gtsam::StereoPoint2& measured, const gtsam::noiseModel::Base* noiseModel, size_t poseKey, size_t landmarkKey, const gtsam::Cal3_S2Stereo* K); gtsam::StereoPoint2 measured() const; gtsam::Cal3_S2Stereo* calibration() const; // enabling serialization functionality void serialize() const; }; typedef gtsam::GenericStereoFactor GenericStereoFactor3D; #include template virtual class PoseTranslationPrior : gtsam::NoiseModelFactor { PoseTranslationPrior(size_t key, const POSE& pose_z, const gtsam::noiseModel::Base* noiseModel); POSE::Translation measured() const; // enabling serialization functionality void serialize() const; }; typedef gtsam::PoseTranslationPrior PoseTranslationPrior2D; typedef gtsam::PoseTranslationPrior PoseTranslationPrior3D; #include template virtual class PoseRotationPrior : gtsam::NoiseModelFactor { PoseRotationPrior(size_t key, const POSE& pose_z, const gtsam::noiseModel::Base* noiseModel); POSE::Rotation measured() const; }; typedef gtsam::PoseRotationPrior PoseRotationPrior2D; typedef gtsam::PoseRotationPrior PoseRotationPrior3D; #include virtual class EssentialMatrixFactor : gtsam::NoiseModelFactor { EssentialMatrixFactor(size_t key, const gtsam::Point2& pA, const gtsam::Point2& pB, const gtsam::noiseModel::Base* noiseModel); void print(string s = "", const gtsam::KeyFormatter& keyFormatter = gtsam::DefaultKeyFormatter) const; bool equals(const gtsam::EssentialMatrixFactor& other, double tol) const; Vector evaluateError(const gtsam::EssentialMatrix& E) const; }; #include virtual class EssentialMatrixConstraint : gtsam::NoiseModelFactor { EssentialMatrixConstraint(size_t key1, size_t key2, const gtsam::EssentialMatrix &measuredE, const gtsam::noiseModel::Base *model); void print(string s = "", const gtsam::KeyFormatter& keyFormatter = gtsam::DefaultKeyFormatter) const; bool equals(const gtsam::EssentialMatrixConstraint& other, double tol) const; Vector evaluateError(const gtsam::Pose3& p1, const gtsam::Pose3& p2) const; const gtsam::EssentialMatrix& measured() const; }; #include class SfmTrack { SfmTrack(); SfmTrack(const gtsam::Point3& pt); const Point3& point3() const; double r; double g; double b; std::vector> measurements; size_t number_measurements() const; pair measurement(size_t idx) const; pair siftIndex(size_t idx) const; void add_measurement(size_t idx, const gtsam::Point2& m); // enabling serialization functionality void serialize() const; // enabling function to compare objects bool equals(const gtsam::SfmTrack& expected, double tol) const; }; class SfmData { SfmData(); size_t number_cameras() const; size_t number_tracks() const; gtsam::PinholeCamera camera(size_t idx) const; gtsam::SfmTrack track(size_t idx) const; void add_track(const gtsam::SfmTrack& t); void add_camera(const gtsam::SfmCamera& cam); // enabling serialization functionality void serialize() const; // enabling function to compare objects bool equals(const gtsam::SfmData& expected, double tol) const; }; gtsam::SfmData readBal(string filename); bool writeBAL(string filename, gtsam::SfmData& data); gtsam::Values initialCamerasEstimate(const gtsam::SfmData& db); gtsam::Values initialCamerasAndPointsEstimate(const gtsam::SfmData& db); pair load2D( string filename, gtsam::noiseModel::Diagonal* model, int maxIndex, bool addNoise, bool smart); pair load2D( string filename, gtsam::noiseModel::Diagonal* model, int maxIndex, bool addNoise); pair load2D( string filename, gtsam::noiseModel::Diagonal* model, int maxIndex); pair load2D( string filename, gtsam::noiseModel::Diagonal* model); pair load2D(string filename); void save2D(const gtsam::NonlinearFactorGraph& graph, const gtsam::Values& config, gtsam::noiseModel::Diagonal* model, string filename); // std::vector::shared_ptr> // Ignored by pybind -> will be List[BetweenFactorPose2] class BetweenFactorPose2s { BetweenFactorPose2s(); size_t size() const; gtsam::BetweenFactor* at(size_t i) const; void push_back(const gtsam::BetweenFactor* factor); }; gtsam::BetweenFactorPose2s parse2DFactors(string filename); // std::vector::shared_ptr> // Ignored by pybind -> will be List[BetweenFactorPose3] class BetweenFactorPose3s { BetweenFactorPose3s(); size_t size() const; gtsam::BetweenFactor* at(size_t i) const; void push_back(const gtsam::BetweenFactor* factor); }; gtsam::BetweenFactorPose3s parse3DFactors(string filename); pair load3D(string filename); pair readG2o(string filename); pair readG2o(string filename, bool is3D); void writeG2o(const gtsam::NonlinearFactorGraph& graph, const gtsam::Values& estimate, string filename); #include class InitializePose3 { static gtsam::Values computeOrientationsChordal( const gtsam::NonlinearFactorGraph& pose3Graph); static gtsam::Values computeOrientationsGradient( const gtsam::NonlinearFactorGraph& pose3Graph, const gtsam::Values& givenGuess, size_t maxIter, const bool setRefFrame); static gtsam::Values computeOrientationsGradient( const gtsam::NonlinearFactorGraph& pose3Graph, const gtsam::Values& givenGuess); static gtsam::NonlinearFactorGraph buildPose3graph( const gtsam::NonlinearFactorGraph& graph); static gtsam::Values initializeOrientations( const gtsam::NonlinearFactorGraph& graph); static gtsam::Values initialize(const gtsam::NonlinearFactorGraph& graph, const gtsam::Values& givenGuess, bool useGradient); static gtsam::Values initialize(const gtsam::NonlinearFactorGraph& graph); }; #include template virtual class KarcherMeanFactor : gtsam::NonlinearFactor { KarcherMeanFactor(const gtsam::KeyVector& keys); }; template const T FindKarcherMean(const std::vector& rotations); #include gtsam::noiseModel::Isotropic* ConvertNoiseModel(gtsam::noiseModel::Base* model, size_t d); template virtual class FrobeniusFactor : gtsam::NoiseModelFactor { FrobeniusFactor(size_t key1, size_t key2); FrobeniusFactor(size_t key1, size_t key2, gtsam::noiseModel::Base* model); Vector evaluateError(const T& R1, const T& R2); }; template virtual class FrobeniusBetweenFactor : gtsam::NoiseModelFactor { FrobeniusBetweenFactor(size_t key1, size_t key2, const T& R12); FrobeniusBetweenFactor(size_t key1, size_t key2, const T& R12, gtsam::noiseModel::Base* model); Vector evaluateError(const T& R1, const T& R2); }; #include namespace lago { gtsam::Values initialize(const gtsam::NonlinearFactorGraph& graph, bool useOdometricPath = true); gtsam::Values initialize(const gtsam::NonlinearFactorGraph& graph, const gtsam::Values& initialGuess); } } // namespace gtsam