gazebo_gst_camera_plugin.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-2016 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 #pragma once
18 
19 #include <string>
20 #include <mutex>
21 
22 #include "gazebo/common/Plugin.hh"
23 #include "gazebo/sensors/CameraSensor.hh"
24 #include "gazebo/gazebo.hh"
25 #include "gazebo/common/common.hh"
26 #include "gazebo/rendering/Camera.hh"
27 #include "gazebo/util/system.hh"
28 #include "gazebo/transport/transport.hh"
29 #include "gazebo/msgs/msgs.hh"
30 
31 #include <gst/gst.h>
32 
33 namespace gazebo
34 {
35 
36 
44 class GAZEBO_VISIBLE GstCameraPlugin : public SensorPlugin
45 {
46  public: GstCameraPlugin();
47 
48  public: virtual ~GstCameraPlugin();
49 
50  public: virtual void Load(sensors::SensorPtr sensor, sdf::ElementPtr sdf);
51 
52  public: virtual void OnNewFrame(const unsigned char *image,
53  unsigned int width, unsigned int height,
54  unsigned int depth, const std::string &format);
55 
56  public: void startGstThread();
57  public: void gstCallback(GstElement *appsrc);
58 
59  protected: unsigned int width, height, depth;
60  float rate;
61  protected: std::string format;
62 
63  protected: int udpPort;
64 
65  protected: sensors::CameraSensorPtr parentSensor;
66  protected: rendering::CameraPtr camera;
67 
68  private: event::ConnectionPtr newFrameConnection;
69 
70  private: transport::NodePtr node_handle_;
71  private: std::string namespace_;
72  private: const std::string topicName = "gst_video";
73 
74  GstBuffer *frameBuffer;
76  GMainLoop *mainLoop;
77  GstClockTime gstTimestamp;
78 
79 };
80 
81 } /* namespace gazebo */
std::string format(const std::string &fmt, Args ... args)
A Gazebo plugin that can be attached to a camera and then streams the video data using gstreamer...
sensors::CameraSensorPtr parentSensor
event::ConnectionPtr newFrameConnection
std::recursive_mutex mutex


rotors_gazebo_plugins
Author(s): Fadri Furrer, Michael Burri, Mina Kamel, Janosch Nikolic, Markus Achtelik
autogenerated on Mon Feb 28 2022 23:39:03