Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • ostasse/dynamic-graph-python
  • gsaurel/dynamic-graph-python
  • stack-of-tasks/dynamic-graph-python
3 results
Show changes
Commits on Source (141)
Showing
with 354 additions and 447 deletions
# pre-commit run -a (Guilhem Saurel, 2022-07-27)
db4d991c9d727b8454695ce8d88948b948c6b36f
[submodule "cmake"]
path = cmake
url = git://github.com/jrl-umi3218/jrl-cmakemodules.git
[submodule ".travis"]
path = .travis
url = git://github.com/jrl-umi3218/jrl-travis
url = https://github.com/jrl-umi3218/jrl-cmakemodules.git
exclude: tests/test_python-syntax_error.py
ci:
autoupdate_branch: 'devel'
repos:
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v14.0.6
hooks:
- id: clang-format
args: [--style=Google]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
- id: check-added-large-files
- id: check-ast
- id: check-executables-have-shebangs
- id: check-json
- id: check-merge-conflict
- id: check-symlinks
- id: check-toml
- id: check-yaml
- id: debug-statements
- id: destroyed-symlinks
- id: detect-private-key
- id: end-of-file-fixer
- id: fix-byte-order-marker
- id: mixed-line-ending
- id: trailing-whitespace
- repo: https://github.com/psf/black
rev: 22.8.0
hooks:
- id: black
- repo: https://github.com/PyCQA/flake8
rev: 5.0.4
hooks:
- id: flake8
- repo: https://github.com/cheshirekow/cmake-format-precommit
rev: v0.6.13
hooks:
- id: cmake-format
Subproject commit cbc92f81bdd0dcfd7fc1eae56801d8111267937d
language: cpp
sudo: required
compiler:
- gcc
- clang
env:
global:
- secure: "ECiHIh0aT5ml/MdKifvFIM2UpDWiPsJPEZpafLYM8U0VAPYThSfUe8JWhMsky8amOwm38akbSbr6C7iBKVpzjAqpgNdOdufO1RUZ6pUvtlVXiXTw2KlqPqbDVlD3QroVDhnX/rIRcg5ezEHAIb594uEaHdf8tlikhjdTc3aAgMA="
- APT_DEPENDENCIES="doxygen doxygen-latex libboost-all-dev libeigen3-dev liblapack-dev libblas-dev gfortran python-dev python-sphinx"
- GIT_DEPENDENCIES="stack-of-tasks/dynamic-graph"
- LCOV_IGNORE_RULES="*unitTesting*"
allow_failures:
- compiler: clang
notifications:
email:
- hpp-source@laas.fr
branches:
only:
- master
- devel
script: ./.travis/run build
script: ./travis_custom/build_custom
after_success: ./.travis/run after_success
after_failure: ./.travis/run after_failure
before_install: ./travis_custom/custom_before_install
matrix:
allow_failures:
- compiler: clang
unitTesting/test_python-syntax_error.py
tests/test_python-syntax_error.py
# Copyright 2010-2020, Florent Lamiraux, Thomas Moulard, Olivier Stasse, Guilhem Saurel, JRL, CNRS/AIST, LAAS-CNRS
# Copyright 2010-2020, Florent Lamiraux, Thomas Moulard, Olivier Stasse, Guilhem
# Saurel, JRL, CNRS/AIST, LAAS-CNRS
CMAKE_MINIMUM_REQUIRED(VERSION 3.1)
cmake_minimum_required(VERSION 3.1)
# Project properties
SET(PROJECT_ORG stack-of-tasks)
SET(PROJECT_NAME dynamic-graph-python)
SET(PROJECT_DESCRIPTION "Dynamic graph library Python bindings")
SET(PROJECT_URL "https://github.com/${PROJECT_ORG}/${PROJECT_NAME}")
set(PROJECT_ORG stack-of-tasks)
set(PROJECT_NAME dynamic-graph-python)
set(PROJECT_DESCRIPTION "Dynamic graph library Python bindings")
set(PROJECT_URL "https://github.com/${PROJECT_ORG}/${PROJECT_NAME}")
# Project options
OPTION(SUFFIX_SO_VERSION "Suffix library name with its version" ON)
option(SUFFIX_SO_VERSION "Suffix library name with its version" ON)
# Project configuration
SET(PROJECT_USE_CMAKE_EXPORT TRUE)
SET(CUSTOM_HEADER_DIR "dynamic-graph/python")
SET(CXX_DISABLE_WERROR TRUE)
SET(DOXYGEN_USE_MATHJAX YES)
set(PROJECT_USE_CMAKE_EXPORT TRUE)
set(CUSTOM_HEADER_DIR "dynamic-graph/python")
set(CXX_DISABLE_WERROR TRUE)
set(DOXYGEN_USE_MATHJAX YES)
# JRL-cmakemodule setup
INCLUDE(cmake/base.cmake)
INCLUDE(cmake/boost.cmake)
INCLUDE(cmake/python.cmake)
include(cmake/base.cmake)
include(cmake/boost.cmake)
# Project definition
COMPUTE_PROJECT_ARGS(PROJECT_ARGS LANGUAGES CXX)
PROJECT(${PROJECT_NAME} ${PROJECT_ARGS})
compute_project_args(PROJECT_ARGS LANGUAGES CXX)
project(${PROJECT_NAME} ${PROJECT_ARGS})
check_minimal_cxx_standard(14 ENFORCE)
# Project dependencies
FINDPYTHON()
ADD_PROJECT_DEPENDENCY(dynamic-graph REQUIRED PKG_CONFIG_REQUIRES dynamic-graph)
SET(BOOST_COMPONENTS filesystem system thread program_options unit_test_framework python)
SEARCH_FOR_BOOST()
set(PYTHON_COMPONENTS Interpreter Development NumPy)
add_project_dependency(dynamic-graph 4.4.0 REQUIRED)
add_project_dependency(eigenpy 2.7.10 REQUIRED)
set(PYTHON_EXPORT_DEPENDENCY_MACROS
"list(APPEND PYTHON_COMPONENTS ${PYTHON_COMPONENTS})\n${PYTHON_EXPORT_DEPENDENCY_MACROS}"
)
if(BUILD_TESTING)
find_package(Boost REQUIRED COMPONENTS unit_test_framework)
endif(BUILD_TESTING)
if(Boost_VERSION GREATER 107299 OR Boost_VERSION_MACRO GREATER 107299)
# Silence a warning about a deprecated use of boost bind by boost >= 1.73
# without dropping support for boost < 1.73
add_definitions(-DBOOST_BIND_GLOBAL_PLACEHOLDERS)
endif()
# Main Library
SET(${PROJECT_NAME}_HEADERS
include/${CUSTOM_HEADER_DIR}/api.hh
include/${CUSTOM_HEADER_DIR}/convert-dg-to-py.hh
include/${CUSTOM_HEADER_DIR}/dynamic-graph-py.hh
include/${CUSTOM_HEADER_DIR}/exception.hh
include/${CUSTOM_HEADER_DIR}/exception-python.hh
include/${CUSTOM_HEADER_DIR}/interpreter.hh
include/${CUSTOM_HEADER_DIR}/python-compat.hh
include/${CUSTOM_HEADER_DIR}/signal-wrapper.hh
)
SET(${PROJECT_NAME}_SOURCES
src/interpreter.cc
src/dynamic_graph/python-compat.cc
)
ADD_LIBRARY(${PROJECT_NAME} SHARED
${${PROJECT_NAME}_SOURCES} ${${PROJECT_NAME}_HEADERS})
TARGET_INCLUDE_DIRECTORIES(${PROJECT_NAME} SYSTEM PUBLIC ${PYTHON_INCLUDE_DIRS})
TARGET_INCLUDE_DIRECTORIES(${PROJECT_NAME} PUBLIC $<INSTALL_INTERFACE:include>)
TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${Boost_LIBRARIES}
${PYTHON_LIBRARY} ${Boost_PYTHON_LIBRARIES} dynamic-graph::dynamic-graph)
IF(SUFFIX_SO_VERSION)
SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES SOVERSION ${PROJECT_VERSION})
ENDIF(SUFFIX_SO_VERSION)
TARGET_COMPILE_DEFINITIONS(${PROJECT_NAME} PRIVATE PYTHON_LIBRARY="${PYTHON_LIBRARY}")
INSTALL(TARGETS ${PROJECT_NAME} EXPORT ${TARGETS_EXPORT_NAME} DESTINATION lib)
ADD_SUBDIRECTORY(src)
ADD_SUBDIRECTORY(tests)
PKG_CONFIG_APPEND_LIBS(${PROJECT_NAME})
INSTALL(FILES package.xml DESTINATION share/${PROJECT_NAME})
set(${PROJECT_NAME}_HEADERS
include/${CUSTOM_HEADER_DIR}/api.hh
include/${CUSTOM_HEADER_DIR}/convert-dg-to-py.hh
include/${CUSTOM_HEADER_DIR}/dynamic-graph-py.hh
include/${CUSTOM_HEADER_DIR}/fwd.hh
include/${CUSTOM_HEADER_DIR}/interpreter.hh
include/${CUSTOM_HEADER_DIR}/module.hh
include/${CUSTOM_HEADER_DIR}/python-compat.hh
include/${CUSTOM_HEADER_DIR}/signal.hh
include/${CUSTOM_HEADER_DIR}/signal-wrapper.hh)
set(${PROJECT_NAME}_SOURCES
src/interpreter.cc src/dynamic_graph/python-compat.cc
src/dynamic_graph/entity-py.cc src/dynamic_graph/convert-dg-to-py.cc)
add_library(${PROJECT_NAME} SHARED ${${PROJECT_NAME}_SOURCES}
${${PROJECT_NAME}_HEADERS})
target_include_directories(${PROJECT_NAME} PUBLIC $<INSTALL_INTERFACE:include>)
target_link_libraries(${PROJECT_NAME} PUBLIC dynamic-graph::dynamic-graph)
modernize_target_link_libraries(
${PROJECT_NAME}
SCOPE
PUBLIC
TARGETS
Python${PYTHON_VERSION_MAJOR}::Python
LIBRARIES
${PYTHON_LIBRARIES}
INCLUDE_DIRS
${PYTHON_INCLUDE_DIRS})
target_link_boost_python(${PROJECT_NAME} PUBLIC)
if(SUFFIX_SO_VERSION)
set_target_properties(${PROJECT_NAME} PROPERTIES SOVERSION ${PROJECT_VERSION})
endif(SUFFIX_SO_VERSION)
target_compile_definitions(${PROJECT_NAME}
PRIVATE PYTHON_LIBRARY="${PYTHON_LIBRARY}")
install(
TARGETS ${PROJECT_NAME}
EXPORT ${TARGETS_EXPORT_NAME}
DESTINATION lib)
add_subdirectory(src)
if(BUILD_TESTING)
add_subdirectory(tests)
endif(BUILD_TESTING)
install(FILES package.xml DESTINATION share/${PROJECT_NAME})
dynamic-graph-python
====================
# dynamic-graph-python
[![Building Status](https://travis-ci.org/stack-of-tasks/dynamic-graph-python.svg?branch=master)](https://travis-ci.org/stack-of-tasks/dynamic-graph-python)
[![Pipeline status](https://gitlab.laas.fr/stack-of-tasks/dynamic-graph-python/badges/master/pipeline.svg)](https://gitlab.laas.fr/stack-of-tasks/dynamic-graph-python/commits/master)
[![Coverage report](https://gitlab.laas.fr/stack-of-tasks/dynamic-graph-python/badges/master/coverage.svg?job=doc-coverage)](http://projects.laas.fr/stack-of-tasks/doc/stack-of-tasks/dynamic-graph-python/master/coverage/)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/stack-of-tasks/dynamic-graph-python/master.svg)](https://results.pre-commit.ci/latest/github/stack-of-tasks/dynamic-graph-python)
Python bindings for dynamic-graph.
......@@ -14,52 +15,19 @@ submodules][git-submodules]. Please clone this repository using the
repository, you can run `git submodule init && git submodule update`
to retrieve the submodules.
## Documentation
Documentation
-------------
[Online](https://gepettoweb.laas.fr/doc/stack-of-tasks/dynamic-graph-python/master/doxygen-html/)
To get started with this library, please read the [online Doxygen
documentation][doxygen-documentation].
It can also be generated locally by running the `make doc`
command. After the package is installed, the documentation will be
located in the `$prefix/share/doc/dynamic-graph` directoy where
`$prefix` is your installation prefix (`/usr/local` by default).
Getting Help
------------
## Getting Help
Support is provided through:
* the HPP mailing-list: hpp@laas.fr
* the following HipChat room: http://www.hipchat.com/gh4wQrZeV
How can I install dynamic-graph?
--------------------------------
### Installing dependencies
The matrix abstract layer depends on several packages which
have to be available on your machine.
- Libraries:
- [Boost][] (>= 1.40)
Its detection is controled by the `BOOST_ROOT` variable, see next section
for more information.
- [Lapack][] library
Use the generic purpose `CMAKE_CXX_FLAGS` and `CMAKE_EXE_LINKER_FLAGS`
to insert the flags required for the compiler to find your Lapack library
if it is installed in a non-standard directory.
- [jrl-mal][] library
- [dynamic-graph][] library
- System tools:
- [CMake][] (>=2.6)
- [pkg-config][]
- usual compilation tools (GCC/G++, make, etc.)
If you are using Ubuntu, these tools are gathered in the `build-essential` package.
* the [issue tracker](https://github.com/stack-of-tasks/dynamic-graph-python/issues)
* the matrix room [#stack-of-tasks:laas.fr](https://matrix.to/#/#stack-of-tasks:laas.fr)
## How can I install dynamic-graph?
### Compiling and installing the package
......@@ -68,24 +36,21 @@ The manual compilation requires two steps:
1. configuration of the build and generation of the build files
2. compilation of the sources and installation of the package
dynamic-graph uses [CMake][] to generate build files. It is
dynamic-graph uses CMake to generate build files. It is
recommended to create a separate build directory:
```sh
mkdir _build # (1) Create a build directory
cd _build # (2) Go to the newly created build directory
cmake [options] .. # (3) Generate the build files
mkdir build
cd build
cmake ..
```
Options which can be passed to CMake are detailed in the next section.
```sh
make # (4) Compile the package
make test # (5) Execute the package tests
make install # (6) Install the package into the prefix (see step 3)
make
make test
make install
```
### Options
Additional options can be set on the command line through the
......@@ -109,13 +74,8 @@ Available options are:
The test suite can be run from your build directory by running:
```sh
make test
make test
```
Please open a ticket if some tests are failing on your computer, it
should not be the case.
Credits
-------
This package authors are credited in the [AUTHORS](AUTHORS) file.
Subproject commit fb4c22c319ec5320f9a85527eb1a4130954846f5
Subproject commit 08c2c18b9033c2f0a86b885b589f4fa63a163caf
......@@ -8,4 +8,3 @@
</center>
</body>
</head>
......@@ -4,4 +4,3 @@
<LINK HREF="package.css" REL="stylesheet" TYPE="text/css">
</HEAD>
<BODY>
......@@ -45,8 +45,8 @@ a:link {
color:#0066CC
}
a:hover, a:active {
text-decoration: underline;
a:hover, a:active {
text-decoration: underline;
color: #3C9A35;
}
......@@ -57,7 +57,7 @@ a:visited {
}
DIV.memitem
{
{
spacing: 10px;
width:100%;
background:#FFFFFF;
......@@ -70,7 +70,7 @@ DIV.memitem
}
DIV.memproto
{
{
width:100%;
background:#F0F0F0;
font-size:100%;
......@@ -82,7 +82,7 @@ DIV.memproto
}
DIV.memdoc
{
{
padding: 10px;
width:100%;
font-size:100%;
......@@ -189,7 +189,7 @@ DIV.nav
}
DIV.groupHeader
{
{
padding-top: 30px;
padding-bottom: 20px;
background : none;
......@@ -201,23 +201,23 @@ DIV.groupHeader
color:#0066CC;
}
.directory p
{
margin: 0px;
white-space: nowrap;
.directory p
{
margin: 0px;
white-space: nowrap;
font-family: 'Lucida Grande','Lucida Sans Unicode',Verdana,Sans-Serif;
font-size: 10pt;
font-weight: normal;
}
.directory h3
{
.directory h3
{
font-family: 'Lucida Grande','Lucida Sans Unicode',Verdana,Sans-Serif;
margin: 0px;
margin-top: 1em;
margin: 0px;
margin-top: 1em;
padding-bottom: 20px;
font-size: 12pt;
font-size: 12pt;
font-variant: small-caps;
text-align: center;
}
......@@ -227,4 +227,3 @@ DIV.groupHeader
text-decoration: none;
color:#0066CC
}
......@@ -23,8 +23,8 @@ ABBREVIATE_BRIEF = "The $name class" \
ALWAYS_DETAILED_SEC = YES
INLINE_INHERITED_MEMB = NO
FULL_PATH_NAMES = NO
STRIP_FROM_PATH =
STRIP_FROM_INC_PATH =
STRIP_FROM_PATH =
STRIP_FROM_INC_PATH =
SHORT_NAMES = NO
JAVADOC_AUTOBRIEF = YES
MULTILINE_CPP_IS_BRIEF = NO
......@@ -50,7 +50,7 @@ SORT_MEMBER_DOCS = YES
SORT_BRIEF_DOCS = NO
SORT_BY_SCOPE_NAME = NO
MAX_INITIALIZER_LINES = 30
FILE_VERSION_FILTER =
FILE_VERSION_FILTER =
#---------------------------------------------------------------------------
# configuration options related to warning and progress messages
#---------------------------------------------------------------------------
......@@ -60,18 +60,18 @@ WARN_IF_UNDOCUMENTED = YES
WARN_IF_DOC_ERROR = YES
WARN_NO_PARAMDOC = NO
WARN_FORMAT = "$file:$line: $text"
WARN_LOGFILE =
WARN_LOGFILE =
#---------------------------------------------------------------------------
# configuration options related to the input files
#---------------------------------------------------------------------------
RECURSIVE = YES
EXCLUDE =
EXCLUDE =
EXCLUDE_SYMLINKS = NO
EXAMPLE_PATH =
EXAMPLE_PATH =
EXAMPLE_PATTERNS = *
EXAMPLE_RECURSIVE = NO
INPUT_FILTER =
FILTER_PATTERNS =
INPUT_FILTER =
FILTER_PATTERNS =
FILTER_SOURCE_FILES = NO
#---------------------------------------------------------------------------
# configuration options related to source browsing
......@@ -81,7 +81,7 @@ FILTER_SOURCE_FILES = NO
#---------------------------------------------------------------------------
ALPHABETICAL_INDEX = NO
COLS_IN_ALPHA_INDEX = 5
IGNORE_PREFIX =
IGNORE_PREFIX =
#---------------------------------------------------------------------------
# configuration options related to the HTML output
#---------------------------------------------------------------------------
......@@ -89,8 +89,8 @@ GENERATE_HTML = YES
HTML_FILE_EXTENSION = .html
HTML_ALIGN_MEMBERS = YES
GENERATE_HTMLHELP = NO
CHM_FILE =
HHC_LOCATION =
CHM_FILE =
HHC_LOCATION =
GENERATE_CHI = NO
BINARY_TOC = NO
TOC_EXPAND = YES
......@@ -106,8 +106,8 @@ LATEX_CMD_NAME = latex
MAKEINDEX_CMD_NAME = makeindex
COMPACT_LATEX = NO
PAPER_TYPE = a4wide
EXTRA_PACKAGES =
LATEX_HEADER =
EXTRA_PACKAGES =
LATEX_HEADER =
PDF_HYPERLINKS = NO
USE_PDFLATEX = NO
LATEX_BATCHMODE = NO
......@@ -118,8 +118,8 @@ LATEX_HIDE_INDICES = NO
RTF_OUTPUT = rtf
COMPACT_RTF = NO
RTF_HYPERLINKS = NO
RTF_STYLESHEET_FILE =
RTF_EXTENSIONS_FILE =
RTF_STYLESHEET_FILE =
RTF_EXTENSIONS_FILE =
#---------------------------------------------------------------------------
# configuration options related to the man page output
#---------------------------------------------------------------------------
......@@ -130,8 +130,8 @@ MAN_LINKS = NO
# configuration options related to the XML output
#---------------------------------------------------------------------------
XML_OUTPUT = xml
XML_SCHEMA =
XML_DTD =
XML_SCHEMA =
XML_DTD =
XML_PROGRAMLISTING = YES
#---------------------------------------------------------------------------
# configuration options for the AutoGen Definitions output
......@@ -142,20 +142,20 @@ GENERATE_AUTOGEN_DEF = NO
#---------------------------------------------------------------------------
PERLMOD_LATEX = NO
PERLMOD_PRETTY = YES
PERLMOD_MAKEVAR_PREFIX =
PERLMOD_MAKEVAR_PREFIX =
#---------------------------------------------------------------------------
# Configuration options related to the preprocessor
# Configuration options related to the preprocessor
#---------------------------------------------------------------------------
ENABLE_PREPROCESSING = YES
MACRO_EXPANSION = YES
EXPAND_ONLY_PREDEF = YES
SEARCH_INCLUDES = YES
INCLUDE_PATH =
INCLUDE_FILE_PATTERNS =
EXPAND_AS_DEFINED =
INCLUDE_PATH =
INCLUDE_FILE_PATTERNS =
EXPAND_AS_DEFINED =
SKIP_FUNCTION_MACROS = YES
#---------------------------------------------------------------------------
# Configuration::additions related to external references
# Configuration::additions related to external references
#---------------------------------------------------------------------------
TAGFILES = \
${DYNAMIC_GRAPH_DOCDIR}/html/dynamic-graph.doxytag=${DYNAMIC_GRAPH_DOCDIR}/html
......@@ -164,10 +164,10 @@ ALLEXTERNALS = NO
EXTERNAL_GROUPS = YES
PERL_PATH = /usr/bin/perl
#---------------------------------------------------------------------------
# Configuration options related to the dot tool
# Configuration options related to the dot tool
#---------------------------------------------------------------------------
#---------------------------------------------------------------------------
# Configuration::additions related to the search engine
# Configuration::additions related to the search engine
#---------------------------------------------------------------------------
SEARCHENGINE = NO
......@@ -196,7 +196,7 @@ GENERATE_TODOLIST = YES
GENERATE_TESTLIST = NO
GENERATE_BUGLIST = NO
GENERATE_DEPRECATEDLIST= YES
ENABLED_SECTIONS =
ENABLED_SECTIONS =
SHOW_USED_FILES = NO
SHOW_DIRECTORIES = NO
#---------------------------------------------------------------------------
......@@ -206,7 +206,7 @@ SHOW_DIRECTORIES = NO
# configuration options related to the input files
#---------------------------------------------------------------------------
FILE_PATTERNS = *.hh *.idl
EXCLUDE_PATTERNS =
EXCLUDE_PATTERNS =
INPUT = ${${PROJECT_NAME}_SOURCE_DIR}/include \
${CMAKE_CURRENT_SOURCE_DIR}/additionalDoc
......@@ -260,13 +260,13 @@ GENERATE_AUTOGEN_DEF = NO
#---------------------------------------------------------------------------
GENERATE_PERLMOD = NO
#---------------------------------------------------------------------------
# Configuration options related to the preprocessor
# Configuration options related to the preprocessor
#---------------------------------------------------------------------------
#---------------------------------------------------------------------------
# Configuration::additions related to external references
# Configuration::additions related to external references
#---------------------------------------------------------------------------
#---------------------------------------------------------------------------
# Configuration options related to the dot tool
# Configuration options related to the dot tool
#---------------------------------------------------------------------------
CLASS_DIAGRAMS = YES
HIDE_UNDOC_RELATIONS = YES
......@@ -282,8 +282,8 @@ CALL_GRAPH = NO
GRAPHICAL_HIERARCHY = YES
DIRECTORY_GRAPH = YES
DOT_IMAGE_FORMAT = png
DOT_PATH =
DOTFILE_DIRS =
DOT_PATH =
DOTFILE_DIRS =
MAX_DOT_GRAPH_DEPTH = 1000
DOT_TRANSPARENT = NO
DOT_MULTI_TARGETS = YES
......
......@@ -2,17 +2,16 @@
#include <dynamic-graph/linear-algebra.h>
#include <dynamic-graph/value.h>
#include <dynamic-graph/python/exception-python.hh>
#include <boost/python.hpp>
namespace dynamicgraph {
namespace python {
namespace convert {
command::Value pythonToValue(PyObject* pyObject, const command::Value::Type& valueType);
PyObject* vectorToPython(const Vector& vector);
PyObject* matrixToPython(const ::dynamicgraph::Matrix& matrix);
PyObject* matrix4dToPython(const Eigen::Matrix4d& matrix);
PyObject* valueToPython(const ::dynamicgraph::command::Value& value);
command::Value toValue(boost::python::object o,
const command::Value::Type& type);
boost::python::object fromValue(const command::Value& value);
} // namespace convert
} // namespace python
......
#ifndef DYNAMIC_GRAPH_PY
#define DYNAMIC_GRAPH_PY
#include <iostream>
#include <sstream>
#include <dynamic-graph/debug.h>
#include <dynamic-graph/exception-factory.h>
#include <dynamic-graph/signal-base.h>
#include <boost/python.hpp>
#include <boost/python/stl_iterator.hpp>
#include <iostream>
#include <sstream>
#include "dynamic-graph/python/signal-wrapper.hh"
namespace bp = boost::python;
namespace dynamicgraph {
namespace python {
template <typename Iterator>
inline bp::list to_py_list(Iterator begin, Iterator end) {
typedef typename Iterator::value_type T;
bp::list lst;
std::for_each(begin, end, [&](const T& t) { lst.append(t); });
return lst;
}
template <typename Iterator>
inline bp::tuple to_py_tuple(Iterator begin, Iterator end) {
return bp::tuple(to_py_list(begin, end));
}
template <typename T>
inline std::vector<T> to_std_vector(const bp::object& iterable) {
return std::vector<T>(bp::stl_input_iterator<T>(iterable),
bp::stl_input_iterator<T>());
}
void exposeSignals();
// Declare functions defined in other source files
namespace signalBase {
PyObject* create(PyObject* self, PyObject* args);
PyObject* createSignalWrapper(PyObject* self, PyObject* args);
PyObject* getTime(PyObject* self, PyObject* args);
PyObject* setTime(PyObject* self, PyObject* args);
PyObject* getName(PyObject* self, PyObject* args);
PyObject* getClassName(PyObject* self, PyObject* args);
PyObject* display(PyObject* self, PyObject* args);
PyObject* displayDependencies(PyObject* self, PyObject* args);
PyObject* getValue(PyObject* self, PyObject* args);
PyObject* setValue(PyObject* self, PyObject* args);
PyObject* recompute(PyObject* self, PyObject* args);
PyObject* unplug(PyObject* self, PyObject* args);
PyObject* isPlugged(PyObject* self, PyObject* args);
PyObject* getPlugged(PyObject* self, PyObject* args);
SignalBase<int>* createSignalWrapper(const char* name, const char* type,
bp::object object);
} // namespace signalBase
namespace entity {
PyObject* create(PyObject* self, PyObject* args);
PyObject* display(PyObject* self, PyObject* args);
PyObject* display(PyObject* self, PyObject* args);
PyObject* getName(PyObject* self, PyObject* args);
PyObject* getClassName(PyObject* self, PyObject* args);
PyObject* hasSignal(PyObject* self, PyObject* args);
PyObject* getSignal(PyObject* self, PyObject* args);
PyObject* listSignals(PyObject* self, PyObject* args);
PyObject* executeCommand(PyObject* self, PyObject* args);
PyObject* listCommands(PyObject* self, PyObject* args);
PyObject* getCommandDocstring(PyObject* self, PyObject* args);
PyObject* getDocString(PyObject* self, PyObject* args);
PyObject* setLoggerVerbosityLevel(PyObject* self, PyObject* args);
PyObject* getLoggerVerbosityLevel(PyObject* self, PyObject* args);
PyObject* setTimeSample(PyObject* self, PyObject* args);
PyObject* getTimeSample(PyObject* self, PyObject* args);
PyObject* setStreamPrintPeriod(PyObject* self, PyObject* args);
PyObject* getStreamPrintPeriod(PyObject* self, PyObject* args);
/// \param obj an Entity object
void addCommands(boost::python::object obj);
void addSignals(boost::python::object obj);
Entity* create(const char* type, const char* name);
bp::object executeCmd(bp::tuple args, bp::dict);
} // namespace entity
namespace factory {
PyObject* getEntityClassList(PyObject* self, PyObject* args);
}
namespace signalCaster {
PyObject* getSignalTypeList(PyObject* self, PyObject* args);
bp::tuple getEntityClassList();
}
namespace pool {
PyObject* writeGraph(PyObject* self, PyObject* args);
PyObject* getEntityList(PyObject* self, PyObject* args);
void writeGraph(const char* filename);
bp::list getEntityList();
const std::map<std::string, Entity*>* getEntityMap();
} // namespace pool
namespace debug {
PyObject* addLoggerFileOutputStream(PyObject* self, PyObject* args);
PyObject* addLoggerCoutOutputStream(PyObject* self, PyObject* args);
PyObject* closeLoggerFileOutputStream(PyObject* self, PyObject* args);
PyObject* realTimeLoggerSpinOnce(PyObject* self, PyObject* args);
PyObject* realTimeLoggerDestroy(PyObject* self, PyObject* args);
PyObject* realTimeLoggerInstance(PyObject* self, PyObject* args);
void addLoggerFileOutputStream(const char* filename);
void addLoggerCoutOutputStream();
void closeLoggerFileOutputStream();
void realTimeLoggerSpinOnce();
void realTimeLoggerDestroy();
void realTimeLoggerInstance();
} // namespace debug
struct module_state {
PyObject* dgpyError;
};
PyObject* plug(PyObject* /*self*/, PyObject* args);
PyObject* enableTrace(PyObject* /*self*/, PyObject* args);
PyObject* error_out(
#if PY_MAJOR_VERSION >= 3
PyObject* m, PyObject*
#else
PyObject*, PyObject*
#endif
);
/**
\brief List of python functions
*/
__attribute__((unused)) static PyMethodDef dynamicGraphMethods[] = {
{"w_plug", dynamicgraph::python::plug, METH_VARARGS, "plug an output signal into an input signal"},
{"enableTrace", dynamicgraph::python::enableTrace, METH_VARARGS, "Enable or disable tracing debug info in a file"},
// Signals
{"create_signal_base", dynamicgraph::python::signalBase::create, METH_VARARGS, "create a SignalBase C++ object"},
{"create_signal_wrapper", dynamicgraph::python::signalBase::createSignalWrapper, METH_VARARGS,
"create a SignalWrapper C++ object"},
{"signal_base_get_time", dynamicgraph::python::signalBase::getTime, METH_VARARGS, "Get time of a SignalBase"},
{"signal_base_set_time", dynamicgraph::python::signalBase::setTime, METH_VARARGS, "Set time of a SignalBase"},
{"signal_base_get_name", dynamicgraph::python::signalBase::getName, METH_VARARGS, "Get the name of a signal"},
{"signal_base_get_class_name", dynamicgraph::python::signalBase::getClassName, METH_VARARGS,
"Get the class name of a signal"},
{"signal_base_display", dynamicgraph::python::signalBase::display, METH_VARARGS, "Print the signal in a string"},
{"signal_base_display_dependencies", dynamicgraph::python::signalBase::displayDependencies, METH_VARARGS,
"Print the signal dependencies in a string"},
{"signal_base_get_value", dynamicgraph::python::signalBase::getValue, METH_VARARGS, "Read the value of a signal"},
{"signal_base_set_value", dynamicgraph::python::signalBase::setValue, METH_VARARGS, "Set the value of a signal"},
{"signal_base_recompute", dynamicgraph::python::signalBase::recompute, METH_VARARGS,
"Recompute the signal at given time"},
{"signal_base_unplug", dynamicgraph::python::signalBase::unplug, METH_VARARGS, "Unplug the signal"},
{"signal_base_isPlugged", dynamicgraph::python::signalBase::isPlugged, METH_VARARGS,
"Whether the signal is plugged"},
{"signal_base_getPlugged", dynamicgraph::python::signalBase::getPlugged, METH_VARARGS,
"To which signal the signal is plugged"},
// Entity
{"create_entity", dynamicgraph::python::entity::create, METH_VARARGS, "create an Entity C++ object"},
{"display_entity", dynamicgraph::python::entity::display, METH_VARARGS, "print an Entity C++ object"},
{"entity_get_name", dynamicgraph::python::entity::getName, METH_VARARGS, "get the name of an Entity"},
{"entity_get_class_name", dynamicgraph::python::entity::getClassName, METH_VARARGS,
"get the class name of an Entity"},
{"entity_has_signal", dynamicgraph::python::entity::hasSignal, METH_VARARGS,
"return True if the entity has a signal with the given name"},
{"entity_get_signal", dynamicgraph::python::entity::getSignal, METH_VARARGS, "get signal by name from an Entity"},
{"entity_list_signals", dynamicgraph::python::entity::listSignals, METH_VARARGS,
"Return the list of signals of an entity."},
{"entity_execute_command", dynamicgraph::python::entity::executeCommand, METH_VARARGS, "execute a command"},
{"entity_list_commands", dynamicgraph::python::entity::listCommands, METH_VARARGS,
"list the commands of an entity"},
{"entity_get_command_docstring", dynamicgraph::python::entity::getCommandDocstring, METH_VARARGS,
"get the docstring of an entity command"},
{"entity_get_docstring", dynamicgraph::python::entity::getDocString, METH_VARARGS,
"get the doc string of an entity type"},
{"factory_get_entity_class_list", dynamicgraph::python::factory::getEntityClassList, METH_VARARGS,
"return the list of entity classes"},
{"signal_caster_get_type_list", dynamicgraph::python::signalCaster::getSignalTypeList, METH_VARARGS,
"return the list of signal type names"},
{"writeGraph", dynamicgraph::python::pool::writeGraph, METH_VARARGS, "Write the graph of entities in a filename."},
{"get_entity_list", dynamicgraph::python::pool::getEntityList, METH_VARARGS,
"return the list of instanciated entities"},
{"entity_set_logger_verbosity", dynamicgraph::python::entity::setLoggerVerbosityLevel, METH_VARARGS,
"set the verbosity level of the entity"},
{"entity_get_logger_verbosity", dynamicgraph::python::entity::getLoggerVerbosityLevel, METH_VARARGS,
"get the verbosity level of the entity"},
{"addLoggerFileOutputStream", dynamicgraph::python::debug::addLoggerFileOutputStream, METH_VARARGS,
"add a output file stream to the logger by filename"},
{"addLoggerCoutOutputStream", dynamicgraph::python::debug::addLoggerCoutOutputStream, METH_VARARGS,
"add std::cout as output stream to the logger"},
{"closeLoggerFileOutputStream", dynamicgraph::python::debug::closeLoggerFileOutputStream, METH_VARARGS,
"close all the loggers file output streams."},
{"entity_set_time_sample", dynamicgraph::python::entity::setTimeSample, METH_VARARGS,
"set the time sample for printing debugging information"},
{"entity_get_time_sample", dynamicgraph::python::entity::getTimeSample, METH_VARARGS,
"get the time sample for printing debugging information"},
{"entity_set_stream_print_period", dynamicgraph::python::entity::setStreamPrintPeriod, METH_VARARGS,
"set the period at which debugging information are printed"},
{"entity_get_stream_print_period", dynamicgraph::python::entity::getStreamPrintPeriod, METH_VARARGS,
"get the period at which debugging information are printed"},
{"real_time_logger_destroy", dynamicgraph::python::debug::realTimeLoggerDestroy, METH_VARARGS,
"Destroy the real time logger."},
{"real_time_logger_spin_once", dynamicgraph::python::debug::realTimeLoggerSpinOnce, METH_VARARGS,
"Destroy the real time logger."},
{"real_time_logger_instance", dynamicgraph::python::debug::realTimeLoggerInstance, METH_VARARGS,
"Starts the real time logger."},
{"error_out", (PyCFunction)dynamicgraph::python::error_out, METH_NOARGS, NULL},
{NULL, NULL, 0, NULL} /* Sentinel */
};
#if PY_MAJOR_VERSION >= 3
__attribute__((unused)) static struct PyModuleDef dynamicGraphModuleDef = {
PyModuleDef_HEAD_INIT,
"wrap",
NULL,
sizeof(struct dynamicgraph::python::module_state),
dynamicGraphMethods,
NULL,
NULL,
NULL,
NULL};
#define GETSTATE(m) ((struct dynamicgraph::python::module_state*)PyModule_GetState(m))
#define DGPYERROR(m) GETSTATE(m)->dgpyError
#define INITERROR return NULL
#else
__attribute__((unused)) static struct module_state _state;
#define GETSTATE(m) (&dynamicgraph::python::_state)
#define DGPYERROR(m) dynamicgraph::python::dgpyError
#define INITERROR return
#endif
} // namespace python
} // namespace dynamicgraph
......
// -*- mode: c++ -*-
// Copyright 2010, François Bleibel, Thomas Moulard, Olivier Stasse,
// JRL, CNRS/AIST.
#ifndef DYNAMIC_GRAPH_PYTHON_EXCEPTION_PYTHON_H
#define DYNAMIC_GRAPH_PYTHON_EXCEPTION_PYTHON_H
#include <dynamic-graph/fwd.hh>
#include <dynamic-graph/exception-abstract.h>
#include "dynamic-graph/python/python-compat.hh"
// Depending on whether one is building or using the
// library define DLLAPI to import or export.
#if defined(WIN32)
#if defined(wrap_EXPORTS)
#define WRAP_DLLAPI __declspec(dllexport)
#else
#define WRAP_DLLAPI __declspec(dllimport)
#endif
#else
#define WRAP_DLLAPI
#endif
namespace dynamicgraph {
namespace python {
/// \ingroup error
///
/// \brief Generic error class.
class WRAP_DLLAPI ExceptionPython : public ExceptionAbstract {
public:
enum ErrorCodeEnum { GENERIC, VALUE_PARSING, VECTOR_PARSING, MATRIX_PARSING, CLASS_INCONSISTENT };
static const std::string EXCEPTION_NAME;
explicit ExceptionPython(const ExceptionPython::ErrorCodeEnum& errcode, const std::string& msg = "");
ExceptionPython(const ExceptionPython::ErrorCodeEnum& errcode, const std::string& msg, const char* format, ...);
virtual ~ExceptionPython() throw() {}
virtual const std::string& getExceptionName() const { return ExceptionPython::EXCEPTION_NAME; }
};
} // end of namespace python
} // end of namespace dynamicgraph
#endif //! DYNAMIC_GRAPH_PYTHON_EXCEPTION_PYTHON_H
// Copyright 2010, Florent Lamiraux, Thomas Moulard, LAAS-CNRS.
#ifndef DYNAMIC_GRAPH_PYTHON_EXCEPTION
#define DYNAMIC_GRAPH_PYTHON_EXCEPTION
#include "dynamic-graph/python/dynamic-graph-py.hh"
/// \brief Catch all exceptions which may be sent when C++ code is
/// called.
#define CATCH_ALL_EXCEPTIONS(m) \
catch (const std::exception& exc) { \
PyErr_SetString(DGPYERROR(m), exc.what()); \
return NULL; \
} \
catch (const char* s) { \
PyErr_SetString(DGPYERROR(m), s); \
return NULL; \
} \
catch (...) { \
PyErr_SetString(DGPYERROR(m), "Unknown exception"); \
return NULL; \
} \
struct e_n_d__w_i_t_h__s_e_m_i_c_o_l_o_n
#endif //! DYNAMIC_GRAPH_PYTHON_EXCEPTION
/*
* Copyright CNRS 2021
*
* Author: Florent Lamiraux
*
* This file is part of sot-core.
*/
#ifndef DYNAMIC_GRAPH_PYTHON_FWD_HH
#define DYNAMIC_GRAPH_PYTHON_FWD_HH
#include <dynamic-graph/fwd.hh>
namespace dynamicgraph {
namespace python {
class Interpreter;
typedef shared_ptr<Interpreter> InterpreterPtr_t;
} // namespace python
} // namespace dynamicgraph
#endif // DYNAMIC_GRAPH_PYTHON_FWD_HH
......@@ -6,11 +6,10 @@
#undef _POSIX_C_SOURCE
#undef _XOPEN_SOURCE
#include "dynamic-graph/python/api.hh"
#include "dynamic-graph/python/deprecated.hh"
#include <dynamic-graph/python/fwd.hh>
#include "dynamic-graph/python/python-compat.hh"
#include "dynamic-graph/python/api.hh"
#include "dynamic-graph/python/python-compat.hh"
namespace dynamicgraph {
namespace python {
......@@ -26,11 +25,13 @@ class DYNAMIC_GRAPH_PYTHON_DLLAPI Interpreter {
/// \brief Method to start python interperter.
/// \param command string to execute
/// Method deprecated, you *SHOULD* handle error messages.
DYNAMIC_GRAPH_PYTHON_DEPRECATED std::string python(const std::string& command);
[[deprecated("you *SHOULD* handle error messages")]] std::string python(
const std::string& command);
/// \brief Method to start python interperter.
/// \param command string to execute, result, stdout, stderr strings
void python(const std::string& command, std::string& result, std::string& out, std::string& err);
void python(const std::string& command, std::string& result, std::string& out,
std::string& err);
/// \brief Method to exectue a python script.
/// \param filename the filename
......
#ifndef DYNAMIC_GRAPH_PYTHON_MODULE_HH
#define DYNAMIC_GRAPH_PYTHON_MODULE_HH
#ifdef PINOCCHIO_WITH_URDFDOM
// If pinocchio is used, we have to include pinocchio header before boost mpl
#include <pinocchio/fwd.hpp>
#endif
#include <dynamic-graph/entity.h>
#include <boost/mpl/for_each.hpp>
#include <boost/mpl/vector.hpp>
#include <boost/python.hpp>
#include <dynamic-graph/python/dynamic-graph-py.hh>
namespace dynamicgraph {
namespace python {
constexpr int AddSignals = 1;
constexpr int AddCommands = 2;
namespace internal {
template <typename T, int Options = AddCommands | AddSignals>
bp::object makeEntity1(const char* name) {
Entity* ent = entity::create(T::CLASS_NAME.c_str(), name);
assert(dynamic_cast<T*>(ent) != NULL);
bp::object obj(bp::ptr(static_cast<T*>(ent)));
if (Options & AddCommands) entity::addCommands(obj);
if (Options & AddSignals) entity::addSignals(obj);
return obj;
}
template <typename T, int Options = AddCommands | AddSignals>
bp::object makeEntity2() {
return makeEntity1<T, Options>("");
}
} // namespace internal
/// \tparam Options by default, all the signals and commands are added as
/// attribute to the Python object. This behaviour works fine for
/// entities that have static commands and signals.
/// If some commands or signals are added or removed dynamiccally, then
/// it is better to disable the default behaviour and handle it
/// specifically.
template <typename T,
typename bases = boost::python::bases<dynamicgraph::Entity>,
int Options = AddCommands | AddSignals>
inline auto exposeEntity() {
// std::string hiddenClassName ("_" + T::CLASS_NAME);
std::string hiddenClassName(T::CLASS_NAME);
namespace bp = boost::python;
bp::class_<T, bases, boost::noncopyable> obj(hiddenClassName.c_str(),
bp::init<std::string>());
/* TODO at the moment, I couldn't easily find a way to define a Python
constructor
* that would create the entity via the factory and then populate the
* python object with its commands.
* This is achieved with a factory function of the same name.
obj.def ("__init__", bp::raw_function(+[](bp::object args, bp::dict) {
if (bp::len(args) != 2)
throw std::length_error("Expected 2 arguments.");
bp::object self = args[0];
self.attr("__init__")(bp::extract<std::string>(args[1]));
Entity* ent = entity::create(T::CLASS_NAME.c_str(), name);
if (dynamic_cast<T*>(ent) == NULL)
std::cout << "foo" << std::endl;
assert(dynamic_cast<T*>(ent) != NULL);
self = bp::object(bp::ptr(static_cast<T*>(ent)));
//dynamicgraph::Entity& unused =
bp::extract<dynamicgraph::Entity&>(self);
//entity::addCommands(self);
})
;
*/
bp::def(T::CLASS_NAME.c_str(), &internal::makeEntity1<T, Options>);
bp::def(T::CLASS_NAME.c_str(), &internal::makeEntity2<T, Options>);
if (!(Options & AddCommands)) obj.def("add_commands", &entity::addCommands);
if (!(Options & AddSignals)) obj.def("add_signals", &entity::addSignals);
return obj;
}
} // namespace python
} // namespace dynamicgraph
#endif // DYNAMIC_GRAPH_PYTHON_MODULE_HH