3 #ifndef __INTERPOLATED_POSITION_BUFFER_HPP__
4 #define __INTERPOLATED_POSITION_BUFFER_HPP__
50 std::vector<std::uint64_t>
popBatch(
bool fullBuffer);
65 using ip_record = std::pair<int, double>;
77 double getMeanVelocity(
const ip_record & earliest,
const ip_record & latest)
const;
80 virtual std::uint64_t
makeDataRecord(
const ip_record & previous,
const ip_record & current,
const ip_record & next) = 0;
82 const double samplingPeriod;
85 const std::uint16_t fixedSamples;
86 std::uint8_t integrityCounter;
88 double initialTimestamp;
90 std::deque<ip_record> pendingTargets;
91 mutable std::mutex queueMutex;
107 std::uint64_t
makeDataRecord(
const ip_record & previous,
const ip_record & current,
const ip_record & next)
override;
127 std::uint64_t
makeDataRecord(
const ip_record & previous,
const ip_record & current,
const ip_record & next)
override;
Base class for a PT/PVT buffer of setpoints.
Definition: InterpolatedPositionBuffer.hpp:23
std::vector< std::uint64_t > popBatch(bool fullBuffer)
Generate next batch of setpoints popped from the front of the queue.
Definition: InterpolatedPositionBuffer.cpp:54
virtual std::uint16_t getBufferSize() const =0
Get PT/PVT buffer size.
double getMeanVelocity(const ip_record &earliest, const ip_record &latest) const
Compute mean velocity (internal units) between two setpoints.
Definition: InterpolatedPositionBuffer.cpp:154
std::uint16_t getSampledTime(double currentTimestamp)
Obtain time samples (internal units) for current segment, update internal counters.
Definition: InterpolatedPositionBuffer.cpp:138
virtual std::size_t getOffset() const
Determine how many points should be left in the queue on each non-final batch update.
Definition: InterpolatedPositionBuffer.cpp:133
bool isQueueEmpty() const
Report whether there are no more points in the queue.
Definition: InterpolatedPositionBuffer.cpp:116
void addSetpoint(int target)
Place a new setpoint (internal units) at the end of the queue.
Definition: InterpolatedPositionBuffer.cpp:48
void setInitial(int initialTarget)
Store initial position (internal units).
Definition: InterpolatedPositionBuffer.cpp:32
int getPrevTarget() const
Retrieve last point loaded into the buffer (internal units).
Definition: InterpolatedPositionBuffer.cpp:103
int getPeriodMs() const
Get PT/PVT period if fixed (synchronous), zero otherwise (asynchronous).
bool isQueueReady() const
Report whether there are enough points in the queue to fill the buffer.
Definition: InterpolatedPositionBuffer.cpp:109
virtual std::uint64_t makeDataRecord(const ip_record &previous, const ip_record ¤t, const ip_record &next)=0
Generate interpolation data record given three contiguous position target (object 60C1h).
std::uint16_t getBufferConfig() const
Get buffer configuration (object 2074h).
Definition: InterpolatedPositionBuffer.cpp:40
virtual std::int16_t getSubMode() const =0
Generate interpolation submode register value (object 60C0h).
virtual ~InterpolatedPositionBuffer()=default
Virtual destructor.
void clearQueue()
Clear internal queue.
Definition: InterpolatedPositionBuffer.cpp:122
InterpolatedPositionBuffer(double samplingPeriod, double interpolationPeriod)
Constructor, sets internal invariable parameters.
Definition: InterpolatedPositionBuffer.cpp:23
std::uint8_t getIntegrityCounter() const
Retrieve current integrity counter value.
Definition: InterpolatedPositionBuffer.cpp:128
Implementation of a PT buffer (linear interpolation).
Definition: InterpolatedPositionBuffer.hpp:99
std::uint64_t makeDataRecord(const ip_record &previous, const ip_record ¤t, const ip_record &next) override
Generate interpolation data record given three contiguous position target (object 60C1h).
Definition: InterpolatedPositionBuffer.cpp:180
std::uint16_t getBufferSize() const override
Get PT/PVT buffer size.
Definition: InterpolatedPositionBuffer.cpp:170
std::int16_t getSubMode() const override
Generate interpolation submode register value (object 60C0h).
Definition: InterpolatedPositionBuffer.cpp:175
Implementation of a PVT buffer (cubic interpolation).
Definition: InterpolatedPositionBuffer.hpp:118
std::int16_t getSubMode() const override
Generate interpolation submode register value (object 60C0h).
Definition: InterpolatedPositionBuffer.cpp:200
std::uint16_t getBufferSize() const override
Get PT/PVT buffer size.
Definition: InterpolatedPositionBuffer.cpp:195
std::uint64_t makeDataRecord(const ip_record &previous, const ip_record ¤t, const ip_record &next) override
Generate interpolation data record given three contiguous position target (object 60C1h).
Definition: InterpolatedPositionBuffer.cpp:210
std::size_t getOffset() const override
Determine how many points should be left in the queue on each non-final batch update.
Definition: InterpolatedPositionBuffer.cpp:205
The main, catch-all namespace for Robotics Lab UC3M.
Definition: groups.dox:6