Skip to content
Snippets Groups Projects
Commit 6a789105 authored by Olivier Stasse's avatar Olivier Stasse
Browse files

[doc] Improve documentation.

parent 3c7460d5
No related branches found
No related tags found
No related merge requests found
/** /**
\ingroup gshellfunctions
\page dgshell_doc dg-shell executable \page dgshell_doc dg-shell executable
The dynamic-graph shell program "dg-shell" allows access to the dynamic-graph library's The dynamic-graph shell program "dg-shell" allows access to the dynamic-graph library's
Interpreter class, which can execute commands and scripts from the command line. Interpreter class, which can execute commands and scripts from the command line.
......
...@@ -22,16 +22,62 @@ ...@@ -22,16 +22,62 @@
/** /**
\mainpage \mainpage
\section intro_dynamicGraph Introduction \section intro_dynamicGraph Introduction
The dynamic-graph package is used to connect computation nodes, "entities" The dynamic-graph package is used to connect computation nodes, "entities"
together using a graph system, akin to what Simulink does. With the building together using a graph system, akin to what Simulink does. Entities are connected
blocks this package provides, you can easily create a full computation graph through input and output signals.
With the building blocks this package provides, you can easily create a full computation graph
for a given problem. It is the basis for the stack of tasks operation. for a given problem. It is the basis for the stack of tasks operation.
\image html entity.png
Functionality: \subsection controlgraph Exemple: Real-time control
\li Built-in scripting language* for fast prototyping and testing
<p>To give a more concrete example, the real-time control used by the Gepetto group for the humanoid robot HRP-2
is detailled.</p>
<p>
Real-time control system are usually driven by a cyclic computational node which
needs to send a control reference value to each motors of a robot. To compute this
control reference values, sensor values need to be provided.
In the Stack-Of-Tasks special entities called Device are used to
provide an abstract interface to the hardware.</p>
A scheme of the real-time control graph used for the humanoid robot HRP-2 is depicted in the following figure:
\image html Concept-Software-Fig.png
<p>The device therefore has a specific input which should contain the control vector.
This control vector is the result of a computation solving a control problem.
The entity in charge of solving this control problem is called "Solver" in the previous
figure.
In the SoT framework it is often cast as an optimization problem.
This optimization problem is build using a control "Task" (not to be confused with the
general word task). A control "Task" regulates the difference with a "Feature" computed
on the current robot state and a "Desired Feature". For instance when walking, the regulated
feature is the robot's Center-Of-Mass (CoM) position. The "Feature" is computed using a
library using the robot model and the sensor value. The entity making this computation is "Dyn".
A walking pattern generator using foot-steps position given in advance generates the desired
value for the CoM.
Note that the "Dyn" entity uses the sensor provided by the entity "Robot". </p>
<p>
From a pure computer science viewpoint we wish to avoid recomputing data such as articular Jacobians
when this is unnecessary. Therefore the data generated by an entity through signals may have two types of
dependencies: one dependency related to time and dependencies on other signals. Internally an entity
does not recompute the data if no new information is available, it is simply providing the same information
computed before. Please note that this package provides only the computational framework to realize
the data dependency and the entities. Solvers, libraries to compute mechanical quantities are provided
in different packages.
</p>
<p>
Finally in order to dynamically create a graph, it is possible \b on-line to load classes of entities and
create instances of entities.</p>
\subsection Functionnalities
\li Built-in scripting language* for fast prototyping and testing of computational graph
\li Support for extensions and modules using dynamic link libraries \li Support for extensions and modules using dynamic link libraries
\li Template-based signal definition, independent \li Template-based signal definition, independent
\li Type-safe connection of input and output signals \li Type-safe connection of input and output signals
...@@ -39,14 +85,37 @@ Functionality: ...@@ -39,14 +85,37 @@ Functionality:
computation of signal values, which is a critical point for real-time systems\n computation of signal values, which is a critical point for real-time systems\n
See \ref scriptingabout See \ref scriptingabout
\section overview Code overview \section entity Computational Entity
This code implements the factory design pattern, making creation of entities \image html entity.png
(as C++ classes) available to packages depending on the dynamic-graph API.
For more information on this package's code or how to develop your own entities, \subsection entity_definition General definition
see \ref usecase. Despite the fact that it looks very similar to a ROS node or a CORBA/OpenRTM server, an entity is simply a C++ object.
The main idea is that this entity is providing mostly a data-driven functionnality working at very high rate (\f$ 200 Hz\f$ or \f$ 1 kHz \f$)
and should have a minimal computational time foot-print.
For this signals (or ports to use a more classical terminology) are providing a time dependency between data.
To implement this, an output signal is linked with a method of the entity. The method calls input signals or use other means
to get the needed data.
It might be provided by the connection with remote computers through a middleware, or specific protocols,
but in general the external data is based upon the sensor values provided by a "Device" entity.
For this reason the signal evaluations are realized through the cascade of dependencies and start from the evaluation of an input
signal of a periodic node (in general the device). This is realized inside a \b real-time thread.
To add flexibility to a node, it is possible to add command with arguments to modify the internal behavior of the entity
or get information from the entity.
As a command is in general asynchronous and rare with respect to the data-flow scheme for the signals the command is in general
executed in a \b none-real-time thread.
\subsection entity_classes Entity class
Entities are implemented as C++ classes and compiled as dynamic libraries. They can be loaded and instancied dynamically.
It is therefore necessary to specify the location of their dynamical libraries.
However given the time it might take to load the library, it is not advised to do that during a control-law computation.
Entity instanciation also implies memory allocation which is also time consuming and thus not advised inside a real-time thread.
The entities will be placed in ${PREFIX}/lib/plugin (since this may change, it is advised to
check the install log or the CMakeLists.txt file to check the installation path).
\section entities List of entities in this package \subsection entities List of entities in this package
Since most of the functionality in projects using the dynamic-graph framework Since most of the functionality in projects using the dynamic-graph framework
is exposed from entities, here is a short description of all the entities contained in is exposed from entities, here is a short description of all the entities contained in
this package. Note that most entities are contained in a binary file that closely matches this package. Note that most entities are contained in a binary file that closely matches
...@@ -57,9 +126,14 @@ enable creation of this entity through the factory. ...@@ -57,9 +126,14 @@ enable creation of this entity through the factory.
\li ShellProcedure \li ShellProcedure
\li \ref shellfunctions_doc \li \ref shellfunctions_doc
The entities will be placed in ${PREFIX}/lib/plugin (since this may change, it is advised to \subsection specific_semantics Specific semantics with entities
check the install log or the CMakeLists.txt file to check the installation path).
\section sigintro About signals It is possible to derive classes and apply specific semantic for the entities. In our case we are interested in specific control semantics:
\li Tasks (more information <a href="http://stack-of-tasks.github.io/sot-core/doxygen/HEAD/a00089.html">here</a>)
\li Features (more information <a href="http://stack-of-tasks.github.io/sot-core/doxygen/HEAD/a00030.html">here</a>)
\li Solver (more information <a href="http://stack-of-tasks.github.io/sot-core/doxygen/HEAD/a00078.html">here</a>)
\section sigintro Signals
Entities can output different types of signals. All signals are templated by a Time Entities can output different types of signals. All signals are templated by a Time
tick type parameter (which is used in the caching of signals) - usually \c int. Signals tick type parameter (which is used in the caching of signals) - usually \c int. Signals
...@@ -67,32 +141,31 @@ are also templated after the type of data they accept or provide. For example: ...@@ -67,32 +141,31 @@ are also templated after the type of data they accept or provide. For example:
(example) (example)
For a more detailed programmer-oriented description of signals, please see \ref signals For a more detailed programmer-oriented description of signals, please see \ref signals
\section scriptingabout Notes about the scripting language \section graph Graph
The scripting language allows entities to define their own commands, and
provides a basic framework for working with the dynamic-graph.
At the time of writing, there is talk about replacing (or complementing) this limited
language with a python interpreter.
A couple of functions are built-in in the interpreter and provides low-level features such as file sourcing or In this package, the graph considered are directed graphs.
plug-in loading.\n
These functions are:\n \subsection factory Factory
\code plug <obj1.sig1> <obj2.sig2> \endcode plugs the signal sig1 of obj1 to the signal sig2 of obj2. sig1 and sig2
have to be of the same type. sig1 has to be an output signal and sig2 an input signal. The class \ref dynamicgraph::FactoryStorage is a singleton which register the entity classes and which is allowing the instancation of such classes.
\code new <class> <object> \endcode instantiates an object object of class class. object has to be a free identifier and
class an existing entity. \subsection pool Pool
\code destroy <object> \endcode deletes an instance previously created. The class \ref dynamicgraph::PoolStorage keeps track of the entities instanciated with the factory.
\code run <script.txt> \endcode sources (i.e. read and interpret) an external file. The entities are the graph nodes. Signals are constructed during the class instanciation, they do not live independently
\code loadPlugin <file.so> <directory> \endcode loads a plugin called file.so and located in the directory directory. from the entities. Signals are the directed edges of the graph.
\code unloadPlugin <path/file.so> \endcode unloads a plugin. The pool can write a file representing the graph of entities.
\code help \endcode lists available functions.
\code set <obj.signal> <value> \endcode defines an input signal to a specific, constant, value. \subsection scriptingabout Building the graph
\code get <obj.signal> <value> \endcode prints out a signal value.
\code compute <obj.sig> <time> \endcode computes an output signal and sets the associated time to time. This package provides a scripting language allows entities to define their own commands, and
provides a basic framework to build dynamically the computational graph.
However bindings have been created with python in the <a href="https://github.com/stack-of-tasks/dynamic-graph-python">dynamic-graph-python package</a>
and we strongly recommend to use this package instead of the in-house scripting language.
\section usecase How to use this package \section usecase How to use this package
1) Programmatically\n \subsection use_programmtically Programmatically
Objects, which are derived from Entities (base class dynamicgraph::Entity), can be Objects, which are derived from Entities (base class dynamicgraph::Entity), can be
declared within the code and compiled to shared libraries (.so/.dll files). declared within the code and compiled to shared libraries (.so/.dll files).
These libraries can be loaded at run-time using the PluginLoader methods, These libraries can be loaded at run-time using the PluginLoader methods,
and at the same time register their class names to the Factory (see the and at the same time register their class names to the Factory (see the
examples in the SOT documentation to learn how). examples in the SOT documentation to learn how).
...@@ -112,7 +185,7 @@ Some basic shell functions, and support for procedures, are also included. ...@@ -112,7 +185,7 @@ Some basic shell functions, and support for procedures, are also included.
For a complete list of those, load the plugin shell-functions.so and type 'help' For a complete list of those, load the plugin shell-functions.so and type 'help'
at the command line. at the command line.
The (singletons made available by including the corresponding headers in this The singletons made available by including the corresponding headers in this
module are: module are:
\li dynamicgraph::FactoryStorage \li dynamicgraph::FactoryStorage
\li dynamicgraph::PoolStorage \li dynamicgraph::PoolStorage
...@@ -120,20 +193,46 @@ module are: ...@@ -120,20 +193,46 @@ module are:
For an example of a program creating entities in C++, see the unit test For an example of a program creating entities in C++, see the unit test
test_pool.cpp (in your package source directory/unitTesting). test_pool.cpp (in your package source directory/unitTesting).
2) Through scripts\n \subsection use_scripts Through scripts
The program \ref dgshell_doc can be used to have scripting access to the dynamic-graph The program \ref dgshell_doc can be used to have scripting access to the dynamic-graph
library, where you can execute scripts and commands, load plugins, create entities and connect signals. library, where you can execute scripts and commands, load plugins, create entities and connect signals.
Here is a typical use case for programmers: Here is a typical use case for programmers:
\image html figures/use-case.png \image html figures/use-case.png
\section References \section references References
\anchor Mansard2009
<b> "A versatile Generalized Inverted Kinematics implementation for collaborative working humanoid robots: The Stack Of Tasks"</b>,
<em>N. Mansard, O. Stasse, P. Evrard, A. Kheddar,</em>
Int. Conf. on Autonomous Robots, ICAR, 2009
\anchor Mansard2007 \anchor Mansard2007
<b>"Task sequencing for sensor-based control"</b>, <b>"Task sequencing for sensor-based control"</b>,
<em>N. Mansard, F. Chaumette,</em> <em>N. Mansard, F. Chaumette,</em>
IEEE Trans. on Robotics, 23(1):60-72, February 2007 IEEE Trans. on Robotics, 23(1):60-72, February 2007
\namespace dynamicgraph This is the namespace where every object and class of this library is located.
\defgroup gshellfunctions Notes about the scripting language
@{
A couple of functions are built-in in the interpreter and provides low-level features such as file sourcing or
plug-in loading.\n
These functions are:\n
\code plug <obj1.sig1> <obj2.sig2> \endcode plugs the signal sig1 of obj1 to the signal sig2 of obj2. sig1 and sig2
have to be of the same type. sig1 has to be an output signal and sig2 an input signal.
\code new <class> <object> \endcode instantiates an object object of class class. object has to be a free identifier and
class an existing entity.
\code destroy <object> \endcode deletes an instance previously created.
\code run <script.txt> \endcode sources (i.e. read and interpret) an external file.
\code loadPlugin <file.so> <directory> \endcode loads a plugin called file.so and located in the directory directory.
\code unloadPlugin <path/file.so> \endcode unloads a plugin.
\code help \endcode lists available functions.
\code set <obj.signal> <value> \endcode defines an input signal to a specific, constant, value.
\code get <obj.signal> <value> \endcode prints out a signal value.
\code compute <obj.sig> <time> \endcode computes an output signal and sets the associated time to time.
@}
\defgroup dgraph Core classes and objects \defgroup dgraph Core classes and objects
@{ @{
...@@ -180,5 +279,4 @@ computations, when accessed. ...@@ -180,5 +279,4 @@ computations, when accessed.
@} @}
\namespace dynamicgraph This is the namespace where every object and class of this library is located.
*/ */
/** /**
\ingroup gshellfunctions
\page shellfunctions_doc ShellFunctions \page shellfunctions_doc ShellFunctions
\note Note: this documentation covers specific aspects of the in-house \note Note: this documentation covers specific aspects of the in-house
scripting language currently used by the dynamic-graph script. Unless scripting language currently used by the dynamic-graph script. Unless
......
doc/figures/Concept-Software-Fig.png

30.9 KiB

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