├── tests ├── data │ ├── empty.dg │ └── interpreter-tracer.dg ├── signal-cast-register-test.h ├── signal-cast-registerer-libA.cpp ├── signal-cast-registerer-libB.cpp ├── signal-cast-registerer-libA.hh ├── signal-cast-registerer-libB.hh ├── test-mt.cpp ├── CMakeLists.txt ├── custom-entity.cpp ├── exceptions.cpp ├── real-time-logger.cpp ├── debug-logger-winit.cpp ├── debug-trace.cpp ├── debug-real-time-tracer.cpp ├── debug-tracer.cpp ├── factory.cpp └── signal-all.cpp ├── .gitignore ├── .gitlab-ci.yml ├── doc ├── pictures │ ├── HRP2.jpg │ ├── sot.ico │ ├── sot.png │ ├── entity.png │ ├── footer.jpg │ ├── use-case.png │ ├── schema_plugin.png │ ├── my_dynamic_graph.png │ ├── Concept-Software-Fig.png │ └── footer.txt ├── additionalDoc │ ├── factory.h │ ├── pool.h │ ├── signal.h │ ├── references.h │ ├── installation.h │ ├── debug-doc.h │ ├── graph.h │ ├── writeGraph.h │ ├── tracer-real-timedoc.h │ ├── debug-logger.h │ ├── tracerdoc.h │ ├── debug-trace-doc.h │ ├── package.h │ ├── doc-debug-real-time-logger.h │ ├── entity.h │ ├── introduction.h │ ├── doc-command.h │ └── extension.h ├── customdoxygen.css └── header.html ├── .gitmodules ├── src ├── signal │ └── signal-array.cpp ├── CMakeLists.txt ├── exception │ ├── exception-traces.cpp │ ├── exception-signal.cpp │ ├── exception-factory.cpp │ └── exception-abstract.cpp ├── debug │ ├── debug.cpp │ ├── logger.cpp │ └── real-time-logger.cpp ├── command │ └── command.cpp ├── dgraph │ └── factory.cpp └── mt │ └── process-list.cpp ├── include └── dynamic-graph │ ├── dynamic-graph-api.h │ ├── signal-cast-helper.h │ ├── linear-algebra.h │ ├── all-signals.h │ ├── entity-helper.h │ ├── all-commands.h │ ├── real-time-logger.h │ ├── command-getter.t.cpp │ ├── exception-traces.h │ ├── exception-signal.h │ ├── exception-factory.h │ ├── fwd.hh │ ├── command-getter.h │ ├── command-setter.h │ ├── command-direct-getter.h │ ├── command-direct-setter.h │ ├── tracer-real-time.h │ ├── command.h │ ├── time-dependency.h │ ├── tracer.h │ ├── signal-helper.h │ ├── pool.h │ ├── signal.h │ ├── exception-abstract.h │ ├── value.h │ ├── signal-array.h │ ├── time-dependency.t.cpp │ ├── real-time-logger-def.h │ ├── signal-ptr.h │ ├── signal-caster.h │ ├── process-list.hh │ ├── eigen-io.h │ └── signal-time-dependent.h ├── AUTHORS ├── .pre-commit-config.yaml ├── package.xml ├── .git-blame-ignore-revs ├── LICENSE ├── .mailmap ├── js └── view_sot_dg.html ├── README.md └── CMakeLists.txt /tests/data/empty.dg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | _build* 2 | .~ 3 | compile_commands.json 4 | -------------------------------------------------------------------------------- /tests/signal-cast-register-test.h: -------------------------------------------------------------------------------- 1 | #include 2 | -------------------------------------------------------------------------------- /.gitlab-ci.yml: -------------------------------------------------------------------------------- 1 | include: http://rainboard.laas.fr/project/dynamic-graph/.gitlab-ci.yml 2 | -------------------------------------------------------------------------------- /doc/pictures/HRP2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stack-of-tasks/dynamic-graph/HEAD/doc/pictures/HRP2.jpg -------------------------------------------------------------------------------- /doc/pictures/sot.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stack-of-tasks/dynamic-graph/HEAD/doc/pictures/sot.ico -------------------------------------------------------------------------------- /doc/pictures/sot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stack-of-tasks/dynamic-graph/HEAD/doc/pictures/sot.png -------------------------------------------------------------------------------- /doc/pictures/entity.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stack-of-tasks/dynamic-graph/HEAD/doc/pictures/entity.png -------------------------------------------------------------------------------- /doc/pictures/footer.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stack-of-tasks/dynamic-graph/HEAD/doc/pictures/footer.jpg -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "cmake"] 2 | path = cmake 3 | url = https://github.com/jrl-umi3218/jrl-cmakemodules.git 4 | -------------------------------------------------------------------------------- /doc/pictures/use-case.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stack-of-tasks/dynamic-graph/HEAD/doc/pictures/use-case.png -------------------------------------------------------------------------------- /doc/pictures/schema_plugin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stack-of-tasks/dynamic-graph/HEAD/doc/pictures/schema_plugin.png -------------------------------------------------------------------------------- /doc/pictures/my_dynamic_graph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stack-of-tasks/dynamic-graph/HEAD/doc/pictures/my_dynamic_graph.png -------------------------------------------------------------------------------- /doc/pictures/Concept-Software-Fig.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stack-of-tasks/dynamic-graph/HEAD/doc/pictures/Concept-Software-Fig.png -------------------------------------------------------------------------------- /tests/signal-cast-registerer-libA.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2010 Thomas Moulard. 2 | // 3 | 4 | #include "signal-cast-registerer-libA.hh" 5 | 6 | vec_type vA; 7 | -------------------------------------------------------------------------------- /tests/signal-cast-registerer-libB.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2010 Thomas Moulard. 2 | // 3 | 4 | #include "signal-cast-registerer-libB.hh" 5 | 6 | vec_type vB; 7 | -------------------------------------------------------------------------------- /doc/pictures/footer.txt: -------------------------------------------------------------------------------- 1 | Copy in this directory the image you wish to use in the footer of the documentation or edit file dynamicGraph/doc/footer.html and 2 | remove this file. 3 | -------------------------------------------------------------------------------- /tests/signal-cast-registerer-libA.hh: -------------------------------------------------------------------------------- 1 | // Copyright 2010 Thomas Moulard. 2 | // 3 | 4 | #include 5 | 6 | typedef Eigen::VectorXd vec_type; 7 | extern vec_type vA; 8 | -------------------------------------------------------------------------------- /tests/signal-cast-registerer-libB.hh: -------------------------------------------------------------------------------- 1 | // Copyright 2010 Thomas Moulard. 2 | // 3 | 4 | #include 5 | 6 | typedef Eigen::VectorXd vec_type; 7 | extern vec_type vB; 8 | -------------------------------------------------------------------------------- /tests/data/interpreter-tracer.dg: -------------------------------------------------------------------------------- 1 | import "tracer" 2 | 3 | new Tracer tracer 4 | tracer.open /tmp debug.dat 5 | tracer.add tracer.triger 6 | tracer.start 7 | tracer.stop 8 | tracer.clear 9 | tracer.record 10 | tracer.close 11 | -------------------------------------------------------------------------------- /doc/additionalDoc/factory.h: -------------------------------------------------------------------------------- 1 | /** 2 | \page subp_factory Factory 3 | \section sec_factory Factory 4 | 5 | The class \ref dynamicgraph::FactoryStorage is a singleton which register the 6 | entity classes and which is allowing the instancation of such classes. 7 | */ 8 | -------------------------------------------------------------------------------- /src/signal/signal-array.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010, 3 | * François Bleibel, 4 | * Olivier Stasse, 5 | * 6 | * CNRS/AIST 7 | * 8 | */ 9 | 10 | #include 11 | 12 | namespace dynamicgraph { 13 | SignalArray sotNOSIGNAL(0); 14 | } 15 | -------------------------------------------------------------------------------- /include/dynamic-graph/dynamic-graph-api.h: -------------------------------------------------------------------------------- 1 | // -*- mode: c++ -*- 2 | // Copyright 2010, François Bleibel, Thomas Moulard, Olivier Stasse, 3 | // JRL, CNRS/AIST. 4 | // 5 | 6 | #ifndef DYNAMIC_GRAPH_API_H 7 | #define DYNAMIC_GRAPH_API_H 8 | #include 9 | #endif //! DYNAMIC_GRAPH_API_H 10 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | This package was written by and with the assistance of 2 | 3 | * François Bleibel fbleibel@gmail.com 4 | * François Keith francois.keith@aist.go.jp 5 | * Nicolas Mansard FIXME 6 | * Thomas Moulardd thomas.moulard@gmail.com 7 | * Olivier Stasse olivier.stasse@aist.go.jp 8 | -------------------------------------------------------------------------------- /include/dynamic-graph/signal-cast-helper.h: -------------------------------------------------------------------------------- 1 | // -*- c++-mode -*- 2 | // Copyright 2010 François Bleibel Thomas Moulard, Olivier Stasse, 3 | // Nicolas Mansard 4 | // 5 | 6 | #ifndef DYNAMIC_GRAPH_SIGNAL_CASTER_HELPER_HH 7 | #define DYNAMIC_GRAPH_SIGNAL_CASTER_HELPER_HH 8 | 9 | #pragma warning "This file is now useless" 10 | 11 | #endif // #ifndef DYNAMIC_GRAPH_SIGNAL_CASTER_HELPER_HH 12 | -------------------------------------------------------------------------------- /doc/additionalDoc/pool.h: -------------------------------------------------------------------------------- 1 | /** 2 | \page subp_pool Pool 3 | \section pool Pool 4 | The class \ref dynamicgraph::PoolStorage keeps track of the entities 5 | instanciated with the factory. The entities are the graph nodes. Signals are 6 | constructed during the class instanciation, they do not live independently from 7 | the entities. Signals are the directed edges of the graph. The pool can write a 8 | file representing the graph of entities. 9 | */ 10 | -------------------------------------------------------------------------------- /include/dynamic-graph/linear-algebra.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2010 CNRS 3 | // 4 | // Author: Florent Lamiraux 5 | // 6 | 7 | #ifndef DYNAMIC_GRAPH_LINEAR_ALGEBRA_H 8 | #define DYNAMIC_GRAPH_LINEAR_ALGEBRA_H 9 | #include 10 | #include 11 | 12 | namespace dynamicgraph { 13 | typedef Eigen::MatrixXd Matrix; 14 | typedef Eigen::VectorXd Vector; 15 | } // namespace dynamicgraph 16 | 17 | #endif // DYNAMIC_GRAPH_LINEAR_ALGEBRA_H 18 | -------------------------------------------------------------------------------- /doc/customdoxygen.css: -------------------------------------------------------------------------------- 1 | /* Customizing Doxygen output */ 2 | 3 | /* Needed to allow line breaks in tables*/ 4 | .memberdecls { 5 | table-layout: fixed; 6 | width: 100%; 7 | } 8 | 9 | /* Needed to break long template names*/ 10 | .memTemplItemLeft { 11 | white-space: normal !important; 12 | word-wrap: break-word; 13 | } 14 | 15 | /* Needed to break long template names*/ 16 | .memItemLeft { 17 | white-space: normal !important; 18 | word-wrap: break-word; 19 | } 20 | -------------------------------------------------------------------------------- /include/dynamic-graph/all-signals.h: -------------------------------------------------------------------------------- 1 | // -*- mode: c++ -*- 2 | // Copyright 2010, François Bleibel, Thomas Moulard, Olivier Stasse, 3 | // JRL, CNRS/AIST. 4 | // 5 | 6 | #ifndef DYNAMIC_GRAPH_ALL_SIGNALS_H 7 | #define DYNAMIC_GRAPH_ALL_SIGNALS_H 8 | 9 | // Utility header files including all signal headers 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | #endif //! DYNAMIC_GRAPH_ALL_SIGNALS_H 16 | -------------------------------------------------------------------------------- /include/dynamic-graph/entity-helper.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2011, Nicolas Mansard, LAAS-CNRS 3 | * 4 | */ 5 | 6 | #ifndef __sot_core_entity_helper_H__ 7 | #define __sot_core_entity_helper_H__ 8 | 9 | namespace dynamicgraph { 10 | 11 | template 12 | struct EntityHelper { 13 | typedef Ent EntityClassName; 14 | // static const std::string CLASS_NAME; TO BE ADDED IN DG DIRECTLY 15 | }; 16 | 17 | } // namespace dynamicgraph 18 | 19 | #endif // __sot_core_entity_helper_H__ 20 | -------------------------------------------------------------------------------- /doc/additionalDoc/signal.h: -------------------------------------------------------------------------------- 1 | /** 2 | \page subp_signals Signals 3 | \section sec_sigintro Signals 4 | 5 | Entities can output different types of signals. To guarante real-time 6 | perforamces, signals are implemented using C++ and mecanism which have a low 7 | time foot-print. All signals are templated by a Time tick type parameter (which 8 | is used in the caching of signals) - usually \c int. Signals are also templated 9 | after the type of data they accept or provide. For example: (example) For a more 10 | detailed programmer-oriented description of signals, please see \ref signals 11 | */ 12 | -------------------------------------------------------------------------------- /include/dynamic-graph/all-commands.h: -------------------------------------------------------------------------------- 1 | // -*- mode: c++ -*- 2 | // Copyright 2010, François Bleibel, Olivier Stasse, JRL, CNRS/AIST 3 | // Thomas Moulard, Nicolas Mansard LAAS-CNRS 4 | // 5 | 6 | #ifndef DYNAMIC_GRAPH_ALL_COMMANDS_H 7 | #define DYNAMIC_GRAPH_ALL_COMMANDS_H 8 | 9 | // Utility header files including all commands headers 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | #endif //! DYNAMIC_GRAPH_ALL_COMMANDS_H 19 | -------------------------------------------------------------------------------- /doc/additionalDoc/references.h: -------------------------------------------------------------------------------- 1 | /** 2 | \page subp_references References 3 | 4 | \section sec_refer References 5 | Please when referencing the Stack-Of-Tasks use the following reference: 6 | 7 | \anchor Mansard2009 8 | 9 | 10 | "A versatile Generalized Inverted Kinematics implementation for collaborative 11 | working humanoid robots: The Stack Of Tasks" 12 | , 13 | N. Mansard, O. Stasse, P. Evrard, A. Kheddar, 14 | Int. Conf. on Autonomous Robots, ICAR, 2009 15 | 16 | \anchor Mansard2007 17 | 18 | "Task sequencing for sensor-based control", 19 | N. Mansard, F. Chaumette, 20 | IEEE Trans. on Robotics, 23(1):60-72, February 2007 21 | 22 | */ 23 | -------------------------------------------------------------------------------- /doc/additionalDoc/installation.h: -------------------------------------------------------------------------------- 1 | /** 2 | \page subp_installation Installation 3 | 4 | \section sec_inst_dep Dependencies 5 | 6 | dynamic-graph depends on: 7 |
    8 |
  • boost
  • 9 |
  • eigen
  • 10 |
  • cmake
  • 11 |
12 | 13 | \section sec_inst_get_src Getting the source 14 | 15 | The sources are available through github at the following URL: 16 | https://github.com/stack-of-tasks/dynamic-graph 18 | 19 | To clone: 20 | \code{.sh} 21 | git clone https://github.com/stack-of-tasks/dynamic-graph.git 22 | \endcode 23 | 24 | 25 | \section sec_inst_comp Compiling 26 | 27 | \code 28 | cd dynamic-graph 29 | mkdir _build 30 | cd _build 31 | cmake .. -DCMAKE_BUILD_TYPE=RELEASE 32 | make 33 | \endcode 34 | 35 | 36 | */ 37 | -------------------------------------------------------------------------------- /doc/additionalDoc/debug-doc.h: -------------------------------------------------------------------------------- 1 | /** 2 | \page debug Debugging 3 | 4 | They are several ways to perform debugging in dynamic-graph depending on your 5 | needs or situation: 6 | - Programmatically inside the entity in C++, a logger will 7 | write inside a buffer in a 8 | different thread and output in a stream (either std::cout or a file). It is 9 | detailed in \subpage subp_debug_rt_logger. 10 | It provides 4 levels of messags :(DEBUG,INFO, 11 | WARNING, ERROR). It is described in details here: \subpage subp_logger 12 | 13 | - Programmatically in C++ to avoid overhead with macros and handling level as an 14 | int: \subpage subp_dbg_trace . 15 | - If you just need to collect informations from signals (like rosbag). You can 16 | use an entity called Tracer inside the graph:\subpage tracerdoc .
A real 17 | time version exists to write directly inside a memory buffer 18 | \subpage tracerrealtimedoc 19 | **/ 20 | -------------------------------------------------------------------------------- /src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) 2 | 3 | set(plugins traces/tracer traces/tracer-real-time) 4 | 5 | set(tracer-real-time_deps tracer) 6 | 7 | foreach(plugin ${plugins}) 8 | get_filename_component(LIBRARY_NAME ${plugin} NAME) 9 | add_library(${LIBRARY_NAME} SHARED "${plugin}.cpp") 10 | 11 | if(SUFFIX_SO_VERSION) 12 | set_target_properties(${LIBRARY_NAME} PROPERTIES SOVERSION 13 | ${PROJECT_VERSION}) 14 | endif(SUFFIX_SO_VERSION) 15 | set_target_properties(${LIBRARY_NAME} PROPERTIES INSTALL_RPATH $ORIGIN) 16 | 17 | target_link_libraries(${LIBRARY_NAME} PUBLIC ${PROJECT_NAME} 18 | ${${LIBRARY_NAME}_deps}) 19 | 20 | install( 21 | TARGETS ${LIBRARY_NAME} 22 | EXPORT ${TARGETS_EXPORT_NAME} 23 | DESTINATION ${DYNAMIC_GRAPH_PLUGINDIR}) 24 | endforeach(plugin) 25 | -------------------------------------------------------------------------------- /include/dynamic-graph/real-time-logger.h: -------------------------------------------------------------------------------- 1 | // -*- mode: c++ -*- 2 | // Copyright 2018, Joseph Mirabel LAAS-CNRS 3 | // 4 | 5 | #ifndef DYNAMIC_GRAPH_LOGGER_REAL_TIME_H 6 | #define DYNAMIC_GRAPH_LOGGER_REAL_TIME_H 7 | 8 | #ifdef ENABLE_RT_LOG 9 | #define dgADD_OSTREAM_TO_RTLOG(ostr) \ 10 | ::dynamicgraph::RealTimeLogger::instance().addOutputStream( \ 11 | ::dynamicgraph::LoggerStreamPtr_t( \ 12 | new ::dynamicgraph::LoggerIOStream(ostr))) 13 | 14 | #define dgRTLOG() ::dynamicgraph::RealTimeLogger::instance().front() 15 | #else // ENABLE_RT_LOG 16 | #define dgADD_OSTREAM_TO_RTLOG(ostr) struct __end_with_semicolon 17 | #define dgRTLOG() \ 18 | if (1) \ 19 | ; \ 20 | else \ 21 | __null_stream() 22 | #endif 23 | 24 | #include 25 | 26 | #endif //! DYNAMIC_GRAPH_LOGGER_REAL_TIME_H 27 | -------------------------------------------------------------------------------- /tests/test-mt.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright 2019, LAAS-CNRS 2 | * 3 | * Olivier Stasse 4 | * 5 | */ 6 | #include 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #define BOOST_TEST_MODULE debug - trace 14 | 15 | #if BOOST_VERSION >= 105900 16 | #include 17 | #else 18 | #include 19 | #endif 20 | #include 21 | 22 | using boost::test_tools::output_test_stream; 23 | 24 | BOOST_AUTO_TEST_CASE(testMt) { 25 | dynamicgraph::CPU::System aSystem; 26 | 27 | // create and open a character archive for output 28 | std::ofstream ofs("cpu_state.dat"); 29 | boost::archive::text_oarchive oa(ofs); 30 | oa << aSystem; 31 | 32 | for (unsigned int i = 0; i < 10; i++) { 33 | usleep(100000); 34 | aSystem.readProcStat(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /include/dynamic-graph/command-getter.t.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2010 CNRS 3 | // 4 | // Author: Florent Lamiraux 5 | // 6 | 7 | #ifndef DYNAMIC_GRAPH_COMMAND_GETTER_T_CPP 8 | #define DYNAMIC_GRAPH_COMMAND_GETTER_T_CPP 9 | 10 | #include "dynamic-graph/command-getter.h" 11 | 12 | #include 13 | 14 | namespace dynamicgraph { 15 | class Entity; 16 | namespace command { 17 | 18 | template 19 | Getter::Getter(E &entity, GetterMethod getterMethod, 20 | const std::string &docstring) 21 | : Command(entity, std::vector(), docstring), 22 | getterMethod_(getterMethod) {} 23 | 24 | template 25 | Value Getter::doExecute() { 26 | E &entity = static_cast(owner()); 27 | T value = (entity.*getterMethod_)(); 28 | return Value(value); 29 | } 30 | } // namespace command 31 | } // namespace dynamicgraph 32 | 33 | #endif // DYNAMIC_GRAPH_COMMAND_GETTER_T_CPP 34 | -------------------------------------------------------------------------------- /doc/additionalDoc/graph.h: -------------------------------------------------------------------------------- 1 | /** 2 | \page p_graph Graph 3 | 4 | 5 | In this package, the graph considered are directed graphs. 6 | 7 | In dynamic-graph a graph is build with: 8 | - computational nodes which are entities \subpage subpage_entities. 9 | - directed edges which are created by connecting input and output signals 10 | \subpage subp_signals. 11 | - commands which are expanding the capabilities of the entity 12 | \subpage subpage_command 13 | - managing the nodes is done through a factory \subpage subp_factory providing 14 | classes and a way to create instances from this list of classes. 15 | - the instances of node are handled through a pool \subpage subp_pool 16 | 17 | We strongly recommend to use a scripting language such as Python to 18 | manage the graph. 19 | See dynamic-graph-python for more information on binding dynamic-graph 20 | with Python. 21 | 22 | It is possible to display the graph of entities \subpage writegraphdoc 23 | 24 | 25 | */ 26 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | ci: 2 | autoupdate_branch: 'devel' 3 | repos: 4 | - repo: https://github.com/pre-commit/mirrors-clang-format 5 | rev: v14.0.6 6 | hooks: 7 | - id: clang-format 8 | args: [--style=Google] 9 | - repo: https://github.com/pre-commit/pre-commit-hooks 10 | rev: v4.3.0 11 | hooks: 12 | - id: check-added-large-files 13 | - id: check-ast 14 | - id: check-executables-have-shebangs 15 | - id: check-json 16 | - id: check-merge-conflict 17 | - id: check-symlinks 18 | - id: check-toml 19 | - id: check-yaml 20 | - id: debug-statements 21 | - id: destroyed-symlinks 22 | - id: detect-private-key 23 | - id: end-of-file-fixer 24 | - id: fix-byte-order-marker 25 | - id: mixed-line-ending 26 | - id: trailing-whitespace 27 | - repo: https://github.com/cheshirekow/cmake-format-precommit 28 | rev: v0.6.13 29 | hooks: 30 | - id: cmake-format 31 | -------------------------------------------------------------------------------- /package.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | dynamic-graph 4 | 4.4.3 5 | 6 | Dynamic graph library 7 | 8 | Guilhem saurel 9 | BSD 10 | 11 | http://github.com/stack-of-tasks/dynamic-graph 12 | Nicolas Mansard 13 | Olivier Stasse 14 | 15 | git 16 | doxygen 17 | 18 | catkin 19 | ament_cmake 20 | eigen 21 | boost 22 | graphviz 23 | 24 | cmake 25 | 26 | 27 | cmake 28 | 29 | 30 | -------------------------------------------------------------------------------- /doc/additionalDoc/writeGraph.h: -------------------------------------------------------------------------------- 1 | /** 2 | \page writegraphdoc Displaying the graph of entities 3 | \section description Description 4 | It is possible to view the graph of entities currently instanciated. 5 | The format used by dynamic-graph is dot. 6 | Using the python interpreter the following command 7 | \code 8 | from dynamic_graph import * 9 | writeGraph('/tmp/my_dynamic_graph.dot') 10 | \endcode 11 | is writing the my_dynamic_graph.dot in the /tmp directory 12 | 13 | \section fromdottopdf Viewing as a PDF file 14 | To view the dot file you can simply use: 15 | \code 16 | dot -Tpdf /tmp/my_dynamic_graph.dot > /tmp/my_dynamic_graph.pdf 17 | \endcode 18 | 19 | It provides the following output: 20 | \image html my_dynamic_graph.png 21 | 22 | \section fromdottojs Viewing in a browser 23 | To view the dot file you can simply use the view_sot_dg.html file. 24 | Click on the "Choose File" to specify the filem and click on "Rendering" to 25 | display the graph. 26 | 27 | */ 28 | -------------------------------------------------------------------------------- /doc/additionalDoc/tracer-real-timedoc.h: -------------------------------------------------------------------------------- 1 | /** 2 | \page tracerrealtimedoc TracerRealTime 3 | 4 | \section tracerrealtimedoc_description Description 5 | The \b TracerRealTime entity monitors a set of signals with real-time 6 | constraints; its function is very similar to the Tracer, except that all traces 7 | are recorded to a memory buffer, which can be emptied at any time. 8 | 9 | \section tracerrealtimedoc_commands Commands 10 | The \b commands that this entity exposes are: 11 | \code 12 | empty (discards all buffers) 13 | getBufferSize (gets buffer size for recording) 14 | setBufferSize (sets buffer size for recording) 15 | \endcode 16 | Plus all the commands exposed by \ref tracerdoc 17 | \n 18 | For more information on the signals exposed by this entity, please check the 19 | code documentation of the dynamicgraph::Tracer class. 20 | 21 | \section tracerrealtimedoc_sample Sample usage 22 | See \ref tracerdoc for a code sample of using TracerRealTime. 23 | 24 | \section tracerrealtimedoc_addi Additional information 25 | See doxygen documentation for the class dynamicgraph::TracerRealTime 26 | 27 | \section tracerrealtimedoc_generates Generated plugin file 28 | tracer-real-time.dll or tracer-real-time.so. 29 | */ 30 | -------------------------------------------------------------------------------- /.git-blame-ignore-revs: -------------------------------------------------------------------------------- 1 | # pre-commit run -a (Guilhem Saurel, 2022-07-27) 2 | e9a222fb0a1f236e534e21c66cb623fd8d25b8d6 3 | 4 | # pre-commit: details (Guilhem Saurel, 2022-04-14) 5 | 1c0f3cc1048a8b2a8206510a51a237b2f1e68a34 6 | 7 | # pre-commit run -a (Guilhem Saurel, 2022-03-30) 8 | 0c1e6fb50735d4d6cc93e15d3bef202392d47c5b 9 | 10 | # clang format defaults + pre-commit (Guilhem Saurel, 2022-03-30) 11 | b6fc5d81e645a84fa8f4d656371adfb27c2b2b23 12 | 13 | # [value] Clang format. (Olivier Stasse, 2022-01-09) 14 | b852eef0d56de04ae91a43b1ddbd837ec69ddbe6 15 | 16 | # linters: fix clang-check-12 (Guilhem Saurel, 2021-09-14) 17 | ca1b2fc51540b4fcb2cd0b4fccaa33b02738af41 18 | 19 | # reformat for clang-format-12 (Guilhem Saurel, 2021-09-07) 20 | ed5899076b7b11c16d9517295e3826dd9b9d80d2 21 | 22 | # format (Guilhem Saurel, 2020-11-13) 23 | c54add29f80f6bcd1d05ca741d472491cf74c180 24 | 25 | # format (Guilhem Saurel, 2020-07-22) 26 | f4def3bfeaf0f9c9a6d5c5eb01c3a3b2fbb04b2f 27 | 28 | # clang format. (Olivier Stasse, 2020-02-03) 29 | 70864112c87365af645f0404f881edf36c1ec734 30 | 31 | # [clang] Update format. (Olivier Stasse, 2019-08-26) 32 | 384b2078e4962d762db4293bf3396be17df4e5c7 33 | 34 | # [clang-format] Comply to Google style. (Olivier Stasse, 2019-08-20) 35 | df48199dd436ba8341ae93c7b1f87eb30d0f457a 36 | -------------------------------------------------------------------------------- /include/dynamic-graph/exception-traces.h: -------------------------------------------------------------------------------- 1 | // -*- mode: c++ -*- 2 | // Copyright 2010, François Bleibel, Thomas Moulard, Olivier Stasse, 3 | // JRL, CNRS/AIST. 4 | // 5 | 6 | #ifndef DYNAMIC_GRAPH_EXCEPTION_TRACES_H 7 | #define DYNAMIC_GRAPH_EXCEPTION_TRACES_H 8 | #include 9 | #include 10 | 11 | #include 12 | #include 13 | 14 | namespace dynamicgraph { 15 | /// \ingroup error 16 | /// 17 | /// \brief Exceptions raised when an error related to traces happen. 18 | class DYNAMIC_GRAPH_DLLAPI ExceptionTraces : public ExceptionAbstract { 19 | public: 20 | enum ErrorCodeEnum { GENERIC = ExceptionAbstract::TRACES, NOT_OPEN }; 21 | 22 | static const std::string EXCEPTION_NAME; 23 | 24 | explicit ExceptionTraces(const ExceptionTraces::ErrorCodeEnum &errcode, 25 | const std::string &msg = ""); 26 | ExceptionTraces(const ExceptionTraces::ErrorCodeEnum &errcode, 27 | const std::string &msg, const char *format, ...); 28 | virtual ~ExceptionTraces() throw() {} 29 | 30 | virtual const std::string &getExceptionName() const { return EXCEPTION_NAME; } 31 | }; 32 | } // end of namespace dynamicgraph. 33 | 34 | #endif //! DYNAMIC_GRAPH_EXCEPTION_TRACES_H 35 | -------------------------------------------------------------------------------- /doc/additionalDoc/debug-logger.h: -------------------------------------------------------------------------------- 1 | /** 2 | \page subp_logger Loggers 3 | 4 | \section sec_init_rt_logger Initialization of the logger 5 | 6 | \subsection subsec_init_rt_logger_hcpp Header and preprocessor variable 7 | 8 | In order to activate the logger you need to add the following lines: 9 | \code 10 | #define ENABLE_RT_LOG 11 | #include 12 | #include 13 | \endcode 14 | 15 | \subsection subsec_logger_ Initialize the output stream 16 | 17 | It is possible to set the output stream of the messages inside a file: 18 | \code 19 | dynamicgraph::RealTimeLogger::instance(); 20 | of.open("/tmp/dg-LOGS.txt",std::ofstream::out|std::ofstream::app); 21 | dgADD_OSTREAM_TO_RTLOG (of); 22 | 23 | dynamicgraph::RealTimeLogger::destroy(); 24 | \endcode 25 | 26 | \section sec_use_rt_logger Using the rt_logger 27 | 28 | 29 | \code 30 | // Somewhere in your library 31 | dgRTLOG() << "your message. Prefer to use \n than std::endl." 32 | \endcode 33 | 34 | 35 | Here the output file is "/tmp/dg-LOGS.txt". 36 | 37 | 38 | Specifying the file with __FILE__ and the line inside the file by __LINE__ are 39 | necessary for the STREAM messages. Indeed they are indexed using the two values. 40 | The default values "" and 0 for the counting are not well understood. 41 | */ 42 | -------------------------------------------------------------------------------- /src/exception/exception-traces.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010, 3 | * François Bleibel, 4 | * Olivier Stasse, 5 | * 6 | * CNRS/AIST 7 | * 8 | */ 9 | 10 | #include 11 | #include 12 | 13 | #include 14 | 15 | using namespace dynamicgraph; 16 | /* --------------------------------------------------------------------- */ 17 | /* --- CLASS ----------------------------------------------------------- */ 18 | /* --------------------------------------------------------------------- */ 19 | 20 | const std::string ExceptionTraces::EXCEPTION_NAME = "Traces"; 21 | 22 | ExceptionTraces::ExceptionTraces(const ExceptionTraces::ErrorCodeEnum &errcode, 23 | const std::string &msg) 24 | : ExceptionAbstract(errcode, msg) {} 25 | 26 | ExceptionTraces::ExceptionTraces(const ExceptionTraces::ErrorCodeEnum &errcode, 27 | const std::string &msg, const char *format, 28 | ...) 29 | : ExceptionAbstract(errcode, msg) { 30 | va_list args; 31 | va_start(args, format); 32 | 33 | const unsigned int SIZE = 256; 34 | char buffer[SIZE]; 35 | vsnprintf(buffer, SIZE, format, args); 36 | 37 | message += buffer; 38 | 39 | va_end(args); 40 | } 41 | 42 | /* 43 | * Local variables: 44 | * c-basic-offset: 2 45 | * End: 46 | */ 47 | -------------------------------------------------------------------------------- /src/exception/exception-signal.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010, 3 | * François Bleibel, 4 | * Olivier Stasse, 5 | * 6 | * CNRS/AIST 7 | * 8 | */ 9 | 10 | #include 11 | #include 12 | 13 | #include 14 | 15 | using namespace dynamicgraph; 16 | 17 | /* --------------------------------------------------------------------- */ 18 | /* --- CLASS ----------------------------------------------------------- */ 19 | /* --------------------------------------------------------------------- */ 20 | 21 | const std::string ExceptionSignal::EXCEPTION_NAME = "Signal"; 22 | 23 | ExceptionSignal::ExceptionSignal(const ExceptionSignal::ErrorCodeEnum &errcode, 24 | const std::string &msg) 25 | : ExceptionAbstract(errcode, msg) {} 26 | 27 | ExceptionSignal::ExceptionSignal(const ExceptionSignal::ErrorCodeEnum &errcode, 28 | const std::string &msg, const char *format, 29 | ...) 30 | : ExceptionAbstract(errcode, msg) { 31 | va_list args; 32 | va_start(args, format); 33 | 34 | const unsigned int SIZE = 256; 35 | char buffer[SIZE]; 36 | vsnprintf(buffer, SIZE, format, args); 37 | 38 | message += buffer; 39 | 40 | va_end(args); 41 | } 42 | 43 | /* 44 | * Local variables: 45 | * c-basic-offset: 2 46 | * End: 47 | */ 48 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | BSD 2-Clause License 2 | 3 | Copyright (c) 2019, CNRS 4 | Author: Stack of Tasks Development Team 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | * Redistributions of source code must retain the above copyright notice, this 11 | list of conditions and the following disclaimer. 12 | 13 | * Redistributions in binary form must reproduce the above copyright notice, 14 | this list of conditions and the following disclaimer in the documentation 15 | and/or other materials provided with the distribution. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 21 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 23 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 24 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 25 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | -------------------------------------------------------------------------------- /include/dynamic-graph/exception-signal.h: -------------------------------------------------------------------------------- 1 | // -*- mode: c++ -*- 2 | // Copyright 2010, François Bleibel, Thomas Moulard, Olivier Stasse, 3 | // JRL, CNRS/AIST. 4 | // 5 | 6 | #ifndef DYNAMIC_GRAPH_EXCEPTION_SIGNAL_H 7 | #define DYNAMIC_GRAPH_EXCEPTION_SIGNAL_H 8 | 9 | #include 10 | #include 11 | 12 | #include 13 | 14 | namespace dynamicgraph { 15 | /// \ingroup error 16 | /// 17 | /// \brief Exceptions raised when an error related to signals 18 | /// happen. 19 | class DYNAMIC_GRAPH_DLLAPI ExceptionSignal : public ExceptionAbstract { 20 | public: 21 | enum ErrorCodeEnum { 22 | GENERIC = ExceptionAbstract::SIGNAL, 23 | READWRITE_LOCK, 24 | COPY_NOT_INITIALIZED, 25 | NOT_INITIALIZED, 26 | PLUG_IMPOSSIBLE, 27 | SET_IMPOSSIBLE, 28 | BAD_CAST 29 | }; 30 | 31 | static const std::string EXCEPTION_NAME; 32 | 33 | explicit ExceptionSignal(const ExceptionSignal::ErrorCodeEnum &errcode, 34 | const std::string &msg = ""); 35 | ExceptionSignal(const ExceptionSignal::ErrorCodeEnum &errcode, 36 | const std::string &msg, const char *format, ...); 37 | virtual ~ExceptionSignal() throw() {} 38 | 39 | virtual const std::string &getExceptionName() const { return EXCEPTION_NAME; } 40 | }; 41 | 42 | } // end of namespace dynamicgraph 43 | 44 | #endif //! DYNAMIC_GRAPH_EXCEPTION_SIGNAL_H 45 | -------------------------------------------------------------------------------- /include/dynamic-graph/exception-factory.h: -------------------------------------------------------------------------------- 1 | // -*- mode: c++ -*- 2 | // Copyright 2010, François Bleibel, Thomas Moulard, Olivier Stasse, 3 | // JRL, CNRS/AIST. 4 | // 5 | 6 | #ifndef DYNAMIC_GRAPH_EXCEPTION_FACTORY_H 7 | #define DYNAMIC_GRAPH_EXCEPTION_FACTORY_H 8 | #include 9 | #include 10 | 11 | #include 12 | #include 13 | 14 | namespace dynamicgraph { 15 | /// \ingroup error 16 | /// 17 | /// \brief Generic error class. 18 | class DYNAMIC_GRAPH_DLLAPI ExceptionFactory : public ExceptionAbstract { 19 | public: 20 | enum ErrorCodeEnum { 21 | GENERIC = ExceptionAbstract::FACTORY, 22 | UNREFERED_OBJECT, 23 | UNREFERED_SIGNAL, 24 | UNREFERED_FUNCTION, 25 | DYNAMIC_LOADING, 26 | SIGNAL_CONFLICT, 27 | FUNCTION_CONFLICT, 28 | OBJECT_CONFLICT, 29 | SYNTAX_ERROR, 30 | READ_FILE 31 | }; 32 | 33 | static const std::string EXCEPTION_NAME; 34 | 35 | explicit ExceptionFactory(const ExceptionFactory::ErrorCodeEnum &errcode, 36 | const std::string &msg = ""); 37 | 38 | ExceptionFactory(const ExceptionFactory::ErrorCodeEnum &errcode, 39 | const std::string &msg, const char *format, ...); 40 | 41 | virtual ~ExceptionFactory() throw() {} 42 | 43 | virtual const std::string &getExceptionName() const { 44 | return ExceptionFactory::EXCEPTION_NAME; 45 | } 46 | }; 47 | } // end of namespace dynamicgraph 48 | 49 | #endif //! DYNAMIC_GRAPH_EXCEPTION_FACTORY_H 50 | -------------------------------------------------------------------------------- /include/dynamic-graph/fwd.hh: -------------------------------------------------------------------------------- 1 | // Copyright 2010-2019, CNRS, JRL, AIST, LAAS 2 | // Thomas Moulard, Olivier Stasse 3 | // 4 | 5 | #ifndef DYNAMIC_GRAPH_FWD_HH 6 | #define DYNAMIC_GRAPH_FWD_HH 7 | 8 | #include 9 | 10 | namespace dynamicgraph { 11 | 12 | // to be replace by std:: when we switch to C++11 and later 13 | using boost::const_pointer_cast; 14 | using boost::dynamic_pointer_cast; 15 | using boost::make_shared; 16 | using boost::shared_ptr; 17 | using boost::static_pointer_cast; 18 | using boost::weak_ptr; 19 | 20 | class DebugTrace; 21 | 22 | class PluginRefMap; 23 | class Entity; 24 | class EntityRegisterer; 25 | class ExceptionAbstract; 26 | class ExceptionFactory; 27 | class ExceptionSignal; 28 | class ExceptionTraces; 29 | class FactoryStorage; 30 | class Interpreter; 31 | typedef shared_ptr InterpreterShPtr_t; 32 | class InterpreterHelper; 33 | class Logger; 34 | class OutStringStream; 35 | class PluginLoader; 36 | class PoolStorage; 37 | 38 | class Tracer; 39 | class TracerRealTime; 40 | 41 | template 42 | class Signal; 43 | 44 | template 45 | class SignalArray; 46 | 47 | template 48 | class SignalArray_const; 49 | 50 | template 51 | class SignalBase; 52 | 53 | template 54 | class SignalPtr; 55 | template 56 | class SignalTimeDependent; 57 | template 58 | class TimeDependency; 59 | 60 | namespace command { 61 | class Command; 62 | } // end of namespace command. 63 | 64 | } // end of namespace dynamicgraph. 65 | 66 | #endif //! DYNAMIC_GRAPH_FWD_HH 67 | -------------------------------------------------------------------------------- /doc/additionalDoc/tracerdoc.h: -------------------------------------------------------------------------------- 1 | /** 2 | \page tracerdoc Tracer 3 | \section tracerdoc_description Description 4 | The \b Tracer entity monitors a set of signals. With an input change on the 5 | entity's [trigger] signal, the tracked signal values are recorded and traced to 6 | a file. The behavior of the trace-to-file function can be changed, from printing 7 | to a file immediately after recording, to printing out only when asked 8 | explicitly. 9 | 10 | \section tracerdoc_commands Commands 11 | The \b commands that this entity exposes are: 12 | \code 13 | open, close (a file); 14 | add (a signal) 15 | clear (recorded values); 16 | record (signal values) 17 | trace (doesn't do anything) 18 | start, stop (traces) 19 | \endcode 20 | \n 21 | For more information on the signals exposed by this entity, please check the 22 | code documentation of the dynamicgraph::Tracer class. 23 | \n\n 24 | 25 | \section tracerdoc_sample Sample usage 26 | The following code creates a TracerRealTime entity and sets the tracing buffer 27 | size to 80MB. It then tells the tracer to create files with names of the form: 28 | /tmp/dg_XXX.dat where XXX is the signal name, and call the signal 29 | after the device has evaluated the control law: 30 | \code 31 | robot.tracer = TracerRealTime("com_tracer") 32 | robot.tracer.setBufferSize(80*(2**20)) 33 | robot.tracer.open('/tmp','dg_','.dat') 34 | robot.device.after.addSignal('{0}.triger'.format(robot.tracer.name)) 35 | \endcode 36 | 37 | \section tracerdoc_addi Additional information 38 | See doxygen documentation for the class dynamicgraph::Tracer 39 | 40 | \section tracerdoc_generates Generated plugin file 41 | tracer.dll or tracer.so. 42 | */ 43 | -------------------------------------------------------------------------------- /src/debug/debug.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010, 3 | * François Bleibel, 4 | * Olivier Stasse, 5 | * 6 | * CNRS/AIST 7 | * 8 | */ 9 | 10 | #include 11 | 12 | #include 13 | #include 14 | 15 | using namespace dynamicgraph; 16 | 17 | #ifdef WIN32 18 | const char *DebugTrace::DEBUG_FILENAME_DEFAULT = 19 | "c:/tmp/dynamic-graph-traces.txt"; 20 | #else /*WIN32*/ 21 | const char *DebugTrace::DEBUG_FILENAME_DEFAULT = 22 | "/tmp/dynamic-graph-traces.txt"; 23 | #endif /*WIN32*/ 24 | 25 | #ifdef VP_DEBUG 26 | #ifdef WIN32 27 | std::ofstream dg_debugfile("C:/tmp/dynamic-graph-traces.txt", 28 | std::ios::trunc &std::ios::out); 29 | #else /*WIN32*/ 30 | std::ofstream dg_debugfile("/tmp/dynamic-graph-traces.txt", 31 | std::ios::trunc &std::ios::out); 32 | #endif /*WIN32*/ 33 | #else 34 | std::ofstream dg_debugfile; 35 | class dgDebug_init { 36 | public: 37 | dgDebug_init() { dg_debugfile.setstate(std::ios::failbit); } 38 | }; 39 | dgDebug_init dgDebug_initialisator; 40 | 41 | #endif 42 | 43 | namespace dynamicgraph { 44 | DebugTrace dgDEBUGFLOW(dg_debugfile); 45 | DebugTrace dgERRORFLOW(dg_debugfile); 46 | } // namespace dynamicgraph 47 | 48 | void DebugTrace::openFile(const char *filename) { 49 | if (dg_debugfile.good() && dg_debugfile.is_open()) dg_debugfile.close(); 50 | dg_debugfile.clear(); 51 | dg_debugfile.open(filename, std::ios::trunc & std::ios::out); 52 | } 53 | 54 | void DebugTrace::closeFile(const char *) { 55 | if (dg_debugfile.good() && dg_debugfile.is_open()) { 56 | dg_debugfile.close(); 57 | } 58 | dg_debugfile.setstate(std::ios::failbit); 59 | } 60 | -------------------------------------------------------------------------------- /.mailmap: -------------------------------------------------------------------------------- 1 | # 2 | # This list is used by git-shortlog to fix a few botched name translations 3 | # in the git archive, either because the author's full name was messed up 4 | # and/or not always written the same way, making contributions from the 5 | # same person appearing not to be so or badly displayed. 6 | 7 | Anthony Mallet 8 | 9 | Olivier Stasse 10 | Olivier Stasse 11 | Olivier Stasse 12 | Olivier Stasse 13 | Olivier Stasse 14 | Olivier Stasse 15 | Olivier Stasse 16 | Olivier Stasse 17 | Olivier Stasse 18 | Olivier Stasse 19 | Olivier Stasse 20 | Olivier Stasse 21 | Olivier Stasse 22 | 23 | 24 | Nicolas Mansard 25 | Nicolas Mansard 26 | Nicolas Mansard 27 | 28 | 29 | Florent Lamiraux 30 | Florent Lamiraux 31 | Florent Lamiraux 32 | Florent Lamiraux 33 | Florent Lamiraux 34 | Florent Lamiraux 35 | Florent Lamiraux 36 | Florent Lamiraux 37 | Florent Lamiraux 38 | Florent Lamiraux 39 | Florent Lamiraux 40 | -------------------------------------------------------------------------------- /src/exception/exception-factory.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010, 3 | * François Bleibel, 4 | * Olivier Stasse, 5 | * 6 | * CNRS/AIST 7 | * 8 | */ 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | #include 15 | 16 | using namespace dynamicgraph; 17 | 18 | /* --------------------------------------------------------------------- */ 19 | /* --- CLASS ----------------------------------------------------------- */ 20 | /* --------------------------------------------------------------------- */ 21 | 22 | const std::string ExceptionFactory::EXCEPTION_NAME = "Factory"; 23 | 24 | ExceptionFactory::ExceptionFactory( 25 | const ExceptionFactory::ErrorCodeEnum &errcode, const std::string &msg) 26 | : ExceptionAbstract(errcode, msg) { 27 | dgDEBUGF(15, "Created with message <%s>.", msg.c_str()); 28 | dgDEBUG(1) << "Created with message <%s>." << msg << std::endl; 29 | } 30 | 31 | ExceptionFactory::ExceptionFactory( 32 | const ExceptionFactory::ErrorCodeEnum &errcode, const std::string &msg, 33 | const char *format, ...) 34 | : ExceptionAbstract(errcode, msg) { 35 | va_list args; 36 | va_start(args, format); 37 | 38 | const unsigned int SIZE = 256; 39 | char buffer[SIZE]; 40 | vsnprintf(buffer, SIZE, format, args); 41 | 42 | dgDEBUG(15) << "Created " 43 | << " with message <" << msg << "> and buffer <" << buffer << ">. " 44 | << std::endl; 45 | 46 | message += buffer; 47 | 48 | va_end(args); 49 | 50 | dgDEBUG(1) << "Throw exception " << EXCEPTION_NAME << "[#" << errcode << "]: " 51 | << "<" << message << ">." << std::endl; 52 | } 53 | 54 | /* 55 | * Local variables: 56 | * c-basic-offset: 2 57 | * End: 58 | */ 59 | -------------------------------------------------------------------------------- /js/view_sot_dg.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 40 | 41 | 42 | 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2010-2020, Olivier Stasse, Guilhem Saurel, JRL, CNRS/AIST, LAAS-CNRS 2 | 3 | add_definitions(-DBOOST_TEST_DYN_LINK -DBOOST_TEST_MAIN) 4 | 5 | add_definitions(-DTESTS_DATADIR="${CMAKE_CURRENT_SOURCE_DIR}/data") 6 | add_definitions(-DTESTS_PLUGINDIR="${LIBRARY_OUTPUT_PATH}") 7 | add_definitions(-DTESTS_DYNLIBSUFFIX="${CMAKE_SHARED_LIBRARY_SUFFIX}") 8 | 9 | macro(DYNAMIC_GRAPH_TEST NAME) 10 | add_unit_test(${NAME} "${NAME}.cpp") 11 | target_link_libraries(${NAME} PRIVATE ${PROJECT_NAME} 12 | Boost::unit_test_framework) 13 | endmacro(DYNAMIC_GRAPH_TEST) 14 | 15 | # Signal cast test. 16 | set(signalcast_libs signal-cast-registerer-libA signal-cast-registerer-libB) 17 | 18 | foreach(lib ${signalcast_libs}) 19 | add_library(${lib} SHARED "${lib}.cpp") 20 | target_link_libraries(${lib} PRIVATE ${PROJECT_NAME}) 21 | endforeach() 22 | 23 | dynamic_graph_test(signal-cast-registerer) 24 | 25 | # Unit testing. 26 | if(NOT APPLE) 27 | dynamic_graph_test(entity) 28 | endif(NOT APPLE) 29 | dynamic_graph_test(custom-entity) 30 | dynamic_graph_test(factory) 31 | dynamic_graph_test(pool) 32 | dynamic_graph_test(signal-time-dependent) 33 | dynamic_graph_test(value) 34 | dynamic_graph_test(signal-ptr) 35 | dynamic_graph_test(real-time-logger) 36 | dynamic_graph_test(debug-trace) 37 | dynamic_graph_test(debug-tracer) 38 | target_link_libraries(debug-tracer PRIVATE tracer) 39 | dynamic_graph_test(debug-real-time-tracer) 40 | target_link_libraries(debug-real-time-tracer PRIVATE tracer-real-time tracer) 41 | dynamic_graph_test(debug-logger) 42 | dynamic_graph_test(debug-logger-winit) 43 | dynamic_graph_test(signal-all) 44 | dynamic_graph_test(command-test) 45 | dynamic_graph_test(test-mt) 46 | target_link_libraries(test-mt PRIVATE tracer) 47 | dynamic_graph_test(exceptions) 48 | -------------------------------------------------------------------------------- /include/dynamic-graph/command-getter.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2010 CNRS 3 | // 4 | // Author: Florent Lamiraux 5 | // 6 | 7 | #ifndef DYNAMIC_GRAPH_COMMAND_GETTER_H 8 | #define DYNAMIC_GRAPH_COMMAND_GETTER_H 9 | 10 | #include "dynamic-graph/command.h" 11 | 12 | namespace dynamicgraph { 13 | namespace command { 14 | 15 | /// 16 | /// Command that calls a parameter getter function 17 | /// 18 | /// This class is templated by a type E deriving from entity and 19 | /// a type T of data. 20 | /// 21 | /// Let us assume that class E has a private member of type T and a 22 | /// public getter function for this member: 23 | /// \code 24 | /// class E : public Entity 25 | /// { 26 | /// public: 27 | /// E (const std::string& inName) : Entity(inName) {} 28 | /// T getParameter() const {return parameter_;} 29 | /// private: 30 | /// T parameter_; 31 | /// }; 32 | /// \endcode 33 | /// Then the command defined by: 34 | /// \code 35 | /// E entity("MyEntity"); 36 | /// Getter command(entity, &E::getParameter) 37 | /// \endcode 38 | /// returns the value of entity.parameter_ upon invocation. 39 | /// 40 | /// \note 41 | /// \li T should be a type supported by class Value, 42 | /// \li prototype of E::getParameter should be exactly as specified in this 43 | /// example. 44 | template 45 | class Getter : public Command { 46 | public: 47 | /// Pointer to method that sets parameter of type T 48 | typedef T (E::*GetterMethod)() const; 49 | /// Constructor 50 | Getter(E &entity, GetterMethod getterMethod, const std::string &docString); 51 | 52 | protected: 53 | virtual Value doExecute(); 54 | 55 | private: 56 | GetterMethod getterMethod_; 57 | }; 58 | } // namespace command 59 | } // namespace dynamicgraph 60 | 61 | #include "dynamic-graph/command-getter.t.cpp" 62 | #endif // DYNAMIC_GRAPH_COMMAND_GETTER_H 63 | -------------------------------------------------------------------------------- /include/dynamic-graph/command-setter.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2010 CNRS 3 | // 4 | // Author: Florent Lamiraux 5 | // 6 | 7 | #ifndef DYNAMIC_GRAPH_COMMAND_SETTER_H 8 | #define DYNAMIC_GRAPH_COMMAND_SETTER_H 9 | 10 | #include "dynamic-graph/command.h" 11 | 12 | namespace dynamicgraph { 13 | namespace command { 14 | 15 | /// 16 | /// Command that calls a parameter setter function 17 | /// 18 | /// This class is templated by a type E deriving from entity and 19 | /// a type T of data. 20 | /// 21 | /// Let us assume that class E has a private member of type T and a 22 | /// public setter function for this member: 23 | /// \code 24 | /// class E : public Entity 25 | /// { 26 | /// public: 27 | /// E (const std::string& inName) : Entity(inName) {} 28 | /// void setParameter(const T& parameter) {parameter_ = parameter;} 29 | /// private: 30 | /// T parameter_; 31 | /// }; 32 | /// \endcode 33 | /// Then the command defined by: 34 | /// \code 35 | /// E entity("MyEntity"); 36 | /// Setter command(entity, &E::getParameter) 37 | /// \endcode 38 | /// sets the value of entity.parameter_ upon invocation. 39 | /// 40 | /// \note 41 | /// \li T should be a type supported by class Value, 42 | /// \li prototype of E::setParameter should be exactly as specified in this 43 | /// example. 44 | template 45 | class Setter : public Command { 46 | public: 47 | /// Pointer to method that sets parameter of type T 48 | typedef void (E::*SetterMethod)(const T &); 49 | /// Constructor 50 | Setter(E &entity, SetterMethod setterMethod, const std::string &docString); 51 | 52 | protected: 53 | virtual Value doExecute(); 54 | 55 | private: 56 | SetterMethod setterMethod_; 57 | }; 58 | } // namespace command 59 | } // namespace dynamicgraph 60 | 61 | #include "dynamic-graph/command-setter.t.cpp" 62 | #endif // DYNAMIC_GRAPH_COMMAND_SETTER_H 63 | -------------------------------------------------------------------------------- /include/dynamic-graph/command-direct-getter.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2010 CNRS 3 | // 4 | // Author: Nicolas Mansard 5 | // 6 | 7 | #ifndef __dg_command_direct_getter_h__ 8 | #define __dg_command_direct_getter_h__ 9 | 10 | /* Define a getter command directly on the attribute (no need to pass by 11 | * an explicit function). A typical use is given here: 12 | * addCommand("getSize", 13 | * makeDirectGetter(*this,&_dimension, 14 | * docDirectGetter("dimension","int"))); 15 | * 16 | */ 17 | 18 | #include 19 | 20 | #include "dynamic-graph/command.h" 21 | 22 | /* --- GETTER --------------------------------------------------------- */ 23 | namespace dynamicgraph { 24 | namespace command { 25 | 26 | template 27 | class DirectGetter : public Command { 28 | public: 29 | /// Pointer to method that sets parameter of type T 30 | typedef T (E::*GetterMethod)() const; 31 | 32 | /// Constructor 33 | DirectGetter(E &entity, T *ptr, const std::string &docString) 34 | : Command(entity, std::vector(), docString), T_ptr(ptr) {} 35 | 36 | protected: 37 | virtual Value doExecute() { return Value(*T_ptr); } 38 | 39 | private: 40 | T *T_ptr; 41 | }; 42 | 43 | template 44 | DirectGetter *makeDirectGetter(E &entity, T *ptr, 45 | const std::string &docString) { 46 | return new DirectGetter(entity, ptr, docString); 47 | } 48 | 49 | inline std::string docDirectGetter(const std::string &name, 50 | const std::string &type) { 51 | return std::string("\nGet the ") + name + ".\n\nNo input.\nReturn an " + 52 | type + ".\n\n"; 53 | } 54 | 55 | } // namespace command 56 | } // namespace dynamicgraph 57 | 58 | #endif // __dg_command_direct_getter_h__ 59 | -------------------------------------------------------------------------------- /include/dynamic-graph/command-direct-setter.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2010 CNRS 3 | // 4 | // Author: Nicolas Mansard 5 | // 6 | 7 | #ifndef __dg_command_direct_setter_h__ 8 | #define __dg_command_direct_setter_h__ 9 | 10 | /* Define a setter command directly on the attribute (no need to pass by 11 | * an explicit function). A typical use is given here: 12 | * addCommand("setSize", 13 | * makeDirectSetter(*this,&_dimension, 14 | * docDirectSetter("dimension","int"))); 15 | * 16 | */ 17 | 18 | #include 19 | 20 | #include "dynamic-graph/command.h" 21 | 22 | /* --- SETTER --------------------------------------------------------- */ 23 | namespace dynamicgraph { 24 | namespace command { 25 | 26 | template 27 | class DirectSetter : public Command { 28 | public: 29 | DirectSetter(E &entity, T *ptr, const std::string &docString) 30 | : Command(entity, boost::assign::list_of(ValueHelper::TypeID), 31 | docString), 32 | T_ptr(ptr) {} 33 | 34 | protected: 35 | virtual Value doExecute() { 36 | const std::vector &values = getParameterValues(); 37 | T val = values[0].value(); 38 | (*T_ptr) = val; 39 | return Value(); // void 40 | } 41 | 42 | private: 43 | T *T_ptr; 44 | }; 45 | 46 | template 47 | DirectSetter *makeDirectSetter(E &entity, T *ptr, 48 | const std::string &docString) { 49 | return new DirectSetter(entity, ptr, docString); 50 | } 51 | 52 | inline std::string docDirectSetter(const std::string &name, 53 | const std::string &type) { 54 | return std::string("\nSet the ") + name + ".\n\nInput:\n - a " + type + 55 | ".\nVoid return.\n\n"; 56 | } 57 | 58 | } // namespace command 59 | } // namespace dynamicgraph 60 | 61 | #endif // __dg_command_direct_setter_h__ 62 | -------------------------------------------------------------------------------- /src/exception/exception-abstract.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2010, François Bleibel, Thomas Moulard, Olivier Stasse, 2 | // JRL, CNRS/AIST. 3 | // 4 | 5 | #include 6 | #include 7 | 8 | #include 9 | 10 | namespace dynamicgraph { 11 | const std::string ExceptionAbstract::EXCEPTION_NAME = "Abstract"; 12 | 13 | ExceptionAbstract::ExceptionAbstract(const int &_code, const std::string &_msg) 14 | : code(_code), message(_msg) {} 15 | 16 | const char *ExceptionAbstract::getMessage() const { 17 | return (this->message).c_str(); 18 | } 19 | 20 | const std::string &ExceptionAbstract::getStringMessage() const { 21 | return this->message; 22 | } 23 | 24 | int ExceptionAbstract::getCode() const { return this->code; } 25 | 26 | ExceptionAbstract::Param &ExceptionAbstract::Param::initCopy(const Param &p) { 27 | if (&p == this) return *this; 28 | 29 | dgDEBUGIN(25); 30 | if (p.pointersSet) { 31 | strncpy(function, p.functionPTR, BUFFER_SIZE); 32 | strncpy(file, p.filePTR, BUFFER_SIZE); 33 | line = p.line; 34 | pointersSet = false; 35 | set = true; 36 | } else 37 | set = false; 38 | dgDEBUGOUT(25); 39 | return *this; 40 | } 41 | 42 | ExceptionAbstract::Param::Param(const int &_line, const char *_function, 43 | const char *_file) 44 | : functionPTR(_function), line(_line), filePTR(_file), pointersSet(true) { 45 | dgDEBUGINOUT(25); 46 | } 47 | 48 | std::ostream &operator<<(std::ostream &os, const ExceptionAbstract &error) { 49 | os << error.getExceptionName() << "Error [#" << error.code 50 | << "]: " << error.message << std::endl; 51 | 52 | #ifdef DYNAMICGRAPH_EXCEPTION_PASSING_PARAM 53 | if (error.p.set) 54 | os << "Thrown from " << error.p.file << ": " << error.p.function << " (#" 55 | << error.p.line << ")" << std::endl; 56 | #endif // DYNAMICGRAPH_EXCEPTION_PASSING_PARAM 57 | 58 | return os; 59 | } 60 | 61 | } // end of namespace dynamicgraph. 62 | -------------------------------------------------------------------------------- /src/command/command.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2010 CNRS 3 | // 4 | // Author: Florent Lamiraux 5 | // 6 | 7 | #include "dynamic-graph/command.h" 8 | 9 | #include 10 | 11 | #include "dynamic-graph/exception-abstract.h" 12 | 13 | namespace dynamicgraph { 14 | namespace command { 15 | 16 | const std::vector Command::EMPTY_ARG = std::vector(); 17 | 18 | Command::~Command() {} 19 | Command::Command(Entity &entity, const std::vector &valueTypes, 20 | const std::string &docstring) 21 | : owner_(entity), valueTypeVector_(valueTypes), docstring_(docstring) {} 22 | 23 | const std::vector &Command::valueTypes() const { 24 | return valueTypeVector_; 25 | } 26 | 27 | void Command::setParameterValues(const std::vector &values) { 28 | const std::vector ¶mTypes = valueTypes(); 29 | // Check that number of parameters is correct 30 | if (values.size() != paramTypes.size()) { 31 | throw ExceptionAbstract(ExceptionAbstract::ABSTRACT, 32 | "wrong number of parameters"); 33 | } 34 | // Check that each parameter is of correct type 35 | for (unsigned int iParam = 0; iParam < values.size(); iParam++) { 36 | if (values[iParam].type() != paramTypes[iParam]) { 37 | std::stringstream ss; 38 | ss << "argument " << iParam 39 | << " is of wrong type: " << Value::typeName(paramTypes[iParam]) 40 | << " expected, got " << Value::typeName(values[iParam].type()); 41 | throw ExceptionAbstract(ExceptionAbstract::TOOLS, ss.str()); 42 | } 43 | } 44 | // Copy vector of values in private part 45 | valueVector_ = values; 46 | } 47 | 48 | const std::vector &Command::getParameterValues() const { 49 | return valueVector_; 50 | } 51 | 52 | Value Command::execute() { return doExecute(); } 53 | 54 | Entity &Command::owner() { return owner_; } 55 | std::string Command::getDocstring() const { return docstring_; } 56 | } // namespace command 57 | } // namespace dynamicgraph 58 | -------------------------------------------------------------------------------- /tests/custom-entity.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2010 Thomas Moulard. 2 | // 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include 10 | 11 | #define BOOST_TEST_MODULE customEntity 12 | 13 | #if BOOST_VERSION >= 105900 14 | #include 15 | #else 16 | #include 17 | #endif 18 | #include 19 | 20 | using boost::test_tools::output_test_stream; 21 | 22 | struct CustomEntity : public dynamicgraph::Entity { 23 | static const std::string CLASS_NAME; 24 | 25 | virtual const std::string &getClassName() const { return CLASS_NAME; } 26 | 27 | explicit CustomEntity(const std::string &n) : Entity(n) {} 28 | 29 | virtual ~CustomEntity() {} 30 | 31 | void display(std::ostream &os) const { os << "custom entity"; } 32 | }; 33 | 34 | DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN(CustomEntity, "CustomEntity"); 35 | 36 | BOOST_AUTO_TEST_CASE(constructor) { 37 | BOOST_CHECK_EQUAL(CustomEntity::CLASS_NAME, "CustomEntity"); 38 | 39 | dynamicgraph::Entity *entity = 40 | dynamicgraph::FactoryStorage::getInstance()->newEntity("CustomEntity", 41 | "my-entity"); 42 | BOOST_CHECK_EQUAL(entity->getName(), "my-entity"); 43 | BOOST_CHECK_EQUAL(entity->Entity::getClassName(), "Entity"); 44 | BOOST_CHECK_EQUAL(entity->getClassName(), CustomEntity::CLASS_NAME); 45 | 46 | // CustomEntity entity2 (""); 47 | // Deregister entities before destroying them 48 | dynamicgraph::PoolStorage::destroy(); 49 | } 50 | 51 | BOOST_AUTO_TEST_CASE(display) { 52 | dynamicgraph::Entity *entity = 53 | dynamicgraph::FactoryStorage::getInstance()->newEntity("CustomEntity", 54 | "my-entity"); 55 | 56 | output_test_stream output; 57 | 58 | entity->display(output); 59 | BOOST_CHECK(output.is_equal("custom entity")); 60 | // Deregister entities before destroying them 61 | dynamicgraph::PoolStorage::destroy(); 62 | } 63 | -------------------------------------------------------------------------------- /tests/exceptions.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2020 Olivier Stasse 2 | // LAAS, CNRS 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include 10 | #include 11 | 12 | #if BOOST_VERSION >= 105900 13 | #include 14 | #else 15 | #include 16 | #endif 17 | #include 18 | #include 19 | 20 | using boost::test_tools::output_test_stream; 21 | using namespace dynamicgraph; 22 | 23 | BOOST_AUTO_TEST_CASE(exception_abstract_param) { 24 | /// Test param from Exception 25 | /// Default constructor 26 | ExceptionAbstract::Param aParamSimple; 27 | /// Advanced constructor 28 | ExceptionAbstract::Param aParam(60, "function_test", "my_file"); 29 | aParamSimple.initCopy(aParam); 30 | } 31 | 32 | BOOST_AUTO_TEST_CASE(exception_abstract) { 33 | /// Test exception abstract with a simple message 34 | std::string msg_aea("Test exception abstract"); 35 | ExceptionAbstract aEA(10, msg_aea); 36 | 37 | const char *aC = aEA.getMessage(); 38 | output_test_stream output; 39 | output << aC; 40 | BOOST_CHECK(output.is_equal("Test exception abstract")); 41 | 42 | output << aEA; 43 | BOOST_CHECK( 44 | output.is_equal("AbstractError [#10]: Test exception abstract\n")); 45 | } 46 | 47 | BOOST_AUTO_TEST_CASE(exception_traces) { 48 | std::string msg_aet("Test exception traces simple"); 49 | ExceptionTraces aET(ExceptionTraces::GENERIC, msg_aet); 50 | output_test_stream output; 51 | output << aET; 52 | BOOST_CHECK( 53 | output.is_equal("TracesError [#300]: Test exception traces simple\n")); 54 | 55 | /// Test exception traces with a format. 56 | int a = 2, b = 3; 57 | std::string msg_aet2("Test exception traces "); 58 | ExceptionTraces aET2(ExceptionTraces::GENERIC, msg_aet2, "(%d,%d)", a, b); 59 | output << aET2; 60 | BOOST_CHECK( 61 | output.is_equal("TracesError [#300]: Test exception traces (2,3)\n")); 62 | } 63 | -------------------------------------------------------------------------------- /include/dynamic-graph/tracer-real-time.h: -------------------------------------------------------------------------------- 1 | // -*- mode: c++ -*- 2 | // Copyright 2010, François Bleibel, Thomas Moulard, Olivier Stasse, 3 | // JRL, CNRS/AIST. 4 | // 5 | 6 | #ifndef DYNAMIC_GRAPH_TRACER_REAL_TIME_H 7 | #define DYNAMIC_GRAPH_TRACER_REAL_TIME_H 8 | #include 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | namespace dynamicgraph { 15 | /// \ingroup plugin 16 | /// 17 | /// \brief Stream for the tracer real-time. 18 | class DG_TRACERREALTIME_DLLAPI OutStringStream : public std::ostringstream { 19 | public: 20 | char *buffer; 21 | std::streamsize index; 22 | std::streamsize bufferSize; 23 | bool full; 24 | std::string givenname; 25 | 26 | public: 27 | OutStringStream(); 28 | ~OutStringStream(); 29 | 30 | void resize(const std::streamsize &size); 31 | bool addData(const char *data, const std::streamoff &size); 32 | void dump(std::ostream &os); 33 | void empty(); 34 | }; 35 | 36 | /// \ingroup plugin 37 | /// 38 | /// \brief Main class of the tracer real-time plug-in. 39 | class DG_TRACERREALTIME_DLLAPI TracerRealTime : public Tracer { 40 | DYNAMIC_GRAPH_ENTITY_DECL(); 41 | 42 | public: 43 | TracerRealTime(const std::string &n); 44 | virtual ~TracerRealTime() {} 45 | 46 | virtual void closeFiles(); 47 | virtual void trace(); 48 | 49 | void display(std::ostream &os) const; 50 | DG_TRACERREALTIME_DLLAPI friend std::ostream &operator<<( 51 | std::ostream &os, const TracerRealTime &t); 52 | 53 | void emptyBuffers(); 54 | 55 | void setBufferSize(const int &SIZE) { bufferSize = SIZE; } 56 | 57 | const int &getBufferSize() { return bufferSize; } 58 | 59 | protected: 60 | virtual void openFile(const SignalBase &sig, 61 | const std::string &filename); 62 | 63 | virtual void recordSignal(std::ostream &os, const SignalBase &sig); 64 | 65 | typedef std::list HardFileList; 66 | static const int BUFFER_SIZE_DEFAULT = 1048576; // 1Mo 67 | 68 | int bufferSize; 69 | HardFileList hardFiles; 70 | }; 71 | } // end of namespace dynamicgraph 72 | 73 | #endif //! DYNAMIC_GRAPH_TRACER_REAL_TIME_H 74 | -------------------------------------------------------------------------------- /doc/header.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | $projectname: $title 9 | $title 10 | 11 | 12 | 13 | 14 | $treeview 15 | $search 16 | $mathjax 17 | 18 | $extrastylesheet 19 | 20 | 21 |
22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 38 | 39 | 40 | 41 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 |
33 |
$projectname 34 |  $projectnumber 35 |
36 |
$projectbrief
37 |
42 |
$projectbrief
43 |
$searchbox
54 |
55 | 56 | 57 | -------------------------------------------------------------------------------- /doc/additionalDoc/debug-trace-doc.h: -------------------------------------------------------------------------------- 1 | /** 2 | \page subp_dbg_trace Debugging with macros and level 3 | 4 | \section subp_dbg_trace_intro Introduction 5 | The idea of this class and collection of MACROS is to specify 6 | a level for a message, and record the message in a stream according to this 7 | level. In addition there are mechanisms allowing that no time is wasted in 8 | condition test. You can therefore let the debugging messages inside the code 9 | without impact on performances. 10 | 11 | \section subp_dbg_trace_set_on_macros Setting up dgDEBUG macros 12 | 13 | To allow message display the entity must be compiled with the macro 14 | \code 15 | #define VP_DEBUG 1 16 | \endcode 17 | Commenting or removing this macro disable all the messages specified 18 | by the following macros. 19 | 20 | The level up to which the messages are accepted for display is 21 | specified by: 22 | \code 23 | #define VP_DEBUG_MODE 50 24 | \endcode 25 | 26 | In the constructor of the entity, the file where all the messages 27 | are written is specified by: 28 | \code 29 | dynamicgraph::dgDEBUGFLOW.openFile("/tmp/dynamic-graph-traces.txt"); 30 | \endcode 31 | 32 | \section subp_dbg_trace_using_macros Using dgDEBUG macros 33 | 34 | To print that the beginning of a method is being executed use the following 35 | macros: \code dgDEBUGIN(5); \endcode 5 here specifies the minimum level that you 36 | be specified by VP_DEBUG_MODE for this message to be displayed. 37 | 38 | It will generate the following output: 39 | \code 40 | /path_to/dynamic-graph/tests/debug-trace.cpp: testDebugTrace(#46) :# In { 41 | \endcode 42 | The output displays the name of the source file, the name of the method, 43 | the line where is the macro, and the message itself. 44 | 45 | When going out of the method: 46 | \code 47 | dgDEBUGOUT(5); 48 | \endcode 49 | 50 | This generates the following output: 51 | \code 52 | /path_to/dynamic-graph/tests/debug-trace.cpp: testDebugTrace(#54) :# Out } 53 | \endcode 54 | 55 | A message inside the code is written through: 56 | \code 57 | dgDEBUG(5) << "Here is a test" << std::endl; 58 | \endcode 59 | 60 | This generates the following output: 61 | \code 62 | /path_to/dynamic-graph/tests/debug-trace.cpp: testDebugTrace(#52) :Here is a 63 | test \endcode 64 | 65 | \section subp_dbg_trace_wrk_exp Working example 66 | 67 | A full working example is given here: 68 | \include tests/debug-trace.cpp 69 | */ 70 | -------------------------------------------------------------------------------- /include/dynamic-graph/command.h: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright 2010 CNRS 3 | // 4 | // Author: Florent Lamiraux 5 | // 6 | 7 | #ifndef DYNAMIC_GRAPH_COMMAND_H 8 | #define DYNAMIC_GRAPH_COMMAND_H 9 | 10 | #include 11 | 12 | #include "dynamic-graph/dynamic-graph-api.h" 13 | #include "dynamic-graph/value.h" 14 | 15 | namespace dynamicgraph { 16 | class Entity; 17 | namespace command { 18 | /// \ingroup dgraph 19 | /// Abstract class for entity commands 20 | /// 21 | /// This class provide a mean to control entities from external 22 | /// python script. 23 | /// 24 | /// A command 25 | /// \li is owned by an entity, 26 | /// \li takes parameters of type Value, 27 | /// \li return an instance of Value when calling Command::execute() 28 | /// 29 | /// At construction, the prototype of the command is defined by providing 30 | /// a vector of Value::Type. 31 | /// 32 | /// Parameters are set by calling Command::setParameterValues with a 33 | /// vector of Values the types of which should fit the vector specified 34 | /// at construction. 35 | class DYNAMIC_GRAPH_DLLAPI Command { 36 | public: 37 | virtual ~Command(); 38 | /// Store the owner entity and a vector of value types 39 | /// \param entity reference to Entity owning this command. 40 | /// \param valueTypes vector specifying the number and types of parameters 41 | /// \param docstring documentation of the command 42 | Command(Entity &entity, const std::vector &valueTypes, 43 | const std::string &docstring); 44 | /// Return the value type of all parameters 45 | const std::vector &valueTypes() const; 46 | /// Set parameter values 47 | void setParameterValues(const std::vector &values); 48 | /// Get parameter values 49 | const std::vector &getParameterValues() const; 50 | /// Execute the command after checking parameters 51 | Value execute(); 52 | /// Get a reference to the Entity owning this command 53 | Entity &owner(); 54 | /// Get documentation string 55 | std::string getDocstring() const; 56 | 57 | protected: 58 | /// Specific action performed by the command 59 | virtual Value doExecute() = 0; 60 | 61 | private: 62 | Entity &owner_; 63 | std::vector valueTypeVector_; 64 | std::vector valueVector_; 65 | std::string docstring_; 66 | 67 | public: 68 | static const std::vector EMPTY_ARG; 69 | }; 70 | } // namespace command 71 | } // namespace dynamicgraph 72 | 73 | #endif // DYNAMIC_GRAPH_COMMAND_H 74 | -------------------------------------------------------------------------------- /tests/real-time-logger.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018, 3 | * Joseph Mirabel 4 | * 5 | * LAAS-CNRS 6 | * 7 | */ 8 | 9 | #include 10 | 11 | #define ENABLE_RT_LOG 12 | #include 13 | 14 | #define BOOST_TEST_MODULE real_time_logger 15 | 16 | #if BOOST_VERSION >= 105900 17 | #include 18 | #else 19 | #include 20 | #endif 21 | #include 22 | #include 23 | #include 24 | 25 | using namespace dynamicgraph; 26 | 27 | BOOST_AUTO_TEST_CASE(monothread) { 28 | RealTimeLogger rtl(10); 29 | rtl.addOutputStream(LoggerStreamPtr_t(new LoggerIOStream(std::cout))); 30 | for (int i = 0; i < 9; ++i) rtl.front() << "Call number " << i << '\n'; 31 | BOOST_CHECK(rtl.full()); 32 | rtl.front() << "This call should not appear in the output" << '\n'; 33 | 34 | rtl.spinOnce(); 35 | BOOST_CHECK(!rtl.full()); 36 | rtl.front() << "This call should appear in the output" << '\n'; 37 | 38 | int spinNb = 0; 39 | while (rtl.spinOnce()) { 40 | spinNb++; 41 | } 42 | BOOST_CHECK_EQUAL(spinNb, 9); 43 | 44 | rtl.front() << "This msg should be short." << '\n'; 45 | rtl.spinOnce(); 46 | } 47 | 48 | BOOST_AUTO_TEST_CASE(multithread) { 49 | // The part of the code changing priority will only be effective 50 | // if this test is run as root. Otherwise it behaves like a classical thread. 51 | // Test confirms that in this case, it runs with a priority -51 52 | // and that the thread for logging is running on SCHED_OTHER 53 | // with a nice priority (20). 54 | int threadPolicy; 55 | struct sched_param threadParam; 56 | if (pthread_getschedparam(pthread_self(), &threadPolicy, &threadParam) == 0) { 57 | threadPolicy = SCHED_RR; 58 | threadParam.sched_priority = 50; 59 | pthread_setschedparam(pthread_self(), threadPolicy, &threadParam); 60 | } 61 | 62 | RealTimeLogger &rtl = RealTimeLogger::instance(); 63 | dgADD_OSTREAM_TO_RTLOG(std::cout); 64 | 65 | for (std::size_t i = 0; i < rtl.getBufferSize() - 1; ++i) 66 | dgRTLOG() << "Call number " << i << '\n'; 67 | for (std::size_t i = 0; i < 12; ++i) { 68 | boost::this_thread::sleep(boost::posix_time::milliseconds(20)); 69 | dgRTLOG() << "Call number " << i << std::endl; 70 | BOOST_CHECK(!rtl.full()); 71 | } 72 | 73 | dgRTLOG() << "This call should appear in the output" << '\n'; 74 | 75 | RealTimeLogger::destroy(); 76 | } 77 | -------------------------------------------------------------------------------- /src/debug/logger.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015, 2019 3 | * LAAS-CNRS 4 | * Andrea Del Prete, François Bailly, Olivier Stasse 5 | * 6 | */ 7 | 8 | #ifndef WIN32 9 | #include 10 | #else 11 | #include 12 | #endif 13 | #define ENABLE_RT_LOG 14 | 15 | #include 16 | #include 17 | #include 18 | 19 | #include // std::setprecision 20 | #include 21 | #include 22 | 23 | namespace dynamicgraph { 24 | 25 | Logger::Logger(double timeSample, double streamPrintPeriod) 26 | : m_timeSample(timeSample), 27 | m_streamPrintPeriod(streamPrintPeriod), 28 | m_printCountdown(0.0) { 29 | m_lv = VERBOSITY_ERROR; 30 | } 31 | 32 | Logger::~Logger() {} 33 | 34 | void Logger::setVerbosity(LoggerVerbosity lv) { m_lv = lv; } 35 | 36 | LoggerVerbosity Logger::getVerbosity() { return m_lv; } 37 | void Logger::countdown() { 38 | if (m_printCountdown < 0.0) m_printCountdown = m_streamPrintPeriod; 39 | m_printCountdown -= m_timeSample; 40 | } 41 | 42 | void Logger::sendMsg(std::string msg, MsgType type, const std::string &lineId) { 43 | stream(type, lineId) << msg << '\n'; 44 | } 45 | 46 | void Logger::sendMsg(std::string msg, MsgType type, const std::string &file, 47 | int line) { 48 | std::ostringstream oss; 49 | oss << file << line; 50 | stream(type, oss.str()) << msg << '\n'; 51 | } 52 | 53 | bool Logger::setTimeSample(double t) { 54 | if (t <= 0.0) return false; 55 | m_timeSample = t; 56 | return true; 57 | } 58 | 59 | bool Logger::setStreamPrintPeriod(double s) { 60 | if (s <= 0.0) return false; 61 | m_streamPrintPeriod = s; 62 | return true; 63 | } 64 | 65 | double Logger::getTimeSample() { return m_timeSample; } 66 | 67 | double Logger::getStreamPrintPeriod() { return m_streamPrintPeriod; } 68 | 69 | bool Logger::checkStreamPeriod(const std::string &lineId) { 70 | // insert element with value 0 if it does not exist. 71 | // otherwise, return a counter to the existing one. 72 | std::pair result = 73 | m_stream_msg_counters.insert(std::make_pair(lineId, 0.)); 74 | 75 | // if counter is greater than 0 then decrement it and do not print 76 | double &counter = result.first->second; 77 | counter -= m_timeSample; 78 | if (counter > 0.0) { 79 | return false; 80 | } else // otherwise reset counter and print 81 | counter = m_streamPrintPeriod; 82 | return true; 83 | } 84 | 85 | } // namespace dynamicgraph 86 | -------------------------------------------------------------------------------- /doc/additionalDoc/package.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2010, 3 | * François Bleibel, 4 | * Thomas Moulard, 5 | * Olivier Stasse, 6 | * 7 | * CNRS/AIST 8 | * 9 | */ 10 | 11 | /** 12 | \mainpage 13 | 14 | The dynamic-graph aims at building computational graphs for real-time control. 15 | It provides the basic software functionnalities. 16 | 17 | A more detailed introduction is available at \subpage subp_concept_intro. 18 | 19 | The installation instruction are given at \subpage subp_installation. 20 | 21 | The software graph structure is detailled in \subpage p_graph 22 | 23 | For debugging your entities detailed instructions are given in \subpage debug 24 | 25 | For citing the software in your research work please refer to 26 | \subpage subp_references 27 | 28 | \namespace dynamicgraph This is the namespace where every object and class of 29 | this library is located. 30 | 31 | \defgroup debug Debugging 32 | 33 | \defgroup dgraph Core classes and objects 34 | @{ 35 | 36 | Classes, entities and binaries that make up the core of the dynamic-graph 37 | library are listed here. 38 | @} 39 | 40 | \defgroup signals Signals 41 | @{ 42 | This part provides the mechanism to transfer information 43 | from one entity to another. There are three main types of signals, 44 | all deriving from the common class dynamicgraph::SignalBase : 45 | \li dynamicgraph::Signal : a "normal" signal, passing data around \b by \b value 46 | \li dynamicgraph::SignalPtr : a signal used for efficient passing of large data, 47 | by reference (or rather, C pointers)* \li dynamicgraph::SignalTimeDependent : a 48 | signal that enforces a time dependency between other signals, making sure its 49 | inputs are up to date on access, using a incrementing time tick as reference. 50 | 51 | \n* Note: this may cause a problem if this package is used in a multithreaded 52 | program. 53 | 54 | Signals can be grouped together using dynamicgraph::SignalArray. 55 | 56 | Signals implement a caching mechanism by storing the last computation time tick. 57 | 58 | For more information, please see the individual signal pages. 59 | 60 | \b Samples 61 | 62 | \li The following code ensures the jacobian output signal uses up-to-date values 63 | for its computations, when accessed. 64 | 65 | \code 66 | // This signal returns the Jacobian of the current value 67 | // according to the robot state 68 | dg::SignalTimeDependent jacobianSOUT; 69 | 70 | (...) 71 | 72 | jacobianSOUT.addDependency( positionSIN ); 73 | jacobianSOUT.addDependency( articularJacobianSIN ); 74 | 75 | \endcode 76 | 77 | @} 78 | 79 | */ 80 | -------------------------------------------------------------------------------- /include/dynamic-graph/time-dependency.h: -------------------------------------------------------------------------------- 1 | // -*- mode: c++ -*- 2 | // Copyright 2010, François Bleibel, Thomas Moulard, Olivier Stasse, 3 | // JRL, CNRS/AIST. 4 | // 5 | 6 | #ifndef DYNAMIC_GRAPH_TIME_DEPENDENCY_H 7 | #define DYNAMIC_GRAPH_TIME_DEPENDENCY_H 8 | #include 9 | #include 10 | 11 | #include 12 | #include 13 | 14 | namespace dynamicgraph { 15 | /** \brief A helper class for setting and specifying dependencies 16 | between signals. 17 | */ 18 | template 19 | class TimeDependency { 20 | public: 21 | enum DependencyType { TIME_DEPENDENT, BOOL_DEPENDENT, ALWAYS_READY }; 22 | 23 | mutable Time lastAskForUpdate; 24 | 25 | public: 26 | SignalBase