RegionEventBoxPlugin.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015 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 
18 #ifndef GAZEBO_PLUGINS_REGIONEVENTBOXPLUGIN_HH_
19 #define GAZEBO_PLUGINS_REGIONEVENTBOXPLUGIN_HH_
20 
21 #include <map>
22 #include <string>
23 
24 #include <gazebo/physics/physics.hh>
25 #include <gazebo/common/Plugin.hh>
26 
27 #include "EventSource.hh"
28 
29 namespace gazebo
30 {
44  {
46  public: RegionEventBoxPlugin();
47 
48  // Documentation Inherited.
49  public: void Load(physics::ModelPtr _parent, sdf::ElementPtr _sdf);
50 
53  public: void OnModelMsg(ConstModelPtr &_msg);
54 
57  public: void OnUpdate(const common::UpdateInfo &_info);
58 
64  private: bool PointInRegion(
65  const ignition::math::Vector3d &_point,
66  const ignition::math::AxisAlignedBox &_box,
67  const ignition::math::Pose3d &_pose)
68  const;
69 
73  private: void UpdateRegion(const ignition::math::Vector3d &_size,
74  const ignition::math::Pose3d &_pose);
75 
78  private: void SendEnteringRegionEvent(physics::ModelPtr _model) const;
79 
82  private: void SendExitingRegionEvent(physics::ModelPtr _model) const;
83 
85  private: physics::WorldPtr world;
86 
88  private: physics::ModelPtr model;
89 
91  private: event::ConnectionPtr updateConnection;
92 
94  private: std::string modelName;
95 
98 
100  public: std::mutex receiveMutex;
101 
103  private: ignition::math::Vector3d boxSize;
104 
106  private: ignition::math::Vector3d boxScale;
107 
109  private: ignition::math::Pose3d boxPose;
110 
112  private: ignition::math::AxisAlignedBox box;
113 
115  private: transport::SubscriberPtr modelSub;
116 
118  private: bool hasStaleSizeAndPose;
119 
122  private: std::map<std::string, common::Time> insiders;
123 
125  private: transport::PublisherPtr eventPub;
126 
128  private: gazebo::EventSourcePtr eventSource;
129  };
130 }
131 
132 #endif
boost::shared_ptr< World > WorldPtr
Definition: PhysicsTypes.hh:90
void OnUpdate(const common::UpdateInfo &_info)
Updates the box event plugin at every physics iteration.
Forward declarations for the common classes.
Definition: Animation.hh:26
void Load(physics::ModelPtr _parent, sdf::ElementPtr _sdf)
Load function.
std::shared_ptr< EventSource > EventSourcePtr
Definition: EventSource.hh:81
void OnModelMsg(ConstModelPtr &_msg)
Callback when a model message is received.
boost::shared_ptr< Publisher > PublisherPtr
Definition: TransportTypes.hh:49
boost::shared_ptr< Subscriber > SubscriberPtr
Definition: TransportTypes.hh:53
Information for use in an update event.
Definition: UpdateInfo.hh:30
boost::shared_ptr< Node > NodePtr
Definition: TransportTypes.hh:57
RegionEventBoxPlugin()
Constructor.
transport::NodePtr node
Transport node pointer.
Definition: RegionEventBoxPlugin.hh:97
std::mutex receiveMutex
Mutex to protect incoming messages.
Definition: RegionEventBoxPlugin.hh:100
boost::shared_ptr< Connection > ConnectionPtr
Definition: CommonTypes.hh:134
boost::shared_ptr< Model > ModelPtr
Definition: PhysicsTypes.hh:94
A plugin that fires an event when another model enters the region defined by the size of this model&#39;s...
Definition: RegionEventBoxPlugin.hh:43
A plugin with access to physics::Model.
Definition: Plugin.hh:303