Datasets#

#include "navground/sim/dataset.h"
class Dataset#

Dynamic homogeneous multi-dimensional numerical data stored in std::vector. Used to record data collected during an ExperimentalRun.

Public Types

using Scalar = std::variant<float, double, int64_t, int32_t, int16_t, int8_t, uint64_t, uint32_t, uint16_t, uint8_t>#

The data type

using Data = std::variant<std::vector<float>, std::vector<double>, std::vector<int64_t>, std::vector<int32_t>, std::vector<int16_t>, std::vector<int8_t>, std::vector<uint64_t>, std::vector<uint32_t>, std::vector<uint16_t>, std::vector<uint8_t>>#

The data container type

using Shape = std::vector<size_t>#

The shape type

using Indices = std::vector<size_t>#

The indices type

Public Functions

void config_to_hold_buffer(const navground::core::Buffer &buffer)#

Configure this dataset to accumulate data from a buffer.

Parameters:

buffer[in] The buffer

Shape get_shape() const#

Returns the shape of the multi-dimensional dataset.

Returns:

The shape

inline size_t size() const#

Returns the total number of stored items.

Returns:

The size

inline Shape get_item_shape() const#

Gets the shape of all axis except the first.

Returns:

The shape.

void set_item_shape(const Shape &item_shape)#

Sets the shape of all axis except the first.

Parameters:

item_shape[in] The desired shape

bool is_valid() const#

Determines if valid.

Returns:

True if the number of items fill the shape exactly, False otherwise.

void reset()#

Clear all data.

template<typename T>
inline void set_dtype()#

Sets the type of data.

Will clear the data if the type is different than the current.

Template Parameters:

T – The desired numerical type.

template<typename T>
inline void push(const T &value)#

Add an item.

The item will be implicitly converted to the current data type, see set_dtype.

Parameters:

value[in] The value to add

Template Parameters:

T – The type of the item. Must be convertible to the current data type.

void push(const Scalar &value)#

Add an item.

The item will be implicitly converted to the current data type, see set_dtype.

Parameters:

value[in] The value to add

template<typename T>
inline void append(const std::vector<T> &values)#

Add items.

The items will be implicitly converted to the current data type, see set_dtype.

Parameters:

values[in] The values to add

Template Parameters:

T – The type of the items. Must be convertible to the current data type.

template<typename T>
inline void append(const std::valarray<T> &values)#

Add items.

The items will be implicitly converted to the current data type, see set_dtype.

Parameters:

values[in] The values to add

Template Parameters:

T – The type of the items. Must be convertible to the current data type.

void append(const Data &values)#

Add items.

The items will be implicitly converted to the current data type, see set_dtype.

Parameters:

values[in] The values to add

void append(const core::Buffer &buffer)#

Add items.

The items will be implicitly converted to the current data type, see set_dtype.

Parameters:

buffer[in] The buffer with the values to add

inline const Data &get_data() const#

Gets the stored data.

Returns:

The data.

inline void set_data(const Data &data)#

Sets the stored data.

Parameters:

data[in] The data.

template<typename T>
inline const std::vector<T> *get_typed_data() const#

Gets the stored data.

Template Parameters:

T – The desired type.

Returns:

A pointer to the stored data or null if data has a different type than T.

template<typename T, int N>
inline Eigen::TensorMap<Eigen::Tensor<T, N>> const as_tensor() const#

Return a tensor view of the dataset.

Template Parameters:
  • T – The desired type.

  • N – The number of dimensions

Returns:

An eigen tensor with the same shape and type as the dataset

inline bool write_buffer(core::Buffer *buffer, unsigned index) const#

Writes a buffer with the content of one dataset entry.

Parameters:
  • buffer – The buffer

  • index[in] The index of the entry

Returns:

True if writing was successful.