##

RegionEventBoxPlugin.hh
Go to the documentation of this file.
/*
* Copyright (C) 2015 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_PLUGINS_REGIONEVENTBOXPLUGIN_HH_
#define GAZEBO_PLUGINS_REGIONEVENTBOXPLUGIN_HH_
#include <map>
#include <string>
#include <gazebo/physics/physics.hh>
#include <gazebo/common/Plugin.hh>
#include "EventSource.hh"
namespace gazebo
{
class RegionEventBoxPlugin : public ModelPlugin
{
public: RegionEventBoxPlugin();
// Documentation Inherited.
public: void Load(physics::ModelPtr _parent, sdf::ElementPtr _sdf);
public: void OnModelMsg(ConstModelPtr &_msg);
public: void OnUpdate(const common::UpdateInfo &_info);
private: bool PointInRegion(const ignition::math::Vector3d &_point,
const ignition::math::Box &_box, const ignition::math::Pose3d &_pose)
const;
private: void UpdateRegion(const ignition::math::Vector3d &_size,
const ignition::math::Pose3d &_pose);
private: void SendEnteringRegionEvent(physics::ModelPtr _model) const;
private: void SendExitingRegionEvent(physics::ModelPtr _model) const;
private: physics::WorldPtr world;
private: physics::ModelPtr model;
private: event::ConnectionPtr updateConnection;
private: std::string modelName;
public: transport::NodePtr node;
public: std::mutex receiveMutex;
private: ignition::math::Vector3d boxSize;
private: ignition::math::Vector3d boxScale;
private: ignition::math::Pose3d boxPose;
private: ignition::math::Box box;
private: transport::SubscriberPtr modelSub;
private: bool hasStaleSizeAndPose;
private: std::map<std::string, common::Time> insiders;
private: transport::PublisherPtr eventPub;
private: gazebo::EventSourcePtr eventSource;
};
}
#endif
gazebo::RegionEventBoxPlugin::node
transport::NodePtr node
Transport node pointer.
Definition: RegionEventBoxPlugin.hh:95
gazebo::RegionEventBoxPlugin::RegionEventBoxPlugin
RegionEventBoxPlugin()
Constructor.
gazebo
Forward declarations for the common classes.
Definition: Animation.hh:26
gazebo::physics::ModelPtr
boost::shared_ptr< Model > ModelPtr
Definition: PhysicsTypes.hh:93
gazebo::transport::PublisherPtr
boost::shared_ptr< Publisher > PublisherPtr
Definition: TransportTypes.hh:49
EventSource.hh
gazebo::transport::SubscriberPtr
boost::shared_ptr< Subscriber > SubscriberPtr
Definition: TransportTypes.hh:53
gazebo::transport::NodePtr
boost::shared_ptr< Node > NodePtr
Definition: TransportTypes.hh:57
gazebo::EventSourcePtr
std::shared_ptr< EventSource > EventSourcePtr
Definition: EventSource.hh:81
gazebo::RegionEventBoxPlugin::OnUpdate
void OnUpdate(const common::UpdateInfo &_info)
Updates the box event plugin at every physics iteration.
gazebo::RegionEventBoxPlugin::receiveMutex
std::mutex receiveMutex
Mutex to protect incoming messages.
Definition: RegionEventBoxPlugin.hh:98
gazebo::event::ConnectionPtr
boost::shared_ptr< Connection > ConnectionPtr
Definition: CommonTypes.hh:134
gazebo::RegionEventBoxPlugin
A plugin that fires an event when another model enters the region defined by the size of this model's...
Definition: RegionEventBoxPlugin.hh:43
gazebo::RegionEventBoxPlugin::Load
void Load(physics::ModelPtr _parent, sdf::ElementPtr _sdf)
Load function.
gazebo::physics::WorldPtr
boost::shared_ptr< World > WorldPtr
Definition: PhysicsTypes.hh:89
gazebo::ModelPlugin
A plugin with access to physics::Model.
Definition: Plugin.hh:303
Plugin.hh
gazebo::common::UpdateInfo
Information for use in an update event.
Definition: UpdateInfo.hh:30
gazebo::RegionEventBoxPlugin::OnModelMsg
void OnModelMsg(ConstModelPtr &_msg)
Callback when a model message is received.