Skip to content

Commit

Permalink
Merge pull request #465 from ami-iit/python/conversions
Browse files Browse the repository at this point in the history
Implement the python bindings for the manif conversions methods
  • Loading branch information
GiulioRomualdi authored Nov 22, 2021
2 parents 8cfbc80 + 2bdfd43 commit 328c2c0
Show file tree
Hide file tree
Showing 8 changed files with 144 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ All notable changes to this project are documented in this file.
- Add the possibility to enable/disable the joints and motors state logging in the `YarpRobotLoggerDevice` (https://github.com/ami-iit/bipedal-locomotion-framework/pull/453)
- Implement `QPInverseKinematics::toString` method and the associated python bindings (https://github.com/ami-iit/bipedal-locomotion-framework/pull/461)
- Add the cartesian wrenches logging in `YarpRobotLoggerDevice` (https://github.com/ami-iit/bipedal-locomotion-framework/pull/447)
- Implement the python bindings for the manif conversions methods (https://github.com/ami-iit/bipedal-locomotion-framework/pull/465)

### Changed
- Inherits all the `Eigen::Matrix` constructors in the `Wrenchd` class (https://github.com/ami-iit/bipedal-locomotion-framework/pull/441)
Expand Down
1 change: 1 addition & 0 deletions bindings/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ add_subdirectory(FloatingBaseEstimators)
add_subdirectory(IK)
add_subdirectory(TSID)
add_subdirectory(TextLogging)
add_subdirectory(Conversions)

include(ConfigureFileWithCMakeIf)

Expand Down
15 changes: 15 additions & 0 deletions bindings/python/Conversions/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright (C) 2021 Istituto Italiano di Tecnologia (IIT). All rights reserved.
# This software may be modified and distributed under the terms of the
# GNU Lesser General Public License v2.1 or any later version.

if(FRAMEWORK_COMPILE_ManifConversions)

set(H_PREFIX include/BipedalLocomotion/bindings/Conversions)

add_bipedal_locomotion_python_module(
NAME ManifConversionsBindings
SOURCES src/ManifConversions.cpp src/Module.cpp
HEADERS ${H_PREFIX}/ManifConversions.h ${H_PREFIX}/Module.h
LINK_LIBRARIES BipedalLocomotion::ManifConversions)

endif()
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
* @file ManifConversions.h
* @authors Giulio Romualdi
* @copyright 2021 Istituto Italiano di Tecnologia (IIT). This software may be modified and
* distributed under the terms of the GNU Lesser General Public License v2.1 or any later version.
*/

#ifndef BIPEDAL_LOCOMOTION_BINDINGS_CONVERSIONS_MANIF_CONVERSIONS_H
#define BIPEDAL_LOCOMOTION_BINDINGS_CONVERSIONS_MANIF_CONVERSIONS_H

#include <pybind11/pybind11.h>

namespace BipedalLocomotion
{
namespace bindings
{
namespace Conversions
{

void CreateManifConversions(pybind11::module& module);

} // namespace Conversions
} // namespace bindings
} // namespace BipedalLocomotion

#endif // BIPEDAL_LOCOMOTION_BINDINGS_CONVERSIONS_MANIF_CONVERSIONS_H
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
* @file Module.h
* @authors Giulio Romualdi
* @copyright 2021 Istituto Italiano di Tecnologia (IIT). This software may be modified and
* distributed under the terms of the GNU Lesser General Public License v2.1 or any later version.
*/

#ifndef BIPEDAL_LOCOMOTION_BINDINGS_CONVERSIONS_MODULE_H
#define BIPEDAL_LOCOMOTION_BINDINGS_CONVERSIONS_MODULE_H

#include <pybind11/pybind11.h>

namespace BipedalLocomotion
{
namespace bindings
{
namespace Conversions
{

void CreateModule(pybind11::module& module);

} // namespace Conversions
} // namespace bindings
} // namespace BipedalLocomotion

#endif // BIPEDAL_LOCOMOTION_BINDINGS_CONVERSIONS_MODULE_H
41 changes: 41 additions & 0 deletions bindings/python/Conversions/src/ManifConversions.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/**
* @file ManifConversions.cpp
* @authors Giulio Romualdi
* @copyright 2021 Istituto Italiano di Tecnologia (IIT). This software may be modified and
* distributed under the terms of the GNU Lesser General Public License v2.1 or any later version.
*/

#include <pybind11/eigen.h>
#include <pybind11/pybind11.h>

#include <Eigen/Dense>

#include <BipedalLocomotion/Conversions/ManifConversions.h>

namespace BipedalLocomotion
{
namespace bindings
{
namespace Conversions
{

void CreateManifConversions(pybind11::module& module)
{
namespace py = ::pybind11;

module
.def("to_manif_pose",
py::overload_cast<const Eigen::Matrix<double, 3, 3>&,
const Eigen::Matrix<double, 3, 1>&>(
&::BipedalLocomotion::Conversions::toManifPose<double>),
py::arg("rotation"),
py::arg("translation"))
.def("to_manif_rot",
py::overload_cast<const Eigen::Matrix<double, 3, 3>&>(
&::BipedalLocomotion::Conversions::toManifRot<double>),
py::arg("rotation"));
}

} // namespace Conversions
} // namespace bindings
} // namespace BipedalLocomotion
26 changes: 26 additions & 0 deletions bindings/python/Conversions/src/Module.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
* @file Module.cpp
* @authors Giulio Romualdi
* @copyright 2021 Istituto Italiano di Tecnologia (IIT). This software may be modified and
* distributed under the terms of the GNU Lesser General Public License v2.1 or any later version.
*/

#include <pybind11/pybind11.h>

#include <BipedalLocomotion/bindings/Conversions/ManifConversions.h>

namespace BipedalLocomotion
{
namespace bindings
{
namespace Conversions
{
void CreateModule(pybind11::module& module)
{
module.doc() = "Conversions module.";

CreateManifConversions(module);
}
} // namespace Conversions
} // namespace bindings
} // namespace BipedalLocomotion
8 changes: 8 additions & 0 deletions bindings/python/bipedal_locomotion_framework.cpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@
#include <BipedalLocomotion/bindings/TSID/Module.h>
@endcmakeif FRAMEWORK_COMPILE_TSID

@cmakeif FRAMEWORK_COMPILE_ManifConversions
#include <BipedalLocomotion/bindings/Conversions/Module.h>
@endcmakeif FRAMEWORK_COMPILE_ManifConversions

// Create the Python module
PYBIND11_MODULE(bindings, m)
Expand Down Expand Up @@ -112,4 +115,9 @@ PYBIND11_MODULE(bindings, m)
py::module tsidModule = m.def_submodule("tsid");
bindings::TSID::CreateModule(tsidModule);
@endcmakeif FRAMEWORK_COMPILE_TSID

@cmakeif FRAMEWORK_COMPILE_ManifConversions
py::module conversionsModule = m.def_submodule("conversions");
bindings::Conversions::CreateModule(conversionsModule);
@endcmakeif FRAMEWORK_COMPILE_ManifConversions
}

0 comments on commit 328c2c0

Please sign in to comment.