Gazebo Sensors

API Reference

3.6.0
gz/sensors/CameraSensor.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2017 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_CAMERASENSOR_HH_
18 #define GZ_SENSORS_CAMERASENSOR_HH_
19 
20 #include <cstdint>
21 #include <memory>
22 #include <string>
23 
24 #include <sdf/sdf.hh>
25 
26 #include <gz/common/PluginMacros.hh>
27 #include <gz/common/SuppressWarning.hh>
28 #include <gz/common/Time.hh>
29 
30 #ifdef _WIN32
31 #pragma warning(push)
32 #pragma warning(disable: 4005)
33 #pragma warning(disable: 4251)
34 #endif
35 #include <ignition/msgs.hh>
36 #ifdef _WIN32
37 #pragma warning(pop)
38 #endif
39 
40 // TODO(louise) Remove these pragmas once ign-rendering is disabling the
41 // warnings
42 #ifdef _WIN32
43 #pragma warning(push)
44 #pragma warning(disable: 4251)
45 #endif
46 #include <gz/rendering/Camera.hh>
47 #ifdef _WIN32
48 #pragma warning(pop)
49 #endif
50 
51 #include "gz/sensors/camera/Export.hh"
52 #include "gz/sensors/config.hh"
53 #include "gz/sensors/Export.hh"
55 
56 namespace ignition
57 {
58  namespace sensors
59  {
60  // Inline bracket to help doxygen filtering.
61  inline namespace IGNITION_SENSORS_VERSION_NAMESPACE {
62  //
64  class CameraSensorPrivate;
65 
73  class IGNITION_SENSORS_CAMERA_VISIBLE CameraSensor : public RenderingSensor
74  {
76  public: CameraSensor();
77 
79  public: virtual ~CameraSensor();
80 
84  public: virtual bool Load(const sdf::Sensor &_sdf) override;
85 
89  public: virtual bool Load(sdf::ElementPtr _sdf) override;
90 
93  public: virtual bool Init() override;
94 
98  public: virtual bool Update(const common::Time &_now) override;
99 
108  public: gz::common::ConnectionPtr ConnectImageCallback(
110  void(const gz::msgs::Image &)> _callback);
111 
114  public: virtual void SetScene(
115  gz::rendering::ScenePtr _scene) override;
116 
119  public: virtual unsigned int ImageWidth() const;
120 
123  public: virtual unsigned int ImageHeight() const;
124 
127  public: rendering::CameraPtr RenderingCamera() const;
128 
131  public: std::string InfoTopic() const;
132 
136  public: void SetBaseline(double _baseline);
137 
140  public: double Baseline() const;
141 
144  protected: bool AdvertiseInfo();
145 
151  protected: bool AdvertiseInfo(const std::string &_topic);
152 
156  protected: void PopulateInfo(const sdf::Camera *_cameraSdf);
157 
160  protected: void PublishInfo(const gz::common::Time &_now);
161 
164  private: bool CreateCamera();
165 
169  private: void OnSceneChange(gz::rendering::ScenePtr /*_scene*/);
170 
171  IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING
174  private: std::unique_ptr<CameraSensorPrivate> dataPtr;
175  IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING
176  };
177  }
178  }
179 }
180 
181 #endif
a rendering sensor class
Definition: gz/sensors/RenderingSensor.hh:52
Definition: gz/sensors/AirPressureSensor.hh:32
STL class.
Camera Sensor Class.
Definition: gz/sensors/CameraSensor.hh:73