ros_sugar.core.component_actions#

Component Actions

Module Contents#

Classes#

ComponentActions

Pre-defined component level actions and system level actions

API#

class ros_sugar.core.component_actions.ComponentActions#

Pre-defined component level actions and system level actions

Component-level Actions:

  • stop

  • start

  • restart

  • reconfigure

  • update_parameter

  • update_parameters

System-level Actions:

  • log

  • publish_message

  • send_srv_request

  • send_action_goal

Usage Example:

    from ros_sugar.actions import Actions

    my_component = BaseComponent(node_name='test_component')
    action1 = Actions.start(component=my_component)
    action2 = Actions.log(msg="I am executing a cool action!")
classmethod send_srv_request(*, srv_name: str, srv_type: type, srv_request_msg: Any) ros_sugar.core.action.Action#

Action to send a ROS2 service request using the Monitor

Parameters:
  • srv_name (str) – Service name

  • srv_type (type) – Service type (ROS2 service)

  • srv_request_msg (Any) – Service request message

Returns:

Sending request action

Return type:

Action

classmethod send_action_goal(*, action_name: str, action_type: type, action_request_msg: Any) ros_sugar.core.action.Action#

Action to send a ROS2 action goal using the Monitor

Parameters:
  • action_name (str) – ROS2 action name

  • action_type (type) – ROS2 action type

  • action_request_msg (Any) – ROS2 action goal message

Returns:

Sending goal action

Return type:

Action

classmethod publish_message(*, topic: ros_sugar.io.topic.Topic, msg: Any, publish_rate: Optional[float] = None, publish_period: Optional[float] = None) ros_sugar.core.action.Action#

Action to send a ROS2 action goal using the Monitor

Parameters:
  • action_name (str) – ROS2 action name

  • action_type (type) – ROS2 action type

  • action_request_msg (Any) – ROS2 action goal message

Returns:

Sending goal action

Return type:

Action

classmethod start(*, component: ros_sugar.core.component.BaseComponent) ros_sugar.core.action.Action#

Action to start a given component

Parameters:

component (BaseComponent) – Component

Returns:

Component start action

Return type:

Action

classmethod stop(*, component: ros_sugar.core.component.BaseComponent) ros_sugar.core.action.Action#

Action to stop a given component

Parameters:

component (BaseComponent) – Component

Returns:

Component stop action

Return type:

Action

classmethod restart(*, component: ros_sugar.core.component.BaseComponent, wait_time: Optional[float] = None) ros_sugar.core.action.Action#

Action to restart a given component

Parameters:
  • component (BaseComponent) – Component

  • wait_time (Optional[float]) – Optional wait time n seconds between stop and start, defaults to None (i.e. no wait)

Returns:

Component restart action

Return type:

Action

classmethod reconfigure(*, component: ros_sugar.core.component.BaseComponent, new_config: Union[str, object], keep_alive: bool = False) ros_sugar.core.action.Action#

Action to reconfigure a given component

Parameters:
  • component (BaseComponent) – Component

  • new_config (Union[str, object]) – Component config class or path to YAML config file

  • keep_alive (bool, optional) – To keep the component running when reconfiguring, defaults to False

Returns:

Component reconfigure action

Return type:

Action

classmethod update_parameter(*, component: ros_sugar.core.component.BaseComponent, param_name: str, new_value: Any, keep_alive: bool = True) ros_sugar.core.action.Action#

Action to update (change) the value of a component config parameter

Parameters:
  • component (BaseComponent) – Component

  • param_name (str) – Parameter name

  • new_value (Any) – Parameter value

  • keep_alive (bool, optional) – To keep the component running when updating the value, defaults to True

Returns:

Component parameter update action

Return type:

Action

classmethod update_parameters(*, component: ros_sugar.core.component.BaseComponent, params_names: List[str], new_values: List, keep_alive: bool = True) ros_sugar.core.action.Action#

Action to update (change) the values of a list of component config parameters

Parameters:
  • component (BaseComponent) – Component

  • params_names (List[str]) – Parameters names

  • new_values (List) – Parameters values

  • keep_alive (bool, optional) – To keep the component running when updating the value, defaults to True

Returns:

Component parameter update action

Return type:

Action

classmethod log(*, msg: str, logger_name: Optional[str] = None) ros_sugar.core.action.LogInfo#

Action to log a message.

Parameters:
  • msg (str)

  • logger_name (Optional[str])

Return type:

LogInfo