gazebo_ros_video.h
Go to the documentation of this file.
1 /*
2  * Copyright 2013 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16 */
17 
18 /*
19  * Desc: Video plugin for displaying ROS image topics on Ogre textures
20  * Author: Piyush Khandelwal
21  * Date: 26 July 2013
22  */
23 
24 #ifndef GAZEBO_ROS_VIDEO_H
25 #define GAZEBO_ROS_VIDEO_H
26 
27 #include <boost/thread/mutex.hpp>
28 #include <cv_bridge/cv_bridge.h>
30 #include <opencv2/core.hpp>
31 #include <ros/advertise_options.h>
32 #include <ros/callback_queue.h>
33 #include <ros/ros.h>
34 #include <sensor_msgs/Image.h>
35 
36 #include <gazebo/common/Events.hh>
37 #include <gazebo/common/Plugin.hh>
38 #include <gazebo/common/Time.hh>
39 #include <gazebo/rendering/rendering.hh>
40 #include <gazebo/transport/TransportTypes.hh>
41 
42 namespace gazebo
43 {
44 
45  class VideoVisual : public rendering::Visual
46  {
47  public:
49  const std::string &name, rendering::VisualPtr parent,
50  int height, int width);
51  virtual ~VideoVisual();
52  void render(const cv::Mat& image);
53  private:
54  Ogre::TexturePtr texture_;
55  int height_;
56  int width_;
57  };
58 
59  class GazeboRosVideo : public VisualPlugin
60  {
61  public:
62 
64  virtual ~GazeboRosVideo();
65 
66  void Load(rendering::VisualPtr parent, sdf::ElementPtr sdf);
67  void processImage(const sensor_msgs::ImageConstPtr &msg);
68 
69  protected:
70 
71  virtual void UpdateChild();
72 
73  // Pointer to the model
74  rendering::VisualPtr model_;
75  // Pointer to the update event connection
76  event::ConnectionPtr update_connection_;
77 
79 
81  boost::mutex m_image_;
83 
86 
87  // ROS Stuff
89  std::string robot_namespace_;
90  std::string topic_name_;
91 
93  boost::thread callback_queue_thread_;
94  void QueueThread();
95 
96  };
97 
98 }
99 
100 #endif
gazebo::VideoVisual::~VideoVisual
virtual ~VideoVisual()
Definition: gazebo_ros_video.cpp:87
msg
msg
gazebo::GazeboRosVideo::video_visual_
boost::shared_ptr< VideoVisual > video_visual_
Definition: gazebo_ros_video.h:78
gazebo::GazeboRosVideo::callback_queue_thread_
boost::thread callback_queue_thread_
Definition: gazebo_ros_video.h:93
boost::shared_ptr
gazebo
ros.h
gazebo::GazeboRosVideo::camera_subscriber_
ros::Subscriber camera_subscriber_
Definition: gazebo_ros_video.h:88
gazebo::GazeboRosVideo::update_connection_
event::ConnectionPtr update_connection_
Definition: gazebo_ros_video.h:76
gazebo::GazeboRosVideo
Definition: gazebo_ros_video.h:59
gazebo::GazeboRosVideo::topic_name_
std::string topic_name_
Definition: gazebo_ros_video.h:90
gazebo::VideoVisual::height_
int height_
Definition: gazebo_ros_video.h:55
gazebo::GazeboRosVideo::QueueThread
void QueueThread()
Definition: gazebo_ros_video.cpp:256
gazebo::GazeboRosVideo::GazeboRosVideo
GazeboRosVideo()
Definition: gazebo_ros_video.cpp:117
ros::CallbackQueue
gazebo::GazeboRosVideo::image_
cv_bridge::CvImagePtr image_
Definition: gazebo_ros_video.h:80
gazebo::GazeboRosVideo::robot_namespace_
std::string robot_namespace_
Definition: gazebo_ros_video.h:89
gazebo::VideoVisual::render
void render(const cv::Mat &image)
Definition: gazebo_ros_video.cpp:89
gazebo::VideoVisual
Definition: gazebo_ros_video.h:45
gazebo::GazeboRosVideo::model_
rendering::VisualPtr model_
Definition: gazebo_ros_video.h:74
gazebo::GazeboRosVideo::processImage
void processImage(const sensor_msgs::ImageConstPtr &msg)
Definition: gazebo_ros_video.cpp:247
gazebo::GazeboRosVideo::new_image_available_
bool new_image_available_
Definition: gazebo_ros_video.h:82
image_transport.h
callback_queue.h
gazebo::GazeboRosVideo::~GazeboRosVideo
virtual ~GazeboRosVideo()
Definition: gazebo_ros_video.cpp:120
advertise_options.h
cv_bridge.h
gazebo::GazeboRosVideo::queue_
ros::CallbackQueue queue_
Definition: gazebo_ros_video.h:92
gazebo::GazeboRosVideo::Load
void Load(rendering::VisualPtr parent, sdf::ElementPtr sdf)
Definition: gazebo_ros_video.cpp:133
gazebo::GazeboRosVideo::m_image_
boost::mutex m_image_
Definition: gazebo_ros_video.h:81
gazebo::VideoVisual::texture_
Ogre::TexturePtr texture_
Definition: gazebo_ros_video.h:54
gazebo::GazeboRosVideo::UpdateChild
virtual void UpdateChild()
Definition: gazebo_ros_video.cpp:228
gazebo::VideoVisual::VideoVisual
VideoVisual(const std::string &name, rendering::VisualPtr parent, int height, int width)
Definition: gazebo_ros_video.cpp:33
gazebo::GazeboRosVideo::rosnode_
ros::NodeHandle * rosnode_
A pointer to the ROS node. A node will be instantiated if it does not exist.
Definition: gazebo_ros_video.h:85
gazebo::VideoVisual::width_
int width_
Definition: gazebo_ros_video.h:56
ros::NodeHandle
ros::Subscriber


gazebo_plugins
Author(s): John Hsu
autogenerated on Thu Sep 5 2024 02:49:55