mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-20 12:43:34 +08:00
EKF simplify RingBuffer allocation check
This commit is contained in:
+9
-10
@@ -45,7 +45,13 @@ template <typename data_type>
|
||||
class RingBuffer
|
||||
{
|
||||
public:
|
||||
RingBuffer() = default;
|
||||
RingBuffer() {
|
||||
if (allocate(1)) {
|
||||
// initialize with one empty sample
|
||||
data_type d = {};
|
||||
push(d);
|
||||
}
|
||||
}
|
||||
~RingBuffer() { delete[] _buffer; }
|
||||
|
||||
// no copy, assignment, move, move assignment
|
||||
@@ -72,8 +78,8 @@ public:
|
||||
_tail = 0;
|
||||
|
||||
// set the time elements to zero so that bad data is not retrieved from the buffers
|
||||
for (unsigned index = 0; index < _size; index++) {
|
||||
_buffer[index].time_us = 0;
|
||||
for (uint8_t index = 0; index < _size; index++) {
|
||||
_buffer[index] = {};
|
||||
}
|
||||
_first_write = true;
|
||||
|
||||
@@ -149,13 +155,6 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// return ttrue if allocated
|
||||
unsigned is_allocated()
|
||||
{
|
||||
return (_buffer != NULL);
|
||||
}
|
||||
private:
|
||||
data_type *_buffer{nullptr};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user