25 #ifndef INCLUDED_TrackerThread_h_GUID_6544B03C_4EB4_4B82_77F1_16EF83578C64 26 #define INCLUDED_TrackerThread_h_GUID_6544B03C_4EB4_4B82_77F1_16EF83578C64 39 #include <opencv2/core/core.hpp> 41 #include <boost/noncopyable.hpp> 42 #include <folly/ProducerConsumerQueue.h> 43 #include <folly/sorted_vector_types.h> 49 #include <condition_variable> 59 static const std::chrono::milliseconds IMU_OVERRIDE_SPACING{2};
61 static const auto MAX_DEBUG_BEACONS = 34;
62 static const auto DEBUG_ANALOGS_PER_BEACON = 6;
63 static const auto DEBUG_ANALOGS_REQUIRED =
64 MAX_DEBUG_BEACONS * DEBUG_ANALOGS_PER_BEACON;
66 using DebugArray = std::array<double, DEBUG_ANALOGS_REQUIRED>;
67 struct BodyIdOrdering {
68 bool operator()(
BodyId const &lhs,
BodyId const &rhs)
const {
69 return lhs.value() < rhs.value();
73 using UpdatedBodyIndices = folly::sorted_vector_set<BodyId, BodyIdOrdering>;
80 BodyReportingVector &reportingVec,
82 std::int32_t cameraUsecOffset = 0,
bool bufferImu =
false,
83 bool debugData =
false);
111 bool checkForDebugData(DebugArray &data);
116 void signalImageProcessingComplete(ImageOutputDataPtr &&imageData,
117 cv::Mat
const &frame,
118 cv::Mat
const &frameGray);
122 std::ostream &msg()
const;
124 std::ostream &warn()
const;
132 void setupReportingVectorProcessModels();
135 bool setupReportingVectorRoomTransforms();
138 void updateReportingVector(UpdatedBodyIndices
const &bodyIds);
143 void updateReportingVector(
BodyId const bodyId);
147 void launchTimeConsumingImageStep();
149 std::pair<BodyId, ImuMessageCategory>
161 void updateExtraCameraReport();
162 void updateExtraIMUReports();
166 BodyReportingVector &m_reportingVec;
168 std::size_t m_numBodies = 0;
169 const std::int32_t m_cameraUsecOffset = 0;
174 const bool m_bufferImu =
false;
176 const bool m_debugData =
false;
178 using our_clock = std::chrono::steady_clock;
180 bool shouldSendImuReport() {
181 auto now = our_clock::now();
182 if (now > m_nextImuOverrideReport) {
183 m_nextImuOverrideReport = now + IMU_OVERRIDE_SPACING;
189 void setImuOverrideClock() {
190 m_nextImuOverrideReport = our_clock::now() + IMU_OVERRIDE_SPACING;
193 our_clock::time_point m_nextImuOverrideReport;
194 boost::optional<our_clock::time_point> m_nextCameraPoseReport;
198 std::promise<void> m_startupSignal;
200 bool m_setCameraPose =
false;
206 ImageOutputDataPtr m_imageData;
211 std::mutex m_runMutex;
218 std::condition_variable m_messageCondVar;
219 std::mutex m_messageMutex;
220 bool m_timeConsumingImageStepComplete =
false;
221 folly::ProducerConsumerQueue<IMUMessage> m_imuMessages;
224 folly::ProducerConsumerQueue<DebugArray> m_debugDataMessages;
229 std::thread m_imageThread;
233 #endif // INCLUDED_TrackerThread_h_GUID_6544B03C_4EB4_4B82_77F1_16EF83578C64
Definition: ImageProcessingThread.h:47
The main namespace for all C++ elements of the framework, internal and external.
Definition: namespace_osvr.dox:3
Definition: TrackerThread.h:77
Definition: CameraParameters.h:41
Definition: TrackingSystem.h:54
Report type for an orientation callback on a tracker interface.
Definition: ClientReportTypesC.h:145
Definition: TrackedBodyIMU.h:44
A per-body class intended to marshall data coming from the tracking/processing thread back to the mai...
Definition: ThreadsafeBodyReporting.h:65
Uniform interface for the various normal to strange image sources for the tracking algorithm...
Definition: ImageSource.h:42
boost::variant< boost::none_t, TimestampedOrientation, TimestampedAngVel > IMUMessage
A "typesafe tagged-union" variant that can hold an IMU report data along with the timestamp and the p...
Definition: IMUMessage.h:93
Report type for an angular velocity callback on a tracker interface.
Definition: ClientReportTypesC.h:187
Standardized, portable parallel to struct timeval for representing both absolute times and time inter...
Definition: TimeValueC.h:81