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 #include <gtsam/base/DerivedValue.h>
14 #include <gtsam/base/Lie.h>
15 
16 namespace vertigo {
17 
21  struct SwitchVariableSigmoid : public gtsam::DerivedValue<SwitchVariableSigmoid> {
22 
24  SwitchVariableSigmoid() : d_(10.0) {};
25 
27  SwitchVariableSigmoid(double d) : d_(d) {
28  if (d_ < -10.0) d_=-10.0;
29  else if(d_>10.0) d_=10.0;
30  };
31 
33  double value() const { return d_; }
34 
36  inline void print(const std::string& name="") const {
37  std::cout << name << ": " << d_ << std::endl;
38  }
39 
41  inline bool equals(const SwitchVariableSigmoid& expected, double tol=1e-5) const {
42  return fabs(expected.d_ - d_) <= tol;
43  }
44 
45  // Manifold requirements
46 
48  inline size_t dim() const { return 1; }
49  inline static size_t Dim() { return 1; }
50 
52  inline SwitchVariableSigmoid retract(const gtsam::Vector& v) const {
53  double x = value() + v(0);
54 
55  if (x>10.0) x=10.0;
56  else if (x<-10.0) x=-10.0;
57 
58  return SwitchVariableSigmoid(x);
59  }
60 
62  inline gtsam::Vector localCoordinates(const SwitchVariableSigmoid& t2) const { return gtsam::Vector1(t2.value() - value()); }
63 
64  // Group requirements
65 
67  inline static SwitchVariableSigmoid identity() {
68  return SwitchVariableSigmoid();
69  }
70 
73  return SwitchVariableSigmoid(d_ + p.d_);
74  }
75 
78  boost::optional<gtsam::Matrix&> H1=boost::none,
79  boost::optional<gtsam::Matrix&> H2=boost::none) const {
80  if(H1) *H1 = -gtsam::eye(1);
81  if(H2) *H2 = gtsam::eye(1);
82  return SwitchVariableSigmoid(l2.value() - value());
83  }
84 
86  inline SwitchVariableSigmoid inverse() const {
87  return SwitchVariableSigmoid(-1.0 * value());
88  }
89 
90  // Lie functions
91 
93  static inline SwitchVariableSigmoid Expmap(const gtsam::Vector& v) { return SwitchVariableSigmoid(v(0)); }
94 
96  static inline gtsam::Vector Logmap(const SwitchVariableSigmoid& p) { return gtsam::Vector1(p.value()); }
97 
98  private:
99  double d_;
100  };
101 }
102 
103 
104 namespace gtsam {
105 // Define Key to be Testable by specializing gtsam::traits
106 template<typename T> struct traits;
107 template<> struct traits<vertigo::SwitchVariableSigmoid> {
108  static void Print(const vertigo::SwitchVariableSigmoid& key, const std::string& str = "") {
109  key.print(str);
110  }
111  static bool Equals(const vertigo::SwitchVariableSigmoid& key1, const vertigo::SwitchVariableSigmoid& key2, double tol = 1e-8) {
112  return key1.equals(key2, tol);
113  }
114  static int GetDimension(const vertigo::SwitchVariableSigmoid & key) {return key.Dim();}
115 
116  typedef OptionalJacobian<3, 3> ChartJacobian;
117  typedef gtsam::Vector TangentVector;
118  static TangentVector Local(const vertigo::SwitchVariableSigmoid& origin, const vertigo::SwitchVariableSigmoid& other,
119  ChartJacobian Horigin = boost::none, ChartJacobian Hother = boost::none) {
120  return origin.localCoordinates(other);
121  }
123  ChartJacobian H1 = boost::none, ChartJacobian H2 = boost::none) {
124  return g.retract(v);
125  }
126 };
127 }
128 
129 #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 Wed Jun 5 2019 22:43:40