00001 /* 00002 * Copyright (C) 2016 Open Source Robotics Foundation 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 * 00016 */ 00017 #ifndef GAZEBO_ROS_HARNESS_H 00018 #define GAZEBO_ROS_HARNESS_H 00019 00020 // Custom Callback Queue 00021 #include <ros/callback_queue.h> 00022 #include <ros/subscribe_options.h> 00023 00024 #include <ros/ros.h> 00025 #include <std_msgs/Float32.h> 00026 #include <std_msgs/Bool.h> 00027 00028 #include <gazebo/plugins/HarnessPlugin.hh> 00029 00030 namespace gazebo 00031 { 00042 class GazeboRosHarness : public HarnessPlugin 00043 { 00045 public: GazeboRosHarness(); 00046 00048 public: virtual ~GazeboRosHarness(); 00049 00051 public: virtual void Load(physics::ModelPtr _parent, sdf::ElementPtr _sdf); 00052 00055 private: virtual void OnVelocity(const std_msgs::Float32::ConstPtr &msg); 00056 00060 private: virtual void OnDetach(const std_msgs::Bool::ConstPtr &msg); 00061 00063 private: void QueueThread(); 00064 00066 private: ros::NodeHandle *rosnode_; 00067 00069 private: ros::Subscriber velocitySub_; 00070 00072 private: ros::Subscriber detachSub_; 00073 00075 private: std::string robotNamespace_; 00076 private: ros::CallbackQueue queue_; 00077 private: boost::thread callbackQueueThread_; 00078 }; 00079 } 00080 #endif