|
BCNP 3.2.1
Batched Command Network Protocol
|
Accumulates high-frequency telemetry data and batches into packets. More...
#include <telemetry_accumulator.h>
Classes | |
| struct | Metrics |
| Metrics for diagnostics. More... | |
Public Types | |
| using | Clock = std::chrono::steady_clock |
Public Member Functions | |
| TelemetryAccumulator (TelemetryAccumulatorConfig config={}) | |
| bool | Record (const MsgType &msg) |
| Record a telemetry reading. | |
| template<typename InputIt > | |
| void | RecordBatch (InputIt first, InputIt last) |
| Record multiple telemetry readings at once. | |
| template<typename Adapter > | |
| bool | MaybeFlush (Adapter &adapter) |
| Flush if interval has elapsed. | |
| template<typename Adapter > | |
| bool | ForceFlush (Adapter &adapter) |
| Force an immediate flush regardless of interval. | |
| std::size_t | BufferedCount () const |
| Get the number of buffered messages waiting to be sent. | |
| void | Clear () |
| Clear all buffered messages without sending. | |
| Metrics | GetMetrics () const |
| void | ResetMetrics () |
| void | SetConfig (const TelemetryAccumulatorConfig &config) |
| Update configuration. | |
Accumulates high-frequency telemetry data and batches into packets.
The accumulator collects sensor/state readings during the control loop and sends them as batched BCNP packets at a configurable rate. This avoids the overhead of a send() syscall per reading.
| MsgType | The message struct type (e.g., DrivetrainState, EncoderData) |
| Storage | Container type (default: StaticVector<MsgType, 64>) |
Usage (robot side):
Definition at line 55 of file telemetry_accumulator.h.
| using bcnp::TelemetryAccumulator< MsgType, Storage >::Clock = std::chrono::steady_clock |
Definition at line 57 of file telemetry_accumulator.h.
|
inlineexplicit |
Definition at line 59 of file telemetry_accumulator.h.
|
inline |
Get the number of buffered messages waiting to be sent.
Definition at line 172 of file telemetry_accumulator.h.
|
inline |
Clear all buffered messages without sending.
Definition at line 180 of file telemetry_accumulator.h.
|
inline |
Force an immediate flush regardless of interval.
| adapter | The transport adapter to send through |
Definition at line 147 of file telemetry_accumulator.h.
|
inline |
Definition at line 197 of file telemetry_accumulator.h.
|
inline |
Flush if interval has elapsed.
Call this at the end of each control loop iteration.
| adapter | The transport adapter to send through (must have SendBytes) |
Definition at line 112 of file telemetry_accumulator.h.
|
inline |
Record a telemetry reading.
Call this for each sensor/state update during the control loop. If the buffer is full, the oldest reading is discarded (ring behavior via clear+re-add).
| msg | The telemetry message to record |
Definition at line 71 of file telemetry_accumulator.h.
|
inline |
Record multiple telemetry readings at once.
Useful for batching multiple encoder readings in a single call.
Definition at line 91 of file telemetry_accumulator.h.
|
inline |
Definition at line 202 of file telemetry_accumulator.h.
|
inline |
Update configuration.
Definition at line 210 of file telemetry_accumulator.h.