/* * Copyright (C) 2012 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 _EVENTS_HH_ #define _EVENTS_HH_ #include #include #include "gazebo/common/Console.hh" #include "gazebo/common/UpdateInfo.hh" #include "gazebo/common/Event.hh" #include "gazebo/util/system.hh" namespace gazebo { namespace event { /// \addtogroup gazebo_event /// \{ /// \class Events Events.hh common/common.hh /// \brief An Event class to get notifications for simulator events class GZ_COMMON_VISIBLE Events { ////////////////////////////////////////////////////////////////////////// /// \brief Connect a boost::slot the the pause signal /// \param[in] _subscriber the subscriber to this event /// \return a connection public: template static ConnectionPtr ConnectPause(T _subscriber) { return pause.Connect(_subscriber); } /// \brief Disconnect a boost::slot the the pause signal /// \param[in] _subscriber the subscriber to this event public: static void DisconnectPause(ConnectionPtr _subscriber) { pause.Disconnect(_subscriber); } ////////////////////////////////////////////////////////////////////////// /// \brief Connect a boost::slot the the step signal /// \param[in] _subscriber the subscriber to this event /// \return a connection public: template static ConnectionPtr ConnectStep(T _subscriber) { return step.Connect(_subscriber); } /// \brief Disconnect a boost::slot the the step signal /// \param[in] _subscriber the subscriber to this event public: static void DisconnectStep(ConnectionPtr _subscriber) { step.Disconnect(_subscriber); } ////////////////////////////////////////////////////////////////////////// /// \brief Connect a boost::slot the the stop signal /// \param[in] _subscriber the subscriber to this event /// \return a connection public: template static ConnectionPtr ConnectStop(T _subscriber) { return stop.Connect(_subscriber); } /// \brief Disconnect a boost::slot the the stop signal /// \param[in] _subscriber the subscriber to this event public: static void DisconnectStop(ConnectionPtr _subscriber) { stop.Disconnect(_subscriber); } ////////////////////////////////////////////////////////////////////////// /// \brief Connect a boost::slot the the world created signal /// \param[in] _subscriber the subscriber to this event /// \return a connection public: template static ConnectionPtr ConnectWorldCreated(T _subscriber) { return worldCreated.Connect(_subscriber); } /// \brief Disconnect a boost::slot the the world created signal public: static void DisconnectWorldCreated(ConnectionPtr _subscriber) { worldCreated.Disconnect(_subscriber); } ////////////////////////////////////////////////////////////////////////// /// \brief Connect a boost::slot the the add entity signal /// \param[in] _subscriber the subscriber to this event /// \return a connection public: template static ConnectionPtr ConnectCreateEntity(T _subscriber) { return entityCreated.Connect(_subscriber); } /// \brief Disconnect a boost::slot the the add entity signal /// \param[in] _subscriber the subscriber to this event public: static void DisconnectCreateEntity(ConnectionPtr _subscriber) { entityCreated.Disconnect(_subscriber); } ////////////////////////////////////////////////////////////////////////// /// \brief Connect a boost::slot the set selected entity /// \param[in] _subscriber the subscriber to this event /// \return a connection public: template static ConnectionPtr ConnectSetSelectedEntity(T _subscriber) { return setSelectedEntity.Connect(_subscriber); } /// \brief Disconnect a boost::slot the set selected entity /// \param[in] _subscriber the subscriber to this event public: static void DisconnectSetSelectedEntity(ConnectionPtr _subscriber) { setSelectedEntity.Disconnect(_subscriber); } ////////////////////////////////////////////////////////////////////////// /// \brief Connect a boost::slot the delete entity /// \param[in] _subscriber the subscriber to this event /// \return a connection public: template static ConnectionPtr ConnectDeleteEntity(T _subscriber) { return deleteEntity.Connect(_subscriber); } /// \brief Disconnect a boost::slot the delete entity /// \param[in] _subscriber the subscriber to this event public: static void DisconnectDeleteEntity(ConnectionPtr _subscriber) { deleteEntity.Disconnect(_subscriber); } ////////////////////////////////////////////////////////////////////////// /// \brief Connect a boost::slot the the add entity signal /// \param[in] _subscriber the subscriber to this event /// \return a connection public: template static ConnectionPtr ConnectAddEntity(T _subscriber) { return addEntity.Connect(_subscriber); } /// \brief Disconnect a boost::slot the the add entity signal /// \param[in] _subscriber the subscriber to this event public: static void DisconnectAddEntity(ConnectionPtr _subscriber) { addEntity.Disconnect(_subscriber); } ////////////////////////////////////////////////////////////////////////// /// \brief Connect a boost::slot the the world update start signal /// \param[in] _subscriber the subscriber to this event /// \return a connection public: template static ConnectionPtr ConnectWorldUpdateBegin(T _subscriber) { return worldUpdateBegin.Connect(_subscriber); } /// \brief Disconnect a boost::slot the the world update start signal /// \param[in] _subscriber the subscriber to this event public: static void DisconnectWorldUpdateBegin( ConnectionPtr _subscriber); ////////////////////////////////////////////////////////////////////////// /// \brief Connect a boost::slot to the before physics update signal /// \param[in] _subscriber the subscriber to this event /// \return a connection /// /// The signal is called after collision detection has finished and before /// the physics update step. So you can e.g. change some forces depending /// on the collisions that have occured. public: template static ConnectionPtr ConnectBeforePhysicsUpdate(T _subscriber) { return beforePhysicsUpdate.Connect(_subscriber); } /// \brief Disconnect a boost::slot from the before physics update signal /// \param[in] _subscriber the subscriber to this event public: static void DisconnectBeforePhysicsUpdate( ConnectionPtr _subscriber) { beforePhysicsUpdate.Disconnect(_subscriber); } ////////////////////////////////////////////////////////////////////////// /// \brief Connect a boost::slot the the world update end signal /// \param[in] _subscriber the subscriber to this event /// \return a connection public: template static ConnectionPtr ConnectWorldUpdateEnd(T _subscriber) { return worldUpdateEnd.Connect(_subscriber); } /// \brief Disconnect a boost::slot the the world update end signal /// \param[in] _subscriber the subscriber to this event public: static void DisconnectWorldUpdateEnd(ConnectionPtr _subscriber) { worldUpdateEnd.Disconnect(_subscriber); } ////////////////////////////////////////////////////////////////////////// /// \brief Connect to the the world reset signal /// \param[in] _subscriber the subscriber to this event /// \return a connection public: template static ConnectionPtr ConnectWorldReset(T _subscriber) { return worldReset.Connect(_subscriber); } /// \brief Disconnect from the world reset signal /// \param[in] _subscriber the subscriber to this event public: static void DisconnectWorldReset(ConnectionPtr _subscriber) { worldReset.Disconnect(_subscriber); } ////////////////////////////////////////////////////////////////////////// /// \brief Connect to the time reset signal /// \param[in] _subscriber the subscriber to this event /// \return a connection public: template static ConnectionPtr ConnectTimeReset(T _subscriber) { return timeReset.Connect(_subscriber); } /// \brief Disconnect from the time reset signal /// \param[in] _subscriber the subscriber to this event public: static void DisconnectTimeReset(ConnectionPtr _subscriber) { timeReset.Disconnect(_subscriber); } ////////////////////////////////////////////////////////////////////////// /// \brief Connect to the remove sensor signal /// \param[in] _subscriber the subscriber to this event /// \return a connection public: template static ConnectionPtr ConnectRemoveSensor(T _subscriber) { return removeSensor.Connect(_subscriber); } /// \brief Disconnect from the remove sensor signal /// \param[in] _subscriber the subscriber to this event public: static void DisconnectRemoveSensor(ConnectionPtr _subscriber) { removeSensor.Disconnect(_subscriber); } ////////////////////////////////////////////////////////////////////////// /// \brief Connect to the create sensor signal /// \param[in] _subscriber the subscriber to this event /// \return a connection public: template static ConnectionPtr ConnectCreateSensor(T _subscriber) { return createSensor.Connect(_subscriber); } /// \brief Disconnect from the create sensor signal /// \param[in] _subscriber the subscriber to this event public: static void DisconnectCreateSensor(ConnectionPtr _subscriber) { createSensor.Disconnect(_subscriber); } ////////////////////////////////////////////////////////////////////////// /// \brief Render start signal /// \param[in] _subscriber the subscriber to this event /// \return a connection public: template static ConnectionPtr ConnectPreRender(T _subscriber) { return preRender.Connect(_subscriber); } /// \brief Disconnect a render start signal /// \param[in] _subscriber the subscriber to this event public: static void DisconnectPreRender(ConnectionPtr _subscriber) { preRender.Disconnect(_subscriber); } ////////////////////////////////////////////////////////////////////////// /// \brief Connect a boost::slot the render update signal /// \param[in] _subscriber the subscriber to this event /// \return a connection public: template static ConnectionPtr ConnectRender(T _subscriber) { return render.Connect(_subscriber); } /// \brief Disconnect a boost::slot the render update signal /// \param[in] _subscriber the subscriber to this event public: static void DisconnectRender(ConnectionPtr _subscriber) { render.Disconnect(_subscriber); } ////////////////////////////////////////////////////////////////////////// /// \brief Connect a boost::slot the post render update signal /// \param[in] _subscriber the subscriber to this event /// \return a connection public: template static ConnectionPtr ConnectPostRender(T _subscriber) { return postRender.Connect(_subscriber); } /// \brief Disconnect a boost::slot the post render update signal /// \param[in] _subscriber the subscriber to this event public: static void DisconnectPostRender(ConnectionPtr _subscriber) { postRender.Disconnect(_subscriber); } ////////////////////////////////////////////////////////////////////////// /// \brief Connect a boost::slot the diagnostic timer start signal /// \param[in] _subscriber the subscriber to this event /// \return a connection public: template static ConnectionPtr ConnectDiagTimerStart(T _subscriber) { return diagTimerStart.Connect(_subscriber); } /// \brief Disconnect a boost::slot the diagnostic timer start signal /// \param[in] _subscriber the subscriber to this event public: static void DisconnectDiagTimerStart(ConnectionPtr _subscriber) { diagTimerStart.Disconnect(_subscriber); } ////////////////////////////////////////////////////////////////////////// /// \brief Connect a boost::slot the diagnostic timer stop signal /// \param[in] _subscriber the subscriber to this event /// \return a connection public: template static ConnectionPtr ConnectDiagTimerStop(T _subscriber) { return diagTimerStop.Connect(_subscriber); } /// \brief Disconnect a boost::slot the diagnostic timer stop signal /// \param[in] _subscriber the subscriber to this event public: static void DisconnectDiagTimerStop(ConnectionPtr _subscriber) { diagTimerStop.Disconnect(_subscriber); } ////////////////////////////////////////////////////////////////////////// /// \brief Connect a boost::slot to the sigint event /// \param[in] _subscriber the subscriber to this event /// \return a connection public: template static ConnectionPtr ConnectSigInt(T _subscriber) { return sigInt.Connect(_subscriber); } /// \brief Disconnect a boost::slot to the sigint event /// \param[in] _subscriber the subscriber to this event public: static void DisconnectSigInt(ConnectionPtr _subscriber) { sigInt.Disconnect(_subscriber); } /// \brief Pause signal public: static EventT pause; /// \brief Step the simulation once signal public: static EventT step; /// \brief Simulation stop signal public: static EventT stop; /// \brief Simulation stop signal public: static EventT sigInt; /// \brief A world has been created public: static EventT worldCreated; /// \brief An entity has been created public: static EventT entityCreated; /// \brief An entity has been selected public: static EventT setSelectedEntity; /// \brief An entity has been added public: static EventT addEntity; /// \brief An entity has been deleted public: static EventT deleteEntity; /// \brief World update has started public: static EventT worldUpdateBegin; /// \brief Collision detection has been done, physics update not yet public: static EventT beforePhysicsUpdate; /// \brief World update has ended public: static EventT worldUpdateEnd; /// \brief World reset signal public: static EventT worldReset; /// \brief Time reset signal public: static EventT timeReset; /// \brief Pre-render public: static EventT preRender; /// \brief Render public: static EventT render; /// \brief Post-Render public: static EventT postRender; /// \brief Diagnostic timer start public: static EventT diagTimerStart; /// \brief Diagnostic timer stop public: static EventT diagTimerStop; /// \brief Remove a sensor /// /// * Parameter 1 (string): Name of the sensor to remove. public: static EventT removeSensor; /// \brief Create a sensor /// * Parameter 1 (sdf::ElementPtr): The SDF element that describes /// the sensor. /// * Parameter 2 (std::string): Name of the world in which to create /// the sensor. /// * Parameter 3 (std::string): The scoped parent name /// (model::link). /// * Parameter 4 (uint32_t): ID of the sensor public: static EventT createSensor; }; /// \} } } #endif