Ocean
Loading...
Searching...
No Matches
AKGeoAnchorsTracker6DOF.h
Go to the documentation of this file.
1/*
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 */
7
8#ifndef META_OCEAN_DEVICES_ARKIT_AK_GEO_ANCHORS_TRACKER_6_DOF_H
9#define META_OCEAN_DEVICES_ARKIT_AK_GEO_ANCHORS_TRACKER_6_DOF_H
10
13
17
18namespace Ocean
19{
20
21namespace Devices
22{
23
24namespace ARKit
25{
26
27/**
28 * This class implements ARKit's 6-DOF Geo Anchors tracker.
29 * @ingroup devicesarkit
30 */
31class OCEAN_DEVICES_ARKIT_EXPORT AKGeoAnchorsTracker6DOF :
32 virtual public AKDevice,
33 virtual public Tracker6DOF,
34 virtual public ObjectTracker,
35 virtual public VisualTracker
36{
37 friend class AKFactory;
38
39 public:
40
41 /**
42 * Definition of an unordered map mapping object ids to transformations.
43 */
44 using TransformationMap = std::unordered_map<ObjectId, HomogenousMatrix4>;
45
46 protected:
47
48 /**
49 * This class stores GPS locations.
50 */
52 {
53 public:
54
55 /**
56 * Creates a new location object.
57 * @param objectId The object id of the location
58 * @param latitude The location's latitude, in degree, with range [-90, 90]
59 * @param longitude The location's longitude, in degree, with range [-180, 180]
60 * @param altitude The location's altitude, in meters, with range (-infinity, infinity), NumericD::minVaue() if unknown
61 */
62 inline Location(const ObjectId objectId, const double latitude, const double longitude, const double altitude);
63
64 public:
65
66 /// The location's latitude, in degree, with range [-90, 90].
68
69 /// The location's longitude, in degree, with range [-180, 180].
71
72 /// The location's altitude, in meters, with range (-infinity, infinity), NumericD::minVaue() if unknown.
74
75 /// The object id of the location.
77 };
78
79 /**
80 * Definition of a vector holding locations.
81 */
82 using Locations = std::vector<Location>;
83
84 public:
85
86 /**
87 * Starts the device.
88 * @see Device::start().
89 */
90 bool start() override;
91
92 /**
93 * Pauses the device.
94 * @see Device::pause().
95 */
96 bool pause() override;
97
98 /**
99 * Stops the device.
100 * @see Device::stop().
101 */
102 bool stop() override;
103
104 /**
105 * Sets the multi-view visual input of this tracker.
106 * @see VisualTracker::setInput().
107 */
108 void setInput(Media::FrameMediumRefs&& frameMediums) override;
109
110 /**
111 * Registers (adds) a new object to be tracked.
112 * @see ObjectTracker::registerObject().
113 */
114 ObjectId registerObject(const std::string& description, const Vector3& dimension) override;
115
116 /**
117 * Unregisters (removes) a previously registered object.
118 * @see ObjectTracker::unregisterObject().
119 */
120 bool unregisterObject(const ObjectId objectId) override;
121
122 /**
123 * Returns whether a specific object is currently actively tracked by this tracker.
124 * @see Tracker::isObjectTracked().
125 */
126 bool isObjectTracked(const ObjectId& objectId) const override;
127
128 /**
129 * Event function for a new 6DOF pose.
130 * @param world_T_camera The transformation between camera and world, invalid if unknown/lost
131 * @param world_T_rotatedWorld The optional transformation between ARKit's rotated world and the standard world, should only be identity or the flip matrix around y-axis
132 * @param timestamp The timestamp of the new transformation
133 * @param arFrame The current ARFRame object containing additional data for the sample, must be valid
134 */
135 API_AVAILABLE(ios(14.0))
137
138 /**
139 * Event function for new 6DOF transformations.
140 * @param anchors_T_camera The transformations of all currently known anchors
141 * @param timestamp The timestamp of the new transformation
142 * @param metadata The metadata of the sample
143 */
144 void onNewSample(const TransformationMap& anchors_T_camera, const Timestamp& timestamp, Metadata&& metadata);
145
146 /**
147 * Returns the name of this tracker.
148 * @return The trackers's name
149 */
150 static inline std::string deviceNameAKGeoAnchorsTracker6DOF();
151
152 /**
153 * Returns the device type of this tracker.
154 * @return The tracker's device type
155 */
157
158 protected:
159
160 /**
161 * Creates a new 6DOF Geo Anchor tracker.
162 */
164
165 /**
166 * Destructs this tracker.
167 */
169
170 protected:
171
172 /// The ids of all objects (including the world object) which are currently tracked.
174
175 /// True, if the tracker has been started.
176 bool isStarted_ = false;
177
178 /// Intermediate locations which have been registered before the device have been started.
180};
181
182inline AKGeoAnchorsTracker6DOF::Location::Location(const ObjectId objectId, const double latitude, const double longitude, const double altitude) :
183 latitude_(latitude),
184 longitude_(longitude),
185 altitude_(altitude),
187{
188 // nothing to do here
189}
190
192{
193 return std::string("ARKit 6DOF Geo Anchors Tracker");
194}
195
200
201}
202
203}
204
205}
206
207#endif // META_OCEAN_DEVICES_ARKIT_AK_GEO_ANCHORS_TRACKER_6_DOF_H
AKDevice(const TrackerCapabilities trackerCapabilities, const std::string &name, const DeviceType type)
Translates the value of an ARGeoTrackingState to a readable string.
ObjectId objectId_
The object id of the location.
Definition AKGeoAnchorsTracker6DOF.h:76
double altitude_
The location's altitude, in meters, with range (-infinity, infinity), NumericD::minVaue() if unknown.
Definition AKGeoAnchorsTracker6DOF.h:73
double longitude_
The location's longitude, in degree, with range [-180, 180].
Definition AKGeoAnchorsTracker6DOF.h:70
double latitude_
The location's latitude, in degree, with range [-90, 90].
Definition AKGeoAnchorsTracker6DOF.h:67
Location(const ObjectId objectId, const double latitude, const double longitude, const double altitude)
Creates a new location object.
Definition AKGeoAnchorsTracker6DOF.h:182
bool isStarted_
True, if the tracker has been started.
Definition AKGeoAnchorsTracker6DOF.h:176
ObjectIdSet trackedObjectIds_
The ids of all objects (including the world object) which are currently tracked.
Definition AKGeoAnchorsTracker6DOF.h:173
const HomogenousMatrix4 & world_T_rotatedWorld
Definition AKGeoAnchorsTracker6DOF.h:136
std::unordered_map< ObjectId, HomogenousMatrix4 > TransformationMap
Definition of an unordered map mapping object ids to transformations.
Definition AKGeoAnchorsTracker6DOF.h:44
static DeviceType deviceTypeAKGeoAnchorsTracker6DOF()
Returns the device type of this tracker.
Definition AKGeoAnchorsTracker6DOF.h:196
AKGeoAnchorsTracker6DOF()
Creates a new 6DOF Geo Anchor tracker.
bool isObjectTracked(const ObjectId &objectId) const override
Returns whether a specific object is currently actively tracked by this tracker.
const HomogenousMatrix4 const Timestamp & timestamp
Definition AKGeoAnchorsTracker6DOF.h:136
bool unregisterObject(const ObjectId objectId) override
Unregisters (removes) a previously registered object.
static std::string deviceNameAKGeoAnchorsTracker6DOF()
Returns the name of this tracker.
Definition AKGeoAnchorsTracker6DOF.h:191
bool start() override
Starts the device.
void onNewSample(const TransformationMap &anchors_T_camera, const Timestamp &timestamp, Metadata &&metadata)
Event function for new 6DOF transformations.
void setInput(Media::FrameMediumRefs &&frameMediums) override
Sets the multi-view visual input of this tracker.
API_AVAILABLE(ios(14.0)) void onNewSample(const HomogenousMatrix4 &world_T_camera
Event function for a new 6DOF pose.
std::vector< Location > Locations
Definition of a vector holding locations.
Definition AKGeoAnchorsTracker6DOF.h:82
const HomogenousMatrix4 const Timestamp ARFrame * arFrame
Definition AKGeoAnchorsTracker6DOF.h:136
Locations intermediateLocations_
Intermediate locations which have been registered before the device have been started.
Definition AKGeoAnchorsTracker6DOF.h:179
ObjectId registerObject(const std::string &description, const Vector3 &dimension) override
Registers (adds) a new object to be tracked.
bool stop() override
Stops the device.
bool pause() override
Pauses the device.
friend class AKFactory
Definition AKGeoAnchorsTracker6DOF.h:37
Definition of a class holding the major and minor device type.
Definition devices/Device.h:62
ObjectId objectId(const std::string &description) const
Returns the object id for an object description.
static constexpr ObjectId invalidObjectId()
Returns an invalid object id.
Definition Measurement.h:631
std::unordered_set< ObjectId > ObjectIdSet
Definition of an unordered set holding object ids.
Definition Measurement.h:57
uint32_t ObjectId
Definition of an object id.
Definition Measurement.h:47
std::unordered_map< std::string, Value > Metadata
Definition of an unordered map mapping keys to values.
Definition Measurement.h:62
ObjectTracker(const std::string &name, const DeviceType type)
Creates a new object tracker object.
Tracker6DOF(const std::string &name)
Creates a new 6DOF tracker object.
static DeviceType deviceTypeTracker6DOF()
Definition of this device type.
Definition Tracker6DOF.h:106
@ TRACKER_VISUAL
Tracker using a visual input for their measurements.
Definition devices/Tracker.h:64
VisualTracker(const std::string &name, const DeviceType type)
Creates a new visual tracker object.
static constexpr double minValue()
This class implements a timestamp.
Definition Timestamp.h:64
HomogenousMatrixT4< Scalar > HomogenousMatrix4
Definition of the HomogenousMatrix4 object, depending on the OCEAN_MATH_USE_SINGLE_PRECISION flag eit...
Definition HomogenousMatrix4.h:44
VectorT3< Scalar > Vector3
Definition of a 3D vector.
Definition Vector3.h:29
std::vector< FrameMediumRef > FrameMediumRefs
Definition of a vector holding frame medium reference objects.
Definition FrameMedium.h:46
Namespace of the Devices ARKit library.
Definition AKDepthTracker6DOF.h:24
Namespace of the Devices library.
Definition AccelerationSensor3DOF.h:24
The namespace covering the entire Ocean framework.
Definition Accessor.h:15