12 #include <gtsam_unstable/dllexport.h> 63 throw std::invalid_argument(
64 "SmartRangeFactor::addRange: adding duplicate measurement for key.");
67 measurements_.push_back(measuredRange);
76 void print(
const std::string&
s =
"",
78 std::cout <<
s <<
"SmartRangeFactor with " <<
size() <<
" measurements\n";
96 std::list<Circle2> circles;
98 for (
size_t j = 0;
j <
n;
j++) {
103 Circle2 circle1 = circles.front();
104 boost::optional<Point2> best_fh;
105 auto bestCircle2 = boost::make_optional(
false, circle1);
108 for (
const Circle2& it : circles) {
115 circle1.
radius / d, it.radius / d);
118 if (fh && (!best_fh || fh->y() > best_fh->y())) {
125 if (bestCircle2 && best_fh) {
126 auto bestCircleCenter = bestCircle2->center;
127 std::list<Point2> intersections =
131 double error1 = 0, error2 = 0;
132 Point2 p1 = intersections.front(),
p2 = intersections.back();
133 for (
const Circle2& it : circles) {
137 return (error1 < error2) ? p1 :
p2;
139 throw std::runtime_error(
"triangulate failed");
147 boost::optional<std::vector<Matrix>&>
H = boost::none)
const override {
152 for (
size_t j = 0;
j <
n;
j++)
153 (*
H)[
j] = Matrix::Zero(3, 1);
165 for (
size_t j = 0;
j <
n;
j++) {
169 error[0] += pose.
range(optimizedPoint, (*
H)[
j]) - measurements_[
j];
171 error[0] += pose.
range(optimizedPoint) - measurements_[
j];
double error(const Values &c) const override
gtsam::NonlinearFactor::shared_ptr clone() const override
double distance2(const Point2 &p, const Point2 &q, OptionalJacobian< 1, 2 > H1, OptionalJacobian< 1, 2 > H2)
distance between two points
~SmartRangeFactor() override
SmartRangeFactor(double s)
KeyVector keys_
The keys involved in this factor.
void addRange(Key key, double measuredRange)
Add a range measurement to a pose with given key.
std::vector< double > measurements_
Range measurements.
const Point2 & translation() const
translation
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy y set format x g set format y g set format x2 g set format y2 g set format z g set angles radians set nogrid set key title set key left top Right noreverse box linetype linewidth samplen spacing width set nolabel set noarrow set nologscale set logscale x set set pointsize set encoding default set nopolar set noparametric set set set set surface set nocontour set clabel set mapping cartesian set nohidden3d set cntrparam order set cntrparam linear set cntrparam levels auto set cntrparam points set size set set xzeroaxis lt lw set x2zeroaxis lt lw set yzeroaxis lt lw set y2zeroaxis lt lw set tics in set ticslevel set tics set mxtics default set mytics default set mx2tics default set my2tics default set xtics border mirror norotate autofreq set ytics border mirror norotate autofreq set ztics border nomirror norotate autofreq set nox2tics set noy2tics set timestamp bottom norotate set rrange[*:*] noreverse nowriteback set trange[*:*] noreverse nowriteback set urange[*:*] noreverse nowriteback set vrange[*:*] noreverse nowriteback set xlabel matrix size set x2label set timefmt d m y n H
static const KeyFormatter DefaultKeyFormatter
const SharedNoiseModel & noiseModel() const
access to the noise model
Point2 triangulate(const Values &x) const
static shared_ptr Variance(size_t dim, double variance, bool smart=true)
Vector unwhitenedError(const Values &x, boost::optional< std::vector< Matrix > & > H=boost::none) const override
void print(const std::string &s="", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const override
double variance_
variance on noise
const ValueType at(Key j) const
static const Pose3 pose(Rot3(Vector3(1,-1,-1).asDiagonal()), Point3(0, 0, 0.5))
boost::shared_ptr< This > shared_ptr
std::function< std::string(Key)> KeyFormatter
Typedef for a function to format a key, i.e. to convert it to a string.
Point2(* f)(const Point3 &, OptionalJacobian< 2, 3 >)
Array< double, 1, 3 > e(1./3., 0.5, 2.)
void print(const std::string &s="", const KeyFormatter &keyFormatter=DefaultKeyFormatter) const override
SharedNoiseModel noiseModel_
Non-linear factor base classes.
bool equals(const NonlinearFactor &f, double tol=1e-9) const override
boost::optional< Point2 > circleCircleIntersection(double R_d, double r_d, double tol)
Circle2(const Point2 &p, double r)
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy x
std::uint64_t Key
Integer nonlinear key type.
GTSAM_EXPORT double range(const Point2 &point, OptionalJacobian< 1, 3 > H1=boost::none, OptionalJacobian< 1, 2 > H2=boost::none) const