diff --git a/include/dynamic-graph/python/dynamic-graph-py.hh b/include/dynamic-graph/python/dynamic-graph-py.hh index f62c16e..1a36c34 100644 --- a/include/dynamic-graph/python/dynamic-graph-py.hh +++ b/include/dynamic-graph/python/dynamic-graph-py.hh @@ -40,8 +40,8 @@ void exposeSignals(); // Declare functions defined in other source files namespace signalBase { -SignalBase* createSignalWrapper(const char* name, const char* type, - bp::object object); +SignalBase* createSignalWrapper(const char* name, const char* type, + bp::object object); } // namespace signalBase namespace entity { diff --git a/include/dynamic-graph/python/signal-wrapper.hh b/include/dynamic-graph/python/signal-wrapper.hh index 30a22e2..9cdaa30 100644 --- a/include/dynamic-graph/python/signal-wrapper.hh +++ b/include/dynamic-graph/python/signal-wrapper.hh @@ -22,7 +22,7 @@ class PythonSignalContainer : public Entity { public: using Entity::Entity; - void signalRegistration(const SignalArray& signals); + void signalRegistration(const SignalArray& signals); void rmSignal(const std::string& name); }; diff --git a/src/dynamic_graph/convert-dg-to-py.cc b/src/dynamic_graph/convert-dg-to-py.cc index 9df3a84..d4b1f50 100644 --- a/src/dynamic_graph/convert-dg-to-py.cc +++ b/src/dynamic_graph/convert-dg-to-py.cc @@ -29,8 +29,12 @@ command::Value toValue(bp::object o, const command::Value::Type& valueType) { return Value(bp::extract(o)); case (Value::UNSIGNED): return Value(bp::extract(o)); + case (Value::UNSIGNEDLONGINT): + return Value(bp::extract(o)); case (Value::INT): return Value(bp::extract(o)); + case (Value::LONGINT): + return Value(bp::extract(o)); case (Value::FLOAT): return Value(bp::extract(o)); case (Value::DOUBLE): @@ -67,8 +71,12 @@ bp::object fromValue(const command::Value& value) { return bp::object(value.boolValue()); case (Value::UNSIGNED): return bp::object(value.unsignedValue()); + case (Value::UNSIGNEDLONGINT): + return bp::object(value.unsignedlongintValue()); case (Value::INT): return bp::object(value.intValue()); + case (Value::LONGINT): + return bp::object(value.longintValue()); case (Value::FLOAT): return bp::object(value.floatValue()); case (Value::DOUBLE): diff --git a/src/dynamic_graph/dynamic-graph-py.cc b/src/dynamic_graph/dynamic-graph-py.cc index 0cf7355..dda53ac 100644 --- a/src/dynamic_graph/dynamic-graph-py.cc +++ b/src/dynamic_graph/dynamic-graph-py.cc @@ -32,7 +32,7 @@ namespace python { /** \brief plug a signal into another one. */ -void plug(SignalBase* signalOut, SignalBase* signalIn) { +void plug(SignalBase* signalOut, SignalBase* signalIn) { signalIn->plug(signalOut); } @@ -66,7 +66,8 @@ MapOfEntities* getEntityMap() { &dg::PoolStorage::getInstance()->getEntityMap()); } -dg::SignalBase* getSignal(dg::Entity& e, const std::string& name) { +dg::SignalBase* getSignal(dg::Entity& e, + const std::string& name) { return &e.getSignal(name); } @@ -76,7 +77,7 @@ class PythonEntity : public dg::Entity { public: using dg::Entity::Entity; - void signalRegistration(dg::SignalBase& signal) { + void signalRegistration(dg::SignalBase& signal) { dg::Entity::signalRegistration(signal); } void signalDeregistration(const std::string& name) { diff --git a/src/dynamic_graph/signal-base-py.cc b/src/dynamic_graph/signal-base-py.cc index a6f4db6..eedb367 100644 --- a/src/dynamic_graph/signal-base-py.cc +++ b/src/dynamic_graph/signal-base-py.cc @@ -22,8 +22,6 @@ namespace bp = boost::python; namespace dynamicgraph { namespace python { -typedef int time_type; - typedef Eigen::AngleAxis VectorUTheta; typedef Eigen::Quaternion Quaternion; @@ -79,18 +77,18 @@ void exposeSignalBase(const char* name) { }) .def( "displayDependencies", - +[](const S_t& s, int time) -> std::string { + +[](const S_t& s, int depth) -> std::string { std::ostringstream oss; - s.displayDependencies(oss, time); + s.displayDependencies(oss, depth); return oss.str(); }, "Print the signal dependencies in a string"); } template <> -auto exposeSignal(const std::string& name) { - typedef Signal S_t; - bp::class_ >, boost::noncopyable> obj( +auto exposeSignal(const std::string& name) { + typedef Signal S_t; + bp::class_ >, boost::noncopyable> obj( name.c_str(), bp::init()); obj.add_property( "value", @@ -107,31 +105,35 @@ auto exposeSignal(const std::string& name) { } void exposeSignals() { - exposeSignalBase("SignalBase"); - - exposeSignalsOfType("Bool"); - exposeSignalsOfType("Int"); - exposeSignalsOfType("Double"); - - exposeSignalsOfType("Vector"); - exposeSignalsOfType("Vector3"); - exposeSignalsOfType("Vector7"); - - exposeSignalsOfType("Matrix"); - exposeSignalsOfType("MatrixRotation"); - exposeSignalsOfType("MatrixHomogeneous"); - exposeSignalsOfType("MatrixTwist"); - - exposeSignalsOfType("Quaternion"); - exposeSignalsOfType("VectorUTheta"); + exposeSignalBase("SignalBase"); + + exposeSignalsOfType("Bool"); + exposeSignalsOfType("UInt"); + exposeSignalsOfType("Int"); + exposeSignalsOfType("UInt64"); + exposeSignalsOfType("Int64"); + exposeSignalsOfType("Double"); + + exposeSignalsOfType("Vector"); + exposeSignalsOfType("Vector3"); + exposeSignalsOfType("Vector7"); + + exposeSignalsOfType("Matrix"); + exposeSignalsOfType("MatrixRotation"); + exposeSignalsOfType("MatrixHomogeneous"); + exposeSignalsOfType("MatrixTwist"); + + exposeSignalsOfType("Quaternion"); + exposeSignalsOfType("VectorUTheta"); } namespace signalBase { template -SignalWrapper* createSignalWrapperTpl(const char* name, bp::object o, - std::string& error) { - typedef SignalWrapper SignalWrapper_t; +SignalWrapper* createSignalWrapperTpl(const char* name, + bp::object o, + std::string& error) { + typedef SignalWrapper SignalWrapper_t; if (!SignalWrapper_t::checkCallable(o, error)) { return NULL; } @@ -153,23 +155,36 @@ PythonSignalContainer* getPythonSignalContainer() { /** \brief Create an instance of SignalWrapper */ -SignalBase* createSignalWrapper(const char* name, const char* type, - bp::object object) { +SignalBase* createSignalWrapper(const char* name, const char* type, + bp::object object) { PythonSignalContainer* psc = getPythonSignalContainer(); if (psc == NULL) return NULL; - SignalBase* obj = NULL; + SignalBase* obj = NULL; std::string error; - SIGNAL_WRAPPER_TYPE(if, BOOL, bool) - // SIGNAL_WRAPPER_TYPE(else if, UNSIGNED ,bool) - SIGNAL_WRAPPER_TYPE(else if, INT, int) - SIGNAL_WRAPPER_TYPE(else if, FLOAT, float) - SIGNAL_WRAPPER_TYPE(else if, DOUBLE, double) - // SIGNAL_WRAPPER_TYPE(else if, STRING ,bool) - SIGNAL_WRAPPER_TYPE(else if, VECTOR, Vector) - // SIGNAL_WRAPPER_TYPE(else if, MATRIX ,bool) - // SIGNAL_WRAPPER_TYPE(else if, MATRIX4D ,bool) - else { + if (command::Value::typeName(command::Value::BOOL).compare(type) == 0) { + obj = createSignalWrapperTpl(name, object, error); + } else if (command::Value::typeName(command::Value::UNSIGNED).compare(type) == + 0) { + obj = createSignalWrapperTpl(name, object, error); + } else if (command::Value::typeName(command::Value::INT).compare(type) == 0) { + obj = createSignalWrapperTpl(name, object, error); + } else if (command::Value::typeName(command::Value::UNSIGNEDLONGINT) + .compare(type) == 0) { + obj = createSignalWrapperTpl(name, object, error); + } else if (command::Value::typeName(command::Value::LONGINT).compare(type) == + 0) { + obj = createSignalWrapperTpl(name, object, error); + } else if (command::Value::typeName(command::Value::FLOAT).compare(type) == + 0) { + obj = createSignalWrapperTpl(name, object, error); + } else if (command::Value::typeName(command::Value::DOUBLE).compare(type) == + 0) { + obj = createSignalWrapperTpl(name, object, error); + } else if (command::Value::typeName(command::Value::VECTOR).compare(type) == + 0) { + obj = createSignalWrapperTpl(name, object, error); + } else { error = "Type not understood"; } diff --git a/src/dynamic_graph/signal-wrapper.cc b/src/dynamic_graph/signal-wrapper.cc index cc41fb0..a878ede 100644 --- a/src/dynamic_graph/signal-wrapper.cc +++ b/src/dynamic_graph/signal-wrapper.cc @@ -9,7 +9,7 @@ namespace dynamicgraph { namespace python { void PythonSignalContainer::signalRegistration( - const SignalArray& signals) { + const SignalArray& signals) { Entity::signalRegistration(signals); } @@ -30,10 +30,13 @@ bool SignalWrapper::checkCallable(pyobject c, std::string& error) { return true; } -template class SignalWrapper; -template class SignalWrapper; -template class SignalWrapper; -template class SignalWrapper; -template class SignalWrapper; +template class SignalWrapper; +template class SignalWrapper; +template class SignalWrapper; +template class SignalWrapper; +template class SignalWrapper; +template class SignalWrapper; +template class SignalWrapper; +template class SignalWrapper; } // namespace python } // namespace dynamicgraph diff --git a/tests/custom_entity.cpp b/tests/custom_entity.cpp index a7aa2f5..1ead109 100644 --- a/tests/custom_entity.cpp +++ b/tests/custom_entity.cpp @@ -46,7 +46,7 @@ void CustomEntity::rmValidSignal() { signalDeregistration("out_double"); } -double &CustomEntity::update(double &res, const int &inTime) { +double &CustomEntity::update(double &res, const sigtime_t &inTime) { const double &aDouble = m_sigdSIN(inTime); res = aDouble; logger().stream(MSG_TYPE_ERROR) << "start update " << res << '\n'; diff --git a/tests/custom_entity.h b/tests/custom_entity.h index fd821f0..c950a07 100644 --- a/tests/custom_entity.h +++ b/tests/custom_entity.h @@ -14,8 +14,8 @@ namespace dynamicgraph { class CustomEntity : public Entity { public: - dynamicgraph::SignalPtr m_sigdSIN; - dynamicgraph::SignalTimeDependent m_sigdTimeDepSOUT; + dynamicgraph::SignalPtr m_sigdSIN; + dynamicgraph::SignalTimeDependent m_sigdTimeDepSOUT; DYNAMIC_GRAPH_ENTITY_DECL(); CustomEntity(const std::string n); @@ -24,7 +24,7 @@ class CustomEntity : public Entity { void rmValidSignal(); - double &update(double &res, const int &inTime); + double &update(double &res, const sigtime_t &inTime); void act(); }; diff --git a/tests/test_bindings.py b/tests/test_bindings.py index 425da39..12f0e13 100644 --- a/tests/test_bindings.py +++ b/tests/test_bindings.py @@ -8,8 +8,8 @@ dynamic_graph.wrap.plug(%s, %s) did not match C++ signature: plug(""" - "dynamicgraph::SignalBase* signalOut, " - "dynamicgraph::SignalBase* signalIn)" + "dynamicgraph::SignalBase* signalOut, " + "dynamicgraph::SignalBase* signalIn)" )