rosros 0.2.5
Simple unified interface to ROS1 / ROS2 Python API
|
Utilities for ROS built-in types, and message and service types. More...
Functions | |
canonical (typename) | |
Returns "pkg/Type" for "pkg/subdir/Type". | |
deserialize_message (raw, cls_or_typename) | |
Returns ROS message or service request/response instantiated from serialized binary. | |
dict_to_message (dct, msg_or_type) | |
Returns ROS message populated from Python dictionary. | |
format_param_name (name) | |
Returns parameter name with correct separator for ROS version, and leading sigils stripped. | |
get_alias_type (typename) | |
Returns ROS built-in type for alias like "char", if any; reverse of get_type_alias(). | |
get_message_class (msg_or_type) | |
Returns ROS message / service class object. | |
get_message_definition (msg_or_type, full=True) | |
Returns ROS message or service request/response type definition text. | |
get_message_fields (val) | |
Returns {field name: field type name} if ROS message or service request/response, else {}. | |
get_message_header (val) | |
Returns message `std_msgs/Header`-attribute if any, else `None`. | |
get_message_type (msg_or_cls) | |
Returns ROS message / service canonical type name, like "std_msgs/Header". | |
get_message_type_hash (msg_or_type) | |
Returns ROS message / service type MD5 hash. | |
get_message_value (msg, name, default=...) | |
Returns object attribute value, with numeric arrays converted to lists. | |
get_service_definition (srv_or_type) | |
Returns ROS service type definition text. | |
get_service_request_class (srv_or_type) | |
Returns ROS service request class object. | |
get_service_response_class (srv_or_type) | |
Returns ROS service response class object. | |
get_type_alias (typename) | |
Returns alias like "char" for ROS built-in type, if any; reverse of get_alias_type(). | |
is_ros_message (val) | |
Returns whether value is a ROS message or service request/response class or instance. | |
is_ros_service (val) | |
Returns whether value is a ROS service class object. | |
is_ros_time (val) | |
Returns whether value is a ROS time/duration class or instance. | |
make_duration (secs=0, nsecs=0) | |
Returns a ROS duration. | |
make_full_typename (typename, category="msg") | |
Returns "pkg/msg/Type" for "pkg/Type". | |
make_time (secs=0, nsecs=0) | |
Returns a ROS time. | |
message_to_dict (msg, replace=None) | |
Returns ROS message as nested Python dictionary. | |
message_to_str (msg, indent=None) | |
Returns ROS message as an evaluatable string, e.g. | |
scalar (typename) | |
Returns scalar type from ROS message data type, like "uint8" from uint8-array. | |
serialize_message (msg) | |
Returns ROS message or service request/response as a serialized binary of `bytes()`. | |
time_category (msg_or_type) | |
Returns "time" or "duration" for time/duration type, else original value. | |
time_message (val, to_message=True, clock_type=None) | |
Converts ROS2 time/duration between `rclpy` and `builtin_interfaces` objects. | |
to_datetime (val) | |
Returns value as datetime.datetime if value is ROS time/duration, else value. | |
to_decimal (val) | |
Returns value as decimal.Decimal if value is ROS time/duration, else value. | |
to_duration (val) | |
Returns value as ROS duration if convertible (int/float/time/datetime/decimal), else value. | |
to_nsec (val) | |
Returns value in nanoseconds if value is ROS time/duration, else value. | |
to_sec (val) | |
Returns value in seconds if value is ROS time/duration, else value. | |
to_sec_nsec (val) | |
Returns value as (seconds, nanoseconds) if value is ROS time/duration, else value. | |
to_time (val) | |
Returns value as ROS time if convertible (int/float/duration/datetime/decimal), else value. | |
Variables | |
FAMILY = ros.FAMILY | |
ROS Python module family, "rospy" or "rclpy". | |
PARAM_SEPARATOR = ros.PARAM_SEPARATOR | |
Separator char between ROS parameter namespace parts. | |
PRIVATE_PREFIX = ros.PRIVATE_PREFIX | |
Prefix for "private" names, auto-namespaced under current namespace. | |
ros = ros1 or ros2 | |
ros1 = None | |
ROS_ALIAS_TYPES = ros.ROS_ALIAS_TYPES | |
Mapping between type aliases and real types, like {"byte": "int8"} in ROS1. | |
dict | ROS_BUILTIN_CTORS |
Python constructors for ROS built-in types, as {ROS name: type class}. | |
list | ROS_BUILTIN_TYPES = ROS_NUMERIC_TYPES + ROS_STRING_TYPES |
All built-in basic types in ROS. | |
list | ROS_COMMON_TYPES = ROS_BUILTIN_TYPES + ROS_TIME_TYPES |
All built-in basic types plus time types in ROS. | |
list | ROS_NUMERIC_TYPES |
All built-in numeric types in ROS. | |
list | ROS_STRING_TYPES = ["string", "wstring"] |
All built-in string types in ROS. | |
ROS_TIME_CLASSES = ros.ROS_TIME_CLASSES | |
ROS time/duration types mapped to type names. | |
ROS_TIME_TYPES = ros.ROS_TIME_TYPES | |
ROS time/duration types. | |
ROSLogHandler = ros.ROSLogHandler | |
Logging handler that forwards logging messages to ROS logger. | |
Utilities for ROS built-in types, and message and service types.
rosros.api.canonical | ( | typename | ) |
rosros.api.deserialize_message | ( | raw, | |
cls_or_typename | |||
) |
rosros.api.dict_to_message | ( | dct, | |
msg_or_type | |||
) |
Returns ROS message populated from Python dictionary.
Raises TypeError on attribute value type mismatch.
msg_or_type | canonical or full class name like "std_msgs/Bool" or "std_msgs/msg/Bool", or class instance like `std_msgs.msg.Bool()`, or class object like `std_msgs.msg.Bool` |
rosros.api.format_param_name | ( | name | ) |
rosros.api.get_alias_type | ( | typename | ) |
rosros.api.get_message_class | ( | msg_or_type | ) |
Returns ROS message / service class object.
msg_or_type | full or canonical class name, like "std_msgs/Bool" or "std_srvs/SetBool" or "std_srvs/SetBoolRequest"; or class instance like `std_msgs.msg.Bool()` |
rosros.api.get_message_definition | ( | msg_or_type, | |
full = True |
|||
) |
Returns ROS message or service request/response type definition text.
Text will include subtype definitions by default.
msg_or_type | canonical or full class name like "std_msgs/Bool" or "std_msgs/msg/Bool", or class instance like `std_msgs.msg.Bool()`, or class object like `std_msgs.msg.Bool` |
full | include definitions of nested types, separated by "\n---\nMSG: pkg/Type\n" (ignored for service request/response types) |
rosros.api.get_message_fields | ( | val | ) |
rosros.api.get_message_header | ( | val | ) |
rosros.api.get_message_type | ( | msg_or_cls | ) |
Returns ROS message / service canonical type name, like "std_msgs/Header".
Returns "*" for `AnyMsg`.
msg_or_cls | class instance like `std_msgs.msg.Bool()`, or class object like `std_msgs.msg.Bool` |
rosros.api.get_message_type_hash | ( | msg_or_type | ) |
rosros.api.get_message_value | ( | msg, | |
name, | |||
default = ... |
|||
) |
rosros.api.get_service_definition | ( | srv_or_type | ) |
Returns ROS service type definition text.
srv_or_type | canonical or full class name like "std_srvs/SetBool" or "std_srvs/srv/SetBool", or class instance like `std_srvs.srv.SetBool()`, or class object like `std_srvs.srv.SetBool` |
rosros.api.get_service_request_class | ( | srv_or_type | ) |
Returns ROS service request class object.
srv_or_type | canonical or full class name like "std_srvs/SetBool" or "std_srvs/srv/SetBool", or class instance like `std_srvs.srv.SetBool()`, or class object like `std_srvs.srv.SetBool` |
rosros.api.get_service_response_class | ( | srv_or_type | ) |
Returns ROS service response class object.
srv_or_type | canonical or full class name like "std_srvs/SetBool" or "std_srvs/srv/SetBool", or class instance like `std_srvs.srv.SetBool()`, or class object like `std_srvs.srv.SetBool` |
rosros.api.get_type_alias | ( | typename | ) |
rosros.api.is_ros_message | ( | val | ) |
rosros.api.is_ros_service | ( | val | ) |
rosros.api.is_ros_time | ( | val | ) |
rosros.api.make_duration | ( | secs = 0 , |
|
nsecs = 0 |
|||
) |
rosros.api.make_full_typename | ( | typename, | |
category = "msg" |
|||
) |
rosros.api.make_time | ( | secs = 0 , |
|
nsecs = 0 |
|||
) |
rosros.api.message_to_dict | ( | msg, | |
replace = None |
|||
) |
rosros.api.message_to_str | ( | msg, | |
indent = None |
|||
) |
rosros.api.scalar | ( | typename | ) |
rosros.api.serialize_message | ( | msg | ) |
rosros.api.time_category | ( | msg_or_type | ) |
rosros.api.time_message | ( | val, | |
to_message = True , |
|||
clock_type = None |
|||
) |
Converts ROS2 time/duration between `rclpy` and `builtin_interfaces` objects.
val | ROS2 time/duration object from `rclpy` or `builtin_interfaces` |
to_message | whether to convert from `rclpy` to `builtin_interfaces` or vice versa |
clock_type | ClockType for converting to `rclpy.Time`, defaults to `ROS_TIME` |
rosros.api.to_datetime | ( | val | ) |
rosros.api.to_decimal | ( | val | ) |
rosros.api.to_duration | ( | val | ) |
rosros.api.to_nsec | ( | val | ) |
rosros.api.to_sec | ( | val | ) |
rosros.api.to_sec_nsec | ( | val | ) |
rosros.api.to_time | ( | val | ) |
rosros.api.FAMILY = ros.FAMILY |
rosros.api.PARAM_SEPARATOR = ros.PARAM_SEPARATOR |
rosros.api.PRIVATE_PREFIX = ros.PRIVATE_PREFIX |
rosros.api.ROS_ALIAS_TYPES = ros.ROS_ALIAS_TYPES |
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 |
list rosros.api.ROS_COMMON_TYPES = ROS_BUILTIN_TYPES + ROS_TIME_TYPES |
list rosros.api.ROS_NUMERIC_TYPES |
list rosros.api.ROS_STRING_TYPES = ["string", "wstring"] |
rosros.api.ROS_TIME_CLASSES = ros.ROS_TIME_CLASSES |
rosros.api.ROS_TIME_TYPES = ros.ROS_TIME_TYPES |