SMACC2
Public Member Functions | Public Attributes | List of all members
smacc2::ControllableLed Class Reference
Inheritance diagram for smacc2::ControllableLed:
Inheritance graph
Collaboration diagram for smacc2::ControllableLed:
Collaboration graph

Public Member Functions

 ControllableLed ()
 
void LightCmd (const std_msgs::msg::Int8::SharedPtr msg)
 
void Load (gazebo::physics::ModelPtr _parent, sdf::ElementPtr _sdf) override
 
void OnCommand (ConstIntPtr &_msg)
 
- Public Member Functions inherited from smacc2::LedPlugin
 LedPlugin ()
 Constructor. More...
 
virtual ~LedPlugin ()
 Destructor. More...
 
- Public Member Functions inherited from smacc2::FlashLightPlugin
 FlashLightPlugin ()
 Constructor. More...
 
virtual ~FlashLightPlugin ()
 Destructor. More...
 
void Load (gazebo::physics::ModelPtr _parent, sdf::ElementPtr _sdf) override
 

Public Attributes

gazebo_ros::Node::SharedPtr ros_node_
 A pointer to the GazeboROS node. More...
 
rclcpp::Subscription< std_msgs::msg::Int8 >::SharedPtr subscription_
 

Additional Inherited Members

- Protected Member Functions inherited from smacc2::LedPlugin
virtual std::shared_ptr< FlashLightSettingCreateSetting (const sdf::ElementPtr &_sdf, const gazebo::physics::ModelPtr &_model, const gazebo::common::Time &_currentTime, gazebo_ros::Node::SharedPtr node)
 Create an object of setting. More...
 
virtual void InitSettingBySpecificData (std::shared_ptr< FlashLightSetting > &_setting)
 Initialize the additional part of an object of setting. More...
 
- Protected Member Functions inherited from smacc2::FlashLightPlugin
virtual void OnUpdate ()
 Called by the world update start event. More...
 
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 identical name, the first appearing light in the list will be updated. More...
 
virtual bool TurnOn (const std::string &_lightName, const std::string &_linkName) final
 Turn on a flash light specified by the name and its link. More...
 
virtual bool TurnOnAll () final
 Turn on all flash lights. More...
 
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 name, the first appearing light in the list will be updated. More...
 
virtual bool TurnOff (const std::string &_lightName, const std::string &_linkName) final
 Turn off a flash light specified by the name. More...
 
virtual bool TurnOffAll () final
 Turn off all flash lights. More...
 
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, it updates all the blocks. More...
 
virtual bool ChangeDuration (const std::string &_lightName, const std::string &_linkName, const double _duration) final
 Change the duration of all the blocks of the flashlight. More...
 
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, it updates all the blocks. More...
 
virtual bool ChangeInterval (const std::string &_lightName, const std::string &_linkName, const double _interval) final
 Change the interval of all the blocks of the flashlight. More...
 
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, it updates all the blocks. More...
 
virtual bool ChangeColor (const std::string &_lightName, const std::string &_linkName, const ignition::math::Color &_color) final
 Change the color of all the blocks of the flashlight. More...
 
virtual std::shared_ptr< FlashLightSettingCreateSetting (const sdf::ElementPtr &_sdf, const gazebo::physics::ModelPtr &_model, const gazebo::common::Time &_currentTime, gazebo_ros::Node::SharedPtr node)
 Create an object of setting. More...
 
virtual void InitSettingBySpecificData (std::shared_ptr< FlashLightSetting > &_setting)
 Initialize the additional part of an object of setting. More...
 

Detailed Description

Definition at line 38 of file controllable_led_plugin.cpp.

Constructor & Destructor Documentation

◆ ControllableLed()

smacc2::ControllableLed::ControllableLed ( )
inline

Definition at line 45 of file controllable_led_plugin.cpp.

45 : LedPlugin()
46 {
47 gzmsg << "Loading ControllableLed plugin\n";
48 // Transport initialization
49 // this->gzNode = gazebo::transport::NodePtr(new gazebo::transport::Node());
50 // this->gzNode->Init();
51
52 // Subscribe to ContainPlugin output
53 //std::string topic("/test_cmd");
54
55 // const bool containSub = this->dataPtr->node.Subscribe(topic, &ControllableLed::OnCommand2, this);
56 // //containSub = this->gzNode->Subscribe(topic, &ControllableLed::OnCommand, this);
57
58 // if (!containSub)
59 // {
60 // gzerr << "Failed to subscribe to [" << topic << "]\n";
61 // }
62 // else
63 // {
64 // gzmsg << "Subscribed to [" << topic << "]\n";
65 // }
66
67 // Subscribe to ContainPlugin output
68 // std::string topic("contain_example/contain");
69 // std::function<void(const ignition::msgs::Boolean &)> cb =
70 // [=](const ignition::msgs::Boolean & _msg)
71 // {
72 // //TurnOnLightPlugin::OnContainPluginMsg(_msg);
73 // };
74 // const bool containSub = this->node.Subscribe(topic, cb);
75 // if (!containSub)
76 // {
77 // gzerr << "Failed to subscribe to [" << topic << "]\n";
78 // }
79 }
LedPlugin()
Constructor.
Definition: LedPlugin.cc:199

Member Function Documentation

◆ LightCmd()

void smacc2::ControllableLed::LightCmd ( const std_msgs::msg::Int8::SharedPtr  msg)
inline

Definition at line 81 of file controllable_led_plugin.cpp.

82 {
83 gzmsg << "Turning on light\n";
84
85 if (msg->data == 1)
86 {
87 gzmsg << "Turning on light\n";
88 this->TurnOnAll();
89 // lightMsg.set_range(15.0);
90 }
91 else if (msg->data == 0)
92 {
93 gzmsg << "Turning off light\n";
94 this->TurnOffAll();
95 // lightMsg.set_range(0.0);
96 }
97 }
virtual bool TurnOffAll() final
Turn off all flash lights.
virtual bool TurnOnAll() final
Turn on all flash lights.

References smacc2::FlashLightPlugin::TurnOffAll(), and smacc2::FlashLightPlugin::TurnOnAll().

Here is the call graph for this function:

◆ Load()

void smacc2::ControllableLed::Load ( gazebo::physics::ModelPtr  _parent,
sdf::ElementPtr  _sdf 
)
inlineoverride

Definition at line 99 of file controllable_led_plugin.cpp.

100 {
101 // Subscribe to wrench messages
102 // ros_node_ = gazebo_ros::Node::Get(_sdf);
103
104 // subscription_ = ros_node_->create_subscription<std_msgs::msg::Int8>(
105 // "led_cmd", rclcpp::SystemDefaultsQoS(),
106 // std::bind(&ControllableLed::LightCmd, this, std::placeholders::_1));
107
108 // // Make a publisher for the light topic
109 // this->lightPub = this->gzNode->Advertise<msgs::Light>("~/light/modify");
110
111 LedPlugin::Load(_parent, _sdf);
112 //this->TurnOnAll();
113 }
void Load(gazebo::physics::ModelPtr _parent, sdf::ElementPtr _sdf) override

References smacc2::FlashLightPlugin::Load().

Here is the call graph for this function:

◆ OnCommand()

void smacc2::ControllableLed::OnCommand ( ConstIntPtr &  _msg)
inline

Definition at line 116 of file controllable_led_plugin.cpp.

117 {
118
119 }

Member Data Documentation

◆ ros_node_

gazebo_ros::Node::SharedPtr smacc2::ControllableLed::ros_node_

A pointer to the GazeboROS node.

Definition at line 42 of file controllable_led_plugin.cpp.

◆ subscription_

rclcpp::Subscription<std_msgs::msg::Int8>::SharedPtr smacc2::ControllableLed::subscription_

Definition at line 43 of file controllable_led_plugin.cpp.


The documentation for this class was generated from the following file: