ros_sugar.robot.command

Robot command descriptor.

A RobotCommand declares one command surface a plugin exposes: which standard message type it stands in for, which transport carries it, and how to encode a component’s output into a wire payload.

Module Contents

Classes

RobotCommand

A robot command surface.

CommandSpec

Introspection record for a RobotCommand (see plugin.list_commands).

API

class ros_sugar.robot.command.RobotCommand

Bases: ros_sugar.config.BaseAttrs

A robot command surface.

Parameters:
  • key – Registry key on plugin.commands. A recipe routes an output topic through this command with Topic(..., use_plugin=True); resolution matches the topic’s name against this key first, then falls back to a unique message-type match. For plugins that expose exactly one command per message type, conventionally the message-type name ("Twist"). For plugins with multiple commands 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.

  • transport – Transport the command is sent on.

  • encoderencoder(output) -> payload — turns a component’s output (the value it would have published) into the transport’s wire payload (bytes for UDP/HTTP, an SDK object for SDK, a request for RosServiceTransport).

  • msg_type – Optional SupportedType subclass — set only when the transport is ROS-typed (RosTopicTransport).

  • description – Human-readable description.

property channel: str

Command bus channel, used when transport.route_via_host is set.

spec() ros_sugar.robot.command.CommandSpec

Return the introspection spec for this command.

asdict(filter: Optional[Callable] = None) Dict
to_dict() Dict
from_dict(dict_obj: Dict) None
from_file(file_path: str, nested_root_name: Union[str, None] = None, get_common: bool = False) bool
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
classmethod get_fields_info(class_object) Dict[str, Dict[str, Any]]
class ros_sugar.robot.command.CommandSpec

Bases: ros_sugar.config.BaseAttrs

Introspection record for a RobotCommand (see plugin.list_commands).

key is the registry key on plugin.commands. To route an output through this command, set Topic(use_plugin=True) and name the topic after this key (needed only to disambiguate multiple commands of the same message type).

asdict(filter: Optional[Callable] = None) Dict
to_dict() Dict
from_dict(dict_obj: Dict) None
from_file(file_path: str, nested_root_name: Union[str, None] = None, get_common: bool = False) bool
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
classmethod get_fields_info(class_object) Dict[str, Dict[str, Any]]