MultiCameraSensor.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012 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 _GAZEBO_SENSORS_MULTICAMERASENSOR_HH_
18 #define _GAZEBO_SENSORS_MULTICAMERASENSOR_HH_
19 
20 #include <memory>
21 #include <string>
22 #include <vector>
23 
24 #include "gazebo/msgs/MessageTypes.hh"
26 #include "gazebo/sensors/Sensor.hh"
28 #include "gazebo/util/system.hh"
29 
30 namespace gazebo
31 {
32  namespace sensors
33  {
34  // Forward declare private data class.
35  class MultiCameraSensorPrivate;
36 
40 
44  class GZ_SENSORS_VISIBLE MultiCameraSensor : public Sensor
45  {
47  public: MultiCameraSensor();
48 
50  public: virtual ~MultiCameraSensor();
51 
52  // Documentation inherited
53  public: virtual void Load(const std::string &_worldName);
54 
55  // Documentation inherited
56  public: virtual void Init();
57 
59  protected: void ResetLastUpdateTime() override;
60 
63  protected: bool NeedsUpdate() override;
64 
67  public: double NextRequiredTimestamp() const override;
68 
69  // Documentation inherited
70  public: virtual std::string Topic() const;
71 
74  public: void SetActive(bool _value) override;
75 
78  public: unsigned int CameraCount() const;
79 
85  public: rendering::CameraPtr Camera(const unsigned int _index) const;
86 
91  public: unsigned int ImageWidth(const unsigned int _index) const;
92 
97  public: unsigned int ImageHeight(const unsigned int _index) const;
98 
103  public: const unsigned char *ImageData(const unsigned int _index);
104 
109  public: bool SaveFrame(const std::vector<std::string> &_filenames);
110 
111  // Documentation inherited.
112  public: virtual bool IsActive() const;
113 
114  // Documentation inherited.
115  protected: virtual bool UpdateImpl(const bool _force);
116 
117  // Documentation inherited.
118  protected: virtual void Fini();
119 
121  private: void Render();
122 
124  private: void PrerenderEnded();
125 
128  private: std::unique_ptr<MultiCameraSensorPrivate> dataPtr;
129  };
131  }
132 }
133 #endif
bool SaveFrame(const std::vector< std::string > &_filenames)
Saves the camera image(s) to the disk.
virtual bool IsActive() const
Returns true if sensor generation is active.
virtual ~MultiCameraSensor()
Destructor.
unsigned int ImageWidth(const unsigned int _index) const
Gets the width of the image in pixels.
Forward declarations for the common classes.
Definition: Animation.hh:27
sensors
Definition: SensorManager.hh:37
Forward declarations for transport.
void SetActive(bool _value) override
Set whether the sensor is active or not.
virtual void Load(const std::string &_worldName)
Load the sensor with default parameters.
virtual bool UpdateImpl(const bool _force)
This gets overwritten by derived sensor types.
bool NeedsUpdate() override
Return true if the sensor needs to be updated.
virtual void Init()
Initialize the sensor.
double NextRequiredTimestamp() const override
Return the next timestamp going to be used by the sensor.
MultiCameraSensor()
Constructor.
rendering::CameraPtr Camera(const unsigned int _index) const
Returns a pointer to a rendering::Camera.
virtual std::string Topic() const
Returns the topic name as set in SDF.
const unsigned char * ImageData(const unsigned int _index)
Gets the raw image data from the sensor.
Multiple camera sensor.
Definition: MultiCameraSensor.hh:45
Base class for sensors.
Definition: Sensor.hh:53
unsigned int ImageHeight(const unsigned int _index) const
Gets the height of the image in pixels.
virtual void Fini()
Finalize the sensor.
boost::shared_ptr< Camera > CameraPtr
Definition: RenderTypes.hh:90
unsigned int CameraCount() const
Get the number of cameras.
void ResetLastUpdateTime() override
reset timing related members