MBot Software Library  v1.0
An API documentation to mbot_firmware repository
Functions
ring_buffer.c File Reference

Ring buffer implementation for double-precision doubles. More...

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <rc/math/ring_buffer.h>
#include "algebra_common.h"
Include dependency graph for ring_buffer.c:

Functions

rc_ringbuf_t rc_ringbuf_empty (void)
 Returns an rc_ringbuf_t struct which is completely zero'd out with no memory allocated for it. More...
 
int rc_ringbuf_alloc (rc_ringbuf_t *buf, int size)
 Allocates memory for a ring buffer and initializes an rc_ringbuf_t struct. More...
 
int rc_ringbuf_free (rc_ringbuf_t *buf)
 Frees the memory allocated for buffer buf. More...
 
int rc_ringbuf_reset (rc_ringbuf_t *buf)
 Sets all values in the buffer to 0.0f and sets the buffer index back to 0. More...
 
int rc_ringbuf_insert (rc_ringbuf_t *buf, double val)
 Puts a new float into the ring buffer and updates the index accordingly. More...
 
double rc_ringbuf_get_value (rc_ringbuf_t *buf, int pos)
 Fetches the float which is 'position' steps behind the last value added to the buffer. More...
 
double rc_ringbuf_std_dev (rc_ringbuf_t buf)
 Returns the standard deviation of all values in the ring buffer. More...
 

Detailed Description

Ring buffer implementation for double-precision doubles.

        Ring buffers are FIFO (first in first out) buffers of fixed
        length which efficiently boot out the oldest value when full.
        They are particularly well suited for storing the last n values
        in a discrete time filter.

        The user creates their own instance of a buffer and passes a
        pointer to the these ring_buf functions to perform normal
        operations.
Author
James Strawson
Date
2016