gtsam
Loading...
Searching...
No Matches
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
19
20#pragma once
21
23#include <gtsam/dllexport.h>
24
25#include <string>
26
27namespace gtsam {
28
35class GTSAM_EXPORT Event {
36 double time_;
37 Point3 location_;
38
39 public:
40 inline constexpr static auto dimension = 4;
41
43 Event() : time_(0), location_(0, 0, 0) {}
44
46 Event(double t, const Point3& p) : time_(t), location_(p) {}
47
49 Event(double t, double x, double y, double z)
50 : time_(t), location_(x, y, z) {}
51
52 double time() const { return time_; }
53 Point3 location() const { return location_; }
54
55 // TODO(frank) we really have to think of a better way to do linear arguments
56 double height(OptionalJacobian<1, 4> H = {}) const {
57 static const Matrix14 JacobianZ{{0, 0, 0, 1}};
58 if (H) *H = JacobianZ;
59 return location_.z();
60 }
61
63 void print(const std::string& s = "") const;
64
66 bool equals(const Event& other,
67 double tol = 1e-9) const;
68
70 inline Event retract(const Vector4& v) const {
71 return Event(time_ + v[0], location_ + Point3(v.tail<3>()));
72 }
73
75 inline Vector4 localCoordinates(const Event& q) const {
76 return Vector4::Zero(); // TODO(frank) implement!
77 }
78};
79
80// Define GTSAM traits
81template <>
82struct traits<Event> : internal::Manifold<Event> {};
83
85class GTSAM_EXPORT TimeOfArrival {
86 const double speed_;
87
88 public:
89 typedef double result_type;
90
92 explicit TimeOfArrival(double speed = 330) : speed_(speed) {}
93
95 double measure(const Event& event, const Point3& sensor) const {
96 double distance = gtsam::distance3(event.location(), sensor);
97 return event.time() + distance / speed_;
98 }
99
101 double operator()(const Event& event, const Point3& sensor, //
102 OptionalJacobian<1, 4> H1 = {}, //
103 OptionalJacobian<1, 3> H2 = {}) const {
104 Matrix13 D1, D2;
105 double distance = gtsam::distance3(event.location(), sensor, D1, D2);
106 if (H1)
107 // derivative of toa with respect to event
108 *H1 << 1.0, D1 / speed_;
109 if (H2)
110 // derivative of toa with respect to sensor location
111 *H2 = D2 / speed_;
112 return event.time() + distance / speed_;
113 }
114};
115
116} // namespace gtsam
3D Point
Global functions in a separate testing namespace.
Definition chartTesting.h:28
Vector3 Point3
As of GTSAM 4, in order to make GTSAM more lean, it is now possible to just typedef Point3 to Vector3...
Definition Point3.h:38
void print(const Matrix &A, const string &s, ostream &stream)
print without optional string, must specify cout yourself
Definition Matrix.cpp:143
double distance3(const Point3 &p1, const Point3 &q, OptionalJacobian< 1, 3 > H1, OptionalJacobian< 1, 3 > H2)
distance between two points
Definition Point3.cpp:29
A manifold defines a space in which there is a notion of a linear tangent space that can be centered ...
Definition Group.h:37
Both ManifoldTraits and Testable.
Definition Manifold.h:156
OptionalJacobian is an Eigen::Ref like class that can take be constructed using either a fixed size o...
Definition OptionalJacobian.h:40
A space-time event models an event that happens at a certain 3D location, at a certain time.
Definition Event.h:35
Event(double t, const Point3 &p)
Constructor from time and location.
Definition Event.h:46
Event(double t, double x, double y, double z)
Constructor with doubles.
Definition Event.h:49
Event()
Default Constructor.
Definition Event.h:43
Event retract(const Vector4 &v) const
Updates a with tangent space delta.
Definition Event.h:70
Vector4 localCoordinates(const Event &q) const
Returns inverse retraction.
Definition Event.h:75
double measure(const Event &event, const Point3 &sensor) const
Calculate time of arrival.
Definition Event.h:95
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:101
TimeOfArrival(double speed=330)
Constructor with optional speed of signal, in m/sec.
Definition Event.h:92