rosros 0.2.5
Simple unified interface to ROS1 / ROS2 Python API
Loading...
Searching...
No Matches
api.py File Reference

Go to the source code of this file.

Namespaces

namespace  rosros
 Simple unified interface to ROS1 / ROS2.
 
namespace  rosros.api
 Utilities for ROS built-in types, and message and service types.
 

Functions

 rosros.api.canonical (typename)
 Returns "pkg/Type" for "pkg/subdir/Type".
 
 rosros.api.deserialize_message (raw, cls_or_typename)
 Returns ROS message or service request/response instantiated from serialized binary.
 
 rosros.api.dict_to_message (dct, msg_or_type)
 Returns ROS message populated from Python dictionary.
 
 rosros.api.format_param_name (name)
 Returns parameter name with correct separator for ROS version, and leading sigils stripped.
 
 rosros.api.get_alias_type (typename)
 Returns ROS built-in type for alias like "char", if any; reverse of get_type_alias().
 
 rosros.api.get_message_class (msg_or_type)
 Returns ROS message / service class object.
 
 rosros.api.get_message_definition (msg_or_type, full=True)
 Returns ROS message or service request/response type definition text.
 
 rosros.api.get_message_fields (val)
 Returns {field name: field type name} if ROS message or service request/response, else {}.
 
 rosros.api.get_message_header (val)
 Returns message `std_msgs/Header`-attribute if any, else `None`.
 
 rosros.api.get_message_type (msg_or_cls)
 Returns ROS message / service canonical type name, like "std_msgs/Header".
 
 rosros.api.get_message_type_hash (msg_or_type)
 Returns ROS message / service type MD5 hash.
 
 rosros.api.get_message_value (msg, name, default=...)
 Returns object attribute value, with numeric arrays converted to lists.
 
 rosros.api.get_service_definition (srv_or_type)
 Returns ROS service type definition text.
 
 rosros.api.get_service_request_class (srv_or_type)
 Returns ROS service request class object.
 
 rosros.api.get_service_response_class (srv_or_type)
 Returns ROS service response class object.
 
 rosros.api.get_type_alias (typename)
 Returns alias like "char" for ROS built-in type, if any; reverse of get_alias_type().
 
 rosros.api.is_ros_message (val)
 Returns whether value is a ROS message or service request/response class or instance.
 
 rosros.api.is_ros_service (val)
 Returns whether value is a ROS service class object.
 
 rosros.api.is_ros_time (val)
 Returns whether value is a ROS time/duration class or instance.
 
 rosros.api.make_duration (secs=0, nsecs=0)
 Returns a ROS duration.
 
 rosros.api.make_full_typename (typename, category="msg")
 Returns "pkg/msg/Type" for "pkg/Type".
 
 rosros.api.make_time (secs=0, nsecs=0)
 Returns a ROS time.
 
 rosros.api.message_to_dict (msg, replace=None)
 Returns ROS message as nested Python dictionary.
 
 rosros.api.message_to_str (msg, indent=None)
 Returns ROS message as an evaluatable string, e.g.
 
 rosros.api.scalar (typename)
 Returns scalar type from ROS message data type, like "uint8" from uint8-array.
 
 rosros.api.serialize_message (msg)
 Returns ROS message or service request/response as a serialized binary of `bytes()`.
 
 rosros.api.time_category (msg_or_type)
 Returns "time" or "duration" for time/duration type, else original value.
 
 rosros.api.time_message (val, to_message=True, clock_type=None)
 Converts ROS2 time/duration between `rclpy` and `builtin_interfaces` objects.
 
 rosros.api.to_datetime (val)
 Returns value as datetime.datetime if value is ROS time/duration, else value.
 
 rosros.api.to_decimal (val)
 Returns value as decimal.Decimal if value is ROS time/duration, else value.
 
 rosros.api.to_duration (val)
 Returns value as ROS duration if convertible (int/float/time/datetime/decimal), else value.
 
 rosros.api.to_nsec (val)
 Returns value in nanoseconds if value is ROS time/duration, else value.
 
 rosros.api.to_sec (val)
 Returns value in seconds if value is ROS time/duration, else value.
 
 rosros.api.to_sec_nsec (val)
 Returns value as (seconds, nanoseconds) if value is ROS time/duration, else value.
 
 rosros.api.to_time (val)
 Returns value as ROS time if convertible (int/float/duration/datetime/decimal), else value.
 

Variables

 rosros.api.FAMILY = ros.FAMILY
 ROS Python module family, "rospy" or "rclpy".
 
 rosros.api.PARAM_SEPARATOR = ros.PARAM_SEPARATOR
 Separator char between ROS parameter namespace parts.
 
 rosros.api.PRIVATE_PREFIX = ros.PRIVATE_PREFIX
 Prefix for "private" names, auto-namespaced under current namespace.
 
 rosros.api.ros = ros1 or ros2
 
 rosros.api.ros1 = None
 
 rosros.api.ROS_ALIAS_TYPES = ros.ROS_ALIAS_TYPES
 Mapping between type aliases and real types, like {"byte": "int8"} in ROS1.
 
dict rosros.api.ROS_BUILTIN_CTORS
 Python constructors for ROS built-in types, as {ROS name: type class}.
 
list rosros.api.ROS_BUILTIN_TYPES = ROS_NUMERIC_TYPES + ROS_STRING_TYPES
 All built-in basic types in ROS.
 
list rosros.api.ROS_COMMON_TYPES = ROS_BUILTIN_TYPES + ROS_TIME_TYPES
 All built-in basic types plus time types in ROS.
 
list rosros.api.ROS_NUMERIC_TYPES
 All built-in numeric types in ROS.
 
list rosros.api.ROS_STRING_TYPES = ["string", "wstring"]
 All built-in string types in ROS.
 
 rosros.api.ROS_TIME_CLASSES = ros.ROS_TIME_CLASSES
 ROS time/duration types mapped to type names.
 
 rosros.api.ROS_TIME_TYPES = ros.ROS_TIME_TYPES
 ROS time/duration types.
 
 rosros.api.ROSLogHandler = ros.ROSLogHandler
 Logging handler that forwards logging messages to ROS logger.