Swarm API

CommsModel.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 
20 
21 #ifndef __SWARM_COMMS_MODEL_HH__
22 #define __SWARM_COMMS_MODEL_HH__
23 
24 #include <map>
25 #include <string>
26 #include <utility>
27 #include <vector>
28 #include <gazebo/common/Time.hh>
29 #include <gazebo/physics/PhysicsTypes.hh>
30 #include <ignition/math.hh>
31 #include <sdf/sdf.hh>
32 
33 #include "swarm/SwarmTypes.hh"
34 
35 namespace swarm
36 {
38  class IGNITION_VISIBLE CommsModel
39  {
45  public: CommsModel(SwarmMembershipPtr _swarm,
46  gazebo::physics::WorldPtr _world,
47  sdf::ElementPtr _sdf);
48 
50  public: virtual ~CommsModel() = default;
51 
54  public: void Update();
55 
57  private: void UpdateOutages();
58 
60  private: void UpdateNeighbors();
61 
66  private: void UpdateNeighborList(const std::string &_address);
67 
69  private: void UpdateVisibility();
70 
83  private: bool LineOfSight(const ignition::math::Pose3d &_p1,
84  const ignition::math::Pose3d &_p2,
85  std::vector<std::string> &_entities);
86 
91  private: void LoadParameters(sdf::ElementPtr _sdf);
92 
95  private: double neighborDistanceMin = -1.0;
96 
99  private: double neighborDistanceMax = -1.0;
100 
104  private: double neighborDistancePenaltyTree = 0.0;
105 
108  private: double commsDistanceMin = -1.0;
109 
112  private: double commsDistanceMax = -1.0;
113 
117  private: double commsDistancePenaltyTree = 0.0;
118 
121  private: double commsDropProbabilityMin = 0.0;
122 
125  private: double commsDropProbabilityMax = 0.0;
126 
128  private: double commsOutageProbability = 0.0;
129 
132  private: double commsOutageDurationMin = -1.0;
133 
136  private: double commsOutageDurationMax = -1.0;
137 
139  private: SwarmMembershipPtr swarm;
140 
142  private: gazebo::physics::WorldPtr world;
143 
145  private: gazebo::common::Time lastUpdateTime;
146 
147  // \brief Ray used to test for line of sight between vehicles.
148  private: gazebo::physics::RayShapePtr ray;
149 
155  private: std::map<std::pair<std::string, std::string>,
156  std::vector<std::string>> visibility;
157  };
158 } // namespace
159 #endif
Definition: BooPlugin.hh:37
Class used to store information about the communication model.
Definition: CommsModel.hh:38