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
27#include "gazebo/util/system.hh"
28
29namespace gazebo
30{
31 namespace sensors
32 {
33 // Forward declare private data class
34 class CameraSensorPrivate;
35
38
43 class GZ_SENSORS_VISIBLE CameraSensor : public Sensor
44 {
46 public: CameraSensor();
47
49 public: virtual ~CameraSensor();
50
54 public: virtual void Load(const std::string &_worldName,
55 sdf::ElementPtr _sdf) override;
56
59 public: virtual void Load(const std::string &_worldName) override;
60
62 public: virtual void Init() override;
63
65 protected: void ResetLastUpdateTime() override;
66
69 protected: bool NeedsUpdate() override;
70
73 public: void Update(bool _force) override;
74
77 public: double NextRequiredTimestamp() const override;
78
81 public: virtual std::string Topic() const override;
82
85 public: std::string TopicIgn() const;
86
89 public: void SetActive(bool _value) override;
90
94
97 public: unsigned int ImageWidth() const;
98
101 public: unsigned int ImageHeight() const;
102
105 public: const unsigned char *ImageData() const;
106
110 public: bool SaveFrame(const std::string &_filename);
111
112 // Documentation inherited
113 public: virtual bool IsActive() const override;
114
115 // Documentation inherited
116 protected: virtual bool UpdateImpl(const bool _force) override;
117
119 protected: virtual void Fini() override;
120
122 protected: virtual void Render();
123
125 protected: bool Rendered() const;
126
129 protected: void SetRendered(const bool _value);
130
132 protected: void PrerenderEnded();
133
136
139
141 protected: ignition::transport::Node::Publisher imagePubIgn;
142
145 private: std::unique_ptr<CameraSensorPrivate> dataPtr;
146 };
148 }
149}
150#endif
sensors
Definition SensorManager.hh:37
Forward declarations for transport.
Basic camera sensor.
Definition CameraSensor.hh:44
virtual void Render()
Handle the render event.
virtual bool UpdateImpl(const bool _force) override
This gets overwritten by derived sensor types.
virtual std::string Topic() const override
Gets the topic name of the sensor.
double NextRequiredTimestamp() const override
Return the next timestamp going to be used by the sensor.
unsigned int ImageWidth() const
Gets the width of the image in pixels.
void Update(bool _force) override
Update the sensor.
transport::PublisherPtr imagePub
Publisher of image messages.
Definition CameraSensor.hh:138
const unsigned char * ImageData() const
Gets the raw image data from the sensor.
rendering::CameraPtr Camera() const
Returns a pointer to the rendering::Camera.
unsigned int ImageHeight() const
Gets the height of the image in pixels.
ignition::transport::Node::Publisher imagePubIgn
Publisher of image messages.
Definition CameraSensor.hh:141
void ResetLastUpdateTime() override
reset timing related members
virtual ~CameraSensor()
Destructor.
void SetActive(bool _value) override
Set whether the sensor is active or not.
virtual void Load(const std::string &_worldName, sdf::ElementPtr _sdf) override
Load the sensor with SDF parameters.
bool Rendered() const
Get the value of the rendered flag.
virtual bool IsActive() const override
Returns true if sensor generation is active.
bool NeedsUpdate() override
Return true if the sensor needs to be updated.
virtual void Fini() override
Finalize the camera.
virtual void Load(const std::string &_worldName) override
Load the sensor with default parameters.
void SetRendered(const bool _value)
Set the value of the rendered flag.
std::string TopicIgn() const
Gets the ignition topic name of the sensor.
rendering::CameraPtr camera
Pointer to the camera.
Definition CameraSensor.hh:135
void PrerenderEnded()
Handle the prerenderEnded event.
virtual void Init() override
Initialize the camera.
bool SaveFrame(const std::string &_filename)
Saves the image to the disk.
Base class for sensors.
Definition Sensor.hh:53
boost::shared_ptr< Camera > CameraPtr
Definition RenderTypes.hh:90
boost::shared_ptr< Publisher > PublisherPtr
Definition TransportTypes.hh:49
Forward declarations for the common classes.
Definition Animation.hh:27