Event.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 
20 #pragma once
21 
22 #include <gtsam/geometry/Point3.h>
23 #include <gtsam_unstable/dllexport.h>
24 
25 #include <cmath>
26 #include <iosfwd>
27 #include <string>
28 
29 namespace gtsam {
30 
37 class GTSAM_UNSTABLE_EXPORT Event {
38  double time_;
40 
41  public:
42  inline constexpr static auto dimension = 4;
43 
45  Event() : time_(0), location_(0, 0, 0) {}
46 
48  Event(double t, const Point3& p) : time_(t), location_(p) {}
49 
51  Event(double t, double x, double y, double z)
52  : time_(t), location_(x, y, z) {}
53 
54  double time() const { return time_; }
55  Point3 location() const { return location_; }
56 
57  // TODO(frank) we really have to think of a better way to do linear arguments
58  double height(OptionalJacobian<1, 4> H = {}) const {
59  static const Matrix14 JacobianZ = (Matrix14() << 0, 0, 0, 1).finished();
60  if (H) *H = JacobianZ;
61  return location_.z();
62  }
63 
65  void print(const std::string& s = "") const;
66 
68  bool equals(const Event& other,
69  double tol = 1e-9) const;
70 
72  inline Event retract(const Vector4& v) const {
73  return Event(time_ + v[0], location_ + Point3(v.tail<3>()));
74  }
75 
77  inline Vector4 localCoordinates(const Event& q) const {
78  return Vector4::Zero(); // TODO(frank) implement!
79  }
80 };
81 
82 // Define GTSAM traits
83 template <>
84 struct traits<Event> : internal::Manifold<Event> {};
85 
88  const double speed_;
89 
90  public:
91  typedef double result_type;
92 
94  explicit TimeOfArrival(double speed = 330) : speed_(speed) {}
95 
97  double measure(const Event& event, const Point3& sensor) const {
98  double distance = gtsam::distance3(event.location(), sensor);
99  return event.time() + distance / speed_;
100  }
101 
103  double operator()(const Event& event, const Point3& sensor, //
104  OptionalJacobian<1, 4> H1 = {}, //
105  OptionalJacobian<1, 3> H2 = {}) const {
106  Matrix13 D1, D2;
107  double distance = gtsam::distance3(event.location(), sensor, D1, D2);
108  if (H1)
109  // derivative of toa with respect to event
110  *H1 << 1.0, D1 / speed_;
111  if (H2)
112  // derivative of toa with respect to sensor location
113  *H2 << D2 / speed_;
114  return event.time() + distance / speed_;
115  }
116 };
117 
118 } // namespace gtsam
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::TimeOfArrival::speed_
const double speed_
signal speed
Definition: Event.h:88
s
RealScalar s
Definition: level1_cplx_impl.h:126
e
Array< double, 1, 3 > e(1./3., 0.5, 2.)
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
gtsam::Event::Event
Event(double t, double x, double y, double z)
Constructor with doubles.
Definition: Event.h:51
Point3.h
3D Point
gtsam::internal::Manifold
Both ManifoldTraits and Testable.
Definition: Manifold.h:117
gtsam::TimeOfArrival
Time of arrival to given sensor.
Definition: Event.h:87
gtsam::TimeOfArrival::result_type
double result_type
Definition: Event.h:91
gtsam::TimeOfArrival::TimeOfArrival
TimeOfArrival(double speed=330)
Constructor with optional speed of signal, in m/sec.
Definition: Event.h:94
gtsam::TimeOfArrival::operator()
double operator()(const Event &event, const Point3 &sensor, OptionalJacobian< 1, 4 > H1={}, OptionalJacobian< 1, 3 > H2={}) const
Calculate time of arrival, with derivatives.
Definition: Event.h:103
gtsam::Event::location_
Point3 location_
Location at time event was generated.
Definition: Event.h:39
gtsam::print
void print(const Matrix &A, const string &s, ostream &stream)
Definition: Matrix.cpp:156
gtsam::TimeOfArrival::measure
double measure(const Event &event, const Point3 &sensor) const
Calculate time of arrival.
Definition: Event.h:97
gtsam::Event::height
double height(OptionalJacobian< 1, 4 > H={}) const
Definition: Event.h:58
gtsam::Event::retract
Event retract(const Vector4 &v) const
Updates a with tangent space delta.
Definition: Event.h:72
Eigen::numext::q
EIGEN_DEVICE_FUNC const Scalar & q
Definition: SpecialFunctionsImpl.h:1984
gtsam::Event::location
Point3 location() const
Definition: Event.h:55
gtsam::Event::time
double time() const
Definition: Event.h:54
gtsam::Event::time_
double time_
Time event was generated.
Definition: Event.h:38
pybind_wrapper_test_script.z
z
Definition: pybind_wrapper_test_script.py:61
gtsam::Event::Event
Event()
Default Constructor.
Definition: Event.h:45
gtsam::Event
Definition: Event.h:37
y
Scalar * y
Definition: level1_cplx_impl.h:124
gtsam::Event::Event
Event(double t, const Point3 &p)
Constructor from time and location.
Definition: Event.h:48
gtsam
traits
Definition: SFMdata.h:40
gtsam::traits
Definition: Group.h:36
gtsam::OptionalJacobian
Definition: OptionalJacobian.h:38
p
float * p
Definition: Tutorial_Map_using.cpp:9
v
Array< int, Dynamic, 1 > v
Definition: Array_initializer_list_vector_cxx11.cpp:1
gtsam::Event::localCoordinates
Vector4 localCoordinates(const Event &q) const
Returns inverse retraction.
Definition: Event.h:77
gtsam::tol
const G double tol
Definition: Group.h:79
gtsam::Point3
Vector3 Point3
Definition: Point3.h:38
gtsam::distance
Double_ distance(const OrientedPlane3_ &p)
Definition: slam/expressions.h:117
align_3::t
Point2 t(10, 10)
gtsam::distance3
double distance3(const Point3 &p1, const Point3 &q, OptionalJacobian< 1, 3 > H1, OptionalJacobian< 1, 3 > H2)
distance between two points
Definition: Point3.cpp:27
pybind_wrapper_test_script.other
other
Definition: pybind_wrapper_test_script.py:42


gtsam
Author(s):
autogenerated on Thu Dec 19 2024 04:01:06