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 
simulated2D::equality_constraints::UnaryEqualityPointConstraint
NonlinearEquality1< Point2 > UnaryEqualityPointConstraint
Definition: simulated2DConstraints.h:38
simulated2D::inequality_constraints::PoseMaxDistConstraint
MaxDistanceConstraint< Point2 > PoseMaxDistConstraint
Simulated2D domain example factor.
Definition: simulated2DConstraints.h:163
H
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
Definition: gnuplot_common_settings.hh:74
gtsam::NonlinearFactor::shared_ptr
std::shared_ptr< This > shared_ptr
Definition: NonlinearFactor.h:79
gtsam::BoundingConstraint1
Definition: BoundingConstraint.h:33
gtsam::BetweenConstraint
Definition: BetweenFactor.h:166
simulated2D::inequality_constraints::MinDistanceConstraint::Base
BoundingConstraint2< POSE, POINT > Base
Base class for factor.
Definition: simulated2DConstraints.h:173
D
MatrixXcd D
Definition: EigenSolver_EigenSolver_MatrixType.cpp:14
simulated2D::inequality_constraints::MaxDistanceConstraint::value
double value(const Point &x1, const Point &x2, OptionalMatrixType H1=OptionalNone, OptionalMatrixType H2=OptionalNone) const override
Definition: simulated2DConstraints.h:154
e
Array< double, 1, 3 > e(1./3., 0.5, 2.)
simulated2D
Definition: simulated2D.h:28
simulated2D::inequality_constraints::ScalarCoordConstraint1::shared_ptr
std::shared_ptr< ScalarCoordConstraint1< VALUE, IDX > > shared_ptr
std::shared_ptr convenience typedef
Definition: simulated2DConstraints.h:58
mu
double mu
Definition: testBoundingConstraint.cpp:37
gtsam::distance2
double distance2(const Point2 &p, const Point2 &q, OptionalJacobian< 1, 2 > H1, OptionalJacobian< 1, 2 > H2)
distance between two points
Definition: Point2.cpp:39
c
Scalar Scalar * c
Definition: benchVecAdd.cpp:17
b
Scalar * b
Definition: benchVecAdd.cpp:17
simulated2D::inequality_constraints::ScalarCoordConstraint1::~ScalarCoordConstraint1
~ScalarCoordConstraint1() override
Definition: simulated2DConstraints.h:61
gtsam::BoundingConstraint1::isGreaterThan
bool isGreaterThan() const
Definition: BoundingConstraint.h:53
x
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
Definition: gnuplot_common_settings.hh:12
simulated2D::inequality_constraints::ScalarCoordConstraint1::Base
BoundingConstraint1< VALUE > Base
Base class convenience typedef.
Definition: simulated2DConstraints.h:56
gtsam::numericalDerivative22
internal::FixedSizeMatrix< Y, X2 >::type numericalDerivative22(std::function< Y(const X1 &, const X2 &)> h, const X1 &x1, const X2 &x2, double delta=1e-5)
Definition: numericalDerivative.h:195
gtsam::Matrix
Eigen::MatrixXd Matrix
Definition: base/Matrix.h:39
gtsam::BoundingConstraint2
Definition: BoundingConstraint.h:105
gtsam::Factor
Definition: Factor.h:70
simulated2D::inequality_constraints::MinDistanceConstraint::Point
POINT Point
Type of point variable constrained.
Definition: simulated2DConstraints.h:176
simulated2D::equality_constraints::PoseEqualityConstraint
NonlinearEquality2< Point2 > PoseEqualityConstraint
Definition: simulated2DConstraints.h:42
simulated2D::inequality_constraints::ScalarCoordConstraint1::value
double value(const Point &x, OptionalMatrixType H=OptionalNone) const override
Definition: simulated2DConstraints.h:91
simulated2D::equality_constraints::PointEqualityConstraint
NonlinearEquality2< Point2 > PointEqualityConstraint
Definition: simulated2DConstraints.h:43
Eigen::internal::VALUE
@ VALUE
Definition: SpecialFunctionsImpl.h:729
gtsam::NonlinearEquality1
Definition: NonlinearEquality.h:209
simulated2D::inequality_constraints::PoseXInequality
ScalarCoordConstraint1< Point2, 0 > PoseXInequality
Simulated2D domain example factor constraining X.
Definition: simulated2DConstraints.h:103
simulated2D::inequality_constraints::MaxDistanceConstraint::MaxDistanceConstraint
MaxDistanceConstraint(Key key1, Key key2, double range_bound, double mu=1000.0)
Definition: simulated2DConstraints.h:143
numericalDerivative.h
Some functions to compute numerical derivatives.
simulated2D::inequality_constraints::MaxDistanceConstraint
Definition: simulated2DConstraints.h:124
simulated2D::inequality_constraints::ScalarCoordConstraint1::Point
VALUE Point
Constrained variable type.
Definition: simulated2DConstraints.h:59
simulated2D::equality_constraints::UnaryEqualityConstraint
NonlinearEquality1< Point2 > UnaryEqualityConstraint
Definition: simulated2DConstraints.h:37
simulated2D::inequality_constraints::MinDistanceConstraint::Pose
POSE Pose
Type of pose variable constrained.
Definition: simulated2DConstraints.h:175
simulated2D::inequality_constraints::MaxDistanceConstraint::clone
gtsam::NonlinearFactor::shared_ptr clone() const override
Definition: simulated2DConstraints.h:132
OptionalNone
#define OptionalNone
Definition: NonlinearFactor.h:50
BetweenFactor.h
x1
Pose3 x1
Definition: testPose3.cpp:663
simulated2D::inequality_constraints::ScalarCoordConstraint1
Definition: simulated2DConstraints.h:55
simulated2D::inequality_constraints::MinDistanceConstraint::~MinDistanceConstraint
~MinDistanceConstraint() override
Definition: simulated2DConstraints.h:178
simulated2D::inequality_constraints::PoseYInequality
ScalarCoordConstraint1< Point2, 1 > PoseYInequality
Simulated2D domain example factor constraining Y.
Definition: simulated2DConstraints.h:104
T2
static const Pose3 T2(Rot3::Rodrigues(0.3, 0.2, 0.1), P2)
simulated2D::inequality_constraints::ScalarCoordConstraint1::This
ScalarCoordConstraint1< VALUE, IDX > This
This class convenience typedef.
Definition: simulated2DConstraints.h:57
NonlinearEquality.h
gtsam::NoiseModelFactorN< VALUE, VALUE >::key1
Key key1() const
Definition: NonlinearFactor.h:732
gtsam::NonlinearEquality2
Definition: NonlinearEquality.h:301
BoundingConstraint.h
Provides partially implemented constraints to implement bounds.
simulated2D.h
measurement functions and derivatives for simulated 2D robot
simulated2D::inequality_constraints::MaxDistanceConstraint::~MaxDistanceConstraint
~MaxDistanceConstraint() override
Definition: simulated2DConstraints.h:129
NonlinearFactor.h
Non-linear factor base classes.
simulated2D::inequality_constraints::MaxDistanceConstraint::This
MaxDistanceConstraint< VALUE > This
This class for factor.
Definition: simulated2DConstraints.h:126
gtsam::NoiseModelFactorN< VALUE, VALUE >::key2
Key key2() const
Definition: NonlinearFactor.h:736
simulated2D::inequality_constraints::MaxDistanceConstraint::Base
BoundingConstraint2< VALUE, VALUE > Base
Base class for factor.
Definition: simulated2DConstraints.h:125
a
ArrayXXi a
Definition: Array_initializer_list_23_cxx11.cpp:1
gtsam::traits
Definition: Group.h:36
gtsam::numericalDerivative21
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)
Definition: numericalDerivative.h:166
simulated2D::inequality_constraints::range_trait
double range_trait(const T1 &a, const T2 &b)
Definition: simulated2DConstraints.h:115
simulated2D::inequality_constraints::LandmarkAvoid
MinDistanceConstraint< Point2, Point2 > LandmarkAvoid
Simulated2D domain example factor.
Definition: simulated2DConstraints.h:213
gtsam::OptionalMatrixType
Matrix * OptionalMatrixType
Definition: NonlinearFactor.h:56
simulated2D::inequality_constraints::MinDistanceConstraint::This
MinDistanceConstraint< POSE, POINT > This
This class for factor.
Definition: simulated2DConstraints.h:174
simulated2D::equality_constraints::OdoEqualityConstraint
BetweenConstraint< Point2 > OdoEqualityConstraint
Definition: simulated2DConstraints.h:39
gtsam::NoiseModelFactorN< VALUE >::key
Key key() const
Definition: NonlinearFactor.h:583
T1
static const Similarity3 T1(R, Point3(3.5, -8.2, 4.2), 1)
gtsam::Key
std::uint64_t Key
Integer nonlinear key type.
Definition: types.h:97
simulated2D::inequality_constraints::ScalarCoordConstraint1::index
unsigned int index() const
Definition: simulated2DConstraints.h:84
simulated2D::inequality_constraints::MinDistanceConstraint::value
double value(const Pose &x1, const Point &x2, OptionalMatrixType H1=OptionalNone, OptionalMatrixType H2=OptionalNone) const override
Definition: simulated2DConstraints.h:204
simulated2D::inequality_constraints::MinDistanceConstraint::MinDistanceConstraint
MinDistanceConstraint(Key key1, Key key2, double range_bound, double mu=1000.0)
Definition: simulated2DConstraints.h:192
x2
Pose3 x2(Rot3::Ypr(0.0, 0.0, 0.0), l2)
simulated2D::inequality_constraints::ScalarCoordConstraint1::clone
gtsam::NonlinearFactor::shared_ptr clone() const override
Definition: simulated2DConstraints.h:64
simulated2D::inequality_constraints::MinDistanceConstraint::clone
gtsam::NonlinearFactor::shared_ptr clone() const override
Definition: simulated2DConstraints.h:181
simulated2D::inequality_constraints::MaxDistanceConstraint::Point
VALUE Point
Type of variable constrained.
Definition: simulated2DConstraints.h:127
simulated2D::inequality_constraints::MinDistanceConstraint
Definition: simulated2DConstraints.h:172
simulated2D::inequality_constraints::ScalarCoordConstraint1::ScalarCoordConstraint1
ScalarCoordConstraint1(Key key, double c, bool isGreaterThan, double mu=1000.0)
Definition: simulated2DConstraints.h:75


gtsam
Author(s):
autogenerated on Sun Dec 22 2024 04:13:24