-
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.
Python bindings for : Centroidal MPC, Centroidal Dynamics and Contacts (
#650)
- Loading branch information
1 parent
9a25588
commit 86e4e57
Showing
16 changed files
with
443 additions
and
7 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
28 changes: 28 additions & 0 deletions
28
...lSystem/include/BipedalLocomotion/bindings/ContinuousDynamicalSystem/CentroidalDynamics.h
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,28 @@ | ||
/** | ||
* @file CentroidalDynamics.h | ||
* @authors Giulio Romualdi | ||
* @copyright 2023 Istituto Italiano di Tecnologia (IIT). This software may be modified and | ||
* distributed under the terms of the BSD-3-Clause license. | ||
*/ | ||
|
||
#ifndef BIPEDAL_LOCOMOTION_BINDINGS_CONTINUOUS_DYNAMICAL_SYSTEM_CENTROIDAL_DYNAMICS_H | ||
#define BIPEDAL_LOCOMOTION_BINDINGS_CONTINUOUS_DYNAMICAL_SYSTEM_CENTROIDAL_DYNAMICS_H | ||
|
||
#include <memory> | ||
|
||
#include <pybind11/pybind11.h> | ||
|
||
namespace BipedalLocomotion | ||
{ | ||
namespace bindings | ||
{ | ||
namespace ContinuousDynamicalSystem | ||
{ | ||
|
||
void CreateCentroidalDynamics(pybind11::module& module); | ||
|
||
} // namespace ContinuousDynamicalSystem | ||
} // namespace bindings | ||
} // namespace BipedalLocomotion | ||
|
||
#endif // BIPEDAL_LOCOMOTION_BINDINGS_CONTINUOUS_DYNAMICAL_SYSTEM_CENTROIDAL_DYNAMICS_H |
46 changes: 46 additions & 0 deletions
46
bindings/python/ContinuousDynamicalSystem/src/CentroidalDynamics.cpp
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,46 @@ | ||
/** | ||
* @file CentroidalDynamics.cpp | ||
* @authors Giulio Romualdi | ||
* @copyright 2023 Istituto Italiano di Tecnologia (IIT). This software may be modified and | ||
* distributed under the terms of the BSD-3-Clause license. | ||
*/ | ||
|
||
#include <BipedalLocomotion/ContinuousDynamicalSystem/DynamicalSystem.h> | ||
#include <BipedalLocomotion/ContinuousDynamicalSystem/CentroidalDynamics.h> | ||
|
||
#include <BipedalLocomotion/bindings/ContinuousDynamicalSystem/DynamicalSystem.h> | ||
#include <BipedalLocomotion/bindings/ContinuousDynamicalSystem/Integrator.h> | ||
#include <BipedalLocomotion/bindings/ContinuousDynamicalSystem/LinearTimeInvariantSystem.h> | ||
#include <BipedalLocomotion/bindings/ContinuousDynamicalSystem/CentroidalDynamics.h> | ||
|
||
#include <pybind11/eigen.h> | ||
#include <pybind11/stl.h> | ||
|
||
namespace BipedalLocomotion | ||
{ | ||
namespace bindings | ||
{ | ||
namespace ContinuousDynamicalSystem | ||
{ | ||
|
||
void CreateCentroidalDynamics(pybind11::module& module) | ||
{ | ||
using namespace BipedalLocomotion::ContinuousDynamicalSystem; | ||
namespace py = ::pybind11; | ||
|
||
constexpr auto name = "CentroidalDynamics"; | ||
|
||
CreateDynamicalSystem<DynamicalSystem<CentroidalDynamics>, | ||
std::shared_ptr<DynamicalSystem<CentroidalDynamics>>> // | ||
(module, name); | ||
|
||
py::class_<CentroidalDynamics, | ||
DynamicalSystem<CentroidalDynamics>, | ||
std::shared_ptr<CentroidalDynamics>>(module, name) | ||
.def(py::init()); | ||
|
||
CreateForwardEulerIntegrator<CentroidalDynamics>(module, name); | ||
} | ||
} // namespace ContinuousDynamicalSystem | ||
} // namespace bindings | ||
} // namespace BipedalLocomotion |
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
20 changes: 20 additions & 0 deletions
20
bindings/python/ContinuousDynamicalSystem/tests/test_centroidal_dynamics.py
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,20 @@ | ||
import pytest | ||
pytestmark = pytest.mark.centroidalDynamics | ||
|
||
import bipedal_locomotion_framework.bindings as blf | ||
import numpy as np | ||
import manifpy as manif | ||
|
||
from datetime import timedelta | ||
|
||
|
||
def test_centroidal_dynamics(): | ||
|
||
centroidal_integrator = blf.continuous_dynamical_system.CentroidalDynamicsForwardEulerIntegrator() | ||
centroidal_dynamics = blf.continuous_dynamical_system.CentroidalDynamics() | ||
dT = timedelta(milliseconds=100) | ||
assert centroidal_integrator.set_dynamical_system(centroidal_dynamics) | ||
assert centroidal_dynamics.set_state((np.zeros(3),np.zeros(3),np.zeros(3))) | ||
assert centroidal_integrator.set_integration_step(timedelta(milliseconds=100)) | ||
|
||
centroidal_integrator.integrate(timedelta(0),dT) |
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,16 @@ | ||
# Copyright (C) 2023 Istituto Italiano di Tecnologia (IIT). All rights reserved. | ||
# This software may be modified and distributed under the terms of the | ||
# BSD-3-Clause license. | ||
|
||
if(FRAMEWORK_COMPILE_ReducedModelControllers) | ||
|
||
set(H_PREFIX include/BipedalLocomotion/bindings/ReducedModelControllers) | ||
|
||
add_bipedal_locomotion_python_module( | ||
NAME ReducedModelControllersBindings | ||
SOURCES src/CentroidalMPC.cpp src/Module.cpp | ||
HEADERS ${H_PREFIX}/CentroidalMPC.h ${H_PREFIX}/Module.h | ||
LINK_LIBRARIES BipedalLocomotion::ReducedModelControllers | ||
TESTS tests/test_centroidal_mpc.py) | ||
|
||
endif() |
26 changes: 26 additions & 0 deletions
26
...delControllers/include/BipedalLocomotion/bindings/ReducedModelControllers/CentroidalMPC.h
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,26 @@ | ||
/** | ||
* @file CentroidalMPC.h | ||
* @authors Carlotta Sartore | ||
* @copyright 2023 Istituto Italiano di Tecnologia (IIT). This software may be modified and | ||
* distributed under the terms of the BSD-3-Clause license. | ||
*/ | ||
|
||
#ifndef BIPEDAL_LOCOMOTION_BINDINGS_REDUCED_MODEL_CONTROLLERS_CENTROIDAL_MPC_H | ||
#define BIPEDAL_LOCOMOTION_BINDINGS_REDUCED_MODEL_CONTROLLERS_CENTROIDAL_MPC_H | ||
|
||
#include <pybind11/pybind11.h> | ||
|
||
namespace BipedalLocomotion | ||
{ | ||
namespace bindings | ||
{ | ||
namespace ReducedModelControllers | ||
{ | ||
|
||
void CreateCentroidalMPC(pybind11::module& module); | ||
|
||
} // namespace ReducedModelControllers | ||
} // namespace bindings | ||
} // namespace BipedalLocomotion | ||
|
||
#endif // BIPEDAL_LOCOMOTION_BINDINGS_REDUCED_MODEL_CONTROLLERS_CENTROIDAL_MPC_H |
26 changes: 26 additions & 0 deletions
26
...ducedModelControllers/include/BipedalLocomotion/bindings/ReducedModelControllers/Module.h
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,26 @@ | ||
/** | ||
* @file Module.h | ||
* @authors Carlotta Sartore | ||
* @copyright 2021 Istituto Italiano di Tecnologia (IIT). This software may be modified and | ||
* distributed under the terms of the BSD-3-Clause license. | ||
*/ | ||
|
||
#ifndef BIPEDAL_LOCOMOTION_BINDINGS_REDUCED_MODEL_CONTROLLERS_MODULE_H | ||
#define BIPEDAL_LOCOMOTION_BINDINGS_REDUCED_MODEL_CONTROLLERS_MODULE_H | ||
|
||
#include <pybind11/pybind11.h> | ||
|
||
namespace BipedalLocomotion | ||
{ | ||
namespace bindings | ||
{ | ||
namespace ReducedModelControllers | ||
{ | ||
|
||
void CreateModule(pybind11::module& module); | ||
|
||
} // namespace Contacts | ||
} // namespace bindings | ||
} // namespace ReducedModelControllers | ||
|
||
#endif // BIPEDAL_LOCOMOTION_BINDINGS_REDUCED_MODEL_CONTROLLERS_MODULE_H |
Oops, something went wrong.