22#ifndef GAZEBO_SMACC_PLUGINS_FLASHLIGHTPLUGIN_HH_ 
   23#define GAZEBO_SMACC_PLUGINS_FLASHLIGHTPLUGIN_HH_ 
   28#include <ignition/math/Color.hh> 
   30#include <gazebo/common/Plugin.hh> 
   31#include <gazebo/physics/physics.hh> 
   32#include <gazebo_ros/node.hpp> 
   33#include <std_msgs/msg/int8.hpp> 
   34#include <rclcpp/rclcpp.hpp> 
   39  using namespace gazebo;
 
   42  class FlashLightSettingPrivate;
 
   56      const sdf::ElementPtr &_sdf,
 
   57      const gazebo::physics::ModelPtr &_model,
 
   58      const gazebo::common::Time &_currentTime,
 
   59      gazebo_ros::Node::SharedPtr node);
 
   67      const gazebo::transport::PublisherPtr &_pubLight) 
final;
 
   73      virtual void UpdateLightInEnv(
const gazebo::common::Time &_currentTime) 
final;
 
   77    public: 
virtual const std::string 
Name() 
const final;
 
   81    public: 
virtual const gazebo::physics::LinkPtr 
Link() 
const final;
 
   84    public: 
virtual void SwitchOn() 
final;
 
   93      const double _duration, 
const int _index) 
final;
 
   97    public: 
virtual void SetDuration(
const double _duration) 
final;
 
  103      const double _interval, 
const int _index) 
final;
 
  107    public: 
virtual void SetInterval(
const double _interval) 
final;
 
  113      const ignition::math::Color &_color, 
const int _index) 
final;
 
  117    public: 
virtual void SetColor(
const ignition::math::Color &_color) 
final;
 
  121    public: 
virtual unsigned int BlockCount() 
final;
 
  126    public: 
virtual bool RemoveBlock(
const int _index) 
final;
 
  136      const double _duration, 
const double _interval,
 
  137      const ignition::math::Color &_color, 
const int _index) 
final;
 
  142    protected: 
virtual void Flash();
 
  147    protected: 
virtual void Dim();
 
  153    protected: 
virtual ignition::math::Color 
CurrentColor() 
final;
 
  156    private: std::unique_ptr<FlashLightSettingPrivate> 
dataPtr;
 
  173    public: 
void Load(gazebo::physics::ModelPtr _parent, sdf::ElementPtr _sdf) 
override;
 
  183    protected: 
virtual bool TurnOn(
const std::string &_lightName) 
final;
 
  189    protected: 
virtual bool TurnOn(
 
  190      const std::string &_lightName, 
const std::string &_linkName) 
final;
 
  194    protected: 
virtual bool TurnOnAll() 
final;
 
  201    protected: 
virtual bool TurnOff(
const std::string &_lightName) 
final;
 
  207    protected: 
virtual bool TurnOff(
 
  208      const std::string &_lightName, 
const std::string &_linkName) 
final;
 
  222      const std::string &_lightName, 
const std::string &_linkName,
 
  223      const double _duration, 
const int _index) 
final;
 
  231      const std::string &_lightName, 
const std::string &_linkName,
 
  232      const double _duration) 
final;
 
  242      const std::string &_lightName, 
const std::string &_linkName,
 
  243      const double _interval, 
const int _index) 
final;
 
  251      const std::string &_lightName, 
const std::string &_linkName,
 
  252      const double _interval) 
final;
 
  262      const std::string &_lightName, 
const std::string &_linkName,
 
  263      const ignition::math::Color &_color, 
const int _index) 
final;
 
  271      const std::string &_lightName, 
const std::string &_linkName,
 
  272      const ignition::math::Color &_color) 
final;
 
  285    protected: 
virtual std::shared_ptr<FlashLightSetting> 
CreateSetting(
 
  286      const sdf::ElementPtr &_sdf,
 
  287      const gazebo::physics::ModelPtr &_model,
 
  288      const gazebo::common::Time &_currentTime,
 
  289    gazebo_ros::Node::SharedPtr node);
 
  302        std::shared_ptr<FlashLightSetting> &_setting);
 
  305    private: std::unique_ptr<FlashLightPluginPrivate> 
dataPtr;
 
virtual bool TurnOffAll() final
Turn off all flash lights.
virtual ~FlashLightPlugin()
Destructor.
rclcpp::Subscription< std_msgs::msg::Int8 >::SharedPtr cmdledsubscription
virtual bool TurnOnAll() final
Turn on all flash lights.
void Load(gazebo::physics::ModelPtr _parent, sdf::ElementPtr _sdf) override
virtual void OnUpdate()
Called by the world update start event.
virtual bool ChangeColor(const std::string &_lightName, const std::string &_linkName, const ignition::math::Color &_color, const int _index) final
Change the color of a specific block of the flashlight. If the index is a negative number,...
virtual bool TurnOn(const std::string &_lightName) final
Turn on a flash light specified by the light name If more than one link have lights with the identica...
virtual bool TurnOff(const std::string &_lightName) final
Turn off a flash light specified by the name If more than one link have lights with the identical nam...
FlashLightPlugin()
Constructor.
std::unique_ptr< FlashLightPluginPrivate > dataPtr
Pointer to private data.
virtual void InitSettingBySpecificData(std::shared_ptr< FlashLightSetting > &_setting)
Initialize the additional part of an object of setting.
virtual std::shared_ptr< FlashLightSetting > CreateSetting(const sdf::ElementPtr &_sdf, const gazebo::physics::ModelPtr &_model, const gazebo::common::Time &_currentTime, gazebo_ros::Node::SharedPtr node)
Create an object of setting.
virtual bool ChangeInterval(const std::string &_lightName, const std::string &_linkName, const double _interval, const int _index) final
Change the interval of a specific block of the flashlight. If the index is a negative number,...
virtual bool ChangeDuration(const std::string &_lightName, const std::string &_linkName, const double _duration, const int _index) final
Change the duration of a specific block of the flashlight. If the index is a negative number,...
Internal data class to hold individual flash light settings. A setting for each flash light is separa...
virtual void SetDuration(const double _duration, const int _index) final
Set the duration time for the specified block.
virtual void InitPubLight(const gazebo::transport::PublisherPtr &_pubLight) final
Set the publisher and send an initial light command.
virtual unsigned int BlockCount() final
Get the number of blocks.
virtual void UpdateLightInEnv(const gazebo::common::Time &_currentTime) final
Update the light based on the given time.
std::unique_ptr< FlashLightSettingPrivate > dataPtr
Pointer to private data.
virtual void InsertBlock(const double _duration, const double _interval, const ignition::math::Color &_color, const int _index) final
Insert a block. Create a block with specified parameters. If the index is out of range,...
virtual const std::string Name() const final
Getter of name.
virtual void SwitchOn() final
Switch on (enable the flashlight).
virtual void Dim()
Dim the light This function is internally used to update the light in the environment.
virtual const gazebo::physics::LinkPtr Link() const final
Getter of link.
virtual ignition::math::Color CurrentColor() final
Get the current color of the light. This is to be used by an inheriting class of FlashLightSetting cl...
virtual void SetInterval(const double _interval, const int _index) final
Set the interval time for the specified block.
virtual void Flash()
Flash the light This function is internally used to update the light in the environment.
virtual void SwitchOff() final
Switch off (disable the flashlight).
virtual ~FlashLightSetting()
Destructor.
virtual void SetColor(const ignition::math::Color &_color, const int _index) final
Set the color for the specified block.
FlashLightSetting(const sdf::ElementPtr &_sdf, const gazebo::physics::ModelPtr &_model, const gazebo::common::Time &_currentTime, gazebo_ros::Node::SharedPtr node)
Constructor. Initialize the setting by the data given to the base plugin.
virtual bool RemoveBlock(const int _index) final
Remove a specified block.