Commit 118db7d4 authored by Guilhem Saurel's avatar Guilhem Saurel
parent ef80e69e
......@@ -38,9 +38,6 @@ GENERATE_CONFIGURATION_HEADER(
GENERATE_CONFIGURATION_HEADER(
${HEADER_DIR}
config-tracer-real-time.hh DG_TRACERREALTIME tracer_real_time_EXPORTS)
GENERATE_CONFIGURATION_HEADER(
${HEADER_DIR}
config-shell-procedure.hh DG_SHELLPROCEDURE shell_procedure_EXPORTS)
GENERATE_CONFIGURATION_HEADER(
${HEADER_DIR}
config-contiifstream.hh DG_CONTIIFSTREAM contiifstream_EXPORTS)
......@@ -65,7 +62,6 @@ SEARCH_FOR_EIGEN()
ADD_SUBDIRECTORY(src)
ADD_SUBDIRECTORY(include)
ADD_SUBDIRECTORY(doc)
ADD_SUBDIRECTORY(tests)
ADD_SUBDIRECTORY(share)
......
......@@ -3,6 +3,8 @@ CHANGELOG
[Current]
* remove shell
[v3.0.0]
* Replace jrl-mal with eigen
* Add ostream and isteram operators for Eigen Classes
......
# Copyright 2010, Olivier Stasse, JRL, CNRS/AIST
#
# This file is part of dynamic-graph.
# dynamic-graph is free software: you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public License
# as published by the Free Software Foundation, either version 3 of
# the License, or (at your option) any later version.
#
# dynamic-graph is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Lesser Public License for more details. You should have
# received a copy of the GNU Lesser General Public License along with
# dynamic-graph. If not, see <http://www.gnu.org/licenses/>.
INCLUDE(../cmake/man.cmake)
IF(UNIX)
# Add `man' target.
ADD_CUSTOM_TARGET(man DEPENDS dg-shell.1.gz dg-shell-plugin.1.gz)
# Man page generation.
MANPAGE(dg-shell)
MANPAGE(dg-shell-plugin)
ENDIF(UNIX)
/**
\ingroup gshellfunctions
\page dgshell_doc dg-shell executable
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.
It can be found in the installation prefix's bin/ directory.
There is also a linux shell script available, dg-shell-plugin, that creates a
and loads a default script whose goal is to load useful plugins at startup
(shell-functions and shell-procedure).
For an example of shell commands and scripts, see \ref scriptingabout.
**/
......@@ -38,7 +38,7 @@ for a given problem. It is the basis for the stack of tasks operation.
<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
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
......@@ -52,13 +52,13 @@ 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
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
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.
value for the CoM.
Note that the "Dyn" entity uses the sensor provided by the entity "Robot". </p>
<p>
......@@ -90,7 +90,7 @@ See \ref scriptingabout
\subsection entity_definition General definition
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$)
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.
......@@ -101,7 +101,7 @@ but in general the external data is based upon the sensor values provided by a "
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
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.
......@@ -123,8 +123,6 @@ the entities' names in the scripts; loading this file with the plugin loader wil
enable creation of this entity through the factory.
\li \ref tracerdoc
\li \ref tracerrealtimedoc
\li ShellProcedure
\li \ref shellfunctions_doc
\subsection specific_semantics Specific semantics with entities
......@@ -152,10 +150,10 @@ The class \ref dynamicgraph::FactoryStorage is a singleton which register the en
\subsection pool Pool
The class \ref dynamicgraph::PoolStorage keeps track of the entities instanciated with the factory.
The entities are the graph nodes. Signals are constructed during the class instanciation, they do not live independently
from the entities. Signals are the directed edges of the graph.
The pool can write a file representing the graph of entities.
from the entities. Signals are the directed edges of the graph.
The pool can write a file representing the graph of entities.
\subsection scriptingabout Building the graph
\subsection scriptingabout Building the graph
This package provides a scripting language allows entities to define their own commands, and
provides a basic framework to build dynamically the computational graph.
......@@ -175,16 +173,6 @@ register them in the Pool, where they can be listed, accessed, and acted upon
(see PoolStorage documentation). Basic commands defined by entities include
signal connection graph file generation, help and name print, and signals.
Finally, a shell (command-line) interface is made available thanks to the
Interpreter class (see the file test_shell.cpp for an example). Objects deriving from
Entity can expose their own commands by overriding the Entity's default
commandLine() method. It is possible to load a plugin to register custom
shell commands; see shell-functions and shell-procedure for an example.
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'
at the command line.
The singletons made available by including the corresponding headers in this
module are:
\li dynamicgraph::FactoryStorage
......@@ -193,13 +181,6 @@ module are:
For an example of a program creating entities in C++, see the unit test
test_pool.cpp (in your package source directory/unitTesting).
\subsection use_scripts Through scripts
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.
Here is a typical use case for programmers:
\image html figures/use-case.png
\subsection Tutorial
A tutorial is available <a href="http://stack-of-tasks.github.io/dynamic-graph-tutorial/">here</a>
\section references References
......@@ -217,25 +198,6 @@ 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
@{
......@@ -258,8 +220,6 @@ Signals can be grouped together using dynamicgraph::SignalArray.
Signals implement a caching mechanism by storing the last computation time tick.
Some signals can be plugged ("plug" script command) into one another or set through shell commands.
For more information, please see the individual signal pages.
\b Samples
......
/**
\ingroup gshellfunctions
\page shellfunctions_doc ShellFunctions
\note Note: this documentation covers specific aspects of the in-house
scripting language currently used by the dynamic-graph script. Unless
otherwise specified, it is only relevant for programmers using this
particular language. At the time of writing, there is talk of
replacing the language with python, so check if this information is still
relevant before reading.
\section description Description
The \b ShellFunctions plugin file adds common shell functions to the
dynamic-graph shell.
\section commands Commands
The supplementary \b commands provided (you can also type 'help' at the
dynamic-graph shell command line to see them and a brief description):
\code
LoadPlugins
Try
DisplayPlugins
DisplayFactory
Commentary
Unplug
ClearPlugin
SignalTime
SynchroSignal
Echo
Copy
Freeze
Squeeze
EnableTrace
SetPrompt
Sleep
Beep
FlagSet
CompletionList
\endcode
\section addi Additional information
See doxygen documentation for the class ShellFunctions
\section generates Generated plugin file
shell-functions.dll or shell-functions.so.
**/
......@@ -5,8 +5,7 @@ The \b TracerRealTime entity monitors a set of signals with real-time constraint
function is very similar to the Tracer, except that all traces are recorded to a
memory buffer, which can be emptied at any time.
\section commands Commands
The \b commands that this entity exposes are (you can also type [entity name].help at the
dynamic-graph shell command line to see this list):
The \b commands that this entity exposes are:
\code
empty (discards all buffers)
buffersize (sets buffer size for recording)
......
......@@ -6,8 +6,7 @@ the tracked signal values are recorded and traced to a file. The behavior of the
function can be changed, from printing to a file immediately after recording, to printing out
only when asked explicitly.
\section commands Commands
The \b commands that this entity exposes are (you can also type [entity name].help at the
dynamic-graph shell command line to see this list):
The \b commands that this entity exposes are:
\code
open, close (a file);
add (a signal)
......
=head1 NAME
dg-shell-plugin - Stack of tasks shell with all plug-ins loaded
=head1 SYNOPSIS
dg-shell-plugin
=head1 DESCRIPTION
Start the stack of tasks with all core plug-ins loaded.
=head1 AUTHORS
This software has been developed at CNRS/AIST and LAAS-CNRS laboratories.
See <@CMAKE_INSTALL_PREFIX@/share/doc/libdg-middleware-dev/AUTHORS> to
see the list of all contributors.
=head1 SEE ALSO
dg-shell(1)
See also <@PROJECT_URL@> for additional resources.
=head1 NAME
dg-shell - Stack of tasks shell
=head1 SYNOPSIS
dg-shell [--input <file>|-i <file>|--noninteractive|-n|--prologue|-prologue <file>|-h|--help]
=head1 DESCRIPTION
Start the stack of tasks and provides to the user an interactive shell
to control the data-flow.
By default, the shell first evaluates the prologue file
($HOME/.dg-shellrc by default). Additional input files passed as
arguments to evaluate multiple files.
=head1 OPTIONS
B<-i> I<file>, B<--input> I<file>
evaluate the file at start-up
B<-n>, B<--noninteractive>
enable the non-interactive mode
B<-p> I<file>, B<--prologue> I<file>
override the default prologue file (i.e. $HOME/.dg-shellrc)
B<-h>, B<--help>
produce help message
=head1 EXAMPLES
No options is required to launch a shell:
dg-shell
To evaluate "example.dg" only:
dg-shell -i example.dg -n
To evaluate "example1.dg", "example2.dg" and provide a shell to the user:
dg-shell -i example1.dg -i example2.dg
=head1 AUTHORS
This software has been developed at CNRS/AIST and LAAS-CNRS laboratories.
See <@CMAKE_INSTALL_PREFIX@/share/doc/libdg-middleware-dev/AUTHORS> to
see the list of all contributors.
=head1 SEE ALSO
dg-shell-plugin(1)
See also <@PROJECT_URL@> for additional resources.
This diff is collapsed.
......@@ -13,16 +13,8 @@
# received a copy of the GNU Lesser General Public License along with
# dynamic-graph. If not, see <http://www.gnu.org/licenses/>.
# Add default import directories.
# It is used by the import directive of the sot shell to locate
# scripts and plug-ins.
SET(
DG_IMPORT_DEFAULT_PATHS
"${CMAKE_INSTALL_PREFIX}/share/dynamic-graph/script:${CMAKE_INSTALL_PREFIX}/${PLUGINDIR}"
)
CONFIGURE_FILE(
${PROJECT_NAME}/import-default-paths.h.cmake
${PROJECT_NAME}/import-default-paths.h.cmake
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/import-default-paths.h)
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/import-default-paths.h
DESTINATION include/${PROJECT_NAME}
......
......@@ -81,8 +81,9 @@ namespace dynamicgraph
inline void trace (const int level=-1)
{
if (level <= traceLevel)
if (level <= traceLevel) {
outputbuffer << tmpbuffer.str (); tmpbuffer.str("");
}
}
inline void traceTemplate (const int level, const char* format, ...)
......
......@@ -64,11 +64,7 @@ namespace dynamicgraph
///
/// These signals link the entities together to form a complete
/// computation graph. To declare a new entity, please see the
/// DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN macro in factory.h. A
/// command-line interface provided by the entity can be used by a
/// sot shell to call methods from entities and display the result
/// of their execution. Classes that derive from Entity can
/// customize the command-line by overriding commandLine ().
/// DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN macro in factory.h.
class DYNAMIC_GRAPH_DLLAPI Entity : private boost::noncopyable
{
public:
......@@ -93,10 +89,6 @@ namespace dynamicgraph
virtual void display (std::ostream& os) const;
virtual void commandLine (const std::string& cmdLine,
std::istringstream& cmdArgs,
std::ostream& os);
virtual SignalBase<int>* test ()
{
return 0;
......
......@@ -169,16 +169,6 @@ namespace dynamicgraph
/// \param list Available entities will be appended to list.
void listEntities (std::vector <std::string>& list) const;
/// \brief Define FactoryStorage commands.
///
/// Define two equivalent commands:
/// - list
/// - listEntities
/// listing the available entities.
void commandLine (const std::string& cmdLine,
std::istringstream& cmdArgs,
std::ostream& os);
private:
/// \brief Constructor the factory.
......@@ -197,7 +187,7 @@ namespace dynamicgraph
/// \brief The entity map storing information about how to
/// instantiate an Entity.
EntityMap entityMap;
/// \pointer to the unique object of the class
static FactoryStorage* instance_;
};
......
......@@ -34,7 +34,6 @@ namespace dynamicgraph
class OutStringStream;
class PluginLoader;
class PoolStorage;
class ShellFunctionRegisterer;
class SignalCaster;
class SignalCastRegisterer;
......@@ -73,7 +72,4 @@ namespace dynamicgraph
} // end of namespace dynamicgraph.
class ShellFunctions;
class ShellProcedure;
#endif //! DYNAMIC_GRAPH_FWD_HH
......@@ -107,19 +107,6 @@ namespace dynamicgraph
/// \param sigpath stream containing a string of the form "entity.signal"
SignalBase<int>& getSignal( std::istringstream& sigpath );
/*! \brief This method looks for the object named objectName,
and ask to provide the function functionName with the arguments cmdArg.
If the method of the object displays some information this will
be done on os.
The commands specific to the \b PoolStorage singleton are:
\li \b list : List all the entities registered in the pool
*/
void commandLine (const std::string& objectName,
const std::string& functionName,
std::istringstream& cmdArg,
std::ostream& os);
/*! \brief This method write a graph description on the file named
FileName. */
void writeGraph (const std::string& aFileName);
......
......@@ -65,10 +65,6 @@ namespace dynamicgraph
DG_TRACERREALTIME_DLLAPI friend std::ostream& operator<<
(std::ostream& os, const TracerRealTime& t);
virtual void commandLine (const std::string& cmdLine,
std::istringstream& cmdArgs,
std::ostream& os);
protected:
virtual void openFile (const SignalBase<int>& sig,
const std::string& filename);
......
......@@ -106,11 +106,8 @@ namespace dynamicgraph
/* --- PARAMS --- */
void display( std::ostream& os ) const;
virtual void commandLine( const std::string& cmdLine
,std::istringstream& cmdArgs
,std::ostream& os );
};
};
} // end of namespace dynamicgraph
......
......@@ -16,7 +16,6 @@
# Install dynamic-graph scripts.
INSTALL(FILES
dynamic-graph/script/shell.dg
dynamic-graph/script/tracer.dg
DESTINATION share/dynamic-graph/script
......
import "shell-functions"
# DO NOT MOVE THIS LINE: comments are not implemented before.
# Copyright 2010, Thomas Moulard, JRL, CNRS/AIST.
# .
# This file is part of dynamic-graph.
# dynamic-graph is free software: you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public License
# as published by the Free Software Foundation, either version 3 of
# the License, or (at your option) any later version.
# .
# dynamic-graph is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Lesser Public License for more details. You should have
# received a copy of the GNU Lesser General Public License along with
# dynamic-graph. If not, see <http://www.gnu.org/licenses/>.
# This script provides basic shell tools.
# This file should ALWAYS be imported as it provides core features
# such as comments.
import "shell-procedure"
import "shell.dg"
# Copyright 2010, Thomas Moulard, JRL, CNRS/AIST.
# .
# This file is part of dynamic-graph.
......
......@@ -158,6 +158,7 @@ namespace dynamicgraph {
switch(value.type()) {
case Value::NONE:
copy = NULL;
break;
case Value::BOOL:
copy = new bool(value.boolValue());
break;
......
......@@ -235,56 +235,6 @@ getCommandList () const
return Entity_COMMAND_LIST;
}
void Entity::
commandLine( const std::string& cmdLine,std::istringstream& cmdArgs,std::ostream& os )
{
if( cmdLine == "help" )
{
os << "Entity : " << std::endl
<< " - print\t\t\tWhat d'you think?"<<endl
<< " - signals\t\t\tDisplay the signals list."<<endl
<< " - signalDep <signame> \tDisplay the dependency graph for signal signame."<<endl;
}
else if( cmdLine == "print")
{
os << *this << std::endl;
}
else if( cmdLine == "signals")
{ displaySignalList(os); }
else if( cmdLine == "signalDep")
{
string sig; cmdArgs>>sig;
cmdArgs >> ws; int depth=-1;
if( cmdArgs.good () ) { cmdArgs >> depth; }
getSignal(sig) .displayDependencies( os,depth ); os<<endl;
}
else
{
try{
SignalBase<int> & sig = getSignal( cmdLine );
int time; cmdArgs>>ws;
if( cmdArgs.good () )
{cmdArgs >> time;} else {time=0;}
sig.recompute( time );
os << cmdLine << " = "; sig.get( os );
} catch( ExceptionFactory& e ) {
switch( e.getCode () )
{
case ExceptionFactory::UNREFERED_SIGNAL:
DG_THROW ExceptionFactory( ExceptionFactory::UNREFERED_FUNCTION,
"The requested function/signal :","<%s> is "
"not registered.",cmdLine.c_str () );
break;
default:
throw;
}
} catch( ... ) { throw; }
}
}
/// Add a command to Entity
void Entity::
addCommand(const std::string& inName, Command* command)
......
......@@ -31,7 +31,7 @@ namespace dynamicgraph
}
return instance_;
}
void FactoryStorage::destroy()
{
delete instance_;
......@@ -144,45 +144,6 @@ namespace dynamicgraph
outList.push_back(entity.first);
}
void
FactoryStorage::commandLine(const std::string& cmdLine,
std::istringstream& cmdArgs,
std::ostream& os)
{
if (cmdLine == "help")
{
os << "factory ";
std::string cmd2;
cmdArgs >> cmd2;
if (!cmdArgs.good ())
os
<< " <arg>\t\t\t\taccess to the factory (help <arg> for more detail)"
<< std::endl;
else if (cmd2 == "list")
os << "list\t\t:List all available entities." << std::endl;
else if (cmd2 == "listEntities")
os <<"listEntities\t:List available entities." << std::endl;
}
else if (cmdLine == "list")
commandLine("listEntities",cmdArgs,os);
else if (cmdLine == "listEntities")
{
os <<" List of available entities:" << std::endl;
typedef std::pair<std::string, EntityConstructor_ptr> iter_t;
BOOST_FOREACH (const iter_t& entity, entityMap)
os << " - " << entity.first << std::endl;
}
return;
}
EntityRegisterer::EntityRegisterer
(const std::string& entityClassName, FactoryStorage::EntityConstructor_ptr maker)
: entityName (entityClassName)
......
......@@ -249,48 +249,6 @@ writeCompletionList(std::ostream& os)
}
void PoolStorage::
commandLine( const std::string& objectName,const std::string& functionName,
std::istringstream& cmdArg, std::ostream& os )
{
dgDEBUG(15) << "Object <" << objectName<< "> function <"
<<functionName<<">"<<std::endl;
if( objectName=="pool" )
{
if( functionName=="help" )
{
os <<"Pool: " << std::endl
<<" - list" << std::endl
<< " - writegraph FileName" << std::endl;
}
else if( functionName=="list" )
{
for( Entities::iterator iter=entityMap.begin ();
iter!=entityMap.end (); ++iter)
{
Entity* ent = iter->second;
os << ent->getName ()
<<" (" << ent->getClassName () << ")" << std::endl;
}
}
else if (functionName=="writegraph")
{
std::string aFileName;
cmdArg >> aFileName;
writeGraph(aFileName);
}
}
else
{
Entity& ent = getEntity(objectName);
ent.commandLine(functionName,cmdArg,os);
}
}
static bool
objectNameParser( std::istringstream& cmdparse,
std::string& objName,
......
// Copyright 2010, François Bleibel, Thomas Moulard, Olivier Stasse,
// JRL, CNRS/AIST.
//
// This file is part of dynamic-graph.
// dynamic-graph is free software: you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation, either version 3 of
// the License, or (at your option) any later version.
//
// dynamic-graph is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Lesser Public License for more details. You should have
// received a copy of the GNU Lesser General Public License along with
// dynamic-graph. If not, see <http://www.gnu.org/licenses/>.