gazebo_gst_camera_plugin.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2012-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 #pragma once
00018 
00019 #include <string>
00020 #include <mutex>
00021 
00022 #include "gazebo/common/Plugin.hh"
00023 #include "gazebo/sensors/CameraSensor.hh"
00024 #include "gazebo/gazebo.hh"
00025 #include "gazebo/common/common.hh"
00026 #include "gazebo/rendering/Camera.hh"
00027 #include "gazebo/util/system.hh"
00028 #include "gazebo/transport/transport.hh"
00029 #include "gazebo/msgs/msgs.hh"
00030 
00031 #include <gst/gst.h>
00032 
00033 namespace gazebo
00034 {
00035 
00036 
00044 class GAZEBO_VISIBLE GstCameraPlugin : public SensorPlugin
00045 {
00046   public: GstCameraPlugin();
00047 
00048   public: virtual ~GstCameraPlugin();
00049 
00050   public: virtual void Load(sensors::SensorPtr sensor, sdf::ElementPtr sdf);
00051 
00052   public: virtual void OnNewFrame(const unsigned char *image,
00053                 unsigned int width, unsigned int height,
00054                 unsigned int depth, const std::string &format);
00055 
00056   public: void startGstThread();
00057   public: void gstCallback(GstElement *appsrc);
00058 
00059   protected: unsigned int width, height, depth;
00060   float rate;
00061   protected: std::string format;
00062 
00063   protected: int udpPort;
00064 
00065   protected: sensors::CameraSensorPtr parentSensor;
00066   protected: rendering::CameraPtr camera;
00067 
00068   private: event::ConnectionPtr newFrameConnection;
00069 
00070   private: transport::NodePtr node_handle_;
00071   private: std::string namespace_;
00072   private: const std::string topicName = "gst_video";
00073 
00074   GstBuffer *frameBuffer;
00075   std::mutex frameBufferMutex;
00076   GMainLoop *mainLoop;
00077   GstClockTime gstTimestamp;
00078 
00079 };
00080 
00081 } /* namespace gazebo */


rotors_gazebo_plugins
Author(s): Fadri Furrer, Michael Burri, Mina Kamel, Janosch Nikolic, Markus Achtelik
autogenerated on Thu Apr 18 2019 02:43:43