Skip to content
Snippets Groups Projects
Commit fe409907 authored by Thomas Moulard's avatar Thomas Moulard
Browse files

Bind vector and matrix MAL types.

parent 5ec15699
No related branches found
No related tags found
No related merge requests found
lib/ lib/
msg/lisp/ msg/lisp/
msg_gen/ msg_gen/
src/hueblob/ src/dynamic_graph/
bin/ bin/
...@@ -17,7 +17,7 @@ set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin) ...@@ -17,7 +17,7 @@ set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib) set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)
#uncomment if you have defined messages #uncomment if you have defined messages
#rosbuild_genmsg() rosbuild_genmsg()
#uncomment if you have defined services #uncomment if you have defined services
#rosbuild_gensrv() #rosbuild_gensrv()
......
...@@ -12,5 +12,6 @@ ...@@ -12,5 +12,6 @@
<depend package="std_msgs"/> <depend package="std_msgs"/>
<depend package="roscpp"/> <depend package="roscpp"/>
<rosdep name="jrl-mal"/>
<rosdep name="dynamic-graph"/> <rosdep name="dynamic-graph"/>
</package> </package>
float64[] data
uint32 width
float64[] data
...@@ -56,8 +56,15 @@ namespace dynamicgraph ...@@ -56,8 +56,15 @@ namespace dynamicgraph
} }
else if (cmdLine == "add") else if (cmdLine == "add")
{ {
cmdArgs >> signal >> topic; cmdArgs >> type >> signal >> topic;
add<double> (signal, topic); if (type == "double")
add<double> (signal, topic);
else if (type == "matrix")
add<ml::Matrix> (signal, topic);
else if (type == "vector")
add<ml::Vector> (signal, topic);
else
throw "bad type";
} }
else if (cmdLine == "rm") else if (cmdLine == "rm")
{ {
......
#ifndef DYNAMIC_GRAPH_ROS_IMPORT_HH #ifndef DYNAMIC_GRAPH_ROS_IMPORT_HH
# define DYNAMIC_GRAPH_ROS_IMPORT_HH # define DYNAMIC_GRAPH_ROS_IMPORT_HH
# include <iostream> # include <iostream>
# include <map>
# include <boost/shared_ptr.hpp> # include <boost/shared_ptr.hpp>
......
#ifndef DYNAMIC_GRAPH_ROS_IMPORT_HXX #ifndef DYNAMIC_GRAPH_ROS_IMPORT_HXX
# define DYNAMIC_GRAPH_ROS_IMPORT_HXX # define DYNAMIC_GRAPH_ROS_IMPORT_HXX
# include <vector>
# include <jrl/mal/boost.hh>
# include <std_msgs/Float64.h> # include <std_msgs/Float64.h>
# include "dynamic_graph/Matrix.h"
# include "dynamic_graph/Vector.h"
namespace ml = maal::boost;
namespace dynamicgraph namespace dynamicgraph
{ {
...@@ -13,6 +20,25 @@ namespace dynamicgraph ...@@ -13,6 +20,25 @@ namespace dynamicgraph
typedef boost::function<sot_t& (sot_t&, int)> callback_t; typedef boost::function<sot_t& (sot_t&, int)> callback_t;
}; };
template <>
struct SotToRos<ml::Matrix>
{
typedef ml::Matrix sot_t;
typedef dynamic_graph::Matrix ros_t;
typedef dynamicgraph::SignalTimeDependent<sot_t, int> signal_t;
typedef boost::function<sot_t& (sot_t&, int)> callback_t;
};
template <>
struct SotToRos<ml::Vector>
{
typedef ml::Vector sot_t;
typedef dynamic_graph::Vector ros_t;
typedef dynamicgraph::SignalTimeDependent<sot_t, int> signal_t;
typedef boost::function<sot_t& (sot_t&, int)> callback_t;
};
template <> template <>
void converter (SotToRos<double>::ros_t& dst, void converter (SotToRos<double>::ros_t& dst,
const SotToRos<double>::sot_t& src) const SotToRos<double>::sot_t& src)
...@@ -20,6 +46,26 @@ namespace dynamicgraph ...@@ -20,6 +46,26 @@ namespace dynamicgraph
dst.data = src; dst.data = src;
} }
template <>
void converter (SotToRos<ml::Matrix>::ros_t& dst,
const SotToRos<ml::Matrix>::sot_t& src)
{
dst.width = src.nbRows ();
dst.data.resize (src.nbCols () * src.nbRows ());
for (unsigned i = 0; i < src.nbCols () * src.nbRows (); ++i)
dst.data[i] = src.elementAt (i);
}
template <>
void converter (SotToRos<ml::Vector>::ros_t& dst,
const SotToRos<ml::Vector>::sot_t& src)
{
dst.data.resize (src.size ());
for (unsigned i = 0; i < src.size (); ++i)
dst.data[i] = src.elementAt (i);
}
template <typename T> template <typename T>
T& T&
RosImport::sendData (boost::shared_ptr<ros::Publisher> publisher, RosImport::sendData (boost::shared_ptr<ros::Publisher> publisher,
......
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