34 center(p), radius(r) {
65 size_t n =
keys_.size();
73 virtual void print(
const std::string& s =
"",
74 const KeyFormatter& keyFormatter = DefaultKeyFormatter)
const {
75 std::cout << s <<
"SmartRangeFactor with " <<
size() <<
" measurements\n";
94 std::list<Circle2> circles;
96 for (
size_t j = 0; j < n; j++) {
101 Circle2 circle1 = circles.front();
102 boost::optional<Point2> best_fh;
103 boost::optional<Circle2> bestCircle2;
106 for (
const Circle2& it : circles) {
108 double d =
distance2(circle1.center, it.center);
112 boost::optional<Point2> fh = circleCircleIntersection(
113 circle1.radius / d, it.radius / d);
116 if (fh && (!best_fh || fh->y() > best_fh->y())) {
123 if (bestCircle2 && best_fh) {
124 auto bestCircleCenter = bestCircle2->center;
125 std::list<Point2> intersections =
126 circleCircleIntersection(circle1.center, bestCircleCenter, best_fh);
129 double error1 = 0, error2 = 0;
130 Point2 p1 = intersections.front(), p2 = intersections.back();
131 for (
const Circle2& it : circles) {
135 return (error1 < error2) ? p1 : p2;
137 throw std::runtime_error(
"triangulate failed");
146 boost::optional<std::vector<Matrix>&> H = boost::none)
const {
151 for (
size_t j = 0; j < n; j++)
152 (*H)[j] = Matrix::Zero(3, 1);
156 Vector
error = Z_1x1;
164 for (
size_t j = 0; j < n; j++) {
177 virtual gtsam::NonlinearFactor::shared_ptr
clone()
const {
178 return boost::static_pointer_cast<gtsam::NonlinearFactor>(
179 gtsam::NonlinearFactor::shared_ptr(
new This(*
this)));
This is the base class for all factor types.
Definition: Factor.h:54
A non-templated config holding any types of Manifold-group elements.
Definition: Values.h:70
double range(const Point2 &point, OptionalJacobian< 1, 3 > H1=boost::none, OptionalJacobian< 1, 2 > H2=boost::none) const
Calculate range to a landmark.
Definition: Pose2.cpp:247
Point2 triangulate(const Values &x) const
Triangulate a point from at least three pose-range pairs Checks for best pair that includes first poi...
Definition: SmartRangeFactor.h:91
ValueType at(Key j) const
Retrieve a variable by key j.
Definition: Values-inl.h:342
virtual void print(const std::string &s="", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const
Print.
Definition: NonlinearFactor.cpp:63
std::uint64_t Key
Integer nonlinear key type.
Definition: types.h:57
virtual gtsam::NonlinearFactor::shared_ptr clone() const
Definition: SmartRangeFactor.h:177
static shared_ptr Variance(size_t dim, double variance, bool smart=true)
An isotropic noise model created by specifying a variance = sigma^2.
Definition: NoiseModel.cpp:567
SmartRangeFactor()
Default constructor: don't use directly.
Definition: SmartRangeFactor.h:47
void addRange(Key key, double measuredRange)
Add a range measurement to a pose with given key.
Definition: SmartRangeFactor.h:62
Definition: SmartRangeFactor.h:32
boost::function< std::string(Key)> KeyFormatter
Typedef for a function to format a key, i.e. to convert it to a string.
Definition: Key.h:33
std::vector< double > measurements_
Range measurements.
Definition: SmartRangeFactor.h:42
const Point2 & translation() const
translation
Definition: Pose2.h:230
Nonlinear factor base class.
Definition: NonlinearFactor.h:50
const SharedNoiseModel & noiseModel() const
access to the noise model
Definition: NonlinearFactor.h:210
size_t size() const
Definition: Factor.h:129
Definition: SmartRangeFactor.h:30
virtual void print(const std::string &s="", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const
print
Definition: SmartRangeFactor.h:73
A nonlinear sum-of-squares factor with a zero-mean noise model implementing the density Templated on...
Definition: NonlinearFactor.h:161
Non-linear factor base classes.
double distance2(const Point2 &p, const Point2 &q, OptionalJacobian< 1, 2 > H1, OptionalJacobian< 1, 2 > H2)
distance between two points
Definition: Point2.cpp:39
Global functions in a separate testing namespace.
Definition: chartTesting.h:28
KeyVector keys_
The keys involved in this factor.
Definition: Factor.h:72
SmartRangeFactor(double s)
Constructor.
Definition: SmartRangeFactor.h:54
virtual Vector unwhitenedError(const Values &x, boost::optional< std::vector< Matrix > & > H=boost::none) const
Error function without the NoiseModel, .
Definition: SmartRangeFactor.h:145
virtual bool equals(const NonlinearFactor &f, double tol=1e-9) const
Check if two factors are equal.
Definition: SmartRangeFactor.h:80
virtual double error(const Values &c) const
Calculate the error of the factor.
Definition: NonlinearFactor.cpp:97
Symbols for exporting classes and methods from DLLs.
double variance_
variance on noise
Definition: SmartRangeFactor.h:43