2014-01-25 05:06:48 +08:00
|
|
|
/* ----------------------------------------------------------------------------
|
|
|
|
|
|
2016-02-11 09:48:52 +08:00
|
|
|
* GTSAM Copyright 2010, Georgia Tech Research Corporation,
|
2014-01-25 05:06:48 +08:00
|
|
|
* Atlanta, Georgia 30332-0415
|
|
|
|
|
* All Rights Reserved
|
|
|
|
|
* Authors: Frank Dellaert, et al. (see THANKS for the full author list)
|
|
|
|
|
|
|
|
|
|
* See LICENSE for the license information
|
|
|
|
|
|
|
|
|
|
* -------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @file GPSFactor.h
|
|
|
|
|
* @author Frank Dellaert
|
|
|
|
|
* @brief Header file for GPS factor
|
|
|
|
|
* @date January 22, 2014
|
|
|
|
|
**/
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <gtsam/nonlinear/NonlinearFactor.h>
|
2016-02-25 03:01:19 +08:00
|
|
|
#include <gtsam/navigation/NavState.h>
|
2014-01-25 05:06:48 +08:00
|
|
|
#include <gtsam/geometry/Pose3.h>
|
|
|
|
|
|
|
|
|
|
namespace gtsam {
|
|
|
|
|
|
|
|
|
|
/**
|
2025-01-17 00:57:29 +08:00
|
|
|
* Prior on position in a Cartesian frame.
|
2025-01-15 20:31:38 +08:00
|
|
|
* If there exists a non-zero lever arm between body frame and GPS
|
|
|
|
|
* antenna, instead use GPSFactorArm.
|
2014-01-29 04:46:18 +08:00
|
|
|
* Possibilities include:
|
|
|
|
|
* ENU: East-North-Up navigation frame at some local origin
|
|
|
|
|
* NED: North-East-Down navigation frame at some local origin
|
|
|
|
|
* ECEF: Earth-centered Earth-fixed, origin at Earth's center
|
|
|
|
|
* See Farrell08book or e.g. http://www.dirsig.org/docs/new/coordinates.html
|
2022-07-27 04:25:41 +08:00
|
|
|
* @ingroup navigation
|
2014-01-25 05:06:48 +08:00
|
|
|
*/
|
2022-12-23 06:25:48 +08:00
|
|
|
class GTSAM_EXPORT GPSFactor: public NoiseModelFactorN<Pose3> {
|
2014-01-25 05:06:48 +08:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
2022-12-23 06:25:48 +08:00
|
|
|
typedef NoiseModelFactorN<Pose3> Base;
|
2014-01-25 05:06:48 +08:00
|
|
|
|
2025-01-17 00:57:29 +08:00
|
|
|
Point3 nT_; ///< Position measurement in cartesian coordinates (navigation frame)
|
2014-01-25 05:06:48 +08:00
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
2023-01-11 08:15:06 +08:00
|
|
|
// Provide access to the Matrix& version of evaluateError:
|
2023-01-07 08:29:15 +08:00
|
|
|
using Base::evaluateError;
|
2023-01-12 03:01:49 +08:00
|
|
|
|
2014-01-25 05:06:48 +08:00
|
|
|
/// shorthand for a smart pointer to a factor
|
2023-01-18 06:05:12 +08:00
|
|
|
typedef std::shared_ptr<GPSFactor> shared_ptr;
|
2014-01-25 05:06:48 +08:00
|
|
|
|
|
|
|
|
/// Typedef to this class
|
|
|
|
|
typedef GPSFactor This;
|
|
|
|
|
|
|
|
|
|
/** default constructor - only use for serialization */
|
2025-01-15 18:54:41 +08:00
|
|
|
GPSFactor(): nT_(0, 0, 0) {}
|
2014-01-25 05:06:48 +08:00
|
|
|
|
2021-01-29 12:02:13 +08:00
|
|
|
~GPSFactor() override {}
|
2014-01-25 05:06:48 +08:00
|
|
|
|
|
|
|
|
/**
|
2014-01-25 05:18:08 +08:00
|
|
|
* @brief Constructor from a measurement in a Cartesian frame.
|
|
|
|
|
* Use GeographicLib to convert from geographic (latitude and longitude) coordinates
|
2014-01-25 05:06:48 +08:00
|
|
|
* @param key of the Pose3 variable that will be constrained
|
2016-02-25 03:01:19 +08:00
|
|
|
* @param gpsIn measurement already in correct coordinates
|
2014-01-25 05:06:48 +08:00
|
|
|
* @param model Gaussian noise model
|
|
|
|
|
*/
|
2025-01-15 18:54:41 +08:00
|
|
|
GPSFactor(Key key, const Point3& gpsIn, const SharedNoiseModel& model) :
|
|
|
|
|
Base(model, key), nT_(gpsIn) {
|
2014-01-25 05:06:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// @return a deep copy of this factor
|
2020-07-26 15:57:54 +08:00
|
|
|
gtsam::NonlinearFactor::shared_ptr clone() const override {
|
2023-01-18 06:39:55 +08:00
|
|
|
return std::static_pointer_cast<gtsam::NonlinearFactor>(
|
2014-01-25 05:06:48 +08:00
|
|
|
gtsam::NonlinearFactor::shared_ptr(new This(*this)));
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-25 03:01:19 +08:00
|
|
|
/// print
|
2021-04-30 07:43:27 +08:00
|
|
|
void print(const std::string& s = "", const KeyFormatter& keyFormatter =
|
|
|
|
|
DefaultKeyFormatter) const override;
|
2014-01-25 05:06:48 +08:00
|
|
|
|
2016-02-25 03:01:19 +08:00
|
|
|
/// equals
|
2020-07-26 15:57:54 +08:00
|
|
|
bool equals(const NonlinearFactor& expected, double tol = 1e-9) const override;
|
2014-01-25 05:06:48 +08:00
|
|
|
|
2016-02-25 03:01:19 +08:00
|
|
|
/// vector of errors
|
2023-01-07 08:29:15 +08:00
|
|
|
Vector evaluateError(const Pose3& p, OptionalMatrixType H) const override;
|
2014-01-25 05:06:48 +08:00
|
|
|
|
2025-01-17 01:12:07 +08:00
|
|
|
/// return the measurement, in the navigation frame
|
2014-01-29 04:46:18 +08:00
|
|
|
inline const Point3 & measurementIn() const {
|
2014-01-25 05:06:48 +08:00
|
|
|
return nT_;
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-25 03:01:19 +08:00
|
|
|
/**
|
|
|
|
|
* Convenience function to estimate state at time t, given two GPS
|
2014-01-29 04:46:18 +08:00
|
|
|
* readings (in local NED Cartesian frame) bracketing t
|
|
|
|
|
* Assumes roll is zero, calculates yaw and pitch from NED1->NED2 vector.
|
|
|
|
|
*/
|
2014-02-03 11:43:00 +08:00
|
|
|
static std::pair<Pose3, Vector3> EstimateState(double t1, const Point3& NED1,
|
|
|
|
|
double t2, const Point3& NED2, double timestamp);
|
2014-01-29 04:46:18 +08:00
|
|
|
|
2014-01-25 05:06:48 +08:00
|
|
|
private:
|
|
|
|
|
|
2024-12-27 12:44:00 +08:00
|
|
|
#if GTSAM_ENABLE_BOOST_SERIALIZATION ///
|
2023-01-19 03:53:38 +08:00
|
|
|
/// Serialization function
|
2016-02-25 03:01:19 +08:00
|
|
|
friend class boost::serialization::access;
|
|
|
|
|
template<class ARCHIVE>
|
|
|
|
|
void serialize(ARCHIVE & ar, const unsigned int /*version*/) {
|
2022-12-23 06:25:48 +08:00
|
|
|
// NoiseModelFactor1 instead of NoiseModelFactorN for backward compatibility
|
2016-02-25 03:01:19 +08:00
|
|
|
ar
|
|
|
|
|
& boost::serialization::make_nvp("NoiseModelFactor1",
|
|
|
|
|
boost::serialization::base_object<Base>(*this));
|
|
|
|
|
ar & BOOST_SERIALIZATION_NVP(nT_);
|
|
|
|
|
}
|
2023-01-19 03:36:21 +08:00
|
|
|
#endif
|
2016-02-25 03:01:19 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
2025-01-15 20:31:38 +08:00
|
|
|
* Version of GPSFactor (for Pose3) with lever arm between GPS and Body frame.
|
|
|
|
|
* Because the actual location of the antenna depends on both position and
|
|
|
|
|
* attitude, providing a lever arm makes components of the attitude observable
|
|
|
|
|
* and accounts for position measurement vs state discrepancies while turning.
|
|
|
|
|
* @ingroup navigation
|
|
|
|
|
*/
|
|
|
|
|
class GTSAM_EXPORT GPSFactorArm: public NoiseModelFactorN<Pose3> {
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
|
|
typedef NoiseModelFactorN<Pose3> Base;
|
|
|
|
|
|
2025-01-17 00:57:29 +08:00
|
|
|
Point3 nT_; ///< Position measurement in cartesian coordinates (navigation frame)
|
2025-01-15 20:31:38 +08:00
|
|
|
Point3 bL_; ///< bL_ is a lever arm in the body frame, denoting the 3D
|
|
|
|
|
///< position of the GPS antenna in the body frame
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
// Provide access to the Matrix& version of evaluateError:
|
|
|
|
|
using Base::evaluateError;
|
|
|
|
|
|
|
|
|
|
/// shorthand for a smart pointer to a factor
|
|
|
|
|
typedef std::shared_ptr<GPSFactorArm> shared_ptr;
|
|
|
|
|
|
|
|
|
|
/// Typedef to this class
|
|
|
|
|
typedef GPSFactorArm This;
|
|
|
|
|
|
|
|
|
|
/// default constructor - only use for serialization
|
|
|
|
|
GPSFactorArm():nT_(0, 0, 0), bL_(0, 0, 0) {}
|
|
|
|
|
|
|
|
|
|
~GPSFactorArm() override {}
|
|
|
|
|
|
2025-01-17 01:12:07 +08:00
|
|
|
/** Constructor from a measurement in a Cartesian frame.
|
|
|
|
|
* @param key key of the Pose3 variable related to this measurement
|
|
|
|
|
* @param gpsIn gps measurement, in Cartesian navigation frame
|
|
|
|
|
* @param leverArm translation from the body frame origin to the gps antenna, in body frame
|
|
|
|
|
* @param model Gaussian noise model
|
|
|
|
|
*/
|
2025-01-15 20:31:38 +08:00
|
|
|
GPSFactorArm(Key key, const Point3& gpsIn, const Point3& leverArm, const SharedNoiseModel& model) :
|
|
|
|
|
Base(model, key), nT_(gpsIn), bL_(leverArm) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// @return a deep copy of this factor
|
|
|
|
|
gtsam::NonlinearFactor::shared_ptr clone() const override {
|
|
|
|
|
return std::static_pointer_cast<gtsam::NonlinearFactor>(
|
|
|
|
|
gtsam::NonlinearFactor::shared_ptr(new This(*this)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// print
|
|
|
|
|
void print(const std::string& s = "", const KeyFormatter& keyFormatter =
|
|
|
|
|
DefaultKeyFormatter) const override;
|
|
|
|
|
|
|
|
|
|
/// equals
|
|
|
|
|
bool equals(const NonlinearFactor& expected, double tol = 1e-9) const override;
|
|
|
|
|
|
|
|
|
|
/// vector of errors
|
|
|
|
|
Vector evaluateError(const Pose3& p, OptionalMatrixType H) const override;
|
|
|
|
|
|
2025-01-17 01:12:07 +08:00
|
|
|
/// return the measurement, in the navigation frame
|
2025-01-15 20:31:38 +08:00
|
|
|
inline const Point3 & measurementIn() const {
|
|
|
|
|
return nT_;
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-17 01:12:07 +08:00
|
|
|
/// return the lever arm, a position in the body frame
|
2025-01-15 20:31:38 +08:00
|
|
|
inline const Point3 & leverArm() const {
|
|
|
|
|
return bL_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
2025-01-17 04:27:42 +08:00
|
|
|
/**
|
|
|
|
|
* Version of GPSFactorArm (for Pose3) with unknown lever arm between GPS and
|
|
|
|
|
* Body frame. Because the actual location of the antenna depends on both
|
|
|
|
|
* position and attitude, providing a lever arm makes components of the attitude
|
|
|
|
|
* observable and accounts for position measurement vs state discrepancies while
|
|
|
|
|
* turning.
|
|
|
|
|
* @ingroup navigation
|
|
|
|
|
*/
|
|
|
|
|
class GTSAM_EXPORT GPSFactorArmCalib: public NoiseModelFactorN<Pose3, Point3> {
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
|
|
typedef NoiseModelFactorN<Pose3, Point3> Base;
|
|
|
|
|
|
|
|
|
|
Point3 nT_; ///< Position measurement in cartesian coordinates (navigation frame)
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
// Provide access to the Matrix& version of evaluateError:
|
|
|
|
|
using Base::evaluateError;
|
|
|
|
|
|
|
|
|
|
/// shorthand for a smart pointer to a factor
|
|
|
|
|
typedef std::shared_ptr<GPSFactorArmCalib> shared_ptr;
|
|
|
|
|
|
|
|
|
|
/// Typedef to this class
|
|
|
|
|
typedef GPSFactorArmCalib This;
|
|
|
|
|
|
|
|
|
|
/// default constructor - only use for serialization
|
|
|
|
|
GPSFactorArmCalib() : nT_(0, 0, 0) {}
|
|
|
|
|
|
|
|
|
|
~GPSFactorArmCalib() override {}
|
|
|
|
|
|
|
|
|
|
/** Constructor from a measurement in a Cartesian frame.
|
|
|
|
|
* @param key1 key of the Pose3 variable related to this measurement
|
|
|
|
|
* @param key2 key of the Point3 variable related to the lever arm
|
|
|
|
|
* @param gpsIn gps measurement, in Cartesian navigation frame
|
|
|
|
|
* @param leverArm translation from the body frame origin to the gps antenna, in body frame
|
|
|
|
|
* @param model Gaussian noise model
|
|
|
|
|
*/
|
|
|
|
|
GPSFactorArmCalib(Key key1, Key key2, const Point3& gpsIn, const SharedNoiseModel& model) :
|
|
|
|
|
Base(model, key1, key2), nT_(gpsIn) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// @return a deep copy of this factor
|
|
|
|
|
gtsam::NonlinearFactor::shared_ptr clone() const override {
|
|
|
|
|
return std::static_pointer_cast<gtsam::NonlinearFactor>(
|
|
|
|
|
gtsam::NonlinearFactor::shared_ptr(new This(*this)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// print
|
|
|
|
|
void print(const std::string& s = "", const KeyFormatter& keyFormatter =
|
|
|
|
|
DefaultKeyFormatter) const override;
|
|
|
|
|
|
|
|
|
|
/// equals
|
|
|
|
|
bool equals(const NonlinearFactor& expected, double tol = 1e-9) const override;
|
|
|
|
|
|
|
|
|
|
/// vector of errors
|
|
|
|
|
Vector evaluateError(const Pose3& p, const Point3& bL, OptionalMatrixType H1,
|
|
|
|
|
OptionalMatrixType H2) const override;
|
|
|
|
|
|
|
|
|
|
/// return the measurement, in the navigation frame
|
|
|
|
|
inline const Point3 & measurementIn() const {
|
|
|
|
|
return nT_;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2025-01-15 20:31:38 +08:00
|
|
|
/**
|
|
|
|
|
* Version of GPSFactor for NavState, assuming zero lever arm between body frame
|
|
|
|
|
* and GPS. If there exists a non-zero lever arm between body frame and GPS
|
|
|
|
|
* antenna, instead use GPSFactor2Arm.
|
2022-07-27 04:25:41 +08:00
|
|
|
* @ingroup navigation
|
2016-02-25 03:01:19 +08:00
|
|
|
*/
|
2022-12-23 06:25:48 +08:00
|
|
|
class GTSAM_EXPORT GPSFactor2: public NoiseModelFactorN<NavState> {
|
2016-02-25 03:01:19 +08:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
2022-12-23 06:25:48 +08:00
|
|
|
typedef NoiseModelFactorN<NavState> Base;
|
2016-02-25 03:01:19 +08:00
|
|
|
|
2025-01-17 00:57:29 +08:00
|
|
|
Point3 nT_; ///< Position measurement in cartesian coordinates (navigation frame)
|
2016-02-25 03:01:19 +08:00
|
|
|
|
|
|
|
|
public:
|
2023-01-12 03:14:26 +08:00
|
|
|
|
2023-01-11 08:15:06 +08:00
|
|
|
// Provide access to the Matrix& version of evaluateError:
|
2023-01-07 08:29:15 +08:00
|
|
|
using Base::evaluateError;
|
2016-02-25 03:01:19 +08:00
|
|
|
|
|
|
|
|
/// shorthand for a smart pointer to a factor
|
2023-01-18 06:05:12 +08:00
|
|
|
typedef std::shared_ptr<GPSFactor2> shared_ptr;
|
2016-02-25 03:01:19 +08:00
|
|
|
|
|
|
|
|
/// Typedef to this class
|
|
|
|
|
typedef GPSFactor2 This;
|
|
|
|
|
|
|
|
|
|
/// default constructor - only use for serialization
|
2025-01-15 18:54:41 +08:00
|
|
|
GPSFactor2():nT_(0, 0, 0) {}
|
2016-02-25 03:01:19 +08:00
|
|
|
|
2021-01-29 12:02:13 +08:00
|
|
|
~GPSFactor2() override {}
|
2016-02-25 03:01:19 +08:00
|
|
|
|
2025-01-17 01:12:07 +08:00
|
|
|
/** Constructor from a measurement in a Cartesian frame.
|
|
|
|
|
* @param key key of the NavState variable related to this measurement
|
|
|
|
|
* @param gpsIn gps measurement, in Cartesian navigation frame
|
|
|
|
|
* @param model Gaussian noise model
|
|
|
|
|
*/
|
2025-01-15 18:54:41 +08:00
|
|
|
GPSFactor2(Key key, const Point3& gpsIn, const SharedNoiseModel& model) :
|
|
|
|
|
Base(model, key), nT_(gpsIn) {
|
2016-02-25 03:01:19 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// @return a deep copy of this factor
|
2020-07-26 15:57:54 +08:00
|
|
|
gtsam::NonlinearFactor::shared_ptr clone() const override {
|
2023-01-18 06:39:55 +08:00
|
|
|
return std::static_pointer_cast<gtsam::NonlinearFactor>(
|
2016-02-25 03:01:19 +08:00
|
|
|
gtsam::NonlinearFactor::shared_ptr(new This(*this)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// print
|
2021-04-30 07:43:27 +08:00
|
|
|
void print(const std::string& s = "", const KeyFormatter& keyFormatter =
|
|
|
|
|
DefaultKeyFormatter) const override;
|
2016-02-25 03:01:19 +08:00
|
|
|
|
|
|
|
|
/// equals
|
2020-07-26 15:57:54 +08:00
|
|
|
bool equals(const NonlinearFactor& expected, double tol = 1e-9) const override;
|
2016-02-25 03:01:19 +08:00
|
|
|
|
|
|
|
|
/// vector of errors
|
2023-01-07 08:29:15 +08:00
|
|
|
Vector evaluateError(const NavState& p, OptionalMatrixType H) const override;
|
2016-02-25 03:01:19 +08:00
|
|
|
|
2025-01-17 01:12:07 +08:00
|
|
|
/// return the measurement, in the navigation frame
|
2016-02-25 03:01:19 +08:00
|
|
|
inline const Point3 & measurementIn() const {
|
|
|
|
|
return nT_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
2024-12-27 12:44:00 +08:00
|
|
|
#if GTSAM_ENABLE_BOOST_SERIALIZATION
|
2016-02-25 03:01:19 +08:00
|
|
|
/// Serialization function
|
2014-01-25 05:06:48 +08:00
|
|
|
friend class boost::serialization::access;
|
|
|
|
|
template<class ARCHIVE>
|
2015-03-06 23:12:09 +08:00
|
|
|
void serialize(ARCHIVE & ar, const unsigned int /*version*/) {
|
2022-12-23 06:25:48 +08:00
|
|
|
// NoiseModelFactor1 instead of NoiseModelFactorN for backward compatibility
|
2014-01-25 05:06:48 +08:00
|
|
|
ar
|
|
|
|
|
& boost::serialization::make_nvp("NoiseModelFactor1",
|
|
|
|
|
boost::serialization::base_object<Base>(*this));
|
|
|
|
|
ar & BOOST_SERIALIZATION_NVP(nT_);
|
|
|
|
|
}
|
2023-01-19 07:25:07 +08:00
|
|
|
#endif
|
2014-01-25 05:06:48 +08:00
|
|
|
};
|
|
|
|
|
|
2025-01-15 20:31:38 +08:00
|
|
|
/**
|
|
|
|
|
* Version of GPSFactor2 with lever arm between GPS and Body frame.
|
|
|
|
|
* Because the actual location of the antenna depends on both position and
|
|
|
|
|
* attitude, providing a lever arm makes components of the attitude observable
|
|
|
|
|
* and accounts for position measurement vs state discrepancies while turning.
|
|
|
|
|
* @ingroup navigation
|
|
|
|
|
*/
|
|
|
|
|
class GTSAM_EXPORT GPSFactor2Arm: public NoiseModelFactorN<NavState> {
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
|
|
typedef NoiseModelFactorN<NavState> Base;
|
|
|
|
|
|
2025-01-17 00:57:29 +08:00
|
|
|
Point3 nT_; ///< Position measurement in cartesian coordinates (navigation frame)
|
2025-01-15 20:31:38 +08:00
|
|
|
Point3 bL_; ///< bL_ is a lever arm in the body frame, denoting the 3D
|
|
|
|
|
///< position of the GPS antenna in the body frame
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
// Provide access to the Matrix& version of evaluateError:
|
|
|
|
|
using Base::evaluateError;
|
|
|
|
|
|
|
|
|
|
/// shorthand for a smart pointer to a factor
|
|
|
|
|
typedef std::shared_ptr<GPSFactor2Arm> shared_ptr;
|
|
|
|
|
|
|
|
|
|
/// Typedef to this class
|
|
|
|
|
typedef GPSFactor2Arm This;
|
|
|
|
|
|
|
|
|
|
/// default constructor - only use for serialization
|
|
|
|
|
GPSFactor2Arm():nT_(0, 0, 0), bL_(0, 0, 0) {}
|
|
|
|
|
|
|
|
|
|
~GPSFactor2Arm() override {}
|
|
|
|
|
|
2025-01-17 01:12:07 +08:00
|
|
|
/** Constructor from a measurement in a Cartesian frame.
|
|
|
|
|
* @param key key of the NavState variable related to this measurement
|
|
|
|
|
* @param gpsIn gps measurement, in Cartesian navigation frame
|
|
|
|
|
* @param leverArm translation from the body frame origin to the gps antenna, in body frame
|
|
|
|
|
* @param model noise model for the factor's residual
|
|
|
|
|
*/
|
2025-01-15 20:31:38 +08:00
|
|
|
GPSFactor2Arm(Key key, const Point3& gpsIn, const Point3& leverArm, const SharedNoiseModel& model) :
|
|
|
|
|
Base(model, key), nT_(gpsIn), bL_(leverArm) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// @return a deep copy of this factor
|
|
|
|
|
gtsam::NonlinearFactor::shared_ptr clone() const override {
|
|
|
|
|
return std::static_pointer_cast<gtsam::NonlinearFactor>(
|
|
|
|
|
gtsam::NonlinearFactor::shared_ptr(new This(*this)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// print
|
|
|
|
|
void print(const std::string& s = "", const KeyFormatter& keyFormatter =
|
|
|
|
|
DefaultKeyFormatter) const override;
|
|
|
|
|
|
|
|
|
|
/// equals
|
|
|
|
|
bool equals(const NonlinearFactor& expected, double tol = 1e-9) const override;
|
|
|
|
|
|
|
|
|
|
/// vector of errors
|
|
|
|
|
Vector evaluateError(const NavState& p, OptionalMatrixType H) const override;
|
|
|
|
|
|
2025-01-17 01:12:07 +08:00
|
|
|
/// return the measurement, in the navigation frame
|
2025-01-15 20:31:38 +08:00
|
|
|
inline const Point3 & measurementIn() const {
|
|
|
|
|
return nT_;
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-17 01:12:07 +08:00
|
|
|
/// return the lever arm, a position in the body frame
|
2025-01-15 20:31:38 +08:00
|
|
|
inline const Point3 & leverArm() const {
|
|
|
|
|
return bL_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
2025-01-17 04:27:42 +08:00
|
|
|
/**
|
|
|
|
|
* Version of GPSFactor2Arm for an unknown lever arm between GPS and Body frame.
|
|
|
|
|
* Because the actual location of the antenna depends on both position and
|
|
|
|
|
* attitude, providing a lever arm makes components of the attitude observable
|
|
|
|
|
* and accounts for position measurement vs state discrepancies while turning.
|
|
|
|
|
* @ingroup navigation
|
|
|
|
|
*/
|
|
|
|
|
class GTSAM_EXPORT GPSFactor2ArmCalib: public NoiseModelFactorN<NavState, Point3> {
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
|
|
typedef NoiseModelFactorN<NavState, Point3> Base;
|
|
|
|
|
|
|
|
|
|
Point3 nT_; ///< Position measurement in cartesian coordinates (navigation frame)
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
// Provide access to the Matrix& version of evaluateError:
|
|
|
|
|
using Base::evaluateError;
|
|
|
|
|
|
|
|
|
|
/// shorthand for a smart pointer to a factor
|
|
|
|
|
typedef std::shared_ptr<GPSFactor2ArmCalib> shared_ptr;
|
|
|
|
|
|
|
|
|
|
/// Typedef to this class
|
|
|
|
|
typedef GPSFactor2ArmCalib This;
|
|
|
|
|
|
|
|
|
|
/// default constructor - only use for serialization
|
|
|
|
|
GPSFactor2ArmCalib():nT_(0, 0, 0) {}
|
|
|
|
|
|
|
|
|
|
~GPSFactor2ArmCalib() override {}
|
|
|
|
|
|
|
|
|
|
/** Constructor from a measurement in a Cartesian frame.
|
|
|
|
|
* @param key1 key of the NavState variable related to this measurement
|
|
|
|
|
* @param key2 key of the Point3 variable related to the lever arm
|
|
|
|
|
* @param gpsIn gps measurement, in Cartesian navigation frame
|
|
|
|
|
* @param model Gaussian noise model
|
|
|
|
|
*/
|
|
|
|
|
GPSFactor2ArmCalib(Key key1, Key key2, const Point3& gpsIn, const SharedNoiseModel& model) :
|
|
|
|
|
Base(model, key1, key2), nT_(gpsIn) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// @return a deep copy of this factor
|
|
|
|
|
gtsam::NonlinearFactor::shared_ptr clone() const override {
|
|
|
|
|
return std::static_pointer_cast<gtsam::NonlinearFactor>(
|
|
|
|
|
gtsam::NonlinearFactor::shared_ptr(new This(*this)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// print
|
|
|
|
|
void print(const std::string& s = "", const KeyFormatter& keyFormatter =
|
|
|
|
|
DefaultKeyFormatter) const override;
|
|
|
|
|
|
|
|
|
|
/// equals
|
|
|
|
|
bool equals(const NonlinearFactor& expected, double tol = 1e-9) const override;
|
|
|
|
|
|
|
|
|
|
/// vector of errors
|
|
|
|
|
Vector evaluateError(const NavState& p, const Point3& bL,
|
|
|
|
|
OptionalMatrixType H1,
|
|
|
|
|
OptionalMatrixType H2) const override;
|
|
|
|
|
|
|
|
|
|
/// return the measurement, in the navigation frame
|
|
|
|
|
inline const Point3 & measurementIn() const {
|
|
|
|
|
return nT_;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2014-01-25 05:06:48 +08:00
|
|
|
} /// namespace gtsam
|