Skip to content

Commit b7a290d

Browse files
Add some documentation about python module and python classes.
1 parent c5cca1a commit b7a290d

File tree

5 files changed

+18
-13
lines changed

5 files changed

+18
-13
lines changed

include/dynamic-graph/tutorial/doc-cxx.hh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff 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

include/dynamic-graph/tutorial/doc-python.hh

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,12 @@
66
Generating 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
*/

src/CMakeLists.txt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,5 @@ PKG_CONFIG_USE_DEPENDENCY(${PROJECT_NAME} dynamic-graph-python)
4141
INSTALL(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
4945
DYNAMIC_GRAPH_PYTHON_MODULE("tutorial" ${LIBRARY_NAME} wrap)

src/feedback-controller.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
using namespace dynamicgraph;
1414
using 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.
1619
DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN(FeedbackController, "FeedbackController");
1720

1821
FeedbackController::FeedbackController(const std::string& inName) :

src/inverted-pendulum.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ using namespace dynamicgraph::tutorial;
1919

2020
const 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.
2225
DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN(InvertedPendulum, "InvertedPendulum");
2326

2427
InvertedPendulum::InvertedPendulum(const std::string& inName) :

0 commit comments

Comments
 (0)