ros_sugar.core.event#

Event

Module Contents#

Classes#

InternalEvent

Class to transform a Kompass event to ROS launch event using event key name

OnInternalEvent

ROS EventHandler for InternalEvent.

Operand

Class to dynamically access nested attributes of an object and perform value Comparisons.

Event

An Event is defined by a change in a ROS2 message value on a specific topic. Events are created to alert a robot software stack to any dynamic change at runtime.

API#

class ros_sugar.core.event.InternalEvent(event_name: str)#

Bases: launch.event.Event

Class to transform a Kompass event to ROS launch event using event key name

property event_name#

Getter of internal event name

Returns:

Event name

Return type:

str

class ros_sugar.core.event.OnInternalEvent(*, internal_event_name: str, entities: ros_sugar.core.event.SomeEntitiesType, handle_once: bool = False)#

Bases: launch.event_handler.EventHandler

ROS EventHandler for InternalEvent.

class ros_sugar.core.event.Operand(ros_message: Any, attributes: List[str])#

Class to dynamically access nested attributes of an object and perform value Comparisons.

class ros_sugar.core.event.Event(event_name: str, event_source: Union[ros_sugar.io.topic.Topic, str, Dict], trigger_value: Union[float, int, bool, str, None], nested_attributes: Union[str, List[str]], topic_template: Optional[ros_sugar.io.topic.Topic] = None)#

An Event is defined by a change in a ROS2 message value on a specific topic. Events are created to alert a robot software stack to any dynamic change at runtime.

Events are used by matching them to ‘Actions’; an Action is meant to be executed at runtime once the Event is triggered.

property under_processing: bool#

If event is triggered and associated action is getting executed

Returns:

Event under processing flag

Return type:

bool

property name: str#

Getter of event name

Returns:

Name

Return type:

str

clear() None#

Clear event trigger

trig() None#

Raise event trigger

property dictionary: Dict#

Property to parse the event into a dictionary

Returns:

Event description dictionary

Return type:

Dict

set_dictionary(dict_obj, topic_template: ros_sugar.io.topic.Topic)#

Set event using a dictionary and a Topic template Note: The template topic is added to pass a child class of the Topic class that exists in auto_ros

Parameters:
  • dict_obj (Dict) – Event description dictionary

  • topic_template (Topic) – Template for the event topic

property json: str#

Property to get/set the event using a json

Returns:

Event description dictionary as json

Return type:

str

callback(msg: Any) None#

Event topic listener callback

Parameters:

msg (Any) – Event trigger topic message

register_method(method_name: str, method: Callable[..., Any]) None#

Adds a new method to the on trigger register

Parameters:
  • method_name (str) – Key name of the method

  • method (Callable[, Any]) – Method to be executed

register_actions(actions: Union[ros_sugar.core.action.Action, List[ros_sugar.core.action.Action]]) None#

Register an Action or a set of Actions to execute on trigger

Parameters:

actions (Union[Action, List[Action]]) – Action or a list of Actions

clear_actions() None#

Clear all registered on trigger Actions

remove_method(method_name: str)#

Adds a new method to the on trigger register

Parameters:
  • method_name (str) – Key name of the method

  • method (Callable[, Any]) – Method to be executed