A plugin that blinks light and visual elements in a model. More...
#include <LedPlugin.hh>
Inherits FlashLightPlugin.
Public Types | |
typedef boost::shared_ptr< ModelPlugin > | TPtr |
plugin pointer type definition More... | |
Public Member Functions | |
LedPlugin () | |
Constructor. More... | |
virtual | ~LedPlugin () |
Destructor. More... | |
std::string | GetFilename () const |
Get the name of the handler. More... | |
std::string | GetHandle () const |
Get the short name of the handler. More... | |
PluginType | GetType () const |
Returns the type of the plugin. More... | |
virtual void | Init () |
Override this method for custom plugin initialization behavior. More... | |
void | Load (physics::ModelPtr _parent, sdf::ElementPtr _sdf) override |
Load function. More... | |
virtual void | Reset () |
Override this method for custom plugin reset behavior. More... | |
Static Public Member Functions | |
static TPtr | Create (const std::string &_filename, const std::string &_name) |
a class method that creates a plugin from a file name. More... | |
Protected Member Functions | |
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. 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 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. 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. 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 std::shared_ptr< FlashLightSetting > | CreateSetting (const sdf::ElementPtr &_sdf, const physics::ModelPtr &_model, const common::Time &_currentTime) |
Create an object of setting. More... | |
virtual void | InitSettingBySpecificData (std::shared_ptr< FlashLightSetting > &_setting) |
Initialize the additional part of an object of setting. More... | |
void | LoadParam (const sdf::ElementPtr &_sdf, const std::string &_name, V &_target, V _defaultValue=V()) const |
Load parameter value from _sdf and store it to the given reference, using the supplied default value if the element in _sdf is not found. More... | |
void | LoadParam (sdf::ElementPtr &_sdf, const std::string &_name, std::string &_target, const char *_defaultValue) const |
Load parameter value from _sdf and store it to the given reference, using the supplied default value if the element in _sdf is not found. More... | |
virtual void | OnUpdate () |
Called by the world update start event. 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 | 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... | |
Protected Attributes | |
std::string | filename |
Path to the shared library file. More... | |
std::string | handleName |
Short name. More... | |
PluginType | type |
Type of plugin. More... | |
A plugin that blinks light and visual elements in a model.
In addition to the features of the base plugin, FlashLightPlugin, this plugin accesses a <visual> element to make it blink.
The <light> and <visual> element to control must have the identical name and specified by <light_id>, including the name of the link, which they are attached on, and their name separated by a slash "/".
Other parameters are inherited from the base plugin, FlashLightPlugin.
Example:
/// <model name='light_model'> /// ... /// <link name='light_source'> /// ... /// <light name='lamp' type='point'> /// ... /// </light> /// <visual name='lamp'> /// ... /// </visual> /// </link> /// ... /// <plugin name='light_control' filename='libLedPlugin.so'> /// <light> /// <id>light_source/lamp</id> /// <block> /// <duration>1</duration> /// <interval>1</interval> /// <color>1 0.5 0.5</color> /// </block> /// <enable>true</enable> /// </light> /// </plugin> /// </model> ///
|
inherited |
plugin pointer type definition
LedPlugin | ( | ) |
Constructor.
|
virtual |
Destructor.
|
finalprotectedvirtualinherited |
Change the color of a specific block of the flashlight.
If the index is a negative number, it updates all the blocks.
[in] | _lightName | The name of flash light |
[in] | _linkName | The name of the link holding the light |
[in] | _color | The new color to set |
[in] | _index | The index to the block to update |
|
finalprotectedvirtualinherited |
Change the color of all the blocks of the flashlight.
[in] | _lightName | The name of flash light |
[in] | _linkName | The name of the link holding the light |
[in] | _color | The new color to set |
|
finalprotectedvirtualinherited |
Change the duration of a specific block of the flashlight.
If the index is a negative number, it updates all the blocks.
[in] | _lightName | The name of flash light |
[in] | _linkName | The name of the link holding the light |
[in] | _duration | The new duration time to set |
[in] | _index | The index to the block to update |
|
finalprotectedvirtualinherited |
Change the duration of all the blocks of the flashlight.
[in] | _lightName | The name of flash light |
[in] | _linkName | The name of the link holding the light |
[in] | _duration | The new duration time to set |
|
finalprotectedvirtualinherited |
Change the interval of a specific block of the flashlight.
If the index is a negative number, it updates all the blocks.
[in] | _lightName | The name of flash light |
[in] | _linkName | The name of the link holding the light |
[in] | _interval | The new interval time to set |
[in] | _index | The index to the block to update |
|
finalprotectedvirtualinherited |
Change the interval of all the blocks of the flashlight.
[in] | _lightName | The name of flash light |
[in] | _linkName | The name of the link holding the light |
[in] | _interval | The new interval time to set |
|
inlinestaticinherited |
a class method that creates a plugin from a file name.
It locates the shared library and loads it dynamically.
[in] | _filename | the path to the shared library. |
[in] | _name | short name of the plugin |
References PluginT< T >::filename, gzerr, and SingletonT< SystemPaths >::Instance().
|
protectedvirtual |
Create an object of setting.
NOTE: This function is internally called in Load() of the base class. If a child class of FlashLightPlugin has also an inherited class of FlashLightSetting, this function must be overridden so that dataPtr deals with objects of the appropriate setting class.
[in] | _sdf | SDF data for the setting. |
[in] | _model | The Model pointer holding the light to control. |
[in] | _currentTime | The current time point. |
Reimplemented from FlashLightPlugin.
|
inlineinherited |
Get the name of the handler.
References PluginT< T >::filename.
|
inlineinherited |
Get the short name of the handler.
References PluginT< T >::handleName.
|
inlineinherited |
|
inlinevirtualinherited |
Override this method for custom plugin initialization behavior.
Reimplemented in KeysToCmdVelPlugin, BuoyancyPlugin, HarnessPlugin, FollowerPlugin, PlaneDemoPlugin, MudPlugin, CartDemoPlugin, VehiclePlugin, GimbalSmall2dPlugin, LinearBatteryPlugin, DiffDrivePlugin, and SphereAtlasDemoPlugin.
|
protectedvirtual |
Initialize the additional part of an object of setting.
NOTE: This function is internally called in Load() of the base class. If a child class of FlashLightPlugin has also an inherited class of FlashLightSetting, this function must be overridden so that the object can be initialized with necessary data. Also, the overridden function must call the original function in it.
[in] | _setting | A pointer to the setting object. |
Reimplemented from FlashLightPlugin.
|
overridevirtualinherited |
Load function.
Called when a Plugin is first created, and after the World has been loaded. This function should not be blocking.
[in] | _model | Pointer to the Model |
[in] | _sdf | Pointer to the SDF element of the plugin. |
Implements ModelPlugin.
|
inlineprotectedinherited |
Load parameter value from _sdf and store it to the given reference, using the supplied default value if the element in _sdf is not found.
A message is written using gzmsg reporting whether the default value was used or not.
[in] | _sdf | The SDF element of the plugin. |
[in] | _name | Name of a tag inside the SDF. |
[out] | _target | The reference to store the param value to. |
[in] | _defaultValue | The default value. |
References gzmsg, and PluginT< T >::handleName.
|
inlineprotectedinherited |
Load parameter value from _sdf and store it to the given reference, using the supplied default value if the element in _sdf is not found.
A message is written using gzmsg reporting whether the default value was used or not. String specialization to allow accepting const char* values for std::string parameters.
[in] | _sdf | The SDF element of the plugin. |
[in] | _name | Name of a tag inside the SDF. |
[out] | _target | The reference to store the param value to. |
[in] | _defaultValue | The default value. |
|
protectedvirtualinherited |
Called by the world update start event.
|
inlinevirtualinherited |
Override this method for custom plugin reset behavior.
Reimplemented in KeysToCmdVelPlugin, RandomVelocityPlugin, ElevatorPlugin, FollowerPlugin, LinearBatteryPlugin, ActorPlugin, InitialVelocityPlugin, and SphereAtlasDemoPlugin.
|
finalprotectedvirtualinherited |
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.
[in] | _lightName | The name of flash light |
|
finalprotectedvirtualinherited |
Turn off a flash light specified by the name.
[in] | _lightName | The name of flash light |
[in] | _linkName | The name of the link holding the light |
|
finalprotectedvirtualinherited |
Turn off all flash lights.
|
finalprotectedvirtualinherited |
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.
[in] | _lightName | The name of flash light |
|
finalprotectedvirtualinherited |
Turn on a flash light specified by the name and its link.
[in] | _lightName | The name of flash light |
[in] | _linkName | The name of the link holding the light |
|
finalprotectedvirtualinherited |
Turn on all flash lights.
|
protectedinherited |
Path to the shared library file.
|
protectedinherited |
Short name.
|
protectedinherited |
Type of plugin.