livoxGen1: Add StimBuffs to PcloudStimProd
* PcloudStimulusProducer now has member sh_ptr<StimulusBuffer>s. * StimulusProducer now has a vector<sh_ptr<StimulusBuffer>s. Created new stimbuff-type-specific Pcloud[Xyz|I|Ambience]StimulusBuffer classes for representing each stim feature exposed by livoxGen1's PcloudStimulusProducer.
This commit is contained in:
@@ -9,10 +9,26 @@
|
||||
#include <componentThread.h>
|
||||
#include <spinLock.h>
|
||||
#include <user/stimulusProducer.h>
|
||||
#include <user/stimulusBuffer.h>
|
||||
|
||||
namespace smo {
|
||||
namespace stim_buff {
|
||||
|
||||
std::shared_ptr<StimulusBuffer> StimulusProducer::getAttachedStimulusBuffer(
|
||||
const std::shared_ptr<device::DeviceAttachmentSpec>& spec) const
|
||||
{
|
||||
for (const auto& buffer : attachedStimulusBuffers)
|
||||
{
|
||||
if (buffer && buffer->deviceAttachmentSpec &&
|
||||
*buffer->deviceAttachmentSpec == *spec)
|
||||
{
|
||||
return buffer;
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void StimulusProducer::stop()
|
||||
{
|
||||
{
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <memory>
|
||||
#include <user/spMcRingBuffer.h>
|
||||
#include "stimulusFrame.h"
|
||||
#include "deviceAttachmentSpec.h"
|
||||
|
||||
namespace smo {
|
||||
namespace stim_buff {
|
||||
@@ -24,9 +25,12 @@ class StimulusBuffer
|
||||
public:
|
||||
explicit StimulusBuffer(
|
||||
std::shared_ptr<StimulusProducer> &producer,
|
||||
const std::shared_ptr<device::DeviceAttachmentSpec>
|
||||
&deviceAttachmentSpec,
|
||||
int histbuffMs,
|
||||
const SpMcRingBuffer::InputEngineConstraints& ringBufferConstraints)
|
||||
: producer(producer),
|
||||
deviceAttachmentSpec(deviceAttachmentSpec),
|
||||
histbuffMs(histbuffMs),
|
||||
frames_(static_cast<size_t>(histbuffMs / CONFIG_STIMBUFF_FRAME_PERIOD_MS)),
|
||||
ringBufferConstraints(ringBufferConstraints),
|
||||
@@ -45,10 +49,11 @@ public:
|
||||
|
||||
public:
|
||||
std::shared_ptr<StimulusProducer> producer;
|
||||
std::shared_ptr<device::DeviceAttachmentSpec> deviceAttachmentSpec;
|
||||
int histbuffMs;
|
||||
std::vector<StimulusFrame> frames_;
|
||||
|
||||
protected:
|
||||
int histbuffMs;
|
||||
SpMcRingBuffer::InputEngineConstraints ringBufferConstraints;
|
||||
SpMcRingBuffer ringBuffer;
|
||||
};
|
||||
|
||||
@@ -19,6 +19,9 @@
|
||||
namespace smo {
|
||||
namespace stim_buff {
|
||||
|
||||
// Forward declaration
|
||||
class StimulusBuffer;
|
||||
|
||||
/**
|
||||
* StimulusProducer manages a collection of stimulus frames with simultaneity stamps.
|
||||
*
|
||||
@@ -66,6 +69,9 @@ public:
|
||||
void allowNextStimulusFrame()
|
||||
{ frameAssemblyRateLimiter.release(); }
|
||||
|
||||
std::shared_ptr<StimulusBuffer> getAttachedStimulusBuffer(
|
||||
const std::shared_ptr<device::DeviceAttachmentSpec>& spec) const;
|
||||
|
||||
protected:
|
||||
SpinLock frameAssemblyRateLimiter;
|
||||
|
||||
@@ -82,6 +88,7 @@ private:
|
||||
|
||||
public:
|
||||
std::shared_ptr<device::DeviceAttachmentSpec> deviceAttachmentSpec;
|
||||
std::vector<std::shared_ptr<StimulusBuffer>> attachedStimulusBuffers;
|
||||
|
||||
private:
|
||||
boost::asio::io_service& ioService;
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
#ifndef _LIVOX_GEN1_PCLOUD_AMBIENCE_STIMULUS_BUFFER_H
|
||||
#define _LIVOX_GEN1_PCLOUD_AMBIENCE_STIMULUS_BUFFER_H
|
||||
|
||||
#include <memory>
|
||||
#include <user/stimulusBuffer.h>
|
||||
|
||||
namespace smo {
|
||||
namespace stim_buff {
|
||||
|
||||
// Forward declaration
|
||||
class StimulusProducer;
|
||||
|
||||
/**
|
||||
* PcloudAmbienceStimulusBuffer is a specialized StimulusBuffer for ambience point cloud data.
|
||||
*/
|
||||
class PcloudAmbienceStimulusBuffer
|
||||
: public StimulusBuffer
|
||||
{
|
||||
public:
|
||||
explicit PcloudAmbienceStimulusBuffer(
|
||||
std::shared_ptr<StimulusProducer>& producer,
|
||||
const std::shared_ptr<device::DeviceAttachmentSpec>& deviceAttachmentSpec,
|
||||
int histbuffMs,
|
||||
const SpMcRingBuffer::InputEngineConstraints& ringBufferConstraints)
|
||||
: StimulusBuffer(
|
||||
producer, deviceAttachmentSpec, histbuffMs, ringBufferConstraints)
|
||||
{}
|
||||
|
||||
~PcloudAmbienceStimulusBuffer() = default;
|
||||
|
||||
// Non-copyable, movable
|
||||
PcloudAmbienceStimulusBuffer(const PcloudAmbienceStimulusBuffer&) = delete;
|
||||
PcloudAmbienceStimulusBuffer& operator=(const PcloudAmbienceStimulusBuffer&) = delete;
|
||||
PcloudAmbienceStimulusBuffer(PcloudAmbienceStimulusBuffer&&) = default;
|
||||
PcloudAmbienceStimulusBuffer& operator=(PcloudAmbienceStimulusBuffer&&) = default;
|
||||
};
|
||||
|
||||
} // namespace stim_buff
|
||||
} // namespace smo
|
||||
|
||||
#endif // _LIVOX_GEN1_PCLOUD_AMBIENCE_STIMULUS_BUFFER_H
|
||||
@@ -11,6 +11,9 @@
|
||||
#include "stagingBuffer.h"
|
||||
#include "ioUringAssemblyEngine.h"
|
||||
#include "openClCollatingAndMeshingEngine.h"
|
||||
#include "pcloudXyzStimulusBuffer.h"
|
||||
#include "pcloudIStimulusBuffer.h"
|
||||
#include "pcloudAmbienceStimulusBuffer.h"
|
||||
|
||||
namespace smo {
|
||||
namespace stim_buff {
|
||||
@@ -74,9 +77,12 @@ public:
|
||||
StagingBuffer assemblyBuffer;
|
||||
IoUringAssemblyEngine ioUringAssemblyEngine;
|
||||
StagingBuffer collationBuffer;
|
||||
std::atomic<size_t> nAttachedStimBuffs{0};
|
||||
StimulusFrame tempStimulusFrame;
|
||||
|
||||
std::shared_ptr<PcloudXyzStimulusBuffer> xyzStimulusBuffer;
|
||||
std::shared_ptr<PcloudIStimulusBuffer> iStimulusBuffer;
|
||||
std::shared_ptr<PcloudAmbienceStimulusBuffer> ambienceStimulusBuffer;
|
||||
|
||||
private:
|
||||
class ProduceFrameReq;
|
||||
};
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
#ifndef _LIVOX_GEN1_PCLOUD_I_STIMULUS_BUFFER_H
|
||||
#define _LIVOX_GEN1_PCLOUD_I_STIMULUS_BUFFER_H
|
||||
|
||||
#include <memory>
|
||||
#include <user/stimulusBuffer.h>
|
||||
|
||||
namespace smo {
|
||||
namespace stim_buff {
|
||||
|
||||
// Forward declaration
|
||||
class StimulusProducer;
|
||||
|
||||
/**
|
||||
* PcloudIStimulusBuffer is a specialized StimulusBuffer for intensity point cloud data.
|
||||
*/
|
||||
class PcloudIStimulusBuffer
|
||||
: public StimulusBuffer
|
||||
{
|
||||
public:
|
||||
explicit PcloudIStimulusBuffer(
|
||||
std::shared_ptr<StimulusProducer>& producer,
|
||||
const std::shared_ptr<device::DeviceAttachmentSpec>& deviceAttachmentSpec,
|
||||
int histbuffMs,
|
||||
const SpMcRingBuffer::InputEngineConstraints& ringBufferConstraints)
|
||||
: StimulusBuffer(
|
||||
producer, deviceAttachmentSpec, histbuffMs, ringBufferConstraints)
|
||||
{}
|
||||
|
||||
~PcloudIStimulusBuffer() = default;
|
||||
|
||||
// Non-copyable, movable
|
||||
PcloudIStimulusBuffer(const PcloudIStimulusBuffer&) = delete;
|
||||
PcloudIStimulusBuffer& operator=(const PcloudIStimulusBuffer&) = delete;
|
||||
PcloudIStimulusBuffer(PcloudIStimulusBuffer&&) = default;
|
||||
PcloudIStimulusBuffer& operator=(PcloudIStimulusBuffer&&) = default;
|
||||
};
|
||||
|
||||
} // namespace stim_buff
|
||||
} // namespace smo
|
||||
|
||||
#endif // _LIVOX_GEN1_PCLOUD_I_STIMULUS_BUFFER_H
|
||||
@@ -0,0 +1,41 @@
|
||||
#ifndef _LIVOX_GEN1_PCLOUD_XYZ_STIMULUS_BUFFER_H
|
||||
#define _LIVOX_GEN1_PCLOUD_XYZ_STIMULUS_BUFFER_H
|
||||
|
||||
#include <memory>
|
||||
#include <user/stimulusBuffer.h>
|
||||
|
||||
namespace smo {
|
||||
namespace stim_buff {
|
||||
|
||||
// Forward declaration
|
||||
class StimulusProducer;
|
||||
|
||||
/**
|
||||
* PcloudXyzStimulusBuffer is a specialized StimulusBuffer for XYZ point cloud data.
|
||||
*/
|
||||
class PcloudXyzStimulusBuffer
|
||||
: public StimulusBuffer
|
||||
{
|
||||
public:
|
||||
explicit PcloudXyzStimulusBuffer(
|
||||
std::shared_ptr<StimulusProducer>& producer,
|
||||
const std::shared_ptr<device::DeviceAttachmentSpec>& deviceAttachmentSpec,
|
||||
int histbuffMs,
|
||||
const SpMcRingBuffer::InputEngineConstraints& ringBufferConstraints)
|
||||
: StimulusBuffer(
|
||||
producer, deviceAttachmentSpec, histbuffMs, ringBufferConstraints)
|
||||
{}
|
||||
|
||||
~PcloudXyzStimulusBuffer() = default;
|
||||
|
||||
// Non-copyable, movable
|
||||
PcloudXyzStimulusBuffer(const PcloudXyzStimulusBuffer&) = delete;
|
||||
PcloudXyzStimulusBuffer& operator=(const PcloudXyzStimulusBuffer&) = delete;
|
||||
PcloudXyzStimulusBuffer(PcloudXyzStimulusBuffer&&) = default;
|
||||
PcloudXyzStimulusBuffer& operator=(PcloudXyzStimulusBuffer&&) = default;
|
||||
};
|
||||
|
||||
} // namespace stim_buff
|
||||
} // namespace smo
|
||||
|
||||
#endif // _LIVOX_GEN1_PCLOUD_XYZ_STIMULUS_BUFFER_H
|
||||
Reference in New Issue
Block a user