/* * Copyright (C) 2015 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ #ifndef _GAZEBO_PLUGINS_EVENTS_OCCUPIED_EVENT_SOURCE_HH_ #define _GAZEBO_PLUGINS_EVENTS_OCCUPIED_EVENT_SOURCE_HH_ #include #include #include #include #include #include #include "Region.hh" #include "EventSource.hh" namespace gazebo { /// \brief A plugin that transmits a message when an in-region event occurs. /// Events are specified in SDF. The following is example usage: // /// \verbatim /// /// /// region1 /// /// 1.5 -1 0 /// 2.5 1 1 /// /// /// /// /// region1_event /// occupied /// ~/elevator /// region1 /// 0 /// /// /// \endverbatim class GAZEBO_VISIBLE OccupiedEventSource : public EventSource { // Documentation inherited public: OccupiedEventSource(transport::PublisherPtr _pub, physics::WorldPtr _world, const std::map &_regions); /// \brief Destructor. public: ~OccupiedEventSource() = default; // Documentation inherited public: virtual void Load(const sdf::ElementPtr _sdf); /// \brief Update function called once every cycle private: void Update(); /// \brief SDF pointer. private: sdf::ElementPtr sdf; /// \brief Map of region names to regions. private: std::map regions; /// \brief String message that is transmitted when an event occurs. public: msgs::GzString msg; /// \brief Publisher that transmits the message when an event occurs. public: transport::PublisherPtr msgPub; /// \brief Pointer to the update event connection private: event::ConnectionPtr updateConnection; /// \brief Pointer to a transport node. private: transport::NodePtr node; /// \brief The region used for the in region check. private: std::string regionName; }; } #endif