diff --git a/src/ros_init.cpp b/src/ros_init.cpp new file mode 100644 index 0000000000000000000000000000000000000000..8f21c053f3c9dd4963d161cafd507a5ddb03d079 --- /dev/null +++ b/src/ros_init.cpp @@ -0,0 +1,24 @@ +#include <boost/make_shared.hpp> +#include <boost/shared_ptr.hpp> + +#include "ros_init.hh" + +namespace dynamicgraph +{ + boost::shared_ptr<ros::NodeHandle> nodeHandle; + + ros::NodeHandle& rosInit() + { + if (!nodeHandle) + { + int argc = 1; + char* arg0 = strdup("dynamic_graph_bridge"); + char* argv[] = {arg0, 0}; + ros::init(argc, argv, "dynamic_graph_bridge"); + free (arg0); + + nodeHandle = boost::make_shared<ros::NodeHandle> ("dynamic_graph"); + } + return *nodeHandle; + } +} // end of namespace dynamicgraph. diff --git a/src/ros_init.hh b/src/ros_init.hh new file mode 100644 index 0000000000000000000000000000000000000000..e7dea47d824487043dff0fe1563fd1dac57d8e99 --- /dev/null +++ b/src/ros_init.hh @@ -0,0 +1,11 @@ +#ifndef ROS_INIT_HH +# define ROS_INIT_HH +# include <ros/ros.h> + +namespace dynamicgraph +{ + ros::NodeHandle& rosInit(); + +} // end of namespace dynamicgraph. + +#endif //! ROS_INIT_HH