Gazebo Sensors

API Reference

10.2.0
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#include <vector>
24
25#include <gz/msgs/boolean.pb.h>
26#include <gz/msgs/camera_info.pb.h>
27#include <gz/msgs/image.pb.h>
28
29#include <sdf/sdf.hh>
30
31#include <gz/utils/SuppressWarning.hh>
32
33// TODO(louise) Remove these pragmas once gz-rendering is disabling the
34// warnings
35#ifdef _WIN32
36#pragma warning(push)
37#pragma warning(disable: 4251)
38#endif
39#include <gz/rendering/Camera.hh>
40#ifdef _WIN32
41#pragma warning(pop)
42#endif
43
44#include "gz/sensors/camera/Export.hh"
45#include "gz/sensors/config.hh"
46#include "gz/sensors/Export.hh"
48
49namespace gz
50{
51 namespace sensors
52 {
53 // Inline bracket to help doxygen filtering.
54 inline namespace GZ_SENSORS_VERSION_NAMESPACE {
55 //
57 class CameraSensorPrivate;
58
66 class GZ_SENSORS_CAMERA_VISIBLE CameraSensor : public RenderingSensor
67 {
69 public: CameraSensor();
70
72 public: virtual ~CameraSensor();
73
77 public: virtual bool Load(const sdf::Sensor &_sdf) override;
78
82 public: virtual bool Load(sdf::ElementPtr _sdf) override;
83
86 public: virtual bool Init() override;
87
88 using Sensor::Update;
89
93 public: virtual bool Update(
94 const std::chrono::steady_clock::duration &_now) override;
95
104 public: gz::common::ConnectionPtr ConnectImageCallback(
106 void(const gz::msgs::Image &)> _callback);
107
110 public: virtual void SetScene(
111 gz::rendering::ScenePtr _scene) override;
112
115 public: virtual unsigned int ImageWidth() const;
116
119 public: virtual unsigned int ImageHeight() const;
120
123 public: virtual rendering::CameraPtr RenderingCamera() const;
124
128 public: bool SetInfoTopic(const std::string &_topic);
129
132 public: const std::string& InfoTopic() const;
133
137 public: void SetBaseline(double _baseline);
138
141 public: double Baseline() const;
142
143 // Documentation inherited.
144 public: virtual bool HasConnections() const override;
145
148 public: virtual bool HasImageConnections() const;
149
152 public: virtual bool HasInfoConnections() const;
153
156 public: const std::string& OpticalFrameId() const;
157
167 rendering::CameraPtr _camera, sdf::Camera &_cameraSdf);
168
171 protected: bool AdvertiseInfo();
172
178 protected: bool AdvertiseInfo(const std::string &_topic);
179
183 protected: void PopulateInfo(const sdf::Camera *_cameraSdf);
184
189 protected: void SetInfoDistortion(
190 msgs::CameraInfo::Distortion::DistortionModelType _model,
191 const std::vector<double> &_k);
192
195 protected: void PublishInfo(
196 const std::chrono::steady_clock::duration &_now);
197
200 private: bool CreateCamera();
201
205 private: void OnSceneChange(gz::rendering::ScenePtr /*_scene*/);
206
207 GZ_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING
211 GZ_UTILS_WARN_RESUME__DLL_INTERFACE_MISSING
212 };
213 }
214 }
215}
216
217#endif