diff --git a/CMakeLists.txt b/CMakeLists.txt index c16a48728b629ee0a9a9ed1f059b2d515cc4d919..cc144480fb6f115dce7e086e80d078fe16f1edbc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -84,6 +84,7 @@ SET(HEADERS python/model.hpp python/data.hpp python/algorithms.hpp + python/parsers.hpp ) MAKE_DIRECTORY("${${PROJECT_NAME}_BINARY_DIR}/include/pinocchio") @@ -117,6 +118,7 @@ MAKE_DIRECTORY("${${PROJECT_NAME}_BINARY_DIR}/lib/python/${PROJECT_NAME}") SET(PYWRAP ${PROJECT_NAME}_pywrap) ADD_LIBRARY(${PYWRAP} SHARED src/python/module.cpp src/python/python.cpp) PKG_CONFIG_USE_DEPENDENCY(${PYWRAP} eigenpy) +PKG_CONFIG_USE_DEPENDENCY(${PYWRAP} urdfdom) TARGET_LINK_LIBRARIES(${PYWRAP} ${Boost_LIBRARIES} eigenpy) SET_TARGET_PROPERTIES(${PYWRAP} PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib/python/${PROJECT_NAME}") @@ -128,6 +130,7 @@ INSTALL(FILES SET(PYTHON_FILES python/__init__.py python/utils.py + python/robot_wrapper.py ) FOREACH(python ${PYTHON_FILES}) GET_FILENAME_COMPONENT(pythonFile ${python} NAME) diff --git a/src/python/module.cpp b/src/python/module.cpp index 690ba9c0f57c6b799913fd5df66887d6b89c9b48..677e2390bd1187d40aff9ddbdc641ee3df816070 100644 --- a/src/python/module.cpp +++ b/src/python/module.cpp @@ -25,5 +25,6 @@ BOOST_PYTHON_MODULE(libpinocchio_pywrap) se3::python::exposeModel(); se3::python::exposeAlgorithms(); + se3::python::exposeParsers(); } diff --git a/src/python/parsers.hpp b/src/python/parsers.hpp new file mode 100644 index 0000000000000000000000000000000000000000..e1755beece08e6aeb54672c17fbf1fa84721d7b7 --- /dev/null +++ b/src/python/parsers.hpp @@ -0,0 +1,41 @@ +#ifndef __se3_python_parsers_hpp__ +#define __se3_python_parsers_hpp__ + +#include <eigenpy/exception.hpp> +#include <eigenpy/eigenpy.hpp> + +#include "pinocchio/python/model.hpp" +#include "pinocchio/python/data.hpp" + +#include "pinocchio/multibody/parser/urdf.hpp" + +namespace se3 +{ + namespace python + { + struct ParsersPythonVisitor + { + static ModelHandler buildModelFromUrdf( const std::string & filename, + bool ff ) + { + Model * model = new Model(); + *model = se3::urdf::buildModel(filename,ff); + return ModelHandler(model,true); + } + + /* --- Expose --------------------------------------------------------- */ + static void expose() + { + bp::def("buildModelFromUrdf",buildModelFromUrdf, + bp::args("Filename (string)", + "Free flyer (bool, false for a fixed robot)"), + "Parse the urdf file given in input and return a proper pinocchio model " + "(remember to create the corresponding data structure)."); + } + + }; + + }} // namespace se3::python + +#endif // ifndef __se3_python_data_hpp__ + diff --git a/src/python/python.cpp b/src/python/python.cpp index 8554689a5717a53802026813a7eb2802856ca36f..8ad5ee078f0da3f0873a20c9cb22523d8c7f638a 100644 --- a/src/python/python.cpp +++ b/src/python/python.cpp @@ -7,6 +7,7 @@ #include "pinocchio/python/model.hpp" #include "pinocchio/python/data.hpp" #include "pinocchio/python/algorithms.hpp" +#include "pinocchio/python/parsers.hpp" namespace se3 { @@ -41,4 +42,8 @@ namespace se3 { AlgorithmsPythonVisitor::expose(); } + void exposeParsers() + { + ParsersPythonVisitor::expose(); + } }} // namespace se3::python diff --git a/src/python/python.hpp b/src/python/python.hpp index f79d68dce48f30a37e011aa892d5c4d7b8fd3aaf..c9952eca9a7434b729e72cfce0fb351f55eb579d 100644 --- a/src/python/python.hpp +++ b/src/python/python.hpp @@ -12,6 +12,7 @@ namespace se3 void exposeModel(); void exposeAlgorithms(); + void exposeParsers(); }} // namespace se3::python