ros_sugar.robot.types

Dynamic SupportedType construction for robot plugins.

create_supported_type wraps a robot’s custom ROS message in a io.supported_types.SupportedType subclass, optionally with a converter (python output -> ROS message, for commands) and a callback (ROS message -> python value, for feedback).

Module Contents

Functions

create_supported_type

Add a new SupportedType derived class wrapping ros_msg_type.

API

ros_sugar.robot.types.create_supported_type(ros_msg_type: type, converter: Optional[Callable] = None, callback: Optional[Callable] = None) Type[ros_sugar.io.supported_types.SupportedType]

Add a new SupportedType derived class wrapping ros_msg_type.

Parameters:
  • ros_msg_type – A valid ROS2 message type.

  • converterconverter(output) -> ros_msg_type — python value to ROS message; its return annotation must equal ros_msg_type.

  • callbackcallback(msg: ros_msg_type) -> <python type> — ROS message to python value; its first-arg annotation must equal ros_msg_type and its return annotation must be a non-ROS python type.

Returns:

The newly registered SupportedType subclass.