Gazebo Sim

API Reference

7.9.0
PerformerDetector.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2020 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 GZ_SIM_SYSTEMS_PERFORMERDETECTOR_HH_
19 #define GZ_SIM_SYSTEMS_PERFORMERDETECTOR_HH_
20 
21 #include <map>
22 #include <memory>
23 #include <string>
24 #include <unordered_set>
25 
26 #include <gz/math/AxisAlignedBox.hh>
27 #include <gz/transport/Node.hh>
28 
29 #include "gz/sim/Model.hh"
30 #include "gz/sim/System.hh"
31 
32 namespace gz
33 {
34 namespace sim
35 {
36 // Inline bracket to help doxygen filtering.
37 inline namespace GZ_SIM_VERSION_NAMESPACE {
38 namespace systems
39 {
82 
84  : public System,
85  public ISystemConfigure,
86  public ISystemPostUpdate
87  {
89  public: PerformerDetector() = default;
90 
92  public: void Configure(const Entity &_entity,
95  EventManager &_eventMgr) final;
96 
98  public: void PostUpdate(
99  const gz::sim::UpdateInfo &_info,
100  const gz::sim::EntityComponentManager &_ecm) final;
101 
105  private: bool IsAlreadyDetected(const Entity &_entity) const;
106 
109  private: void AddToDetected(const Entity &_entity);
110 
113  private: void RemoveFromDetected(const Entity &_entity);
114 
122  private: void Publish(const Entity &_entity, const std::string &_name,
123  bool _state, const math::Pose3d &_pose,
124  const std::chrono::steady_clock::duration &_stamp);
125 
127  private: std::unordered_set<Entity> detectedEntities;
128 
130  private: Model model;
131 
133  private: std::string detectorName;
134 
136  private: math::AxisAlignedBox detectorGeometry;
137 
139  private: transport::Node::Publisher pub;
140 
142  private: bool initialized{false};
143 
145  private: math::Pose3d poseOffset;
146 
148  private: std::map<std::string, std::string> extraHeaderData;
149  };
150 
151  }
152 }
153 }
154 }
155 
156 #endif