Class SegmentLayerInterface

Inheritance Relationships

Derived Types

Class Documentation

class SegmentLayerInterface

Interface for LED segment layers.

Subclassed by husarion_ugv_lights::SegmentLayer, husarion_ugv_lights::SegmentQueueLayer

Public Functions

inline SegmentLayerInterface(const std::size_t num_led, const bool invert_led_order, const float controller_frequency)

Parses basic parameters of the LED segment.

Parameters:
  • num_led – number of LEDs

  • invert_led_order – if true will invert the order of LEDs

  • controller_frequency – frequency at which animation will be updated.

Throws:

std::runtime_error – if pluginlib fails to load animation plugin

inline virtual ~SegmentLayerInterface()
virtual void SetAnimation(const std::string &type, const YAML::Node &animation_description, const bool repeating, const std::string &param = "") = 0

Overwrite current animation.

Parameters:
  • type – pluginlib animation type

  • animation_description – YAML description of the animation. Must contain ‘type’ key - pluginlib animation type

  • repeating – if true, will repeat animation for the panel

  • param – optional parameter to pass to animation when initializing

Throws:

std::runtime_error – if failed to set animation

virtual void UpdateAnimation() = 0

Update animation frame.

Throws:

std::runtime_error – if failed to update animation

inline bool IsAnimationFinished() const

Check if animation is finished. This does not return state of the default animation.

Returns:

True if animation is finished, false otherwise

inline std::vector<std::uint8_t> GetAnimationFrame() const

Get current animation frame.

Throws:

std::runtime_error – if segment animation is not defined

Returns:

Current animation frame or default animation frame if it was defined and the main animation is finished

inline float GetAnimationProgress() const

Get current animation progress.

Throws:

std::runtime_error – if segment animation is not defined

Returns:

Current animation progress

inline void ResetAnimation()

Reset current animation.

Throws:

std::runtime_error – if segment animation is not defined

inline bool HasAnimation() const

Protected Attributes

std::shared_ptr<husarion_ugv_lights::Animation> animation_
const float controller_frequency_
bool invert_led_order_ = false
bool animation_finished_ = true
std::size_t num_led_
std::shared_ptr<pluginlib::ClassLoader<husarion_ugv_lights::Animation>> animation_loader_