f32a472c5d
Basic implementation of the stimbuff mechanism's frame rate limiting behaviour.
68 lines
1.9 KiB
C++
68 lines
1.9 KiB
C++
#ifndef _LIVOX_GEN1_PCLOUD_STIMULUS_BUFFER_H
|
|
#define _LIVOX_GEN1_PCLOUD_STIMULUS_BUFFER_H
|
|
|
|
#include <config.h>
|
|
#include <atomic>
|
|
#include <boost/asio/deadline_timer.hpp>
|
|
#include <spinLock.h>
|
|
#include <user/stimulusBuffer.h>
|
|
#include <user/stimFrame.h>
|
|
#include <livoxProto1/device.h>
|
|
#include "stagingBuffer.h"
|
|
#include "ioUringAssemblyEngine.h"
|
|
|
|
namespace smo {
|
|
namespace stim_buff {
|
|
|
|
/**
|
|
* PcloudStimulusBuffer is a specialized StimulusBuffer for point cloud data.
|
|
*
|
|
* This class extends StimulusBuffer to handle point cloud-specific stimulus
|
|
* frames, particularly those generated from LiDAR point cloud data. It
|
|
* provides additional functionality for managing point cloud frame metadata
|
|
* and processing.
|
|
*/
|
|
class PcloudStimulusBuffer
|
|
: public StimulusBuffer
|
|
{
|
|
public:
|
|
explicit PcloudStimulusBuffer(
|
|
const device::DeviceAttachmentSpec& deviceAttachmentSpec,
|
|
std::shared_ptr<livoxProto1::Device> &device,
|
|
const PcloudFormatDesc& formatDesc,
|
|
size_t nDgramsPerStagingBufferFrame);
|
|
|
|
~PcloudStimulusBuffer() = default;
|
|
|
|
// Non-copyable, movable
|
|
PcloudStimulusBuffer(const PcloudStimulusBuffer&) = delete;
|
|
PcloudStimulusBuffer& operator=(const PcloudStimulusBuffer&) = delete;
|
|
PcloudStimulusBuffer(PcloudStimulusBuffer&&) = default;
|
|
PcloudStimulusBuffer& operator=(PcloudStimulusBuffer&&) = default;
|
|
|
|
// Control methods
|
|
void start();
|
|
void stop();
|
|
|
|
public:
|
|
device::DeviceAttachmentSpec deviceAttachmentSpec;
|
|
std::shared_ptr<livoxProto1::Device> device;
|
|
PcloudFormatDesc formatDesc;
|
|
StagingBuffer stagingBuffer;
|
|
IoUringAssemblyEngine ioUringAssemblyEngine;
|
|
|
|
private:
|
|
std::atomic<bool> shouldContinue;
|
|
boost::asio::deadline_timer timer;
|
|
SpinLock frameAssemblyRateLimiter;
|
|
|
|
private:
|
|
void scheduleNextTimeout(int delayMs = CONFIG_STIMBUFF_FRAME_PERIOD_MS);
|
|
void onTimeout(const boost::system::error_code& error);
|
|
};
|
|
|
|
} // namespace stim_buff
|
|
} // namespace smo
|
|
|
|
#endif // _LIVOX_GEN1_PCLOUD_STIMULUS_BUFFER_H
|