Skip to content
Snippets Groups Projects
Commit e69d61e6 authored by Nicolas Mansard's avatar Nicolas Mansard Committed by Valenza Florian
Browse files

Python: Added urdf parser.

parent c81cc2dc
No related branches found
No related tags found
No related merge requests found
...@@ -84,6 +84,7 @@ SET(HEADERS ...@@ -84,6 +84,7 @@ SET(HEADERS
python/model.hpp python/model.hpp
python/data.hpp python/data.hpp
python/algorithms.hpp python/algorithms.hpp
python/parsers.hpp
) )
MAKE_DIRECTORY("${${PROJECT_NAME}_BINARY_DIR}/include/pinocchio") MAKE_DIRECTORY("${${PROJECT_NAME}_BINARY_DIR}/include/pinocchio")
...@@ -117,6 +118,7 @@ MAKE_DIRECTORY("${${PROJECT_NAME}_BINARY_DIR}/lib/python/${PROJECT_NAME}") ...@@ -117,6 +118,7 @@ MAKE_DIRECTORY("${${PROJECT_NAME}_BINARY_DIR}/lib/python/${PROJECT_NAME}")
SET(PYWRAP ${PROJECT_NAME}_pywrap) SET(PYWRAP ${PROJECT_NAME}_pywrap)
ADD_LIBRARY(${PYWRAP} SHARED src/python/module.cpp src/python/python.cpp) ADD_LIBRARY(${PYWRAP} SHARED src/python/module.cpp src/python/python.cpp)
PKG_CONFIG_USE_DEPENDENCY(${PYWRAP} eigenpy) PKG_CONFIG_USE_DEPENDENCY(${PYWRAP} eigenpy)
PKG_CONFIG_USE_DEPENDENCY(${PYWRAP} urdfdom)
TARGET_LINK_LIBRARIES(${PYWRAP} ${Boost_LIBRARIES} eigenpy) TARGET_LINK_LIBRARIES(${PYWRAP} ${Boost_LIBRARIES} eigenpy)
SET_TARGET_PROPERTIES(${PYWRAP} PROPERTIES SET_TARGET_PROPERTIES(${PYWRAP} PROPERTIES
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib/python/${PROJECT_NAME}") LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib/python/${PROJECT_NAME}")
...@@ -128,6 +130,7 @@ INSTALL(FILES ...@@ -128,6 +130,7 @@ INSTALL(FILES
SET(PYTHON_FILES SET(PYTHON_FILES
python/__init__.py python/__init__.py
python/utils.py python/utils.py
python/robot_wrapper.py
) )
FOREACH(python ${PYTHON_FILES}) FOREACH(python ${PYTHON_FILES})
GET_FILENAME_COMPONENT(pythonFile ${python} NAME) GET_FILENAME_COMPONENT(pythonFile ${python} NAME)
......
...@@ -25,5 +25,6 @@ BOOST_PYTHON_MODULE(libpinocchio_pywrap) ...@@ -25,5 +25,6 @@ BOOST_PYTHON_MODULE(libpinocchio_pywrap)
se3::python::exposeModel(); se3::python::exposeModel();
se3::python::exposeAlgorithms(); se3::python::exposeAlgorithms();
se3::python::exposeParsers();
} }
#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__
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "pinocchio/python/model.hpp" #include "pinocchio/python/model.hpp"
#include "pinocchio/python/data.hpp" #include "pinocchio/python/data.hpp"
#include "pinocchio/python/algorithms.hpp" #include "pinocchio/python/algorithms.hpp"
#include "pinocchio/python/parsers.hpp"
namespace se3 namespace se3
{ {
...@@ -41,4 +42,8 @@ namespace se3 ...@@ -41,4 +42,8 @@ namespace se3
{ {
AlgorithmsPythonVisitor::expose(); AlgorithmsPythonVisitor::expose();
} }
void exposeParsers()
{
ParsersPythonVisitor::expose();
}
}} // namespace se3::python }} // namespace se3::python
...@@ -12,6 +12,7 @@ namespace se3 ...@@ -12,6 +12,7 @@ namespace se3
void exposeModel(); void exposeModel();
void exposeAlgorithms(); void exposeAlgorithms();
void exposeParsers();
}} // namespace se3::python }} // namespace se3::python
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment