Gazebo Gazebo

API Reference

6.18.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_GAZEBO_SYSTEMS_PERFORMERDETECTOR_HH_
19 #define GZ_GAZEBO_SYSTEMS_PERFORMERDETECTOR_HH_
20 
21 #include <map>
22 #include <memory>
23 #include <string>
24 #include <unordered_set>
25 
26 #include <gz/transport/Node.hh>
27 
28 #include "gz/sim/Model.hh"
29 #include "gz/sim/System.hh"
30 
31 namespace ignition
32 {
33 namespace gazebo
34 {
35 // Inline bracket to help doxygen filtering.
36 inline namespace IGNITION_GAZEBO_VERSION_NAMESPACE {
37 namespace systems
38 {
85 
87  : public System,
88  public ISystemConfigure,
89  public ISystemPostUpdate
90  {
92  public: PerformerDetector() = default;
93 
95  public: void Configure(const Entity &_entity,
98  EventManager &_eventMgr) final;
99 
101  public: void PostUpdate(
102  const gz::sim::UpdateInfo &_info,
103  const gz::sim::EntityComponentManager &_ecm) final;
104 
108  private: bool IsAlreadyDetected(const Entity &_entity) const;
109 
112  private: void AddToDetected(const Entity &_entity);
113 
116  private: void RemoveFromDetected(const Entity &_entity);
117 
125  private: void Publish(const Entity &_entity, const std::string &_name,
126  bool _state, const math::Pose3d &_pose,
127  const std::chrono::steady_clock::duration &_stamp);
128 
130  private: std::unordered_set<Entity> detectedEntities;
131 
133  private: Model model;
134 
136  private: std::string detectorName;
137 
139  private: math::AxisAlignedBox detectorGeometry;
140 
142  private: transport::Node::Publisher pub;
143 
145  private: bool initialized{false};
146 
148  private: math::Pose3d poseOffset;
149 
151  private: std::map<std::string, std::string> extraHeaderData;
152  };
153 
154  }
155 }
156 }
157 }
158 
159 #endif
The EntityComponentManager constructs, deletes, and returns components and entities....
Definition: gz/sim/EntityComponentManager.hh:67
The EventManager is used to send/receive notifications of simulator events.
Definition: gz/sim/EventManager.hh:55
Interface for a system that implements optional configuration.
Definition: gz/sim/System.hh:90
Interface for a system that uses the PostUpdate phase.
Definition: gz/sim/System.hh:135
This class provides wrappers around entities and components which are more convenient and straight-fo...
Definition: gz/sim/Model.hh:60
Base class for a System.
Definition: gz/sim/System.hh:76
A system system that publishes on a topic when a performer enters or leaves a specified region.
Definition: PerformerDetector.hh:90
PerformerDetector()=default
Documentation inherited.
void PostUpdate(const gz::sim::UpdateInfo &_info, const gz::sim::EntityComponentManager &_ecm) final
Documentation inherited.
void Configure(const Entity &_entity, const std::shared_ptr< const sdf::Element > &_sdf, EntityComponentManager &_ecm, EventManager &_eventMgr) final
Documentation inherited.
Component< gz::math::AxisAlignedBox, class AxisAlignedBoxTag, serializers::AxisAlignedBoxSerializer > AxisAlignedBox
A component type that contains axis aligned box, gz::math::AxisAlignedBox, information....
Definition: gz/sim/components/AxisAlignedBox.hh:47
uint64_t Entity
An Entity identifies a single object in simulation such as a model, link, or light....
Definition: gz/sim/Entity.hh:58
This library is part of the Gazebo project.
Definition: gz/sim/Actor.hh:34
Information passed to systems on the update callback.
Definition: include/gz/sim/Types.hh:39