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  boost::optional<gtsam::Matrix&> H1=boost::none,
80  boost::optional<gtsam::Matrix&> H2=boost::none) const {
81  if(H1) *H1 = -gtsam::Matrix::Identity(1, 1);
82  if(H2) *H2 = gtsam::Matrix::Identity(1, 1);
83  return SwitchVariableSigmoid(l2.value() - value());
84  }
85 
87  inline SwitchVariableSigmoid inverse() const {
88  return SwitchVariableSigmoid(-1.0 * value());
89  }
90 
91  // Lie functions
92 
94  static inline SwitchVariableSigmoid Expmap(const gtsam::Vector& v) { return SwitchVariableSigmoid(v(0)); }
95 
97  static inline gtsam::Vector Logmap(const SwitchVariableSigmoid& p) { return gtsam::Vector1(p.value()); }
98 
99  private:
100  double d_;
101  };
102 }
103 
104 
105 namespace gtsam {
106 // Define Key to be Testable by specializing gtsam::traits
107 template<typename T> struct traits;
108 template<> struct traits<vertigo::SwitchVariableSigmoid> {
109  static void Print(const vertigo::SwitchVariableSigmoid& key, const std::string& str = "") {
110  key.print(str);
111  }
112  static bool Equals(const vertigo::SwitchVariableSigmoid& key1, const vertigo::SwitchVariableSigmoid& key2, double tol = 1e-8) {
113  return key1.equals(key2, tol);
114  }
115  static int GetDimension(const vertigo::SwitchVariableSigmoid & key) {return key.Dim();}
116 
117  typedef OptionalJacobian<3, 3> ChartJacobian;
118  typedef gtsam::Vector TangentVector;
119  static TangentVector Local(const vertigo::SwitchVariableSigmoid& origin, const vertigo::SwitchVariableSigmoid& other,
120  ChartJacobian Horigin = boost::none, ChartJacobian Hother = boost::none) {
121  return origin.localCoordinates(other);
122  }
124  ChartJacobian H1 = boost::none, ChartJacobian H2 = boost::none) {
125  return g.retract(v);
126  }
127 };
128 }
129 
130 #endif /* SWITCHVARIABLESIGMOID_H_ */
static SwitchVariableSigmoid Expmap(const gtsam::Vector &v)
static gtsam::Vector Logmap(const SwitchVariableSigmoid &p)
void print(const std::string &name="") const
GLM_FUNC_DECL genType e()
static int GetDimension(const vertigo::SwitchVariableSigmoid &key)
static void Print(const vertigo::SwitchVariableSigmoid &key, const std::string &str="")
SwitchVariableSigmoid retract(const gtsam::Vector &v) const
static TangentVector Local(const vertigo::SwitchVariableSigmoid &origin, const vertigo::SwitchVariableSigmoid &other, ChartJacobian Horigin=boost::none, ChartJacobian Hother=boost::none)
gtsam::Vector localCoordinates(const SwitchVariableSigmoid &t2) const
static bool Equals(const vertigo::SwitchVariableSigmoid &key1, const vertigo::SwitchVariableSigmoid &key2, double tol=1e-8)
SwitchVariableSigmoid compose(const SwitchVariableSigmoid &p) const
static SwitchVariableSigmoid identity()
SwitchVariableSigmoid inverse() const
static vertigo::SwitchVariableSigmoid Retract(const vertigo::SwitchVariableSigmoid &g, const TangentVector &v, ChartJacobian H1=boost::none, ChartJacobian H2=boost::none)
bool equals(const SwitchVariableSigmoid &expected, double tol=1e-5) const
SwitchVariableSigmoid between(const SwitchVariableSigmoid &l2, boost::optional< gtsam::Matrix & > H1=boost::none, boost::optional< gtsam::Matrix & > H2=boost::none) const


rtabmap
Author(s): Mathieu Labbe
autogenerated on Mon Dec 14 2020 03:37:06