Swarm API

BooPlugin.hh
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 
20 
21 #ifndef __SWARM_BOO_PLUGIN_HH__
22 #define __SWARM_BOO_PLUGIN_HH__
23 
24 #include <map>
25 #include <mutex>
26 #include <string>
27 #include <gazebo/common/Events.hh>
28 #include <gazebo/common/Plugin.hh>
29 #include <gazebo/common/Time.hh>
30 #include <gazebo/common/UpdateInfo.hh>
31 #include <gazebo/physics/PhysicsTypes.hh>
32 #include <ignition/math/Vector3.hh>
33 #include <sdf/sdf.hh>
34 #include "swarm/RobotPlugin.hh"
35 #include "swarm/SwarmTypes.hh"
36 
37 namespace swarm
38 {
58  {
60  public: BooPlugin();
61 
63  public: virtual ~BooPlugin();
64 
66  private: virtual void OnUpdateEnd();
67 
68  // Documentation inherited.
69  private: virtual void Load(gazebo::physics::ModelPtr _model,
70  sdf::ElementPtr _sdf);
71 
77  private: void OnDataReceived(const std::string &_srcAddress,
78  const std::string &_dstAddress,
79  const uint32_t _dstPort,
80  const std::string &_data);
81 
85  private: ignition::math::Vector3i PosToGrid(ignition::math::Vector3d _pos);
86 
88  private: bool found = false;
89 
91  private: gazebo::physics::ModelPtr lostPerson;
92 
100  private: std::map<gazebo::common::Time,
101  ignition::math::Vector3i> lostPersonBuffer;
102 
104  private: ignition::math::Vector3i lastPersonPosInGrid;
105 
107  private: gazebo::event::ConnectionPtr updateEndConnection;
108 
109  // \brief Mutex to avoid race conditions.
110  private: std::mutex mutex;
111 
116  private: double cellSize = 1;
117 
120  private: gazebo::common::Time maxDt = 30.0;
121  };
122 }
123 #endif
Main Swarm API for agent development.
virtual ~BooPlugin()
Class destructor.
Definition: BooPlugin.hh:37
Class that drives the behavior of the base of operations (BOO).
Definition: BooPlugin.hh:57
BooPlugin()
Class constructor.
A Model plugin that is the base class for all agent plugins in a swarm.
Definition: RobotPlugin.hh:106