##

Sensor.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_SENSOR_HH_
#define GAZEBO_SENSORS_SENSOR_HH_
#include <vector>
#include <memory>
#include <map>
#include <string>
#include <sdf/sdf.hh>
#include <ignition/math/Pose3.hh>
#include <ignition/transport/Node.hh>
#include "gazebo/physics/PhysicsTypes.hh"
#include "gazebo/rendering/RenderTypes.hh"
#include "gazebo/sensors/SensorTypes.hh"
#include "gazebo/msgs/msgs.hh"
#include "gazebo/common/Events.hh"
#include "gazebo/common/Time.hh"
#include "gazebo/transport/TransportTypes.hh"
#include "gazebo/util/system.hh"
namespace gazebo
{
namespace sensors
{
// Forward declare private data
class SensorPrivate;
class GZ_SENSORS_VISIBLE Sensor
: public std::enable_shared_from_this<Sensor>
{
public: explicit Sensor(SensorCategory _cat);
public: virtual ~Sensor();
public: virtual void Load(const std::string &_worldName,
sdf::ElementPtr _sdf);
public: virtual void Load(const std::string &_worldName);
public: virtual void Init();
public: void SetParent(const std::string &_name, const uint32_t _id);
public: std::string ParentName() const;
public: void Update(const bool _force);
public: double UpdateRate() const;
public: void SetUpdateRate(const double _hz);
public: virtual void Fini();
public: std::string Name() const;
public: std::string ScopedName() const;
public: virtual ignition::math::Pose3d Pose() const;
public: virtual void SetPose(const ignition::math::Pose3d &_pose);
public: virtual void SetActive(const bool _value);
public: virtual bool IsActive() const;
public: std::string Type() const;
public: common::Time LastUpdateTime() const;
public: common::Time LastMeasurementTime() const;
public: bool Visualize() const;
public: virtual std::string Topic() const;
public: void FillMsg(msgs::Sensor &_msg);
public: std::string WorldName() const;
public: event::ConnectionPtr ConnectUpdated(
std::function<void()> _subscriber);
public: SensorCategory Category() const;
public: void ResetLastUpdateTime();
public: uint32_t Id() const;
public: uint32_t ParentId() const;
public: NoisePtr Noise(const SensorNoiseType _type) const;
protected: virtual bool UpdateImpl(const bool /*_force*/) {return false;}
protected: bool NeedsUpdate();
private: void LoadPlugin(sdf::ElementPtr _sdf);
protected: bool active;
protected: sdf::ElementPtr sdf;
protected: ignition::math::Pose3d pose;
protected: std::vector<event::ConnectionPtr> connections;
protected: transport::NodePtr node;
protected: std::string parentName;
protected: uint32_t parentId;
protected: std::vector<SensorPluginPtr> plugins;
protected: gazebo::physics::WorldPtr world;
protected: gazebo::rendering::ScenePtr scene;
protected: common::Time updatePeriod;
protected: common::Time lastUpdateTime;
protected: common::Time lastMeasurementTime;
protected: std::map<SensorNoiseType, NoisePtr> noises;
protected: ignition::transport::Node nodeIgn;
private: std::unique_ptr<SensorPrivate> dataPtr;
};
}
}
#endif
gazebo::sensors::Sensor::sdf
sdf::ElementPtr sdf
Pointer the the SDF element for the sensor.
Definition: Sensor.hh:204
gazebo::sensors::Sensor::pose
ignition::math::Pose3d pose
Pose of the sensor.
Definition: Sensor.hh:207
gazebo::sensors::Sensor::plugins
std::vector< SensorPluginPtr > plugins
All the plugins for the sensor.
Definition: Sensor.hh:222
gazebo::sensors::Sensor::Fini
virtual void Fini()
Finalize the sensor.
gazebo::sensors::Sensor::Sensor
Sensor(SensorCategory _cat)
Constructor.
gazebo::sensors::Sensor::node
transport::NodePtr node
Node for communication.
Definition: Sensor.hh:213
gazebo::sensors::Sensor::SetUpdateRate
void SetUpdateRate(const double _hz)
Set the update rate of the sensor.
Time.hh
gazebo::sensors::Sensor::UpdateImpl
virtual bool UpdateImpl(const bool)
This gets overwritten by derived sensor types.
Definition: Sensor.hh:190
gazebo::sensors::Sensor::Load
virtual void Load(const std::string &_worldName, sdf::ElementPtr _sdf)
Load the sensor with SDF parameters.
gazebo::sensors::Sensor::~Sensor
virtual ~Sensor()
Destructor.
Events.hh
gazebo
Forward declarations for the common classes.
Definition: Animation.hh:26
gazebo::common::Time
A Time class, can be used to hold wall- or sim-time. stored as sec and nano-sec.
Definition: Time.hh:47
gazebo::sensors::Sensor::ParentId
uint32_t ParentId() const
Get the sensor's parent's ID.
gazebo::sensors::Sensor::SetParent
void SetParent(const std::string &_name, const uint32_t _id)
Set the sensor's parent.
gazebo::sensors::Sensor::parentName
std::string parentName
Name of the parent.
Definition: Sensor.hh:216
gazebo::sensors::Sensor::Update
void Update(const bool _force)
Update the sensor.
gazebo::sensors::Sensor::FillMsg
void FillMsg(msgs::Sensor &_msg)
fills a msgs::Sensor message.
sensors
sensors
Definition: SensorManager.hh:35
gazebo::sensors::Sensor::LastMeasurementTime
common::Time LastMeasurementTime() const
Return last measurement time.
gazebo::sensors::Sensor::Category
SensorCategory Category() const
Get the category of the sensor.
TransportTypes.hh
Forward declarations for transport.
gazebo::sensors::Sensor::LastUpdateTime
common::Time LastUpdateTime() const
Return last update time.
gazebo::sensors::Sensor::active
bool active
True if sensor generation is active.
Definition: Sensor.hh:201
SensorTypes.hh
Forward declarations and typedefs for sensors.
gazebo::sensors::Noise
Noise models for sensor output signals.
Definition: Noise.hh:55
system.hh
gazebo::sensors::Sensor::connections
std::vector< event::ConnectionPtr > connections
All event connections.
Definition: Sensor.hh:210
msgs.hh
gazebo::sensors::Sensor::nodeIgn
ignition::transport::Node nodeIgn
Ignition transport node.
Definition: Sensor.hh:245
gazebo::sensors::Sensor::Topic
virtual std::string Topic() const
Returns the topic name as set in SDF.
gazebo::sensors::Sensor::ResetLastUpdateTime
void ResetLastUpdateTime()
Reset the lastUpdateTime to zero.
PhysicsTypes.hh
default namespace for gazebo
gazebo::transport::NodePtr
boost::shared_ptr< Node > NodePtr
Definition: TransportTypes.hh:57
gazebo::sensors::Sensor::parentId
uint32_t parentId
The sensor's parent ID.
Definition: Sensor.hh:219
gazebo::rendering::ScenePtr
boost::shared_ptr< Scene > ScenePtr
Definition: RenderTypes.hh:82
RenderTypes.hh
gazebo::sensors::Sensor::WorldName
std::string WorldName() const
Returns the name of the world the sensor is in.
gazebo::sensors::Sensor::Visualize
bool Visualize() const
Return true if user requests the sensor to be visualized via tag: <visualize>true</visualize> in SDF.
gazebo::sensors::Sensor::lastUpdateTime
common::Time lastUpdateTime
Time of the last update.
Definition: Sensor.hh:235
gazebo::sensors::Sensor::Name
std::string Name() const
Get name.
gazebo::sensors::Sensor::UpdateRate
double UpdateRate() const
Get the update rate of the sensor.
gazebo::sensors::Sensor::ConnectUpdated
event::ConnectionPtr ConnectUpdated(std::function< void()> _subscriber)
Connect a signal that is triggered when the sensor is updated.
gazebo::sensors::Sensor::world
gazebo::physics::WorldPtr world
Pointer to the world.
Definition: Sensor.hh:225
gazebo::sensors::Sensor::Type
std::string Type() const
Get sensor type.
gazebo::sensors::Sensor::ScopedName
std::string ScopedName() const
Get fully scoped name of the sensor.
gazebo::sensors::Sensor::scene
gazebo::rendering::ScenePtr scene
Pointer to the Scene.
Definition: Sensor.hh:228
gazebo::event::ConnectionPtr
boost::shared_ptr< Connection > ConnectionPtr
Definition: CommonTypes.hh:134
gazebo::sensors::Sensor::ParentName
std::string ParentName() const
Returns the name of the sensor parent.
gazebo::sensors::Sensor::Id
uint32_t Id() const
Get the sensor's ID.
gazebo::sensors::Sensor::SetActive
virtual void SetActive(const bool _value)
Set whether the sensor is active or not.
gazebo::msgs::Init
GAZEBO_VISIBLE void Init(google::protobuf::Message &_message, const std::string &_id="")
Initialize a message.
gazebo::sensors::Sensor::IsActive
virtual bool IsActive() const
Returns true if sensor generation is active.
gazebo::sensors::SensorNoiseType
SensorNoiseType
Definition: SensorTypes.hh:208
gazebo::sensors::Sensor::Init
virtual void Init()
Initialize the sensor.
gazebo::sensors::Sensor::NeedsUpdate
bool NeedsUpdate()
Return true if the sensor needs to be updated.
gazebo::sensors::Sensor::noises
std::map< SensorNoiseType, NoisePtr > noises
Noise added to sensor data.
Definition: Sensor.hh:242
gazebo::sensors::Sensor::lastMeasurementTime
common::Time lastMeasurementTime
Stores last time that a sensor measurement was generated; this value must be updated within each sens...
Definition: Sensor.hh:239
gazebo::sensors::Sensor
Base class for sensors.
Definition: Sensor.hh:51
gazebo::sensors::Sensor::Noise
NoisePtr Noise(const SensorNoiseType _type) const
Get the sensor's noise model for a specified noise type.
gazebo::sensors::Sensor::Pose
virtual ignition::math::Pose3d Pose() const
Get the current pose.
gazebo::physics::WorldPtr
boost::shared_ptr< World > WorldPtr
Definition: PhysicsTypes.hh:89
gazebo::sensors::NoisePtr
std::shared_ptr< Noise > NoisePtr
Definition: SensorTypes.hh:124
gazebo::sensors::Sensor::SetPose
virtual void SetPose(const ignition::math::Pose3d &_pose)
Set the current pose.
gazebo::sensors::SensorCategory
SensorCategory
SensorCategory is used to categorize sensors.
Definition: SensorTypes.hh:308
gazebo::sensors::Sensor::updatePeriod
common::Time updatePeriod
Desired time between updates, set indirectly by Sensor::SetUpdateRate.
Definition: Sensor.hh:232