2012-08-20 22:25:04 +08:00
|
|
|
/**
|
|
|
|
* @file RelativeElevationFactor.h
|
|
|
|
*
|
|
|
|
* @brief Factor representing a known relative altitude in global frame
|
2019-02-11 22:39:48 +08:00
|
|
|
*
|
2012-08-20 22:25:04 +08:00
|
|
|
* @date Aug 17, 2012
|
|
|
|
* @author Alex Cunningham
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2019-07-18 14:22:41 +08:00
|
|
|
#include <gtsam_unstable/dllexport.h>
|
2012-08-20 22:25:04 +08:00
|
|
|
#include <gtsam/geometry/Pose3.h>
|
|
|
|
#include <gtsam/nonlinear/NonlinearFactor.h>
|
|
|
|
|
|
|
|
namespace gtsam {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Binary factor for a relative elevation. Note that this
|
|
|
|
* factor takes into account only elevation, and corrects for orientation.
|
|
|
|
* Unlike a range factor, the relative elevation is signed, and only affects
|
|
|
|
* the Z coordinate. Measurement function h(pose, pt) = h.z() - pt.z()
|
|
|
|
*
|
|
|
|
* Dimension: 1
|
|
|
|
*
|
|
|
|
* TODO: enable use of a Pose3 for the target as well
|
|
|
|
*/
|
2022-12-23 06:25:48 +08:00
|
|
|
class GTSAM_UNSTABLE_EXPORT RelativeElevationFactor: public NoiseModelFactorN<Pose3, Point3> {
|
2012-08-20 22:25:04 +08:00
|
|
|
private:
|
|
|
|
|
2012-10-02 22:40:07 +08:00
|
|
|
double measured_; /** measurement */
|
2012-08-20 22:25:04 +08:00
|
|
|
|
2012-10-02 22:40:07 +08:00
|
|
|
typedef RelativeElevationFactor This;
|
2022-12-23 06:25:48 +08:00
|
|
|
typedef NoiseModelFactorN<Pose3, Point3> Base;
|
2012-08-20 22:25:04 +08:00
|
|
|
|
|
|
|
public:
|
2023-01-12 03:14:26 +08:00
|
|
|
|
2023-01-11 05:07:58 +08:00
|
|
|
// Provide access to the Matrix& version of evaluateError:
|
2023-01-10 06:52:56 +08:00
|
|
|
using Base::evaluateError;
|
2012-08-20 22:25:04 +08:00
|
|
|
|
2012-10-02 22:40:07 +08:00
|
|
|
RelativeElevationFactor() : measured_(0.0) {} /* Default constructor */
|
2012-08-20 22:25:04 +08:00
|
|
|
|
2012-10-02 22:40:07 +08:00
|
|
|
RelativeElevationFactor(Key poseKey, Key pointKey, double measured,
|
|
|
|
const SharedNoiseModel& model);
|
2012-08-20 22:25:04 +08:00
|
|
|
|
2021-01-29 12:02:13 +08:00
|
|
|
~RelativeElevationFactor() override {}
|
2012-08-20 22:25:04 +08:00
|
|
|
|
2012-10-02 22:40:07 +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>(
|
2012-10-02 22:40:07 +08:00
|
|
|
gtsam::NonlinearFactor::shared_ptr(new This(*this))); }
|
2012-08-20 22:25:04 +08:00
|
|
|
|
2012-10-02 22:40:07 +08:00
|
|
|
/** h(x)-z */
|
|
|
|
Vector evaluateError(const Pose3& pose, const Point3& point,
|
2023-01-10 06:52:56 +08:00
|
|
|
OptionalMatrixType H1, OptionalMatrixType H2) const override;
|
2012-08-20 22:25:04 +08:00
|
|
|
|
2012-10-02 22:40:07 +08:00
|
|
|
/** return the measured */
|
|
|
|
inline double measured() const { return measured_; }
|
2012-08-20 22:25:04 +08:00
|
|
|
|
2012-10-02 22:40:07 +08:00
|
|
|
/** equals specialized to this factor */
|
2020-07-26 15:57:54 +08:00
|
|
|
bool equals(const NonlinearFactor& expected, double tol=1e-9) const override;
|
2012-08-20 22:25:04 +08:00
|
|
|
|
2012-10-02 22:40:07 +08:00
|
|
|
/** print contents */
|
2020-07-26 15:57:54 +08:00
|
|
|
void print(const std::string& s="", const KeyFormatter& keyFormatter = DefaultKeyFormatter) const override;
|
2012-08-20 22:25:04 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
2024-12-27 12:44:00 +08:00
|
|
|
#if GTSAM_ENABLE_BOOST_SERIALIZATION
|
2012-10-02 22:40:07 +08:00
|
|
|
/** Serialization function */
|
|
|
|
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
|
|
|
// NoiseModelFactor2 instead of NoiseModelFactorN for backward compatibility
|
2012-10-02 22:40:07 +08:00
|
|
|
ar & boost::serialization::make_nvp("NoiseModelFactor2",
|
|
|
|
boost::serialization::base_object<Base>(*this));
|
|
|
|
ar & BOOST_SERIALIZATION_NVP(measured_);
|
|
|
|
}
|
2023-01-19 04:03:30 +08:00
|
|
|
#endif
|
2012-08-20 22:25:04 +08:00
|
|
|
}; // RelativeElevationFactor
|
|
|
|
|
|
|
|
|
|
|
|
} // \namespace gtsam
|
|
|
|
|
|
|
|
|