Gazebo Sensors

API Reference

8.2.1
DepthCameraSensor.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2018 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 #ifndef GZ_SENSORS_DEPTHCAMERASENSOR_HH_
18 #define GZ_SENSORS_DEPTHCAMERASENSOR_HH_
19 
20 #include <memory>
21 #include <cstdint>
22 #include <string>
23 
24 #include <sdf/sdf.hh>
25 
26 #include <gz/common/Event.hh>
27 #include <gz/utils/SuppressWarning.hh>
28 
29 #include <gz/msgs/image.pb.h>
30 
31 // TODO(louise) Remove these pragmas once gz-rendering is disabling the
32 // warnings
33 #ifdef _WIN32
34 #pragma warning(push)
35 #pragma warning(disable: 4251)
36 #endif
37 #include <gz/rendering/DepthCamera.hh>
38 #ifdef _WIN32
39 #pragma warning(pop)
40 #endif
41 
42 #include "gz/sensors/depth_camera/Export.hh"
44 #include "gz/sensors/Export.hh"
45 #include "gz/sensors/Sensor.hh"
46 
47 namespace gz
48 {
49  namespace sensors
50  {
51  // Inline bracket to help doxygen filtering.
52  inline namespace GZ_SENSORS_VERSION_NAMESPACE {
53  // forward declarations
54  class DepthCameraSensorPrivate;
55 
63  class GZ_SENSORS_DEPTH_CAMERA_VISIBLE DepthCameraSensor
64  : public CameraSensor
65  {
67  public: DepthCameraSensor();
68 
70  public: virtual ~DepthCameraSensor();
71 
75  public: virtual bool Load(const sdf::Sensor &_sdf) override;
76 
80  public: virtual bool Load(sdf::ElementPtr _sdf) override;
81 
84  public: virtual bool Init() override;
85 
89  public: virtual bool Update(
90  const std::chrono::steady_clock::duration &_now) override;
91 
94  public: virtual rendering::DepthCameraPtr DepthCamera() const;
95 
102  public: void OnNewDepthFrame(const float *_scan,
103  unsigned int _width, unsigned int _height,
104  unsigned int _channel,
105  const std::string &_format);
106 
113  public: void OnNewRgbPointCloud(const float *_scan,
114  unsigned int _width, unsigned int _height,
115  unsigned int _channels,
116  const std::string &_format);
117 
126  public: gz::common::ConnectionPtr ConnectImageCallback(
128  void(const gz::msgs::Image &)> _callback);
129 
132  public: virtual void SetScene(
133  gz::rendering::ScenePtr _scene) override;
134 
137  public: virtual unsigned int ImageWidth() const override;
138 
141  public: virtual unsigned int ImageHeight() const override;
142 
145  public: virtual double FarClip() const;
146 
149  public: virtual double NearClip() const;
150 
151  // Documentation inherited.
152  public: virtual bool HasConnections() const override;
153 
156  public: virtual bool HasDepthConnections() const;
157 
160  public: virtual bool HasPointConnections() const;
161 
164  private: bool CreateCamera();
165 
169  private: void OnSceneChange(gz::rendering::ScenePtr /*_scene*/)
170  { }
171 
172  GZ_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING
176  GZ_UTILS_WARN_RESUME__DLL_INTERFACE_MISSING
177  };
178  }
179  }
180 }
181 
182 #endif