ros_sugar.core.status
#
Component Status
Module Contents#
Classes#
Component health status Updated by the component during runtime to declare any detected failure in the component, or in the component algorithm, or in the external system |
API#
- class ros_sugar.core.status.Status(msg: Optional[automatika_ros_sugar.msg.ComponentStatus] = None)#
Component health status Updated by the component during runtime to declare any detected failure in the component, or in the component algorithm, or in the external system
Status is configured in the base component along with a corresponding publisher if the health broadcasting is enabled.
To use health status in your component (inheriting from BaseComponent):
To indicate a malfunction in general without details on the failure level / source, use:
self.health_status.set_failure()
It can indicate a mal-function/ failure in the algorithm (algorithm) used by the component. In this case it is possible to indicate the failed algorithm name in the message.
self.health_status.set_fail_algorithm(algorithm_names=['algorithm_1', 'algorithm_2'])
It can indicate a mal-function/ failure in the component itself or another component. Component fail by default refers to a failure in the component itself, however it is possible to specify a failure detected in a specific component by passing the name(s)
# To indicate failure in the component itself self.health_status.set_fail_component() # To indicate failure in another component self.health_status.set_fail_component(component_names=['other_component_name']) # To indicate failure in multiple components self.health_status.set_fail_component(component_names=[self.node_name, 'other_component_name'])
It can indicate a mal-function/ failure in the external system. It is possible to add the failure source using component names or topic names (in case a required topic is not available, for example)
# For failure related to a specific topic self.health_status.set_fail_system(topic_names=['some_topic_name'])
NOTE: TIMED components publish the status periodically (if broadcasting is enabled). If the component is not TIMED, then the child component should implement the publishing, using:
self.health_status_publisher.publish(self.health_status)
- property value#
Status health value
- Returns:
Current status value
- Return type:
- set_healthy()#
Set status to Running - Healthy
- set_failure()#
Set status to Non Healthy - General (Any) Failure
- set_fail_algorithm(algorithm_names: Optional[List[str]] = None)#
Set status to Error: Algorithmic Level
- set_fail_component(component_names: Optional[List[str]] = None)#
Set status to Error: Component Level
- set_fail_system(component_names: Optional[List[str]] = None, topic_names: Optional[List[str]] = None)#
Set status to Error: System Level
- property is_healthy: bool#
Property to check if the current health status is healthy
- Returns:
If status is ComponentStatus.STATUS_HEALTHY
- Return type:
bool
- property is_component_fail: bool#
Property to check if there is a component fail status
- Returns:
If status is ComponentStatus.STATUS_FAILURE_COMPONENT_LEVEL
- Return type:
bool
- property is_algorithm_fail: bool#
Property to check if there is a algorithm fail status
- Returns:
If status is ComponentStatus.STATUS_FAILURE_ALGORITHM_LEVEL
- Return type:
bool
- property is_system_fail: bool#
Property to check if there is a system “external” fail status
- Returns:
If status is ComponentStatus.STATUS_FAILURE_SYSTEM_LEVEL
- Return type:
bool