Skip to content
Snippets Groups Projects
Commit 0467c816 authored by Joseph Mirabel's avatar Joseph Mirabel Committed by Olivier Stasse
Browse files

RosPublish can publish integers

parent 1accd8f8
No related branches found
No related tags found
No related merge requests found
......@@ -66,6 +66,17 @@ namespace dynamicgraph
dst = src.data;
}
// Int
SOT_TO_ROS_IMPL(int)
{
dst.data = src;
}
ROS_TO_SOT_IMPL(int)
{
dst = src.data;
}
// Unsigned
SOT_TO_ROS_IMPL(unsigned int)
{
......@@ -229,6 +240,7 @@ namespace dynamicgraph
DG_BRIDGE_MAKE_SHPTR_IMPL(bool);
DG_BRIDGE_MAKE_SHPTR_IMPL(double);
DG_BRIDGE_MAKE_SHPTR_IMPL(int);
DG_BRIDGE_MAKE_SHPTR_IMPL(unsigned int);
DG_BRIDGE_MAKE_SHPTR_IMPL(Vector);
DG_BRIDGE_MAKE_SHPTR_IMPL(specific::Vector3);
......
......@@ -84,6 +84,8 @@ namespace dynamicgraph
entity.add<double> (signal, topic);
else if (type == "unsigned")
entity.add<unsigned int> (signal, topic);
else if (type == "int")
entity.add<int> (signal, topic);
else if (type == "matrix")
entity.add<Matrix> (signal, topic);
else if (type == "vector")
......
......@@ -5,6 +5,7 @@ namespace dynamicgraph
const char* SotToRos<bool>::signalTypeName = "bool";
const char* SotToRos<double>::signalTypeName = "Double";
const char* SotToRos<int>::signalTypeName = "int";
const char* SotToRos<unsigned int>::signalTypeName = "Unsigned";
const char* SotToRos<Matrix>::signalTypeName = "Matrix";
const char* SotToRos<Vector>::signalTypeName = "Vector";
......
......@@ -8,6 +8,7 @@
# include <std_msgs/Bool.h>
# include <std_msgs/Float64.h>
# include <std_msgs/UInt32.h>
# include <std_msgs/Int32.h>
# include "dynamic_graph_bridge_msgs/Matrix.h"
# include "dynamic_graph_bridge_msgs/Vector.h"
......@@ -121,6 +122,30 @@ namespace dynamicgraph
}
};
template <>
struct SotToRos<int>
{
typedef int sot_t;
typedef std_msgs::Int32 ros_t;
typedef std_msgs::Int32ConstPtr 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);
}
static void setDefault(sot_t& s)
{
s = 0;
}
};
template <>
struct SotToRos<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