diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..22cf052921772422e3c990e8b7dc3a3fe00e2e3c --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +_build* +*~ \ No newline at end of file diff --git a/.gitmodules b/.gitmodules index 5a0f6c96ed7ab18de3526d12a5d335d9a06e1e5a..6dc3ed2b21103954f059301d375426b642e0ad3c 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,6 @@ [submodule "jrl-cmakemodules"] - path = jrl-cmakemodules - url = git://github.com/jrl-umi3218/jrl-cmakemodules.git + path = jrl-cmakemodules + url = git://github.com/jrl-umi3218/jrl-cmakemodules.git [submodule "cmake"] path = cmake url = git://github.com/jrl-umi3218/jrl-cmakemodules.git diff --git a/.travis.yml b/.travis.yml index 786db3a2418b74d1de8417b1af0c277dfef2eef8..9cd6f2ceffaab02f36e6c72deb32df799cca25e8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,5 @@ language: cpp +sudo: required compiler: - gcc - clang diff --git a/.version b/.version new file mode 100644 index 0000000000000000000000000000000000000000..56fea8a08d2faa60fec80b40241566d3c39744f7 --- /dev/null +++ b/.version @@ -0,0 +1 @@ +3.0.0 \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 32666977e8f800f897228a6feb7188fdb7d9b5b3..b4cbf66ba243e61dc42cb883e44e27cd40f8fbbc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,6 +17,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6) INCLUDE(cmake/base.cmake) INCLUDE(cmake/boost.cmake) +INCLUDE(cmake/eigen.cmake) INCLUDE(cmake/pthread.cmake) INCLUDE(cmake/cpack.cmake) @@ -31,9 +32,6 @@ SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib) SETUP_PROJECT() -# Trigger dependency to jrl-mal -ADD_REQUIRED_DEPENDENCY("jrl-mal >= 1.8.0") - # Add configuration headers for plug-ins. GENERATE_CONFIGURATION_HEADER( ${HEADER_DIR} config-tracer.hh DG_TRACER tracer_EXPORTS) @@ -62,6 +60,9 @@ PKG_CONFIG_APPEND_LIBS("dynamic-graph") SEARCH_FOR_BOOST() SEARCH_FOR_PTHREAD() +# Search for Boost. +SEARCH_FOR_EIGEN() + ADD_SUBDIRECTORY(src) ADD_SUBDIRECTORY(include) ADD_SUBDIRECTORY(doc) diff --git a/ChangeLog b/ChangeLog index 6899fbb19a09d65e3cab61d253d4c47172c0bcfb..155b576a8e367ae96c324a69d62f141cea0a0e74 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,11 @@ CHANGELOG [Current] +[v3.0.0] + * Replace jrl-mal with eigen + * Add ostream and isteram operators for Eigen Classes + + [v2.5.5] * Improve Travis support diff --git a/README.md b/README.md index a368e44ace2adf80db0dd4ddc4ac8afb890b0dc1..f8165cddb0ee356494d658915d60255397d4cd02 100644 --- a/README.md +++ b/README.md @@ -58,7 +58,7 @@ have to be available on your machine. - Libraries: - [Boost][] (>= 1.40) - Its detection is controled by the `BOOST_ROOT` variable, see next section + Its detection is controlled by the `BOOST_ROOT` variable, see next section for more information. - [Lapack][] library Use the generic purpose `CMAKE_CXX_FLAGS` and `CMAKE_EXE_LINKER_FLAGS` diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000000000000000000000000000000000000..df73393fcf7c2af7b3b1917ecd321c6e98bf76b1 --- /dev/null +++ b/debian/changelog @@ -0,0 +1,5 @@ +dynamic-graph (3.0.0-1) unstable; urgency=low + + * Initial release (Closes: #822608) + + -- Rohan Budhiraja <budhiraja.rohan@gmail.com> Fri, 01 Jul 2016 12:30:14 +0200 diff --git a/debian/compat b/debian/compat new file mode 100644 index 0000000000000000000000000000000000000000..ec635144f60048986bc560c5576355344005e6e7 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +9 diff --git a/debian/control b/debian/control new file mode 100644 index 0000000000000000000000000000000000000000..628040c38cc9909e1e88924934bebe852a9c4e6f --- /dev/null +++ b/debian/control @@ -0,0 +1,53 @@ +Source: dynamic-graph +Section: libs +Priority: extra +Maintainer: Rohan Budhiraja <budhiraja.rohan@gmail.com> +Build-Depends: debhelper (>= 9.0.0), + cmake (>= 2.6), + doxygen (>=1.6.3), + pkg-config (>=0.22), + perl (>=5.10.1), + libboost-dev (>=1.46), + libboost-filesystem-dev (>=1.46), + libboost-system-dev (>=1.46), + libboost-test-dev (>=1.46), + libboost-thread-dev (>=1.46), + libboost-program-options-dev (>=1.46), + libpthread-stubs0-dev (>=0.3), + libeigen3-dev (>=3.0.5) +Standards-Version: 3.9.8 +Homepage: http://stack-of-tasks.github.io +Vcs-Git: https://github.com/proyan/dynamic-graph.git + +Package: libdynamic-graph-dev +Section: libdevel +Architecture: any +Depends: libdynamic-graph3.0.0 (= ${binary:Version}), + ${misc:Depends} +Suggests: libdynamic-graph-doc +Description: Dynamic graph C++ library development package + The dynamic graph library allows the representation of data-flow in C++. + It provides fast graph evaluation and a simple script language to manipulate + the graph actions. + . + This package contains development files (headers and pkg-config file). + +Package: libdynamic-graph3.0.0 +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends} +Description: Dynamic graph C++ library + The dynamic graph library allows the representation of data-flow in C++. + It provides fast graph evaluation and a simple script language to manipulate + the graph actions. + + +Package: libdynamic-graph-doc +Section: doc +Architecture: all +Depends: ${misc:Depends} +Description: documentation for the dynamic graph C++ library + The dynamic graph library allows the representation of data-flow in C++. + It provides fast graph evaluation and a simple script language to manipulate + the graph actions. + . + This package contains the Doxygen documentation. \ No newline at end of file diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 0000000000000000000000000000000000000000..795c55c816ca3ec84b413acd850f5a965bb8dd49 --- /dev/null +++ b/debian/copyright @@ -0,0 +1,15 @@ +Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: dynamic-graph +Upstream-Contact: HPP mailing list <hpp@laas.fr> +Source: https://github.com/proyan/dynamic-graph + +Files: * +Copyright: 2010-2016 JRL, CNRS/AIST. +License: LGPL-3 + +Files: debian/* +Copyright: 2016 Rohan Budhiraja +License: LGPL-3 + +License: LGPL-3 + See `/usr/share/common-licenses/LGPL-3'. \ No newline at end of file diff --git a/debian/docs b/debian/docs new file mode 100644 index 0000000000000000000000000000000000000000..46a4ca7180f4a6e0f569152a8ec634c8ed313ca6 --- /dev/null +++ b/debian/docs @@ -0,0 +1,3 @@ +AUTHORS +NEWS +README.md diff --git a/debian/libdynamic-graph-dev.install b/debian/libdynamic-graph-dev.install new file mode 100644 index 0000000000000000000000000000000000000000..fc5fd602d0a05a0bed37403ef45d4f9399eddd23 --- /dev/null +++ b/debian/libdynamic-graph-dev.install @@ -0,0 +1,3 @@ +usr/include/* +usr/lib/lib*.so +usr/lib/pkgconfig/* \ No newline at end of file diff --git a/debian/libdynamic-graph-doc.doc-base b/debian/libdynamic-graph-doc.doc-base new file mode 100644 index 0000000000000000000000000000000000000000..116ecde60270a29a491d05bf46c6ca17912a3a70 --- /dev/null +++ b/debian/libdynamic-graph-doc.doc-base @@ -0,0 +1,9 @@ +Document: dynamic-graph +Title: Debian dynamic-graph Manual +Author: Thomas Moulard <thomas.moulard@gmail.com> +Abstract: Doxygen documentation of dynamic-graph. +Section: Programming + +Format: HTML +Index: /usr/share/doc/dynamic-graph/doxygen-html/index.html +Files: /usr/share/doc/dynamic-graph/doxygen-html/*.html \ No newline at end of file diff --git a/debian/libdynamic-graph-doc.install b/debian/libdynamic-graph-doc.install new file mode 100644 index 0000000000000000000000000000000000000000..5536e7c10a5f8db99bbf779f486788a43725cbaf --- /dev/null +++ b/debian/libdynamic-graph-doc.install @@ -0,0 +1 @@ +usr/share/doc/dynamic-graph/* \ No newline at end of file diff --git a/debian/libdynamic-graph-doc.lintian-overrides b/debian/libdynamic-graph-doc.lintian-overrides new file mode 100644 index 0000000000000000000000000000000000000000..829488b9678c7c3381f1d900b46b05b08d1088c7 --- /dev/null +++ b/debian/libdynamic-graph-doc.lintian-overrides @@ -0,0 +1,3 @@ +#Suppresses the embedded javascript warning produced by doxygen embed of jquery. +#See https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=736360 +libdynamic-graph-doc binary: embedded-javascript-library usr/share/doc/dynamic-graph/doxygen-html/jquery.js \ No newline at end of file diff --git a/debian/libdynamic-graph3.0.0.install b/debian/libdynamic-graph3.0.0.install new file mode 100644 index 0000000000000000000000000000000000000000..eddacbfc33e1902241aa84d53a971a3dc636c4d4 --- /dev/null +++ b/debian/libdynamic-graph3.0.0.install @@ -0,0 +1,4 @@ +usr/lib/*.so.* +usr/lib/plugin/*.so +usr/share/man/* +usr/share/dynamic-graph/* \ No newline at end of file diff --git a/debian/libdynamic-graph3.0.0.triggers b/debian/libdynamic-graph3.0.0.triggers new file mode 100644 index 0000000000000000000000000000000000000000..72850ac4b5a0fc64b1281183596d641cefacd705 --- /dev/null +++ b/debian/libdynamic-graph3.0.0.triggers @@ -0,0 +1 @@ +activate-noawait ldconfig \ No newline at end of file diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000000000000000000000000000000000000..ab6136c99a806ac6f823838d51c9e636e7ff2046 --- /dev/null +++ b/debian/rules @@ -0,0 +1,32 @@ +#!/usr/bin/make -f +# -*- makefile -*- +# Sample debian/rules that uses debhelper. +# This file was originally written by Joey Hess and Craig Small. +# As a special exception, when this file is copied by dh-make into a +# dh-make output file, you may use that output file without restriction. +# This special exception was added by Craig Small in version 0.37 of dh-make. + +# Uncomment this to turn on verbose mode. +export DH_VERBOSE=1 +export DEB_BUILD_MAINT_OPTIONS = hardening=+all + +DPKG_EXPORT_BUILDFLAGS = 1 +include /usr/share/dpkg/buildflags.mk +CFLAGS+=$(CPPFLAGS) +CXXFLAGS+=$(CPPFLAGS) + + +override_dh_auto_configure: + dh_auto_configure -- -DGENERATE_DOC=ON + +override_dh_makeshlibs: + dh_makeshlibs --exclude=lib/plugin --noscripts + +override_dh_shlibdeps: + dh_shlibdeps --exclude=lib/plugin + +override_dh_installchangelogs: + dh_installchangelogs changelog + +%: + dh $@ diff --git a/debian/source/format b/debian/source/format new file mode 100644 index 0000000000000000000000000000000000000000..163aaf8d82b6c54f23c45f32895dbdfdcc27b047 --- /dev/null +++ b/debian/source/format @@ -0,0 +1 @@ +3.0 (quilt) diff --git a/debian/upstream/signing-key.asc b/debian/upstream/signing-key.asc new file mode 100644 index 0000000000000000000000000000000000000000..9c97e30f5bdd2ef7a1074c615bcfbee6fa2922cb --- /dev/null +++ b/debian/upstream/signing-key.asc @@ -0,0 +1,52 @@ +-----BEGIN PGP PUBLIC KEY BLOCK----- +Version: GnuPG v1.4.11 (GNU/Linux) + +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 +ZjNmUHOna0zViA== +=nPA5 +-----END PGP PUBLIC KEY BLOCK----- diff --git a/debian/watch b/debian/watch new file mode 100644 index 0000000000000000000000000000000000000000..e33ea088d215a6c4be76baa5ffc6ff433778ce39 --- /dev/null +++ b/debian/watch @@ -0,0 +1,7 @@ +version=3 +opts=filenamemangle=s/.+\/v?(\d\S*)\.tar\.gz/dynamic-graph-$1\.tar\.gz/,\ +pgpsigurlmangle=s/github.com/raw.githubusercontent.com/;\ +s/archive\/master/signatures/;\ +s/([^\/]+)\.tar\.gz/dynamic-graph-$1\.tar\.gz/;\ +s/$/.asc/ \ + https://github.com/proyan/dynamic-graph/releases .*/v?(\d\S*)\.tar\.gz \ No newline at end of file diff --git a/doc/additionalDoc/package.h b/doc/additionalDoc/package.h index 3933783915edf09f9a3c9a90fbc840bf8fa79969..7aa365ebeef90653ec7a8911fd5b90be0382ee51 100644 --- a/doc/additionalDoc/package.h +++ b/doc/additionalDoc/package.h @@ -33,7 +33,7 @@ for a given problem. It is the basis for the stack of tasks operation. Functionality: \li Built-in scripting language* for fast prototyping and testing \li Support for extensions and modules using dynamic link libraries -\li Template-based signal definition, independant +\li Template-based signal definition, independent \li Type-safe connection of input and output signals \li On-demand signal computation as well as a caching system for signal values allow fast computation of signal values, which is a critical point for real-time systems\n diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt index 079ed6d1747284fe04cd3a07a0e0ded279cb2422..ec6d20b86ce1a2d93923afcbfff8109330a3e72d 100644 --- a/include/CMakeLists.txt +++ b/include/CMakeLists.txt @@ -67,6 +67,7 @@ tracer.h tracer-real-time.h command.h +eigen-io.h linear-algebra.h value.h diff --git a/include/dynamic-graph/command-direct-getter.h b/include/dynamic-graph/command-direct-getter.h index e64efa6613343a7fddf4a8e09282ab69335b5ebe..7f3da90ea2282f1348e00d310556c98eb5eb5401 100644 --- a/include/dynamic-graph/command-direct-getter.h +++ b/include/dynamic-graph/command-direct-getter.h @@ -38,7 +38,7 @@ namespace dynamicgraph { : public Command { public: - /// Pointer to method that sets paramter of type T + /// Pointer to method that sets parameter of type T typedef T (E::*GetterMethod) () const; /// Constructor diff --git a/include/dynamic-graph/command-getter.h b/include/dynamic-graph/command-getter.h index 9c60a231063cfb2d6e9d8897a89e7e0ba9a7f198..731c9dd674bed95342b9f752e031ed4f2f2f11e7 100644 --- a/include/dynamic-graph/command-getter.h +++ b/include/dynamic-graph/command-getter.h @@ -55,7 +55,7 @@ namespace dynamicgraph { template <class E, typename T> class Getter : public Command { public: - /// Pointer to method that sets paramter of type T + /// Pointer to method that sets parameter of type T typedef T (E::*GetterMethod) () const; /// Constructor Getter(E& entity, GetterMethod getterMethod, diff --git a/include/dynamic-graph/command-setter.h b/include/dynamic-graph/command-setter.h index cc8859386f5087d48e8d72dba15aaad8b82b7014..45cc9dc98d9f2123254b9ae376f2dba88fabf0ed 100644 --- a/include/dynamic-graph/command-setter.h +++ b/include/dynamic-graph/command-setter.h @@ -55,7 +55,7 @@ namespace dynamicgraph { template <class E, typename T> class Setter : public Command { public: - /// Pointer to method that sets paramter of type T + /// Pointer to method that sets parameter of type T typedef void (E::*SetterMethod) (const T&); /// Constructor Setter(E& entity, SetterMethod setterMethod, diff --git a/include/dynamic-graph/command-setter.t.cpp b/include/dynamic-graph/command-setter.t.cpp index 937c7edeb70bdb7a1ccb41d1193df7b5ee692a32..0a26374c7e98620a76df446e83a683c41eac732b 100644 --- a/include/dynamic-graph/command-setter.t.cpp +++ b/include/dynamic-graph/command-setter.t.cpp @@ -32,7 +32,7 @@ namespace dynamicgraph { template <class E> class Setter<E, bool> : public Command { public: - /// Pointer to method that sets paramter of type bool + /// Pointer to method that sets parameter of type bool typedef void (E::*SetterMethod) (const bool&); /// Constructor Setter(E& entity, SetterMethod setterMethod, @@ -70,7 +70,7 @@ namespace dynamicgraph { template <class E> class Setter<E, unsigned> : public Command { public: - /// Pointer to method that sets paramter of type unsigned + /// Pointer to method that sets parameter of type unsigned typedef void (E::*SetterMethod) (const unsigned&); /// Constructor Setter(E& entity, SetterMethod setterMethod, @@ -108,7 +108,7 @@ namespace dynamicgraph { template <class E> class Setter<E, int> : public Command { public: - /// Pointer to method that sets paramter of type int + /// Pointer to method that sets parameter of type int typedef void (E::*SetterMethod) (const int&); /// Constructor Setter(E& entity, SetterMethod setterMethod, @@ -146,7 +146,7 @@ namespace dynamicgraph { template <class E> class Setter<E, float> : public Command { public: - /// Pointer to method that sets paramter of type float + /// Pointer to method that sets parameter of type float typedef void (E::*SetterMethod) (const float&); /// Constructor Setter(E& entity, SetterMethod setterMethod, @@ -184,7 +184,7 @@ namespace dynamicgraph { template <class E> class Setter<E, double> : public Command { public: - /// Pointer to method that sets paramter of type double + /// Pointer to method that sets parameter of type double typedef void (E::*SetterMethod) (const double&); /// Constructor Setter(E& entity, SetterMethod setterMethod, @@ -222,7 +222,7 @@ namespace dynamicgraph { template <class E> class Setter<E, std::string> : public Command { public: - /// Pointer to method that sets paramter of type std::string + /// Pointer to method that sets parameter of type std::string typedef void (E::*SetterMethod) (const std::string&); /// Constructor Setter(E& entity, SetterMethod setterMethod, @@ -260,7 +260,7 @@ namespace dynamicgraph { template <class E> class Setter<E, Vector> : public Command { public: - /// Pointer to method that sets paramter of type Vector + /// Pointer to method that sets parameter of type Vector typedef void (E::*SetterMethod) (const Vector&); /// Constructor Setter(E& entity, SetterMethod setterMethod, @@ -298,7 +298,7 @@ namespace dynamicgraph { template <class E> class Setter<E, Matrix> : public Command { public: - /// Pointer to method that sets paramter of type Matrix + /// Pointer to method that sets parameter of type Matrix typedef void (E::*SetterMethod) (const Matrix&); /// Constructor Setter(E& entity, SetterMethod setterMethod, diff --git a/include/dynamic-graph/eigen-io.h b/include/dynamic-graph/eigen-io.h new file mode 100644 index 0000000000000000000000000000000000000000..6352cb520dcf36e4e4512bb897d274a33bbe70ae --- /dev/null +++ b/include/dynamic-graph/eigen-io.h @@ -0,0 +1,175 @@ +// +// Copyright 2016 CNRS +// +// Author: Rohan Budhiraja +// +// 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 Lesser General 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/>. + +#ifndef DYNAMIC_GRAPH_EIGEN_IO_H +#define DYNAMIC_GRAPH_EIGEN_IO_H + +#include <iostream> +#include <boost/format.hpp> +#include <boost/numeric/conversion/cast.hpp> + +#include <dynamic-graph/exception-signal.h> +#include <dynamic-graph/linear-algebra.h> +#include <Eigen/Geometry> + +using dynamicgraph::ExceptionSignal; + +//TODO: Eigen 3.3 onwards has a global Eigen::Index definition. +//If Eigen version is updated, use Eigen::Index instead of this macro. + + + /* \brief Eigen Vector input from istream + * + * Input Vector format: [N](val1,val2,val3,...,valN) + * e.g. [5](1,23,32.2,12.12,32) + */ +namespace Eigen { + typedef EIGEN_DEFAULT_DENSE_INDEX_TYPE eigen_index; + + inline std::istringstream& operator >> (std::istringstream &iss, + dynamicgraph::Vector &inst) { + unsigned int _size; + double _dbl_val; + char _ch; + boost::format fmt ("Failed to enter %s as vector. Reenter as [N](val1,val2,val3,...,valN)"); + fmt %iss.str(); + if(iss>> _ch && _ch != '['){ + throw ExceptionSignal(ExceptionSignal::GENERIC, fmt.str()); + } + else { + if(iss >> _size && !iss.fail()){ + inst.resize(_size); + } + else + throw ExceptionSignal(ExceptionSignal::GENERIC, fmt.str()); + if(iss >> _ch && _ch != ']') + throw ExceptionSignal(ExceptionSignal::GENERIC, fmt.str()); + else { + if(iss>> _ch && _ch != '(') + throw ExceptionSignal(ExceptionSignal::GENERIC, fmt.str()); + else { + for (unsigned int i=0;i<_size; i++){ + iss >> _dbl_val; + if (iss.peek() == ',' || iss.peek() == ' ') + iss.ignore(); + inst(i) = _dbl_val; + } + if(iss >> _ch && _ch != ')') + throw ExceptionSignal(ExceptionSignal::GENERIC, fmt.str()); + } + } + } + return iss; + } + + /* \brief Eigen Matrix input from istream + * + * Matrix format: [M,N]((val11,val12,val13,...,val1N),...,(valM1,valM2,...,valMN)) + * e.g. [2,5]((1 23 32.2 12.12 32),(2 32 23 92.01 19.2)) + */ + + template<typename Derived> + inline std::istringstream& operator >> (std::istringstream &iss, + DenseBase<Derived> &inst) { + unsigned int _colsize; + unsigned int _rowsize; + double _dbl_val; + char _ch; + boost::format fmt ("Failed to enter %s as matrix. Reenter as ((val11,val12,val13,...,val1N),...,(valM1,valM2,...,valMN))"); + MatrixXd _tmp_matrix; + fmt %iss.str(); + if(iss>> _ch && _ch != '['){ + throw ExceptionSignal(ExceptionSignal::GENERIC, fmt.str()); + } + else { + iss >>_rowsize; + if (iss.peek() == ',' || iss.peek() == ' ') + iss.ignore(); + iss >> _colsize; + if (iss.fail()) + throw ExceptionSignal(ExceptionSignal::GENERIC,fmt.str()); + else { + _tmp_matrix.resize(_rowsize,_colsize); + if(iss >> _ch && _ch != ']') + throw ExceptionSignal(ExceptionSignal::GENERIC, fmt.str()); + else { + if(iss>> _ch && _ch != '(') + throw ExceptionSignal(ExceptionSignal::GENERIC, fmt.str()); + else { + for (unsigned int j=0;j<_rowsize; j++){ + if(iss>> _ch && _ch != '(') + throw ExceptionSignal(ExceptionSignal::GENERIC, fmt.str()); + for (unsigned int i=0;i<_colsize; i++){ + iss >> _dbl_val; + if (iss.peek() == ',' || iss.peek() == ' ') + iss.ignore(); + _tmp_matrix(j,i) = _dbl_val; + } + if(iss >> _ch && _ch != ')') + throw ExceptionSignal(ExceptionSignal::GENERIC, fmt.str()); + if (iss.peek() == ',' || iss.peek() == ' ') + iss.ignore(); + } + if(iss >> _ch && _ch != ')') + throw ExceptionSignal(ExceptionSignal::GENERIC, fmt.str()); + } + } + } + } + inst = _tmp_matrix; + return iss; + } + + + inline std::istringstream& operator >> (std::istringstream &iss, + Transform<double,3,Affine> &inst) { + MatrixXd M; iss >> M; inst.matrix() = M; return iss; } + + + + + /* \brief Eigen Homogeneous Matrix output + * + * Matrix format: [M,N]((val11,val12,val13,...,val1N),...,(valM1,valM2,...,valMN)) + * e.g. [2,5]((1 23 32.2 12.12 32),(2 32 23 92.01 19.2)) + */ + + inline std::ostream& operator << (std::ostream &os, + Transform<double,3,Affine> MH) { + IOFormat boostFmt(StreamPrecision, DontAlignCols, + ",", ",", + "(",")", + "(",")"); + + os << "[4,4]"<< MH.matrix().format(boostFmt); return os; } + + + inline std::ostream& operator << (std::ostream &os, + AngleAxisd quat) { + VectorXd v(4); v(0) = quat.angle(); v.tail<3>() = quat.axis(); + os << v; return os; } + + inline std::istringstream& operator >> (std::istringstream &iss, + AngleAxisd &inst) { + VectorXd v(4); iss >>v; + inst.angle() = v(0); inst.axis() = v.tail<3>(); + return iss; } + +} + + +#endif //DYNAMIC_GRAPH_EIGEN_IO_H diff --git a/include/dynamic-graph/linear-algebra.h b/include/dynamic-graph/linear-algebra.h index 62cc76dfb8067294cb78f14cf40c281b40258361..4b566fb6f881935454e5c019d542b58383cde15e 100644 --- a/include/dynamic-graph/linear-algebra.h +++ b/include/dynamic-graph/linear-algebra.h @@ -17,15 +17,13 @@ #ifndef DYNAMIC_GRAPH_LINEAR_ALGEBRA_H #define DYNAMIC_GRAPH_LINEAR_ALGEBRA_H - -#include <jrl/mal/boost.hh> -#include <boost/numeric/ublas/matrix.hpp> +#include <Eigen/Core> +#include <Eigen/Geometry> namespace dynamicgraph { - typedef maal::boost::Vector Vector; - typedef maal::boost::Matrix Matrix; + typedef Eigen::MatrixXd Matrix; + typedef Eigen::VectorXd Vector; } -#endif //DYNAMIC_GRAPH_LINEAR_ALGEBRA_H - +#endif //DYNAMIC_GRAPH_LINEAR_ALGEBRA_H diff --git a/include/dynamic-graph/signal-cast-helper.h b/include/dynamic-graph/signal-cast-helper.h index f7704dba15802d22faa918774f8aa505bd644491..4024e9ad371511e8c20de37e4d5240e13902e2cd 100644 --- a/include/dynamic-graph/signal-cast-helper.h +++ b/include/dynamic-graph/signal-cast-helper.h @@ -28,6 +28,8 @@ # include <boost/lexical_cast.hpp> # include <boost/tuple/tuple.hpp> +#include <dynamic-graph/eigen-io.h> + # include <dynamic-graph/dynamic-graph-api.h> # include "dynamic-graph/exception-signal.h" # include "dynamic-graph/signal-caster.h" @@ -99,8 +101,8 @@ namespace dynamicgraph class SignalCast { public: - static T cast( std::istringstream& stringValue ) { throw 1;} - static void disp( const T& t,std::ostream& os ) { throw 1; } + static T cast( std::istringstream& ) { throw 1;} + static void disp( const T&,std::ostream&) { throw 1; } static void trace( const T& t,std::ostream& os ) { disp(t,os); } public: // adapter functions for SignalCast diff --git a/include/dynamic-graph/value.h b/include/dynamic-graph/value.h index f3614bbec54572338ecea654c20d08a4727884f6..ffa43c065a5df8711569575019070b8a9d41ecd0 100644 --- a/include/dynamic-graph/value.h +++ b/include/dynamic-graph/value.h @@ -23,7 +23,7 @@ #include <cassert> #include <typeinfo> #include "dynamic-graph/dynamic-graph-api.h" -#include "dynamic-graph/linear-algebra.h" +#include <dynamic-graph/linear-algebra.h> namespace dynamicgraph { namespace command { @@ -39,7 +39,8 @@ namespace dynamicgraph { operator double () const; operator std::string () const; operator Vector () const; - operator Matrix () const; + operator Eigen::MatrixXd () const; + operator Eigen::Matrix4d () const; private: const Value* value_; }; @@ -56,6 +57,7 @@ namespace dynamicgraph { STRING, VECTOR, MATRIX, + MATRIX4D, NB_TYPES }; ~Value(); @@ -67,7 +69,8 @@ namespace dynamicgraph { explicit Value(const double& value); explicit Value(const std::string& value); explicit Value(const Vector& value); - explicit Value(const Matrix& value); + explicit Value(const Eigen::MatrixXd& value); + explicit Value(const Eigen::Matrix4d& value); /// Copy constructor Value(const Value& value); // Construct an empty value (None) @@ -103,7 +106,8 @@ namespace dynamicgraph { double doubleValue() const; std::string stringValue() const; Vector vectorValue() const; - Matrix matrixValue() const; + Eigen::MatrixXd matrixXdValue() const; + Eigen::Matrix4d matrix4dValue() const; Type type_; const void* const value_; }; diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index de7b7f88dfc69b98ea27f497c38210b79a8c88f7..9209da60e94313adc87ab350840ae7018186580d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -50,7 +50,6 @@ ADD_LIBRARY(${LIBRARY_NAME} SET_TARGET_PROPERTIES(${LIBRARY_NAME} PROPERTIES SOVERSION ${PROJECT_VERSION}) -PKG_CONFIG_USE_DEPENDENCY(${LIBRARY_NAME} jrl-mal) IF (UNIX) TARGET_LINK_LIBRARIES(${LIBRARY_NAME} ${CMAKE_DL_LIBS} pthread) @@ -58,9 +57,9 @@ ENDIF (UNIX) TARGET_LINK_LIBRARIES(${LIBRARY_NAME} ${Boost_LIBRARIES}) -IF (UNIX AND NOT APPLE) - TARGET_LINK_LIBRARIES(${LIBRARY_NAME} ${JRL_MAL_LDFLAGS_OTHER}) -ENDIF (UNIX AND NOT APPLE) +#IF (UNIX AND NOT APPLE) +# TARGET_LINK_LIBRARIES(${LIBRARY_NAME} ${JRL_MAL_LDFLAGS_OTHER}) +#ENDIF (UNIX AND NOT APPLE) INSTALL(TARGETS ${LIBRARY_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR}) diff --git a/src/command/command.cpp b/src/command/command.cpp index 7cd2b512a553f70bcedb32a52a7763abb1f044ac..350a6afdd2691acf9b65f798dd9df90edd9943e5 100644 --- a/src/command/command.cpp +++ b/src/command/command.cpp @@ -50,7 +50,7 @@ namespace dynamicgraph { for (unsigned int iParam=0; iParam < values.size(); iParam++) { if (values[iParam].type() != paramTypes[iParam]) { std::stringstream ss; - ss << "argument " << iParam << "is of wrong type: " + ss << "argument " << iParam << " is of wrong type: " << Value::typeName(paramTypes[iParam]) << " expected, got " << Value::typeName(values[iParam].type()); throw ExceptionAbstract(ExceptionAbstract::TOOLS, ss.str()); diff --git a/src/command/value.cpp b/src/command/value.cpp index 92a032d1d016e7b9222ee2f7334b9a556ea5fa0b..4ff312353292abf0af47a92fe551e56ae6939933 100644 --- a/src/command/value.cpp +++ b/src/command/value.cpp @@ -15,7 +15,6 @@ // have received a copy of the GNU Lesser General Public License along // with dynamic-graph. If not, see <http://www.gnu.org/licenses/>. -#include <boost/numeric/ublas/io.hpp> #include "dynamic-graph/value.h" #include "dynamic-graph/exception-abstract.h" @@ -62,9 +61,14 @@ namespace dynamicgraph { { return value_->vectorValue(); } - EitherType::operator Matrix() const + EitherType::operator Eigen::MatrixXd() const { - return value_->matrixValue(); + return value_->matrixXdValue(); + } + + EitherType::operator Eigen::Matrix4d() const + { + return value_->matrix4dValue(); } void Value::deleteValue () @@ -92,7 +96,10 @@ namespace dynamicgraph { delete(const Vector*)value_; break; case MATRIX: - delete(const Matrix*)value_; + delete(const Eigen::MatrixXd*)value_; + break; + case MATRIX4D: + delete(const Eigen::Matrix4d*)value_; break; default:; } @@ -130,8 +137,12 @@ namespace dynamicgraph { value_(new Vector(value)) { } - Value::Value(const Matrix& value) : type_(MATRIX), - value_(new Matrix(value)) + Value::Value(const Eigen::MatrixXd& value) : type_(MATRIX), + value_(new Eigen::MatrixXd(value)) + { + } + Value::Value(const Eigen::Matrix4d& value) : type_(MATRIX4D), + value_(new Eigen::Matrix4d(value)) { } @@ -169,7 +180,10 @@ namespace dynamicgraph { copy = new Vector(value.vectorValue()); break; case Value::MATRIX: - copy = new Matrix(value.matrixValue()); + copy = new Eigen::MatrixXd(value.matrixXdValue()); + break; + case Value::MATRIX4D: + copy = new Eigen::Matrix4d(value.matrix4dValue()); break; default: abort(); @@ -263,12 +277,20 @@ namespace dynamicgraph { "value is not an vector"); } - Matrix Value::matrixValue() const + Eigen::MatrixXd Value::matrixXdValue() const { if(type_ == MATRIX) - return *((const Matrix*)value_); + return *((const Eigen::MatrixXd*)value_); + throw ExceptionAbstract(ExceptionAbstract::TOOLS, + "value is not a Eigen matrixXd"); + } + + Eigen::Matrix4d Value::matrix4dValue() const + { + if(type_ == MATRIX4D) + return *((const Eigen::Matrix4d*)value_); throw ExceptionAbstract(ExceptionAbstract::TOOLS, - "value is not a matrix"); + "value is not a Eigen matrix4d"); } std::string Value::typeName(Type type) @@ -289,7 +311,9 @@ namespace dynamicgraph { case VECTOR: return std::string("vector"); case MATRIX: - return std::string("matrix"); + return std::string("matrixXd"); + case MATRIX4D: + return std::string("matrix4d"); default: return std::string("unknown"); } @@ -322,7 +346,10 @@ namespace dynamicgraph { os << value.vectorValue(); break; case Value::MATRIX: - os << value.matrixValue(); + os << value.matrixXdValue(); + break; + case Value::MATRIX4D: + os << value.matrix4dValue(); break; default: return os; @@ -337,7 +364,8 @@ namespace dynamicgraph { template<> const Value::Type ValueHelper<double>::TypeID = Value::DOUBLE; template<> const Value::Type ValueHelper<std::string>::TypeID = Value::STRING; template<> const Value::Type ValueHelper<Vector>::TypeID = Value::VECTOR; - template<> const Value::Type ValueHelper<Matrix>::TypeID = Value::MATRIX; + template<> const Value::Type ValueHelper<Eigen::MatrixXd>::TypeID = Value::MATRIX; + template<> const Value::Type ValueHelper<Eigen::Matrix4d>::TypeID = Value::MATRIX4D; } // namespace command } //namespace dynamicgraph diff --git a/src/signal/signal-cast-helper.cpp b/src/signal/signal-cast-helper.cpp index 00a683b4f47879d4acd22db53e0cbc9aa387d636..376bfe42561549874a13dfab549ca81abd9b3ce4 100644 --- a/src/signal/signal-cast-helper.cpp +++ b/src/signal/signal-cast-helper.cpp @@ -24,7 +24,6 @@ #include <sstream> #include <algorithm> #include <dynamic-graph/exception-signal.h> - #include <dynamic-graph/linear-algebra.h> namespace dynamicgraph @@ -41,6 +40,7 @@ namespace dynamicgraph // To workaround this problem, parse special values manually // (the strings used are the one produces by displaying special // values on a stream). + template <> inline boost::any DefaultCastRegisterer<double>::cast (std::istringstream& iss) @@ -68,13 +68,14 @@ namespace dynamicgraph } /* Specialize Matrix and Vector traces. */ + template <> void DefaultCastRegisterer<dynamicgraph::Vector>:: trace(const boost::any& object, std::ostream& os) { const dynamicgraph::Vector & v = boost::any_cast<dynamicgraph::Vector> (object); - for( unsigned int i=0;i<v.size();++i ) + for( int i=0;i<v.size();++i ) { os << "\t" << v(i); } } template <> @@ -83,13 +84,12 @@ namespace dynamicgraph trace(const boost::any& object, std::ostream& os) { const dynamicgraph::Matrix & m = boost::any_cast<dynamicgraph::Matrix> (object); - for( unsigned int i=0;i<m.nbRows();++i ) - for( unsigned int j=0;j<m.nbCols();++j ) + for(int i=0;i<m.rows();++i ) + for(int j=0;j<m.cols();++j ) { os << "\t" << m(i,j); } } - /// Registers useful casts namespace { diff --git a/src/traces/tracer.cpp b/src/traces/tracer.cpp index 36e0e52d746cbdc6c47ffe4af3d754ca7a44d31a..3cc3b66d0d1a620f47d046e7c32ad97535d69bdc 100644 --- a/src/traces/tracer.cpp +++ b/src/traces/tracer.cpp @@ -256,7 +256,7 @@ recordSignal( std::ostream& os, } } catch( ExceptionAbstract& exc ) { os << exc << std::endl; } - catch( ... ) { os << "Unknown error occured while reading signal." << std::endl; } + catch( ... ) { os << "Unknown error occurred while reading signal." << std::endl; } dgDEBUGOUT(15); diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 723b69b2065f4be6c8d8417f8be6417fd794d890..4d14693d9b7097ffddbb7356779fb4c0d7b6f021 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -43,12 +43,6 @@ MACRO(DYNAMIC_GRAPH_TEST NAME) # Link against Boost. TARGET_LINK_LIBRARIES(${NAME} ${Boost_LIBRARIES}) - # Search for jrl-mal. - INCLUDE_DIRECTORIES(${JRL_MAL_INCLUDE_DIRS}) - LINK_DIRECTORIES(${JRL_MAL_LIBRARY_DIRS}) - IF(UNIX AND NOT APPLE) - TARGET_LINK_LIBRARIES(${NAME} ${JRL_MAL_LDFLAGS}) - ENDIF(UNIX AND NOT APPLE) ENDMACRO(DYNAMIC_GRAPH_TEST) diff --git a/tests/signal-cast-registerer-libA.hh b/tests/signal-cast-registerer-libA.hh index 7dcdd3bc2ed5df2a2a713ec72ec6ac3f1960dd5b..f0065e224f434fc72190f2ff49efa82a5e8bd37f 100644 --- a/tests/signal-cast-registerer-libA.hh +++ b/tests/signal-cast-registerer-libA.hh @@ -13,8 +13,7 @@ // 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 <boost/numeric/ublas/vector.hpp> -#include <boost/numeric/ublas/io.hpp> +#include <Eigen/Dense> -typedef boost::numeric::ublas::vector<double> vec_type; +typedef Eigen::VectorXd vec_type; extern vec_type vA; diff --git a/tests/signal-cast-registerer-libB.hh b/tests/signal-cast-registerer-libB.hh index ea04629ecfb188e1fe8d9bc8f866d5289965b738..1c600a5b6bfdba87e4ce6ad84c0df57eb19e5c93 100644 --- a/tests/signal-cast-registerer-libB.hh +++ b/tests/signal-cast-registerer-libB.hh @@ -13,8 +13,7 @@ // 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 <boost/numeric/ublas/vector.hpp> -#include <boost/numeric/ublas/io.hpp> +#include <Eigen/Core> -typedef boost::numeric::ublas::vector<double> vec_type; +typedef Eigen::VectorXd vec_type; extern vec_type vB; diff --git a/tests/signal-cast-registerer.cpp b/tests/signal-cast-registerer.cpp index cc61c4935d7f9e36e3bd745b1c70f1fba3817150..1982589f3d3d73f0a8092541a2c781a355845441 100644 --- a/tests/signal-cast-registerer.cpp +++ b/tests/signal-cast-registerer.cpp @@ -17,13 +17,15 @@ #include <boost/foreach.hpp> #include <boost/format.hpp> -#include <boost/numeric/ublas/vector.hpp> -#include <boost/numeric/ublas/io.hpp> + +#include <Eigen/Dense> #include <dynamic-graph/debug.h> #include <dynamic-graph/entity.h> #include <dynamic-graph/factory.h> #include <dynamic-graph/pool.h> +#include <dynamic-graph/eigen-io.h> +#include <dynamic-graph/linear-algebra.h> #include <dynamic-graph/signal-caster.h> #include <dynamic-graph/signal.h> #include <dynamic-graph/signal-cast-helper.h> @@ -39,14 +41,14 @@ using boost::test_tools::output_test_stream; -typedef boost::numeric::ublas::vector<double> Vector; +typedef Eigen::VectorXd Vector; -struct BoostNumericsCastRegisterer : public dynamicgraph::SignalCastRegisterer +struct EigenCastRegisterer : public dynamicgraph::SignalCastRegisterer { - typedef boost::numeric::ublas::vector<double> bnuVector; + typedef Vector bnuVector; - BoostNumericsCastRegisterer () : + EigenCastRegisterer () : SignalCastRegisterer (typeid(bnuVector), dispVector, castVector, traceVector) {} @@ -62,7 +64,7 @@ struct BoostNumericsCastRegisterer : public dynamicgraph::SignalCastRegisterer { const bnuVector& v = boost::any_cast<bnuVector> (object); os << "[ "; - for (unsigned int i = 0; i < v.size (); ++i) + for (int i = 0; i < v.size (); ++i) os << v(i) << " "; os << " ];" << std::endl; } @@ -70,13 +72,13 @@ struct BoostNumericsCastRegisterer : public dynamicgraph::SignalCastRegisterer static void traceVector (const boost::any& object, std::ostream& os) { const bnuVector& v = boost::any_cast<bnuVector> (object); - for (unsigned int i = 0; i < v.size (); ++i) + for (int i = 0; i < v.size (); ++i) os << v(i) << " "; os << std::endl; } }; -BoostNumericsCastRegisterer myVectorCast; +EigenCastRegisterer myVectorCast; // Define a new cast with a type that supports streaming operators to // and from it (this could be automated with macros). @@ -132,9 +134,8 @@ BOOST_AUTO_TEST_CASE (standard_double_registerer) // Check a custom cast registerer for Boost uBLAS vectors. BOOST_AUTO_TEST_CASE (custom_vector_registerer) { - namespace ublas = boost::numeric::ublas; - dynamicgraph::Signal<Vector, int> myVectorSignal("vector"); + dynamicgraph::Signal<dynamicgraph::Vector, int> myVectorSignal("vector"); // Print the signal name. { @@ -145,10 +146,10 @@ BOOST_AUTO_TEST_CASE (custom_vector_registerer) for (unsigned int i = 0; i < 5; ++i) { - ublas::unit_vector<double> v (5, i); + Vector v = Vector::Unit(5,i) ; std::ostringstream os; os << v; - std::istringstream ss (os.str ()); + std::istringstream ss ("[5]("+os.str ()+")"); // Set signal value. myVectorSignal.set (ss);