##

LedPlugin Class Reference

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) final
| Change the color 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. 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 | 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 | 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 | 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 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...

## Detailed Description

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>
    ///

## Member Typedef Documentation

## TPtr

typedef boost::shared_ptr<ModelPlugin > TPtr

inherited

plugin pointer type definition

## Constructor & Destructor Documentation

## LedPlugin()

LedPlugin | ( |  | ) |

Constructor.

## ~LedPlugin()

virtual ~LedPlugin | ( |  | ) |

virtual

Destructor.

## Member Function Documentation

## ChangeColor() [1/2]

virtual bool ChangeColor | ( | const std::string & | _lightName,
|  | const std::string & | _linkName,
|  | const ignition::math::Color & | _color
| ) |  |

final protected virtual inherited

Change the color of all the blocks of the flashlight.

Parameters

  [in] | _lightName | The name of flash light
  [in] | _linkName | The name of the link holding the light
  [in] | _color | The new color to set

Returns
  True if the specified light is found.

## ChangeColor() [2/2]

virtual bool ChangeColor | ( | const std::string & | _lightName,
|  | const std::string & | _linkName,
|  | const ignition::math::Color & | _color,
|  | const int | _index
| ) |  |

final protected virtual inherited

Change the color of a specific block of the flashlight.

If the index is a negative number, it updates all the blocks.

Parameters

  [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

Returns
  True if the specified light is found.

## ChangeDuration() [1/2]

virtual bool ChangeDuration | ( | const std::string & | _lightName,
|  | const std::string & | _linkName,
|  | const double | _duration
| ) |  |

final protected virtual inherited

Change the duration of all the blocks of the flashlight.

Parameters

  [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

Returns
  True if the specified light is found.

## ChangeDuration() [2/2]

virtual bool ChangeDuration | ( | const std::string & | _lightName,
|  | const std::string & | _linkName,
|  | const double | _duration,
|  | const int | _index
| ) |  |

final protected virtual inherited

Change the duration of a specific block of the flashlight.

If the index is a negative number, it updates all the blocks.

Parameters

  [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

Returns
  True if the specified light is found.

## ChangeInterval() [1/2]

virtual bool ChangeInterval | ( | const std::string & | _lightName,
|  | const std::string & | _linkName,
|  | const double | _interval
| ) |  |

final protected virtual inherited

Change the interval of all the blocks of the flashlight.

Parameters

  [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

Returns
  True if the specified light is found.

## ChangeInterval() [2/2]

virtual bool ChangeInterval | ( | const std::string & | _lightName,
|  | const std::string & | _linkName,
|  | const double | _interval,
|  | const int | _index
| ) |  |

final protected virtual inherited

Change the interval of a specific block of the flashlight.

If the index is a negative number, it updates all the blocks.

Parameters

  [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

Returns
  True if the specified light is found.

## Create()

static TPtr Create | ( | const std::string & | _filename,
|  | const std::string & | _name
| ) |  |

inline static inherited

a class method that creates a plugin from a file name.

It locates the shared library and loads it dynamically.

Parameters

  [in] | _filename | the path to the shared library.
  [in] | _name | short name of the plugin

Returns
  Shared Pointer to this class type

## CreateSetting()

virtual std::shared_ptr<FlashLightSetting> CreateSetting | ( | const sdf::ElementPtr & | _sdf,
|  | const physics::ModelPtr & | _model,
|  | const common::Time & | _currentTime
| ) |  |

protected virtual

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.

Parameters

  [in] | _sdf | SDF data for the setting.
  [in] | _model | The Model pointer holding the light to control.
  [in] | _currentTime | The current time point.

Returns
  A pointer to the newly created setting object.

Reimplemented from FlashLightPlugin.

## GetFilename()

std::string GetFilename | ( |  | ) | const

inline inherited

Get the name of the handler.

## GetHandle()

std::string GetHandle | ( |  | ) | const

inline inherited

Get the short name of the handler.

## GetType()

PluginType GetType | ( |  | ) | const

inline inherited

Returns the type of the plugin.

Returns
  type of the plugin

## Init()

virtual void Init | ( |  | ) |

inline virtual inherited

Override this method for custom plugin initialization behavior.

Reimplemented in TrackedVehiclePlugin, KeysToCmdVelPlugin, SimpleTrackedVehiclePlugin, WheelTrackedVehiclePlugin, BuoyancyPlugin, HarnessPlugin, FollowerPlugin, PlaneDemoPlugin, MudPlugin, CartDemoPlugin, VehiclePlugin, GimbalSmall2dPlugin, LinearBatteryPlugin, DiffDrivePlugin, and SphereAtlasDemoPlugin.

## InitSettingBySpecificData()

virtual void InitSettingBySpecificData | ( | std::shared_ptr< FlashLightSetting > & | _setting | ) |

protected virtual

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.

Parameters

  [in] | _setting | A pointer to the setting object.

Reimplemented from FlashLightPlugin.

## Load()

void Load | ( | physics::ModelPtr | _model,
|  | sdf::ElementPtr | _sdf
| ) |  |

override virtual inherited

Load function.

Called when a Plugin is first created, and after the World has been loaded. This function should not be blocking.

Parameters

  [in] | _model | Pointer to the Model
  [in] | _sdf | Pointer to the SDF element of the plugin.

Implements ModelPlugin.

## LoadParam() [1/2]

void LoadParam | ( | const sdf::ElementPtr & | _sdf,
|  | const std::string & | _name,
|  | V & | _target,
|  | V | _defaultValue = `V()`
| ) |  | const

inline protected inherited

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.

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.

## LoadParam() [2/2]

void LoadParam | ( | sdf::ElementPtr & | _sdf,
|  | const std::string & | _name,
|  | std::string & | _target,
|  | const char * | _defaultValue
| ) |  | const

inline protected inherited

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.

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.

## OnUpdate()

virtual void OnUpdate | ( |  | ) |

protected virtual inherited

Called by the world update start event.

## Reset()

virtual void Reset | ( |  | ) |

inline virtual inherited

Override this method for custom plugin reset behavior.

Reimplemented in TrackedVehiclePlugin, KeysToCmdVelPlugin, SimpleTrackedVehiclePlugin, WheelTrackedVehiclePlugin, RandomVelocityPlugin, ElevatorPlugin, FollowerPlugin, LinearBatteryPlugin, ActorPlugin, InitialVelocityPlugin, and SphereAtlasDemoPlugin.

## TurnOff() [1/2]

virtual bool TurnOff | ( | const std::string & | _lightName | ) |

final protected virtual inherited

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.

Parameters

  [in] | _lightName | The name of flash light

Returns
  True if the specified light is found.

## TurnOff() [2/2]

virtual bool TurnOff | ( | const std::string & | _lightName,
|  | const std::string & | _linkName
| ) |  |

final protected virtual inherited

Turn off a flash light specified by the name.

Parameters

  [in] | _lightName | The name of flash light
  [in] | _linkName | The name of the link holding the light

Returns
  True if the specified light is found.

## TurnOffAll()

virtual bool TurnOffAll | ( |  | ) |

final protected virtual inherited

Turn off all flash lights.

Returns
  True if there is one or more lights to turn off.

## TurnOn() [1/2]

virtual bool TurnOn | ( | const std::string & | _lightName | ) |

final protected virtual inherited

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.

Parameters

  [in] | _lightName | The name of flash light

Returns
  True if the specified light is found.

## TurnOn() [2/2]

virtual bool TurnOn | ( | const std::string & | _lightName,
|  | const std::string & | _linkName
| ) |  |

final protected virtual inherited

Turn on a flash light specified by the name and its link.

Parameters

  [in] | _lightName | The name of flash light
  [in] | _linkName | The name of the link holding the light

Returns
  True if the specified light is found.

## TurnOnAll()

virtual bool TurnOnAll | ( |  | ) |

final protected virtual inherited

Turn on all flash lights.

Returns
  True if there is one or more lights to turn on.

## Member Data Documentation

## filename

std::string filename

protected inherited

Path to the shared library file.

## handleName

std::string handleName

protected inherited

Short name.

## type

PluginType type

protected inherited

Type of plugin.

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

- LedPlugin.hh