ros_sugar.robot.feedback#
Robot feedback descriptor.
A Feedback declares one telemetry stream a plugin exposes: which standard
message type it stands in for, which transport carries it, and how to
decode a raw inbound payload into a ROS message.
Module Contents#
Classes#
A robot telemetry stream. |
|
Introspection record for a |
API#
- class ros_sugar.robot.feedback.Feedback#
Bases:
ros_sugar.config.BaseAttrsA robot telemetry stream.
- Parameters:
key – Registry key on
plugin.feedbacks. A recipe binds a topic to this feedback withTopic(..., use_plugin=True); resolution matches the topic’snameagainst this key first, then falls back to a unique message-type match. For plugins that expose exactly one feedback per message type, conventionally the message-type name ("Odometry","Imu"). For plugins with multiple feedbacks of the same type (e.g. a humanoid’s"left_arm"/"right_arm"JointStates), choose a descriptive role name and name the recipe’s topic to match it.msg_type –
SupportedTypesubclass wrapping the robot’s message, typically built with :func:ros_sugar.robot.create_supported_type.transport – Transport carrying this stream.
decoder –
decoder(raw_payload) -> ros_msg | None— turns a raw inbound payload (bytes for UDP, response body for HTTP, SDK object for SDK) into a ROS message instance, orNoneto ignore this packet. Required for non-ROS transports; ignored forRosTopicTransport.rate_hz – Nominal stream rate, for introspection/documentation.
description – Human-readable description.
- property channel: str#
Feedback bus channel / synthetic topic name for this stream.
- as_topic() ros_sugar.io.topic.Topic#
Return the
io.topic.Topicthat Events, Conditions andMsgConditionBuilderreference for this feedback.For a ROS-topic-backed feedback this is the ROS topic the robot publishes on; for any other transport it is a synthetic topic whose name is the feedback bus channel and whose
use_pluginnames the owning plugin.
- property is_ros_topic: bool#
Whether this feedback is carried on a plain ROS topic (and therefore consumed via a native ROS subscription rather than the feedback bus).
- spec() ros_sugar.robot.feedback.FeedbackSpec#
Return the introspection spec for this feedback.
- asdict(filter: Optional[Callable] = None) Dict#
Convert class to dict.
- Return type:
dict
- to_dict() Dict#
Convert class to dict.
- Return type:
dict
- asdict_explicit() Dict#
Convert to dict, keeping only what differs from the class defaults.
See
explicit_fields, which this defers to.- Returns:
Fields that differ from the defaults
- Return type:
dict
- from_dict(dict_obj: Dict) None#
Gets attributes values from given dictionary
- Parameters:
dict_obj (Dict) – Dictionary {attribute_name: attribute_value}
- Raises:
ValueError – If attribute_name in dictionary does not exists in class attributes
TypeError – If attribute_value type in dictionary does not correspond to class attribute type
- from_file(file_path: str, nested_root_name: Union[str, None] = None, get_common: bool = False) bool#
Update class attributes from yaml, json, or toml
- Parameters:
file_path – Path to config file (.yaml, .json, .toml)
nested_root_name – Nested root name for the config, defaults to None
get_common – Whether to get extra config root (for merging), defaults to False
- to_json() Union[str, bytes, bytearray]#
Dump to json
- Returns:
description
- Return type:
str | bytes | bytearray
- from_json(json_obj: Union[str, bytes, bytearray]) None#
Gets attributes values from given json
- Parameters:
json_obj (str | bytes | bytearray) – Json object
- has_attribute(attr_name: str) bool#
Checks if class object has attribute with given name
- Parameters:
attr_name (str) – description
- Returns:
If object has attribute with given name
- Return type:
bool
- get_attribute_type(attr_name: str) Optional[type]#
Gets type of given attribute name
- Parameters:
attr_name (str) – description
- Raises:
AttributeError – If class does not have attribute with given name
- Returns:
Attribute type
- Return type:
type
- update_value(attr_name: str, attr_value: Any) bool#
Updates the value of an attribute in the class
- Parameters:
attr_name (str) – Attribute name - can be nested name
attr_value (Any) – Attribute value
- Raises:
AttributeError – If class does not contain attribute with given name
TypeError – If class attribute with given name if of different type
- Returns:
If attribute value is updated
- Return type:
bool
- classmethod get_fields_info(class_object) Dict[str, Dict[str, Any]]#
Returns a dictionary with metadata about each field in the class.
This includes the field’s name, type annotation, and parsed validator info.
- Returns:
A dictionary where keys are field names and values are dicts of metadata.
- class ros_sugar.robot.feedback.FeedbackSpec#
Bases:
ros_sugar.config.BaseAttrsIntrospection record for a
Feedback(seeplugin.list_feedbacks).keyis the registry key onplugin.feedbacks. To wire a topic to this feedback, setTopic(use_plugin=True)and name the topic after this key – needed when the plugin exposes multiple feedbacks of the same message type and a recipe must disambiguate. For plugins with exactly one feedback per type,use_plugin=Trueresolves by message type and the name need not match the key.- asdict(filter: Optional[Callable] = None) Dict#
Convert class to dict.
- Return type:
dict
- to_dict() Dict#
Convert class to dict.
- Return type:
dict
- asdict_explicit() Dict#
Convert to dict, keeping only what differs from the class defaults.
See
explicit_fields, which this defers to.- Returns:
Fields that differ from the defaults
- Return type:
dict
- from_dict(dict_obj: Dict) None#
Gets attributes values from given dictionary
- Parameters:
dict_obj (Dict) – Dictionary {attribute_name: attribute_value}
- Raises:
ValueError – If attribute_name in dictionary does not exists in class attributes
TypeError – If attribute_value type in dictionary does not correspond to class attribute type
- from_file(file_path: str, nested_root_name: Union[str, None] = None, get_common: bool = False) bool#
Update class attributes from yaml, json, or toml
- Parameters:
file_path – Path to config file (.yaml, .json, .toml)
nested_root_name – Nested root name for the config, defaults to None
get_common – Whether to get extra config root (for merging), defaults to False
- to_json() Union[str, bytes, bytearray]#
Dump to json
- Returns:
description
- Return type:
str | bytes | bytearray
- from_json(json_obj: Union[str, bytes, bytearray]) None#
Gets attributes values from given json
- Parameters:
json_obj (str | bytes | bytearray) – Json object
- has_attribute(attr_name: str) bool#
Checks if class object has attribute with given name
- Parameters:
attr_name (str) – description
- Returns:
If object has attribute with given name
- Return type:
bool
- get_attribute_type(attr_name: str) Optional[type]#
Gets type of given attribute name
- Parameters:
attr_name (str) – description
- Raises:
AttributeError – If class does not have attribute with given name
- Returns:
Attribute type
- Return type:
type
- update_value(attr_name: str, attr_value: Any) bool#
Updates the value of an attribute in the class
- Parameters:
attr_name (str) – Attribute name - can be nested name
attr_value (Any) – Attribute value
- Raises:
AttributeError – If class does not contain attribute with given name
TypeError – If class attribute with given name if of different type
- Returns:
If attribute value is updated
- Return type:
bool
- classmethod get_fields_info(class_object) Dict[str, Dict[str, Any]]#
Returns a dictionary with metadata about each field in the class.
This includes the field’s name, type annotation, and parsed validator info.
- Returns:
A dictionary where keys are field names and values are dicts of metadata.