8#ifndef META_OCEAN_DEVICES_SERIALIZATION_SERIALIZER_DEVICE_RECORDER_H
9#define META_OCEAN_DEVICES_SERIALIZATION_SERIALIZER_DEVICE_RECORDER_H
121 using ExtraDataSample = std::pair<IO::Serialization::DataSerializer::ChannelId, IO::Serialization::UniqueDataSample>;
167 using FrameMediumMap = std::unordered_map<const Media::FrameMedium*, FrameMediumData>;
188 bool start(
const std::string& filename);
SmartObjectRef< Acceleration3DOFSample, Sample > Acceleration3DOFSampleRef
Definition of a smart object reference for 3DOF acceleration sensor samples.
Definition AccelerationSensor3DOF.h:93
This class is the base class for all devices of any type.
Definition devices/Device.h:28
SmartObjectRef< GPSTrackerSample, Sample > GPSTrackerSampleRef
Definition of a smart object reference for GPS tracker samples.
Definition GPSTracker.h:205
SmartObjectRef< GravityTracker3DOFSample, Sample > GravityTracker3DOFSampleRef
Definition of a smart object reference for 3DOF gravity tracker samples.
Definition GravityTracker3DOF.h:94
SmartObjectRef< Gyro3DOFSample, Sample > Gyro3DOFSampleRef
Definition of a smart object reference for 3DOF gyro sensor samples.
Definition GyroSensor3DOF.h:91
This class implements the base class for all devices providing measurement samples.
Definition Measurement.h:41
ObjectRef< Sample > SampleRef
Definition of an object reference for samples.
Definition Measurement.h:144
std::unordered_set< ObjectId > ObjectIdSet
Definition of an unordered set holding object ids.
Definition Measurement.h:57
SmartObjectRef< OrientationTracker3DOFSample, Sample > OrientationTracker3DOFSampleRef
Definition of a smart object reference for 3DOF orientation tracker samples.
Definition OrientationTracker3DOF.h:92
SmartObjectRef< PositionTracker3DOFSample, Sample > PositionTracker3DOFSampleRef
Definition of a smart object reference for 3DOF position tracker samples.
Definition PositionTracker3DOF.h:92
Measurement::SampleRef sample_
The sample as received from the sender, may be invalid.
Definition SerializerDeviceRecorder.h:148
DeviceSampleData(const Measurement *measurement, const Measurement::SampleRef &sample)
Creates a new object based on a sample.
Definition SerializerDeviceRecorder.h:440
Timestamp sampleCreationTimestamp_
The timestamp when the sample was received, used to determine the playback timestamp.
Definition SerializerDeviceRecorder.h:151
const Measurement * measurement_
The sender of the sample.
Definition SerializerDeviceRecorder.h:145
This class combines relevant data for a FrameMedium object.
Definition SerializerDeviceRecorder.h:68
unsigned int referenceCounter_
The reference counter for the medium object.
Definition SerializerDeviceRecorder.h:89
Media::FrameMediumRef frameMedium_
The actual medium object.
Definition SerializerDeviceRecorder.h:80
FrameMediumData(const Media::FrameMediumRef &frameMedium)
Creates a new object and initializes the object with an existing FrameMedium object.
Definition SerializerDeviceRecorder.h:434
IO::Serialization::DataSerializer::ChannelId channelId_
The channel id to which the medium's image data will be streamed.
Definition SerializerDeviceRecorder.h:92
Timestamp lastTimestamp_
The timestamp of the last image that has been recorded.
Definition SerializerDeviceRecorder.h:95
HomogenousMatrixD4 device_T_camera_
The transformation between the camera and the device which has been used to record the last frame(s).
Definition SerializerDeviceRecorder.h:86
SharedAnyCamera camera_
The camera model of the medium which has been used to record the last frame(s).
Definition SerializerDeviceRecorder.h:83
void recordTracker6DOFSample(const Measurement *sender, const Tracker6DOF::Tracker6DOFSampleRef &sample, const Timestamp &sampleCreationTimestamp)
Records the content of a given 6DOF tracker sample.
FrameMediumMap frameMediumMap_
The map mapping media pointers to media data objects.
Definition SerializerDeviceRecorder.h:401
void onMeasurementSample(const Measurement *sender, const Measurement::SampleRef &sample)
Event function for new sample events from Measurement objects.
void recordAccelerationSensor3DOFSample(const Measurement *sender, const AccelerationSensor3DOF::Acceleration3DOFSampleRef &sample, const Timestamp &sampleCreationTimestamp)
Records the content of a given 3DOF acceleration sensor sample.
std::unordered_set< const Measurement * > MeasurementSet
Definition of an unordered set holding measurement objects.
Definition SerializerDeviceRecorder.h:116
void onDeviceChanged(Device *device, const bool added)
Event function for new or removed devices.
RecorderState
Definition of different recorder states.
Definition SerializerDeviceRecorder.h:53
@ RS_IDLE
Idle state, not recording.
Definition SerializerDeviceRecorder.h:55
@ RS_STOPPING
Stopping recording.
Definition SerializerDeviceRecorder.h:59
@ RS_RECORDING
Currently recording.
Definition SerializerDeviceRecorder.h:57
@ RS_STOPPED
Recording has stopped.
Definition SerializerDeviceRecorder.h:61
void recordSample(const Measurement *sender, const Measurement::SampleRef &sample, const Timestamp &sampleCreationTimestamp)
Records the content of a given sample.
bool stop()
Stops the recording, returns immediately while pending samples are finished to be recorded.
void recordGravityTracker3DOFSample(const Measurement *sender, const GravityTracker3DOF::GravityTracker3DOFSampleRef &sample, const Timestamp &sampleCreationTimestamp)
Records the content of a given 3DOF gravity tracker sample.
void queueUnqueuedSamples()
Moves all not yet queued samples to the queue.
void recordOrientationTracker3DOFSample(const Measurement *sender, const OrientationTracker3DOF::OrientationTracker3DOFSampleRef &sample, const Timestamp &sampleCreationTimestamp)
Records the content of a given 3DOF orientation tracker sample.
SerializerDeviceRecorder(const SerializerDeviceRecorder &)=delete
Disabled copy constructor.
void recordPositionTracker3DOFSample(const Measurement *sender, const PositionTracker3DOF::PositionTracker3DOFSampleRef &sample, const Timestamp &sampleCreationTimestamp)
Records the content of a given 3DOF position tracker sample.
std::unordered_map< const Measurement *, IO::Serialization::DataSerializer::ChannelId > MeasurementChannelMap
Definition of an unordered map mapping measurements to channel ids.
Definition SerializerDeviceRecorder.h:111
MeasurementChannelMap measurementChannelMap_
The map mapping measurements objects to channel ids.
Definition SerializerDeviceRecorder.h:398
bool addExtraDataSample(const IO::Serialization::DataSerializer::ChannelId channelId, IO::Serialization::UniqueDataSample &&sample)
Adds a new extra data sample to be recorded on a specific channel.
SampleEventSubscriptionMap sampleEventSubscriptionMap_
The map of event subscriptions for sample events.
Definition SerializerDeviceRecorder.h:392
void recordGyroSensor3DOFSample(const Measurement *sender, const GyroSensor3DOF::Gyro3DOFSampleRef &sample, const Timestamp &sampleCreationTimestamp)
Records the content of a given 3DOF gyro sensor sample.
void release()
Releases this device recorder explicitly before the recorder is disposed.
IO::Serialization::DataSerializer::ChannelId addExtraChannel(const std::string &sampleType, const std::string &channelName, const std::string &contentType)
Adds a new extra channel for custom data recording.
std::atomic< RecorderState > recorderState_
The state of the recorder.
Definition SerializerDeviceRecorder.h:386
void recordTrackerSample(const Measurement *sender, const Measurement::SampleRef &sample, const Timestamp &sampleCreationTimestamp)
Records the content of a given tracker sample.
std::unordered_map< Device *, Measurement::SampleEventSubscription > SampleEventSubscriptionMap
Definition of an unordered map mapping devices to sample event subscription objects.
Definition SerializerDeviceRecorder.h:101
DeviceSampleDatas unqueuedDeviceSampleDatas_
The samples which are not yet pushed into the recording queue.
Definition SerializerDeviceRecorder.h:407
bool start(const std::string &filename)
Starts recording with a given filename for the new serialization file.
bool isRecording() const
Returns whether the recorder is currently recording.
Definition SerializerDeviceRecorder.h:447
Lock frameMediumMapLock_
The lock for the 'frameMediumMap_' object.
Definition SerializerDeviceRecorder.h:404
std::pair< IO::Serialization::DataSerializer::ChannelId, IO::Serialization::UniqueDataSample > ExtraDataSample
Definition of a pair combining a channel id with a data sample for extra data.
Definition SerializerDeviceRecorder.h:121
TrackerObjectEventSubscriptionMap trackerObjectEventSubscriptionMap_
The map of event subscriptions for object events.
Definition SerializerDeviceRecorder.h:395
ExtraDataSampleQueue extraDataSampleQueue_
The queue with extra data samples that are waiting to be recorded.
Definition SerializerDeviceRecorder.h:419
Lock unqueuedDeviceSampleDatasLock_
The lock for the 'unqueuedDeviceSampleDatas_' object.
Definition SerializerDeviceRecorder.h:410
~SerializerDeviceRecorder() override
Destructs the recorder, an active recording will be stopped.
void recordGPSTrackerSample(const Measurement *sender, const GPSTracker::GPSTrackerSampleRef &sample, const Timestamp &sampleCreationTimestamp)
Records the content of a given GPS tracker sample.
std::unordered_map< const Media::FrameMedium *, FrameMediumData > FrameMediumMap
Definition of an unordered map mapping medium objects to medium data objects.
Definition SerializerDeviceRecorder.h:167
Lock recorderLock_
The lock for the entire recorder.
Definition SerializerDeviceRecorder.h:425
bool hasStopped() const
Returns whether the recorder has finished recording.
Definition SerializerDeviceRecorder.h:454
DeviceSampleDataQueue deviceSampleDataQueue_
The queue with samples that are waiting to be recorded.
Definition SerializerDeviceRecorder.h:413
SerializerDeviceRecorder & operator=(const SerializerDeviceRecorder &)=delete
Disabled copy operator.
bool callbackEventDeviceChangedRegistered_
True, if the callback event function for changed devices has been registered.
Definition SerializerDeviceRecorder.h:389
bool addFrameMedium(const Media::FrameMediumRef &frameMedium)
Adds a new frame medium for recording.
void onTrackerObject(const Tracker *sender, const bool found, const Measurement::ObjectIdSet &objectIds, const Timestamp ×tamp)
Event function for lost or found tracker object ids.
SerializerDeviceRecorder()
Creates a new recorder.
Lock deviceSampleDataQueueLock_
The lock for the 'deviceSampleDataQueue_' object.
Definition SerializerDeviceRecorder.h:416
std::vector< DeviceSampleData > DeviceSampleDatas
Definition of a vector holding DeviceSampleData objects.
Definition SerializerDeviceRecorder.h:157
void threadRun() override
The recorder's thread function in which the actual recording is happening.
std::unordered_map< Device *, Tracker::TrackerObjectEventSubscription > TrackerObjectEventSubscriptionMap
Definition of an unordered map mapping devices to tracker object event subscription objects.
Definition SerializerDeviceRecorder.h:106
void recordSensorSample(const Measurement *sender, const Measurement::SampleRef &sample, const Timestamp &sampleCreationTimestamp)
Records the content of a given sensor sample.
std::queue< DeviceSampleDatas > DeviceSampleDataQueue
Definition of a queue holding DeviceSampleDatas objects.
Definition SerializerDeviceRecorder.h:162
bool removeFrameMedium(const Media::FrameMediumRef &frameMedium)
Removes a frame medium from the recording.
std::unique_ptr< IO::Serialization::FileOutputDataSerializer > outputSerializer_
The actual serialization output serializer.
Definition SerializerDeviceRecorder.h:431
bool recordFrame(FrameMediumData &frameMediumData, const Frame &frame, const SharedAnyCamera &camera)
Records a new frame from a frame medium.
Lock extraDataSampleQueueLock_
The lock for the 'extraDataSampleQueue_' object.
Definition SerializerDeviceRecorder.h:422
MeasurementSet invalidMeasurements_
The set of measurement objects which are not valid anymore.
Definition SerializerDeviceRecorder.h:428
std::queue< ExtraDataSample > ExtraDataSampleQueue
Definition of a queue holding extra data samples.
Definition SerializerDeviceRecorder.h:126
SmartObjectRef< Tracker6DOFSample, Sample > Tracker6DOFSampleRef
Definition of a smart object reference for 6DOF tracker samples.
Definition Tracker6DOF.h:77
This class implements the base class for all tracker devices.
Definition devices/Tracker.h:39
This class implements Ocean's image class.
Definition Frame.h:1969
static constexpr ChannelId invalidChannelId()
Returns an invalid channel id.
Definition DataSerializer.h:360
uint32_t ChannelId
Definition of a channel id.
Definition DataSerializer.h:44
This class implements a recursive lock object.
Definition Lock.h:31
Thread(const std::string &name=std::string())
Creates a new thread object.
This class implements a timestamp.
Definition Timestamp.h:64
std::unique_ptr< DataSample > UniqueDataSample
Definition of a unique pointer holding a DataSample.
Definition DataSample.h:39
HomogenousMatrixT4< double > HomogenousMatrixD4
Instantiation of the HomogenousMatrixT4 template class using a double precision float data type.
Definition HomogenousMatrix4.h:51
std::shared_ptr< AnyCamera > SharedAnyCamera
Definition of a shared pointer holding an AnyCamera object with Scalar precision.
Definition AnyCamera.h:61
Namespace of the Devices Serialization library.
Definition DeviceSerializer.h:32
Namespace of the Devices library.
Definition AccelerationSensor3DOF.h:24
The namespace covering the entire Ocean framework.
Definition Accessor.h:15