ros_sugar.io.topic#

ROS Topic Configuration

Module Contents#

Classes#

Topic

Class for ROS topic configuration (name, type and QoS)

AllowedTopic

Configure a key name and allowed types to restrict a component Topic

RestrictedTopicsConfig

Class used to define a restriction on component inputs/outputs topics

Functions#

get_all_msg_types

Gets all message types from supported data_types

get_msg_type

Gets a message type from supported data_types given a string name

msg_type_validator

Validates that a string message type corresponds to a supported data type

API#

ros_sugar.io.topic.get_all_msg_types(msg_types_module: types.ModuleType = supported_types, additional_types: Optional[List[type[ros_sugar.io.supported_types.SupportedType]]] = None) List[type[ros_sugar.io.supported_types.SupportedType]]#

Gets all message types from supported data_types

Returns:

Supported data types

Return type:

list[type]

ros_sugar.io.topic.get_msg_type(type_name: Union[type[ros_sugar.io.supported_types.SupportedType], str], msg_types_module: Optional[types.ModuleType] = supported_types, additional_types: Optional[List[type[ros_sugar.io.supported_types.SupportedType]]] = None) Union[type[ros_sugar.io.supported_types.SupportedType], str]#

Gets a message type from supported data_types given a string name

Parameters:

type_name (str) – Message name

Returns:

Supported data type or None if not found

Return type:

type

ros_sugar.io.topic.msg_type_validator(*_: Any, value)#

Validates that a string message type corresponds to a supported data type

Parameters:

value (type) – description

Raises:

ValueErrordescription

class ros_sugar.io.topic.Topic#

Bases: ros_sugar.config.BaseAttrs

Class for ROS topic configuration (name, type and QoS)

asdict(filter: Optional[Callable] = None) Dict#
from_dict(dict_obj: Dict) None#
from_yaml(file_path: str, nested_root_name: str | None = None, get_common: bool = False) None#
to_json() Union[str, bytes, bytearray]#
from_json(json_obj: Union[str, bytes, bytearray]) None#
has_attribute(attr_name: str) bool#
get_attribute_type(attr_name: str) Optional[type]#
update_value(attr_name: str, attr_value: Any) bool#
class ros_sugar.io.topic.AllowedTopic#

Bases: ros_sugar.config.BaseAttrs

Configure a key name and allowed types to restrict a component Topic

asdict(filter: Optional[Callable] = None) Dict#
from_dict(dict_obj: Dict) None#
from_yaml(file_path: str, nested_root_name: str | None = None, get_common: bool = False) None#
to_json() Union[str, bytes, bytearray]#
from_json(json_obj: Union[str, bytes, bytearray]) None#
has_attribute(attr_name: str) bool#
get_attribute_type(attr_name: str) Optional[type]#
update_value(attr_name: str, attr_value: Any) bool#
class ros_sugar.io.topic.RestrictedTopicsConfig#

Class used to define a restriction on component inputs/outputs topics

classmethod keys() List[str]#

keys.

Return type:

List[str]

classmethod types(key: str) List[Union[ros_sugar.io.supported_types.SupportedType, str]]#

types.

Parameters:

key (str)

Return type:

List[Union[supported_types.SupportedType, str]]

classmethod required_number(key: str) int#

required_number.

Parameters:

key (str)

Return type:

int

classmethod optional_number(key: str) int#

optional_number.

Parameters:

key (str)

Return type:

int