##

CameraSensor.hh
Go to the documentation of this file.
/*
* Copyright (C) 2012 Open Source Robotics Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef GAZEBO_SENSORS_CAMERASENSOR_HH_
#define GAZEBO_SENSORS_CAMERASENSOR_HH_
#include <memory>
#include <string>
#include <ignition/transport/Node.hh>
#include "gazebo/sensors/Sensor.hh"
#include "gazebo/rendering/RenderTypes.hh"
#include "gazebo/transport/TransportTypes.hh"
#include "gazebo/util/system.hh"
namespace gazebo
{
namespace sensors
{
// Forward declare private data class
class CameraSensorPrivate;
class GZ_SENSORS_VISIBLE CameraSensor : public Sensor
{
public: CameraSensor();
public: virtual ~CameraSensor();
public: virtual void Load(const std::string &_worldName,
sdf::ElementPtr _sdf);
public: virtual void Load(const std::string &_worldName);
public: virtual void Init();
public: virtual std::string Topic() const;
public: std::string TopicIgn() const;
public: rendering::CameraPtr Camera() const;
public: unsigned int ImageWidth() const;
public: unsigned int ImageHeight() const;
public: const unsigned char *ImageData() const;
public: bool SaveFrame(const std::string &_filename);
// Documentation inherited
public: virtual bool IsActive() const;
// Documentation inherited
protected: virtual bool UpdateImpl(const bool _force);
protected: virtual void Fini();
protected: virtual void Render();
protected: bool Rendered() const;
protected: void SetRendered(const bool _value);
protected: rendering::CameraPtr camera;
protected: transport::PublisherPtr imagePub;
protected: ignition::transport::Node::Publisher imagePubIgn;
private: std::unique_ptr<CameraSensorPrivate> dataPtr;
};
}
}
#endif
gazebo::sensors::CameraSensor::Load
virtual void Load(const std::string &_worldName, sdf::ElementPtr _sdf)
Load the sensor with SDF parameters.
gazebo::sensors::CameraSensor::Topic
virtual std::string Topic() const
Gets the topic name of the sensor.
gazebo
Forward declarations for the common classes.
Definition: Animation.hh:26
gazebo::sensors::CameraSensor::Camera
rendering::CameraPtr Camera() const
Returns a pointer to the rendering::Camera.
gazebo::sensors::CameraSensor::ImageWidth
unsigned int ImageWidth() const
Gets the width of the image in pixels.
gazebo::sensors::CameraSensor::UpdateImpl
virtual bool UpdateImpl(const bool _force)
This gets overwritten by derived sensor types.
sensors
sensors
Definition: SensorManager.hh:35
gazebo::transport::PublisherPtr
boost::shared_ptr< Publisher > PublisherPtr
Definition: TransportTypes.hh:49
TransportTypes.hh
Forward declarations for transport.
system.hh
gazebo::sensors::CameraSensor::SetRendered
void SetRendered(const bool _value)
Set the value of the rendered flag.
gazebo::sensors::CameraSensor::CameraSensor
CameraSensor()
Constructor.
Sensor.hh
RenderTypes.hh
gazebo::sensors::CameraSensor::imagePub
transport::PublisherPtr imagePub
Publisher of image messages.
Definition: CameraSensor.hh:116
gazebo::sensors::CameraSensor::ImageHeight
unsigned int ImageHeight() const
Gets the height of the image in pixels.
gazebo::sensors::CameraSensor::~CameraSensor
virtual ~CameraSensor()
Destructor.
gazebo::msgs::Init
GAZEBO_VISIBLE void Init(google::protobuf::Message &_message, const std::string &_id="")
Initialize a message.
gazebo::sensors::Sensor
Base class for sensors.
Definition: Sensor.hh:51
gazebo::sensors::CameraSensor::TopicIgn
std::string TopicIgn() const
Gets the ignition topic name of the sensor.
gazebo::sensors::CameraSensor::Render
virtual void Render()
Handle the render event.
gazebo::sensors::CameraSensor::imagePubIgn
ignition::transport::Node::Publisher imagePubIgn
Publisher of image messages.
Definition: CameraSensor.hh:119
gazebo::rendering::CameraPtr
boost::shared_ptr< Camera > CameraPtr
Definition: RenderTypes.hh:90
gazebo::sensors::CameraSensor::Rendered
bool Rendered() const
Get the value of the rendered flag.
gazebo::sensors::CameraSensor::Init
virtual void Init()
Initialize the camera.
gazebo::sensors::CameraSensor::IsActive
virtual bool IsActive() const
Returns true if sensor generation is active.
gazebo::sensors::CameraSensor::ImageData
const unsigned char * ImageData() const
Gets the raw image data from the sensor.
gazebo::sensors::CameraSensor::SaveFrame
bool SaveFrame(const std::string &_filename)
Saves the image to the disk.
gazebo::sensors::CameraSensor::camera
rendering::CameraPtr camera
Pointer to the camera.
Definition: CameraSensor.hh:113
gazebo::sensors::CameraSensor
Basic camera sensor.
Definition: CameraSensor.hh:43
gazebo::sensors::CameraSensor::Fini
virtual void Fini()
Finalize the camera.