ros_plugin.cpp
Go to the documentation of this file.
00001 /***************************************************************************
00002   tag: Ruben Smits  Tue Nov 16 09:19:02 CET 2010  ros_plugin.cpp
00003 
00004                         ros_plugin.cpp -  description
00005                            -------------------
00006     begin                : Tue November 16 2010
00007     copyright            : (C) 2010 Ruben Smits
00008     email                : first.last@mech.kuleuven.be
00009 
00010  ***************************************************************************
00011  *   This library is free software; you can redistribute it and/or         *
00012  *   modify it under the terms of the GNU Lesser General Public            *
00013  *   License as published by the Free Software Foundation; either          *
00014  *   version 2.1 of the License, or (at your option) any later version.    *
00015  *                                                                         *
00016  *   This library is distributed in the hope that it will be useful,       *
00017  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00018  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
00019  *   Lesser General Public License for more details.                       *
00020  *                                                                         *
00021  *   You should have received a copy of the GNU Lesser General Public      *
00022  *   License along with this library; if not, write to the Free Software   *
00023  *   Foundation, Inc., 59 Temple Place,                                    *
00024  *   Suite 330, Boston, MA  02111-1307  USA                                *
00025  *                                                                         *
00026  ***************************************************************************/
00027 
00028 
00029 #include <rtt/plugin/Plugin.hpp>
00030 #include <rtt/TaskContext.hpp>
00031 #include <rtt/Activity.hpp>
00032 #include <rtt/Logger.hpp>
00033 #include <rtt/os/startstop.h>
00034 #include <ros/ros.h>
00035 
00036 void loadROSService();
00037 
00038 using namespace RTT;
00039 extern "C" {
00040   bool loadRTTPlugin(RTT::TaskContext* c){
00041     log(Info)<<"Initializing ROS node"<<endlog();
00042     if(!ros::isInitialized()){
00043         int argc =__os_main_argc();
00044         char ** argv = __os_main_argv();
00045         ros::init(argc,argv,"rtt",ros::init_options::AnonymousName);
00046       if(ros::master::check())
00047           ros::start();
00048       else{
00049           log(Warning)<<"'roscore' is not running: no ROS functions will be available."<<endlog();
00050           ros::shutdown();
00051           return true;
00052       }
00053     }
00054     static ros::AsyncSpinner spinner(1); // Use 1 threads
00055     spinner.start();
00056     log(Info)<<"ROS node spinner started"<<endlog();
00057     loadROSService();
00058 
00059     return true;
00060   }
00061   std::string getRTTPluginName (){
00062     return "ros_integration";
00063   }
00064   std::string getRTTTargetName (){
00065     return OROCOS_TARGET_NAME;
00066   }
00067 }
00068 


rtt_rosnode
Author(s): Ruben Smits, ruben.smits@mech.kuleuven.be
autogenerated on Mon Oct 6 2014 07:24:21