mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-23 13:33:34 +08:00
EKF: Add methods to ring buffer to access specific indices
This commit is contained in:
@@ -160,6 +160,30 @@ public:
|
|||||||
return _buffer[index];
|
return _buffer[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// return data at the specified index
|
||||||
|
data_type get_from_index(unsigned index)
|
||||||
|
{
|
||||||
|
if (index >= _size) {
|
||||||
|
index = _size-1;
|
||||||
|
}
|
||||||
|
return _buffer[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
// push data to the specified index
|
||||||
|
void push_to_index(unsigned index, data_type sample)
|
||||||
|
{
|
||||||
|
if (index >= _size) {
|
||||||
|
index = _size-1;
|
||||||
|
}
|
||||||
|
_buffer[index] = sample;
|
||||||
|
}
|
||||||
|
|
||||||
|
// return the length of the buffer
|
||||||
|
unsigned get_length()
|
||||||
|
{
|
||||||
|
return _size;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
data_type *_buffer;
|
data_type *_buffer;
|
||||||
unsigned _head, _tail, _size;
|
unsigned _head, _tail, _size;
|
||||||
|
|||||||
Reference in New Issue
Block a user