simulated2DConstraints.h
Go to the documentation of this file.
1 /* ----------------------------------------------------------------------------
2 
3  * GTSAM Copyright 2010, Georgia Tech Research Corporation,
4  * Atlanta, Georgia 30332-0415
5  * All Rights Reserved
6  * Authors: Frank Dellaert, et al. (see THANKS for the full author list)
7 
8  * See LICENSE for the license information
9 
10  * -------------------------------------------------------------------------- */
11 
18 // \callgraph
19 
20 #pragma once
21 
23 
27 #include <tests/simulated2D.h>
29 
30 // \namespace
31 
32 namespace simulated2D {
33 
34  namespace equality_constraints {
35 
40 
44 
45  } // \namespace equality_constraints
46 
47  namespace inequality_constraints {
48 
54  template<class VALUE, unsigned int IDX>
58  typedef std::shared_ptr<ScalarCoordConstraint1<VALUE, IDX> > shared_ptr;
59  typedef VALUE Point;
60 
62 
65  return std::static_pointer_cast<gtsam::NonlinearFactor>(
67 
76  bool isGreaterThan, double mu = 1000.0) :
77  Base(key, c, isGreaterThan, mu) {
78  }
79 
84  inline unsigned int index() const { return IDX; }
85 
91  double value(const Point& x, OptionalMatrixType H =
92  OptionalNone) const override {
93  if (H) {
94  Matrix D = Matrix::Zero(1, traits<Point>::GetDimension(x));
95  D(0, IDX) = 1.0;
96  *H = D;
97  }
98  return traits<Point>::Logmap(x)(IDX);
99  }
100  };
101 
105 
114  template<class T1, class T2>
115  double range_trait(const T1& a, const T2& b) { return distance2(a, b); }
116 
123  template<class VALUE>
124  struct MaxDistanceConstraint : public BoundingConstraint2<VALUE, VALUE> {
127  typedef VALUE Point;
128 
130 
133  return std::static_pointer_cast<gtsam::NonlinearFactor>(
135 
143  MaxDistanceConstraint(Key key1, Key key2, double range_bound, double mu = 1000.0) :
144  Base(key1, key2, range_bound, false, mu) {}
145 
154  double value(const Point& x1, const Point& x2,
156  OptionalMatrixType H2 = OptionalNone) const override {
157  if (H1) *H1 = numericalDerivative21(range_trait<Point,Point>, x1, x2, 1e-5);
158  if (H1) *H2 = numericalDerivative22(range_trait<Point,Point>, x1, x2, 1e-5);
159  return range_trait(x1, x2);
160  }
161  };
162 
164 
171  template<class POSE, class POINT>
172  struct MinDistanceConstraint : public BoundingConstraint2<POSE, POINT> {
175  typedef POSE Pose;
176  typedef POINT Point;
177 
179 
182  return std::static_pointer_cast<gtsam::NonlinearFactor>(
184 
193  double range_bound, double mu = 1000.0)
194  : Base(key1, key2, range_bound, true, mu) {}
195 
204  double value(const Pose& x1, const Point& x2,
206  OptionalMatrixType H2 = OptionalNone) const override {
207  if (H1) *H1 = numericalDerivative21(range_trait<Pose,Point>, x1, x2, 1e-5);
208  if (H1) *H2 = numericalDerivative22(range_trait<Pose,Point>, x1, x2, 1e-5);
209  return range_trait(x1, x2);
210  }
211  };
212 
214 
215 
216  } // \namespace inequality_constraints
217 
218 } // \namespace simulated2D
219 
const gtsam::Symbol key('X', 0)
double value(const Point &x1, const Point &x2, OptionalMatrixType H1=OptionalNone, OptionalMatrixType H2=OptionalNone) const override
ScalarCoordConstraint1< Point2, 1 > PoseYInequality
Simulated2D domain example factor constraining Y.
NonlinearEquality1< Point2 > UnaryEqualityConstraint
double value(const Pose &x1, const Point &x2, OptionalMatrixType H1=OptionalNone, OptionalMatrixType H2=OptionalNone) const override
Scalar * b
Definition: benchVecAdd.cpp:17
NonlinearEquality1< Point2 > UnaryEqualityPointConstraint
MaxDistanceConstraint(Key key1, Key key2, double range_bound, double mu=1000.0)
ScalarCoordConstraint1(Key key, double c, bool isGreaterThan, double mu=1000.0)
double mu
Provides partially implemented constraints to implement bounds.
Eigen::MatrixXd Matrix
Definition: base/Matrix.h:39
Scalar Scalar * c
Definition: benchVecAdd.cpp:17
Some functions to compute numerical derivatives.
Pose3 x2(Rot3::Ypr(0.0, 0.0, 0.0), l2)
static const Pose3 T2(Rot3::Rodrigues(0.3, 0.2, 0.1), P2)
NonlinearEquality2< Point2 > PoseEqualityConstraint
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
BoundingConstraint2< POSE, POINT > Base
Base class for factor.
internal::FixedSizeMatrix< Y, X1 >::type numericalDerivative21(const std::function< Y(const X1 &, const X2 &)> &h, const X1 &x1, const X2 &x2, double delta=1e-5)
#define OptionalNone
Matrix * OptionalMatrixType
BoundingConstraint1< VALUE > Base
Base class convenience typedef.
double value(const Point &x, OptionalMatrixType H=OptionalNone) const override
gtsam::NonlinearFactor::shared_ptr clone() const override
const Symbol key1('v', 1)
BetweenConstraint< Point2 > OdoEqualityConstraint
NonlinearEquality2< Point2 > PointEqualityConstraint
MaxDistanceConstraint< VALUE > This
This class for factor.
Array< double, 1, 3 > e(1./3., 0.5, 2.)
#define This
double range_trait(const T1 &a, const T2 &b)
MinDistanceConstraint(Key key1, Key key2, double range_bound, double mu=1000.0)
gtsam::NonlinearFactor::shared_ptr clone() const override
measurement functions and derivatives for simulated 2D robot
Non-linear factor base classes.
BoundingConstraint2< VALUE, VALUE > Base
Base class for factor.
MinDistanceConstraint< POSE, POINT > This
This class for factor.
double distance2(const Point2 &p, const Point2 &q, OptionalJacobian< 1, 2 > H1, OptionalJacobian< 1, 2 > H2)
distance between two points
Definition: Point2.cpp:39
static const Similarity3 T1(R, Point3(3.5, -8.2, 4.2), 1)
Pose3 x1
Definition: testPose3.cpp:663
std::shared_ptr< This > shared_ptr
internal::FixedSizeMatrix< Y, X2 >::type numericalDerivative22(std::function< Y(const X1 &, const X2 &)> h, const X1 &x1, const X2 &x2, double delta=1e-5)
ScalarCoordConstraint1< VALUE, IDX > This
This class convenience typedef.
std::shared_ptr< ScalarCoordConstraint1< VALUE, IDX > > shared_ptr
std::shared_ptr convenience typedef
MinDistanceConstraint< Point2, Point2 > LandmarkAvoid
Simulated2D domain example factor.
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
ScalarCoordConstraint1< Point2, 0 > PoseXInequality
Simulated2D domain example factor constraining X.
gtsam::NonlinearFactor::shared_ptr clone() const override
MaxDistanceConstraint< Point2 > PoseMaxDistConstraint
Simulated2D domain example factor.
std::uint64_t Key
Integer nonlinear key type.
Definition: types.h:102
const Symbol key2('v', 2)


gtsam
Author(s):
autogenerated on Tue Jul 4 2023 02:35:48