#pragma once

#include "../../../include/dv-processing/kinematics/linear_transformer.hpp"

#include <pybind11/pybind11.h>

namespace py = pybind11;

/**
 * @brief Bind kinematics::LinearTransformerf class to python
 * @param m pybind The module to bind to
 */
void bind_linear_transformer(py::module &m) {
	py::class_<dv::kinematics::LinearTransformerf>(m, "LinearTransformerf",
		"A buffer containing time increasing 3D transformations and capable of timewise linear interpolation between "
		"available transforms.")
		.def(py::init<size_t>(), py::arg("capacity"))
		.def("pushTransformation", &dv::kinematics::LinearTransformerf::pushTransformation, py::arg("transformation"),
			"Push a transformation into the transformation buffer.")
		.def("clear", &dv::kinematics::LinearTransformerf::clear, "Delete all transformations from the buffer.")
		.def("empty", &dv::kinematics::LinearTransformerf::empty, "Check whether the buffer is empty.")
		.def("getTransformAt", &dv::kinematics::LinearTransformerf::getTransformAt, py::arg("timestamp"),
			"Get a transform at the given timestamp. If no transform with the exact timestamp was pushed, estimates a "
			"transform assuming linear motion.")
		.def("isWithinTimeRange", &dv::kinematics::LinearTransformerf::isWithinTimeRange, py::arg("timestamp"),
			"Checks whether the timestamp is within the range of transformations available in the buffer.")
		.def("size", &dv::kinematics::LinearTransformerf::size, "Return the size of the buffer.")
		.def("latestTransformation", &dv::kinematics::LinearTransformerf::latestTransformation,
			"Return transformation with highest timestamp.")
		.def("earliestTransformation", &dv::kinematics::LinearTransformerf::earliestTransformation,
			"Return transformation with lowest timestamp.")
		.def("setCapacity", &dv::kinematics::LinearTransformerf::setCapacity,
			"Set new capacity, if the size of the buffer is larger than the newCapacity, oldest transformations from "
			"the start will be removed.")
		.def("getTransformsBetween", &dv::kinematics::LinearTransformerf::getTransformsBetween, py::arg("start"),
			py::arg("end"),
			"Extract transformation between two given timestamps. If timestamps are not at exact available "
			"transformations, additional transformations will be added so the resulting transformer would complete "
			"overlap over the period (if that is possible).")
		.def("resampleTransforms", &dv::kinematics::LinearTransformerf::resampleTransforms, py::arg("samplingInterval"),
			"Resample containing transforms into a new transformer, containing interpolated transforms at given "
			"interval. Will contain the last transformation as well, although the interval might not be maintained for "
			"the last transform.");
}
