From 22f4ede91ba8db7d2b26be4041bf8ad7ef2be6aa Mon Sep 17 00:00:00 2001 From: Thomas Moulard <thomas.moulard@gmail.com> Date: Mon, 14 Nov 2011 19:32:55 +0100 Subject: [PATCH] Add missing files. --- src/ros_init.cpp | 24 ++++++++++++++++++++++++ src/ros_init.hh | 11 +++++++++++ 2 files changed, 35 insertions(+) create mode 100644 src/ros_init.cpp create mode 100644 src/ros_init.hh diff --git a/src/ros_init.cpp b/src/ros_init.cpp new file mode 100644 index 0000000..8f21c05 --- /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 0000000..e7dea47 --- /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 -- GitLab