Skip to content
Snippets Groups Projects
Commit 8985d852 authored by Damien Petit's avatar Damien Petit Committed by Thomas Moulard
Browse files

add support for unsigned int values import/export (close #2)

parent 992a40c4
No related branches found
No related tags found
No related merge requests found
...@@ -55,6 +55,17 @@ namespace dynamicgraph ...@@ -55,6 +55,17 @@ namespace dynamicgraph
dst = src.data; dst = src.data;
} }
// Unsigned
SOT_TO_ROS_IMPL(unsigned int)
{
dst.data = src;
}
ROS_TO_SOT_IMPL(unsigned int)
{
dst = src.data;
}
// Vector // Vector
SOT_TO_ROS_IMPL(ml::Vector) SOT_TO_ROS_IMPL(ml::Vector)
{ {
...@@ -210,6 +221,7 @@ namespace dynamicgraph ...@@ -210,6 +221,7 @@ namespace dynamicgraph
struct e_n_d__w_i_t_h__s_e_m_i_c_o_l_o_n struct e_n_d__w_i_t_h__s_e_m_i_c_o_l_o_n
DG_BRIDGE_MAKE_SHPTR_IMPL(double); DG_BRIDGE_MAKE_SHPTR_IMPL(double);
DG_BRIDGE_MAKE_SHPTR_IMPL(unsigned int);
DG_BRIDGE_MAKE_SHPTR_IMPL(ml::Vector); DG_BRIDGE_MAKE_SHPTR_IMPL(ml::Vector);
DG_BRIDGE_MAKE_SHPTR_IMPL(specific::Vector3); DG_BRIDGE_MAKE_SHPTR_IMPL(specific::Vector3);
DG_BRIDGE_MAKE_SHPTR_IMPL(ml::Matrix); DG_BRIDGE_MAKE_SHPTR_IMPL(ml::Matrix);
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include <ros/ros.h> #include <ros/ros.h>
#include <std_msgs/Float64.h> #include <std_msgs/Float64.h>
#include <std_msgs/UInt32.h>
#include <dynamic-graph/factory.h> #include <dynamic-graph/factory.h>
...@@ -73,6 +74,8 @@ namespace dynamicgraph ...@@ -73,6 +74,8 @@ namespace dynamicgraph
if (type == "double") if (type == "double")
entity.add<double> (signal, topic); entity.add<double> (signal, topic);
else if (type == "unsigned")
entity.add<unsigned int> (signal, topic);
else if (type == "matrix") else if (type == "matrix")
entity.add<ml::Matrix> (signal, topic); entity.add<ml::Matrix> (signal, topic);
else if (type == "vector") else if (type == "vector")
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include <ros/ros.h> #include <ros/ros.h>
#include <std_msgs/Float64.h> #include <std_msgs/Float64.h>
#include <std_msgs/UInt32.h>
#include <dynamic-graph/factory.h> #include <dynamic-graph/factory.h>
#include <dynamic-graph/command.h> #include <dynamic-graph/command.h>
...@@ -77,6 +78,8 @@ namespace dynamicgraph ...@@ -77,6 +78,8 @@ namespace dynamicgraph
if (type == "double") if (type == "double")
entity.add<double> (signal, topic); entity.add<double> (signal, topic);
else if (type == "unsigned")
entity.add<unsigned int> (signal, topic);
else if (type == "matrix") else if (type == "matrix")
entity.add<ml::Matrix> (signal, topic); entity.add<ml::Matrix> (signal, topic);
else if (type == "vector") else if (type == "vector")
......
...@@ -4,6 +4,7 @@ namespace dynamicgraph ...@@ -4,6 +4,7 @@ namespace dynamicgraph
{ {
const char* SotToRos<double>::signalTypeName = "Double"; const char* SotToRos<double>::signalTypeName = "Double";
const char* SotToRos<unsigned int>::signalTypeName = "Unsigned";
const char* SotToRos<ml::Matrix>::signalTypeName = "Matrix"; const char* SotToRos<ml::Matrix>::signalTypeName = "Matrix";
const char* SotToRos<ml::Vector>::signalTypeName = "Vector"; const char* SotToRos<ml::Vector>::signalTypeName = "Vector";
const char* SotToRos<specific::Vector3>::signalTypeName = "Vector3"; const char* SotToRos<specific::Vector3>::signalTypeName = "Vector3";
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
# include <jrl/mal/boost.hh> # include <jrl/mal/boost.hh>
# include <std_msgs/Float64.h> # include <std_msgs/Float64.h>
# include <std_msgs/UInt32.h>
# include "dynamic_graph_bridge/Matrix.h" # include "dynamic_graph_bridge/Matrix.h"
# include "dynamic_graph_bridge/Vector.h" # include "dynamic_graph_bridge/Vector.h"
...@@ -67,6 +68,25 @@ namespace dynamicgraph ...@@ -67,6 +68,25 @@ namespace dynamicgraph
} }
}; };
template <>
struct SotToRos<unsigned int>
{
typedef unsigned int sot_t;
typedef std_msgs::UInt32 ros_t;
typedef std_msgs::UInt32ConstPtr ros_const_ptr_t;
typedef dynamicgraph::Signal<sot_t, int> signal_t;
typedef dynamicgraph::SignalPtr<sot_t, int> signalIn_t;
typedef boost::function<sot_t& (sot_t&, int)> callback_t;
static const char* signalTypeName;
template <typename S>
static void setDefault(S& s)
{
s.setConstant (0);
}
};
template <> template <>
struct SotToRos<ml::Matrix> struct SotToRos<ml::Matrix>
{ {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment