-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #609 from ami-iit/bindings/spline
Finalize the python bindings for the Spline
- Loading branch information
Showing
7 changed files
with
97 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/** | ||
* @file Spline.cpp | ||
* @authors Giulio Romualdi, Diego Ferigo | ||
* @copyright 2020 Istituto Italiano di Tecnologia (IIT). This software may be modified and | ||
* distributed under the terms of the BSD-3-Clause license. | ||
*/ | ||
|
||
#include <Eigen/Dense> | ||
|
||
#include <pybind11/eigen.h> | ||
#include <pybind11/pybind11.h> | ||
#include <pybind11/stl.h> | ||
|
||
#include <BipedalLocomotion/Planners/QuinticSpline.h> | ||
#include <BipedalLocomotion/Planners/CubicSpline.h> | ||
#include <BipedalLocomotion/Planners/Spline.h> | ||
|
||
#include <BipedalLocomotion/bindings/Planners/Spline.h> | ||
|
||
namespace BipedalLocomotion | ||
{ | ||
namespace bindings | ||
{ | ||
namespace Planners | ||
{ | ||
|
||
void CreateSpline(pybind11::module& module) | ||
{ | ||
namespace py = ::pybind11; | ||
using namespace BipedalLocomotion::Planners; | ||
|
||
py::class_<SplineState>(module, "SplineState") | ||
.def(py::init()) | ||
.def_readwrite("position", &SplineState::position) | ||
.def_readwrite("velocity", &SplineState::velocity) | ||
.def_readwrite("acceleration", &SplineState::acceleration); | ||
|
||
py::class_<Spline>(module, "Spline") | ||
.def("set_advance_time_step", &Spline::setAdvanceTimeStep, py::arg("dt")) | ||
.def("set_knots", &Spline::setKnots) | ||
.def("set_initial_conditions", | ||
&Spline::setInitialConditions, | ||
py::arg("velocity"), | ||
py::arg("acceleration")) | ||
.def("set_final_conditions", | ||
&Spline::setFinalConditions, | ||
py::arg("velocity"), | ||
py::arg("acceleration")) | ||
.def("evaluate_point", | ||
py::overload_cast<const double&, | ||
Eigen::Ref<Eigen::VectorXd>, | ||
Eigen::Ref<Eigen::VectorXd>, | ||
Eigen::Ref<Eigen::VectorXd>>(&Spline::evaluatePoint), | ||
py::arg("time"), | ||
py::arg("position"), | ||
py::arg("velocity"), | ||
py::arg("acceleration")) | ||
.def("get_output", &Spline::getOutput) | ||
.def("is_output_valid", &Spline::isOutputValid) | ||
.def("advance", &Spline::advance); | ||
} | ||
|
||
void CreateCubicSpline(pybind11::module& module) | ||
{ | ||
namespace py = ::pybind11; | ||
using namespace BipedalLocomotion::Planners; | ||
|
||
py::class_<CubicSpline, Spline>(module, "CubicSpline") | ||
.def(py::init()); | ||
} | ||
|
||
void CreateQuinticSpline(pybind11::module& module) | ||
{ | ||
namespace py = ::pybind11; | ||
using namespace BipedalLocomotion::Planners; | ||
|
||
py::class_<QuinticSpline, Spline>(module, "QuinticSpline") | ||
.def(py::init()); | ||
} | ||
|
||
} // namespace Planners | ||
} // namespace bindings | ||
} // namespace BipedalLocomotion |