Ignition Sensors

API Reference

6.0.1
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 IGNITION_SENSORS_CAMERASENSOR_HH_
18 #define IGNITION_SENSORS_CAMERASENSOR_HH_
19 
20 #include <cstdint>
21 #include <memory>
22 #include <string>
23 
24 #include <sdf/sdf.hh>
25 
26 #include <ignition/common/SuppressWarning.hh>
27 
28 #ifdef _WIN32
29 #pragma warning(push)
30 #pragma warning(disable: 4005)
31 #pragma warning(disable: 4251)
32 #endif
33 #include <ignition/msgs.hh>
34 #ifdef _WIN32
35 #pragma warning(pop)
36 #endif
37 
38 // TODO(louise) Remove these pragmas once ign-rendering is disabling the
39 // warnings
40 #ifdef _WIN32
41 #pragma warning(push)
42 #pragma warning(disable: 4251)
43 #endif
44 #include <ignition/rendering/Camera.hh>
45 #ifdef _WIN32
46 #pragma warning(pop)
47 #endif
48 
49 #include "ignition/sensors/camera/Export.hh"
50 #include "ignition/sensors/config.hh"
51 #include "ignition/sensors/Export.hh"
53 
54 namespace ignition
55 {
56  namespace sensors
57  {
58  // Inline bracket to help doxygen filtering.
59  inline namespace IGNITION_SENSORS_VERSION_NAMESPACE {
60  //
62  class CameraSensorPrivate;
63 
71  class IGNITION_SENSORS_CAMERA_VISIBLE CameraSensor : public RenderingSensor
72  {
74  public: CameraSensor();
75 
77  public: virtual ~CameraSensor();
78 
82  public: virtual bool Load(const sdf::Sensor &_sdf) override;
83 
87  public: virtual bool Load(sdf::ElementPtr _sdf) override;
88 
91  public: virtual bool Init() override;
92 
96  public: virtual bool Update(
97  const std::chrono::steady_clock::duration &_now) override;
98 
107  public: ignition::common::ConnectionPtr ConnectImageCallback(
109  void(const ignition::msgs::Image &)> _callback);
110 
113  public: virtual void SetScene(
114  ignition::rendering::ScenePtr _scene) override;
115 
118  public: virtual unsigned int ImageWidth() const;
119 
122  public: virtual unsigned int ImageHeight() const;
123 
126  public: rendering::CameraPtr RenderingCamera() const;
127 
130  public: std::string InfoTopic() const;
131 
135  public: void SetBaseline(double _baseline);
136 
139  public: double Baseline() const;
140 
143  protected: bool AdvertiseInfo();
144 
150  protected: bool AdvertiseInfo(const std::string &_topic);
151 
155  protected: void PopulateInfo(const sdf::Camera *_cameraSdf);
156 
159  protected: void PublishInfo(
160  const std::chrono::steady_clock::duration &_now);
161 
164  private: bool CreateCamera();
165 
169  private: void OnSceneChange(ignition::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: RenderingSensor.hh:52
Camera Sensor Class.
Definition: CameraSensor.hh:71
STL class.
Definition: AirPressureSensor.hh:31