CameraSensor.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_CAMERASENSOR_HH_
18 #define GAZEBO_SENSORS_CAMERASENSOR_HH_
19 
20 #include <memory>
21 #include <string>
22 #include <ignition/transport/Node.hh>
23 
24 #include "gazebo/sensors/Sensor.hh"
27 #include "gazebo/util/system.hh"
28 
29 namespace gazebo
30 {
31  namespace sensors
32  {
33  // Forward declare private data class
34  class CameraSensorPrivate;
35 
38 
44  {
46  public: CameraSensor();
47 
49  public: virtual ~CameraSensor();
50 
54  public: virtual void Load(const std::string &_worldName,
55  sdf::ElementPtr _sdf);
56 
59  public: virtual void Load(const std::string &_worldName);
60 
62  public: virtual void Init();
63 
66  public: virtual std::string Topic() const;
67 
70  public: std::string TopicIgn() const;
71 
74  public: rendering::CameraPtr Camera() const;
75 
79  public: unsigned int ImageWidth() const;
80 
83  public: unsigned int ImageHeight() const;
84 
87  public: const unsigned char *ImageData() const;
88 
92  public: bool SaveFrame(const std::string &_filename);
93 
94  // Documentation inherited
95  public: virtual bool IsActive() const;
96 
97  // Documentation inherited
98  protected: virtual bool UpdateImpl(const bool _force);
99 
101  protected: virtual void Fini();
102 
104  protected: virtual void Render();
105 
107  protected: bool Rendered() const;
108 
111  protected: void SetRendered(const bool _value);
112 
115 
118 
120  protected: ignition::transport::Node::Publisher imagePubIgn;
121 
124  private: std::unique_ptr<CameraSensorPrivate> dataPtr;
125  };
127  }
128 }
129 #endif
Basic camera sensor.
Definition: CameraSensor.hh:43
transport::PublisherPtr imagePub
Publisher of image messages.
Definition: CameraSensor.hh:117
Forward declarations for transport.
boost::shared_ptr< Publisher > PublisherPtr
Definition: TransportTypes.hh:49
ignition::transport::Node::Publisher imagePubIgn
Publisher of image messages.
Definition: CameraSensor.hh:120
GAZEBO_VISIBLE void Init(google::protobuf::Message &_message, const std::string &_id="")
Initialize a message.
Base class for sensors.
Definition: Sensor.hh:51
#define GAZEBO_VISIBLE
Use to represent "symbol visible" if supported.
Definition: system.hh:58
boost::shared_ptr< Camera > CameraPtr
Definition: RenderTypes.hh:89
rendering::CameraPtr camera
Pointer to the camera.
Definition: CameraSensor.hh:114