View data_tamer mcap files as numpy array
- Linux (for now)
- Clone pydata_tamer
git clone https://github.com/raghavauppuluri13/pydatatamer.git
cd pydata_tamer
- Install pydata_tamer (also builds pybind11)
pip3 install -e .
- Run example
cd examples
python3 read_data.py
- Update
include/mcap_types.hpp
with your new snapshot type
struct Point {
double x;
double y;
Point() {}
inline void update(std::string name,
const DataTamerParser::VarNumber &data) {
if (name == "x")) {
position = std::get<double>(data);
} else if (name == "y") {
velocity = std::get<double>(data);
} else {
std::cerr << "unknown series name: " << name << std::endl;
throw std::runtime_error("Unknown series!");
}
}
};
- Update mcap_reader.cpp's
PYBIND11_MODULE->McapReader
with your new snapshot type template
py::class_<Point>(m, "Point")
.def(py::init<>())
.def_readwrite("x", &Point::x)
.def_readwrite("y", &Point::y);
PYBIND11_NUMPY_DTYPE(Point, x, y);
py::class_<McapTamer<Point>>(m, "McapTamer")
.def(py::init<>())
.def("init", &McapTamer<Point>::init)
.def("parse", &McapTamer<Point>::parse);
- pip install again to build
- Read in python
from pydatatamer.mcap_tamer import McapTamer
import numpy as np
mcap_tamer = McapTamer()
mcap_tamer.init("points.mcap")
# structured array
points_data = mcap_tamer.parse()
print(points)
- MCAP reader code from mcap-cpp
- mcap_reader.cpp and data_tamer_parser.hpp data_tamer