A plugin that blinks a light component in the model. More...
#include <FlashLightPlugin.hh>
Inherits ModelPlugin.
Inherited by LedPlugin.
Public Types | |
typedef boost::shared_ptr< ModelPlugin > | TPtr |
plugin pointer type definition More... | |
Public Member Functions | |
FlashLightPlugin () | |
Constructor. More... | |
virtual | ~FlashLightPlugin () |
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 a light component in the model.
This plugin accesses <light> elements in the model specified by <light> as a parameter. More than one <light> can exist.
NOTE: This base class provides basic functions to control the lights. Users can create their own flash light plugin by inheriting this base model plugin.
A light is specified by <id>, including link and light names separated by a slash "/".
<enable> is optional. The default value is true. When it is set to true, a light starts flashing from the beginning. If <enable> is directly under the <plugin>, it affects all the lights. If it is under <light>, it individually affects the corresponding light. When it is set to false, the light is off, and it is necessary to call TurnOn() or TurnOnAll() in an inherited class to enable the light. A locally placed <enable> has a higher priority than the global one so specific lights can be turned on while the others are all off, and vice versa.
<duration> and <interval> specify the time to flash and dim in seconds, respectively. That is, the phase is determined as the sum of them: duration + interval.
<color> is optional. It specifies the color of light. If it is not given, the original color of the <light> element in the model will be used.
<block> is optional. It specifies a single phase. By adding multiple <block> elements, the light can generate a specific sequence of light patterns with different colors. It must have <duration> and <interval>. It can have <color> to specify the color of light. If <color> is not given, it will be set to the same color as that of the previous block. The first two elements are in the same format described above. <color> has three values representing RGB values.
Example (single color):
/// <enable>true</enable> /// <light> /// <id>link1/light_source</id> /// <duration>0.1</duration> /// <interval>0.4</interval> /// <enable>true</enable> /// </light> /// <light> /// <id>link1/light_source2</id> /// <duration>0.8</duration> /// <interval>0.2</interval> /// <enable>false</enable> /// </light> /// ... ///
Example (multiple colors by <block> elements):
/// <enable>true</enable> /// /// <light> /// <id>link1/light_source</id> /// <block> /// <duration>0.6</duration> /// <interval>0</interval> /// <color>1 0 0</color> /// </block> /// <block> /// <duration>0.2</duration> /// <interval>0.5</interval> /// <color>0 1 0</color> /// </block> /// <enable>true</enable> /// </light> /// /// ... ///
|
inherited |
plugin pointer type definition
FlashLightPlugin | ( | ) |
Constructor.
|
virtual |
Destructor.
|
finalprotectedvirtual |
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 |
|
finalprotectedvirtual |
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 |
|
finalprotectedvirtual |
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 |
|
finalprotectedvirtual |
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 |
|
finalprotectedvirtual |
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 |
|
finalprotectedvirtual |
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 in LedPlugin.
|
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 in LedPlugin.
|
overridevirtual |
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. |
|
protectedvirtual |
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.
|
finalprotectedvirtual |
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 |
|
finalprotectedvirtual |
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 |
|
finalprotectedvirtual |
Turn off all flash lights.
|
finalprotectedvirtual |
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 |
|
finalprotectedvirtual |
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 |
|
finalprotectedvirtual |
Turn on all flash lights.
|
protectedinherited |
Path to the shared library file.
|
protectedinherited |
Short name.
|
protectedinherited |
Type of plugin.