switchVariableSigmoid.h
Go to the documentation of this file.
1 /*
2  * switchVariableSigmoid.h
3  *
4  * Created on: 08.08.2012
5  * Author: niko
6  */
7 
8 #ifndef SWITCHVARIABLESIGMOID_H_
9 #define SWITCHVARIABLESIGMOID_H_
10 
11 #pragma once
12 
13 // DerivedValue.h removed from gtsam repo (Dec 2018): https://github.com/borglab/gtsam/commit/e550f4f2aec423cb3f2791b81cb5858b8826ebac
14 #include "DerivedValue.h"
15 #include <gtsam/base/Lie.h>
16 
17 namespace vertigo {
18 
22  struct SwitchVariableSigmoid : public rtabmap::DerivedValue<SwitchVariableSigmoid> {
23 
25  SwitchVariableSigmoid() : d_(10.0) {};
26 
28  SwitchVariableSigmoid(double d) : d_(d) {
29  if (d_ < -10.0) d_=-10.0;
30  else if(d_>10.0) d_=10.0;
31  };
32 
34  double value() const { return d_; }
35 
37  inline void print(const std::string& name="") const {
38  std::cout << name << ": " << d_ << std::endl;
39  }
40 
42  inline bool equals(const SwitchVariableSigmoid& expected, double tol=1e-5) const {
43  return fabs(expected.d_ - d_) <= tol;
44  }
45 
46  // Manifold requirements
47 
49  inline size_t dim() const { return 1; }
50  inline static size_t Dim() { return 1; }
51 
53  inline SwitchVariableSigmoid retract(const gtsam::Vector& v) const {
54  double x = value() + v(0);
55 
56  if (x>10.0) x=10.0;
57  else if (x<-10.0) x=-10.0;
58 
59  return SwitchVariableSigmoid(x);
60  }
61 
63  inline gtsam::Vector localCoordinates(const SwitchVariableSigmoid& t2) const { return gtsam::Vector1(t2.value() - value()); }
64 
65  // Group requirements
66 
68  inline static SwitchVariableSigmoid identity() {
69  return SwitchVariableSigmoid();
70  }
71 
74  return SwitchVariableSigmoid(d_ + p.d_);
75  }
76 
79 #if GTSAM_VERSION_NUMERIC >= 40300
80  OptionalMatrixType H1=OptionalNone,
81  OptionalMatrixType H2=OptionalNone) const {
82 #else
83  boost::optional<gtsam::Matrix&> H1=boost::none,
84  boost::optional<gtsam::Matrix&> H2=boost::none) const {
85 #endif
86  if(H1) *H1 = -gtsam::Matrix::Identity(1, 1);
87  if(H2) *H2 = gtsam::Matrix::Identity(1, 1);
88  return SwitchVariableSigmoid(l2.value() - value());
89  }
90 
92  inline SwitchVariableSigmoid inverse() const {
93  return SwitchVariableSigmoid(-1.0 * value());
94  }
95 
96  // Lie functions
97 
99  static inline SwitchVariableSigmoid Expmap(const gtsam::Vector& v) { return SwitchVariableSigmoid(v(0)); }
100 
102  static inline gtsam::Vector Logmap(const SwitchVariableSigmoid& p) { return gtsam::Vector1(p.value()); }
103 
104  private:
105  double d_;
106  };
107 }
108 
109 
110 namespace gtsam {
111 // Define Key to be Testable by specializing gtsam::traits
112 template<typename T> struct traits;
113 template<> struct traits<vertigo::SwitchVariableSigmoid> {
114  static void Print(const vertigo::SwitchVariableSigmoid& key, const std::string& str = "") {
115  key.print(str);
116  }
117  static bool Equals(const vertigo::SwitchVariableSigmoid& key1, const vertigo::SwitchVariableSigmoid& key2, double tol = 1e-8) {
118  return key1.equals(key2, tol);
119  }
120  static int GetDimension(const vertigo::SwitchVariableSigmoid & key) {return key.Dim();}
121 
125 #if GTSAM_VERSION_NUMERIC >= 40300
126  ChartJacobian Horigin = {}, ChartJacobian Hother = {}) {
127 #else
128  ChartJacobian Horigin = boost::none, ChartJacobian Hother = boost::none) {
129 #endif
130  return origin.localCoordinates(other);
131  }
133 #if GTSAM_VERSION_NUMERIC >= 40300
134  ChartJacobian H1 = {}, ChartJacobian H2 = {}) {
135 #else
136  ChartJacobian H1 = boost::none, ChartJacobian H2 = boost::none) {
137 #endif
138  return g.retract(v);
139  }
140 };
141 }
142 
143 #endif /* SWITCHVARIABLESIGMOID_H_ */
key1
const Symbol key1( 'v', 1)
vertigo::SwitchVariableSigmoid::print
void print(const std::string &name="") const
Definition: switchVariableSigmoid.h:37
vertigo::SwitchVariableSigmoid::retract
SwitchVariableSigmoid retract(const gtsam::Vector &v) const
Definition: switchVariableSigmoid.h:53
vertigo::SwitchVariableSigmoid::equals
bool equals(const SwitchVariableSigmoid &expected, double tol=1e-5) const
Definition: switchVariableSigmoid.h:42
gtsam::Vector1
Eigen::Matrix< double, 1, 1 > Vector1
name
vertigo::SwitchVariableSigmoid::dim
size_t dim() const
Definition: switchVariableSigmoid.h:49
vertigo::SwitchVariableSigmoid::localCoordinates
gtsam::Vector localCoordinates(const SwitchVariableSigmoid &t2) const
Definition: switchVariableSigmoid.h:63
l2
gtsam::Key l2
expected
const set< Key > expected
vertigo::SwitchVariableSigmoid::value
double value() const
Definition: switchVariableSigmoid.h:34
vertigo::SwitchVariableSigmoid::compose
SwitchVariableSigmoid compose(const SwitchVariableSigmoid &p) const
Definition: switchVariableSigmoid.h:73
vertigo::SwitchVariableSigmoid::SwitchVariableSigmoid
SwitchVariableSigmoid(double d)
Definition: switchVariableSigmoid.h:28
gtsam::traits< vertigo::SwitchVariableSigmoid >::Retract
static vertigo::SwitchVariableSigmoid Retract(const vertigo::SwitchVariableSigmoid &g, const TangentVector &v, ChartJacobian H1=boost::none, ChartJacobian H2=boost::none)
Definition: switchVariableSigmoid.h:132
vertigo::SwitchVariableSigmoid::between
SwitchVariableSigmoid between(const SwitchVariableSigmoid &l2, boost::optional< gtsam::Matrix & > H1=boost::none, boost::optional< gtsam::Matrix & > H2=boost::none) const
Definition: switchVariableSigmoid.h:78
gtsam::Vector
Eigen::VectorXd Vector
Lie.h
vertigo::SwitchVariableSigmoid::Logmap
static gtsam::Vector Logmap(const SwitchVariableSigmoid &p)
Definition: switchVariableSigmoid.h:102
vertigo::SwitchVariableSigmoid::Dim
static size_t Dim()
Definition: switchVariableSigmoid.h:50
fabs
Real fabs(const Real &a)
vertigo::SwitchVariableSigmoid::Expmap
static SwitchVariableSigmoid Expmap(const gtsam::Vector &v)
Definition: switchVariableSigmoid.h:99
gtsam::traits< vertigo::SwitchVariableSigmoid >::Local
static TangentVector Local(const vertigo::SwitchVariableSigmoid &origin, const vertigo::SwitchVariableSigmoid &other, ChartJacobian Horigin=boost::none, ChartJacobian Hother=boost::none)
Definition: switchVariableSigmoid.h:124
gtsam::traits< vertigo::SwitchVariableSigmoid >::Equals
static bool Equals(const vertigo::SwitchVariableSigmoid &key1, const vertigo::SwitchVariableSigmoid &key2, double tol=1e-8)
Definition: switchVariableSigmoid.h:117
key2
const Symbol key2( 'v', 2)
g
float g
DerivedValue.h
vertigo::SwitchVariableSigmoid
Definition: switchVariableSigmoid.h:22
gtsam::traits< vertigo::SwitchVariableSigmoid >::TangentVector
gtsam::Vector TangentVector
Definition: switchVariableSigmoid.h:123
vertigo::SwitchVariableSigmoid::inverse
SwitchVariableSigmoid inverse() const
Definition: switchVariableSigmoid.h:92
vertigo::SwitchVariableSigmoid::identity
static SwitchVariableSigmoid identity()
Definition: switchVariableSigmoid.h:68
gtsam::traits< vertigo::SwitchVariableSigmoid >::Print
static void Print(const vertigo::SwitchVariableSigmoid &key, const std::string &str="")
Definition: switchVariableSigmoid.h:114
d
d
x
x
p
Point3_ p(2)
gtsam::Symbol::print
void print(const std::string &s="") const
str
key
const gtsam::Symbol key( 'X', 0)
e
Array< double, 1, 3 > e(1./3., 0.5, 2.)
gtsam
vertigo
Definition: betweenFactorMaxMix.h:24
rtabmap::DerivedValue
Definition: DerivedValue.h:44
gtsam::traits
Definition: switchVariableLinear.h:111
gtsam::OptionalJacobian
origin
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 origin
gtsam::traits< vertigo::SwitchVariableSigmoid >::ChartJacobian
OptionalJacobian< 3, 3 > ChartJacobian
Definition: switchVariableSigmoid.h:122
vertigo::SwitchVariableSigmoid::SwitchVariableSigmoid
SwitchVariableSigmoid()
Definition: switchVariableSigmoid.h:25
v
Array< int, Dynamic, 1 > v
tol
const G double tol
gtsam::traits< vertigo::SwitchVariableSigmoid >::GetDimension
static int GetDimension(const vertigo::SwitchVariableSigmoid &key)
Definition: switchVariableSigmoid.h:120
Eigen.Matrix< double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor >
vertigo::SwitchVariableSigmoid::d_
double d_
Definition: switchVariableSigmoid.h:105


rtabmap
Author(s): Mathieu Labbe
autogenerated on Thu Jul 25 2024 02:50:22