Skip to content

Commit 8eeebe9

Browse files
jmirabelolivier-stasse
authored andcommitted
RosPublish can publish integers
1 parent 0951b1a commit 8eeebe9

File tree

4 files changed

+40
-0
lines changed

4 files changed

+40
-0
lines changed

src/converter.hh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,17 @@ namespace dynamicgraph
6666
dst = src.data;
6767
}
6868

69+
// Int
70+
SOT_TO_ROS_IMPL(int)
71+
{
72+
dst.data = src;
73+
}
74+
75+
ROS_TO_SOT_IMPL(int)
76+
{
77+
dst = src.data;
78+
}
79+
6980
// Unsigned
7081
SOT_TO_ROS_IMPL(unsigned int)
7182
{
@@ -229,6 +240,7 @@ namespace dynamicgraph
229240

230241
DG_BRIDGE_MAKE_SHPTR_IMPL(bool);
231242
DG_BRIDGE_MAKE_SHPTR_IMPL(double);
243+
DG_BRIDGE_MAKE_SHPTR_IMPL(int);
232244
DG_BRIDGE_MAKE_SHPTR_IMPL(unsigned int);
233245
DG_BRIDGE_MAKE_SHPTR_IMPL(Vector);
234246
DG_BRIDGE_MAKE_SHPTR_IMPL(specific::Vector3);

src/ros_publish.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ namespace dynamicgraph
8484
entity.add<double> (signal, topic);
8585
else if (type == "unsigned")
8686
entity.add<unsigned int> (signal, topic);
87+
else if (type == "int")
88+
entity.add<int> (signal, topic);
8789
else if (type == "matrix")
8890
entity.add<Matrix> (signal, topic);
8991
else if (type == "vector")

src/sot_to_ros.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ namespace dynamicgraph
55

66
const char* SotToRos<bool>::signalTypeName = "bool";
77
const char* SotToRos<double>::signalTypeName = "Double";
8+
const char* SotToRos<int>::signalTypeName = "int";
89
const char* SotToRos<unsigned int>::signalTypeName = "Unsigned";
910
const char* SotToRos<Matrix>::signalTypeName = "Matrix";
1011
const char* SotToRos<Vector>::signalTypeName = "Vector";

src/sot_to_ros.hh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
# include <std_msgs/Bool.h>
99
# include <std_msgs/Float64.h>
1010
# include <std_msgs/UInt32.h>
11+
# include <std_msgs/Int32.h>
1112
# include "dynamic_graph_bridge_msgs/Matrix.h"
1213
# include "dynamic_graph_bridge_msgs/Vector.h"
1314

@@ -121,6 +122,30 @@ namespace dynamicgraph
121122
}
122123
};
123124

125+
template <>
126+
struct SotToRos<int>
127+
{
128+
typedef int sot_t;
129+
typedef std_msgs::Int32 ros_t;
130+
typedef std_msgs::Int32ConstPtr ros_const_ptr_t;
131+
typedef dynamicgraph::Signal<sot_t, int> signal_t;
132+
typedef dynamicgraph::SignalPtr<sot_t, int> signalIn_t;
133+
typedef boost::function<sot_t& (sot_t&, int)> callback_t;
134+
135+
static const char* signalTypeName;
136+
137+
template <typename S>
138+
static void setDefault(S& s)
139+
{
140+
s.setConstant (0);
141+
}
142+
143+
static void setDefault(sot_t& s)
144+
{
145+
s = 0;
146+
}
147+
};
148+
124149
template <>
125150
struct SotToRos<Matrix>
126151
{

0 commit comments

Comments
 (0)