File tree Expand file tree Collapse file tree 5 files changed +18
-13
lines changed
include/dynamic-graph/tutorial Expand file tree Collapse file tree 5 files changed +18
-13
lines changed Original file line number Diff line number Diff line change @@ -125,6 +125,10 @@ using a macro defined in <c>dynamic-graph/factory.h</c>:
125125\code
126126 DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN(InvertedPendulum, "InvertedPendulum");
127127\endcode
128+ \note The two parameters of the macros are respectively
129+ \li the C++ type of the new Entity,
130+ \li the name of the type of the corresponding python class. It is highly
131+ recommended to use the same name for both.
128132
129133\subsection dg_tutorial_inverted_pendulum_cxx_implementation_constructor Constructor
130134
Original file line number Diff line number Diff line change 66Generating python bindings for new Entity classes is straightforward. We only need to add the following lines into file <c>src/CMakeLists.txt</c>:
77
88<code>
9- SET(NEW_ENTITY_CLASS
10- InvertedPendulum
11- FeedbackController
12- )
13-
14- DYNAMIC_GRAPH_PYTHON_MODULE("tutorial")
9+ DYNAMIC_GRAPH_PYTHON_MODULE("tutorial" ${LIBRARY_NAME} wrap)
1510</code>
16- \sa <a href="../sphinx-html/index.html">documentation of python bindings</a>,
17- <c>src/simu.py</c> for an example python script.
11+
12+ This will create and install a python module called <c>dynamic_graph.tutorial</c>, linked with library <c>${LIBRARY_NAME} (libdynamic-graph-tutorial.so)</c>.
13+ When importing this module, two new python classes deriving from <c>Entity</c> are created:
14+ \li InvertedPendulum, and
15+ \li FeedbackController.
16+ \sa <c>src/simu.py</c> for an example python script.
1817 */
Original file line number Diff line number Diff line change @@ -41,9 +41,5 @@ PKG_CONFIG_USE_DEPENDENCY(${PROJECT_NAME} dynamic-graph-python)
4141INSTALL (TARGETS ${LIBRARY_NAME}
4242 DESTINATION ${CMAKE_INSTALL_PREFIX} /lib)
4343
44- SET (NEW_ENTITY_CLASS
45- InvertedPendulum
46- FeedbackController
47- )
48-
44+ # Create a python module containing new Python entity classes
4945DYNAMIC_GRAPH_PYTHON_MODULE("tutorial" ${LIBRARY_NAME} wrap)
Original file line number Diff line number Diff line change 1313using namespace dynamicgraph ;
1414using namespace dynamicgraph ::tutorial;
1515
16+ // Register new Entity type in the factory
17+ // Note that the second argument is the type name of the python class
18+ // that will be created when importing the python module.
1619DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN (FeedbackController, " FeedbackController" );
1720
1821FeedbackController::FeedbackController (const std::string& inName) :
Original file line number Diff line number Diff line change @@ -19,6 +19,9 @@ using namespace dynamicgraph::tutorial;
1919
2020const double Constant::gravity = 9.81 ;
2121
22+ // Register new Entity type in the factory
23+ // Note that the second argument is the type name of the python class
24+ // that will be created when importing the python module.
2225DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN (InvertedPendulum, " InvertedPendulum" );
2326
2427InvertedPendulum::InvertedPendulum (const std::string& inName) :
You can’t perform that action at this time.
0 commit comments