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

Go to the source code of this file.

Classes

class  rosros.ros2.Bag
 ROS2 bag interface, partially mimicking rosbag.Bag. More...
 
class  rosros.ros2.Mutex
 Container for local mutexes. More...
 
class  rosros.ros2.ROSLogHandler
 Logging handler that forwards logging messages to ROS2 logger. More...
 

Namespaces

namespace  rosros
 Simple unified interface to ROS1 / ROS2.
 
namespace  rosros.ros2
 ROS2 core interface.
 

Functions

 rosros.ros2._assert_node ()
 Raises if ROS2 node not inited.
 
 rosros.ros2._get_message_type_hash (typename)
 Returns ROS2 message type MD5 hash (internal caching method).
 
 rosros.ros2._resolve_name (name, namespace=None)
 Returns absolute name, namespaced under current node if relative or private.
 
 rosros.ros2.canonical (typename)
 Returns "pkg/Type" for "pkg/msg/Type", standardizes various ROS2 formats.
 
 rosros.ros2.create_client (service, cls_or_typename, **qosargs)
 Returns a ROS2 service client instance, for invoking a service.
 
 rosros.ros2.create_publisher (topic, cls_or_typename, latch=False, queue_size=0, **qosargs)
 Returns a ROS2 publisher instance.
 
 rosros.ros2.create_rate (frequency)
 Returns a ROS2 rate instance, for sleeping at a fixed rate.
 
 rosros.ros2.create_service (service, cls_or_typename, callback, **qosargs)
 Returns a ROS2 service server instance, for providing a service.
 
 rosros.ros2.create_subscriber (topic, cls_or_typename, callback, callback_args=None, queue_size=0, raw=False, **qosargs)
 Returns a ROS2 subscriber instance.
 
 rosros.ros2.create_timer (period, callback, oneshot=False, immediate=False)
 Returns a ROS2 timer instance.
 
 rosros.ros2.delete_param (name)
 Deletes parameter from the node.
 
 rosros.ros2.deserialize_message (raw, cls_or_typename)
 Returns ROS2 message or service request/response instantiated from serialized binary.
 
 rosros.ros2.destroy_entity (item)
 Closes the given publisher, subscriber, service client, service server, timer, or rate instance.
 
 rosros.ros2.format_param_name (name)
 Returns parameter name using "." separator, and leading root or private sigils stripped.
 
 rosros.ros2.get_logger ()
 Returns `logging.Logger` for logging to ROS2 log handler.
 
 rosros.ros2.get_message_class (msg_or_type)
 Returns ROS2 message / service class object.
 
 rosros.ros2.get_message_definition (msg_or_type, full=True)
 Returns ROS2 message or service request/response type definition text.
 
 rosros.ros2.get_message_fields (val)
 Returns {field name: field type name} if ROS2 message or service request/response, else {}.
 
 rosros.ros2.get_message_header (val)
 Returns message `std_msgs/Header`-attribute if any, else `None`.
 
 rosros.ros2.get_message_type (msg_or_cls)
 Returns ROS2 message / service canonical type name, like "std_msgs/Header".
 
 rosros.ros2.get_message_type_hash (msg_or_type)
 Returns ROS2 message / service type MD5 hash.
 
 rosros.ros2.get_message_value (msg, name, default=...)
 Returns object attribute value, with numeric arrays converted to lists.
 
 rosros.ros2.get_namespace ()
 Returns ROS2 node namespace.
 
 rosros.ros2.get_node_name ()
 Returns ROS2 node full name with namespace.
 
 rosros.ros2.get_nodes ()
 Returns all ROS2 nodes, as `[node full name, ]`.
 
 rosros.ros2.get_package_share_directory (name)
 Returns the share directory of the package.
 
 rosros.ros2.get_param (name, default=None, autoset=True)
 Returns parameter value from current ROS2 node.
 
 rosros.ros2.get_param_names ()
 Returns the names of all current ROS2 node parameters.
 
 rosros.ros2.get_params (nested=True)
 Returns the current ROS2 node parameters, by default as nested dictionary.
 
 rosros.ros2.get_rostime ()
 Returns current ROS2 time, as `rclpy.time.Time`.
 
 rosros.ros2.get_service_definition (srv_or_type)
 Returns ROS2 service type definition text.
 
 rosros.ros2.get_service_request_class (srv_or_type)
 Returns ROS2 service request class object.
 
 rosros.ros2.get_service_response_class (srv_or_type)
 Returns ROS2 service response class object.
 
 rosros.ros2.get_services (node=None, namespace=None, include_types=True)
 Returns all available ROS2 services, as `[(service name, [type name, ]), ]`.
 
 rosros.ros2.get_topic_qos (topic, cls_or_typename, queue_size=10, publish=False)
 Returns dictionary for populating rclpy.qos.QoSProfile compatible with counterparts on topic.
 
 rosros.ros2.get_topics ()
 Returns all available ROS2 topics, as `[(topic name, [type name, ]), ]`.
 
 rosros.ros2.has_param (name)
 Returns whether the parameter exists.
 
 rosros.ros2.init_node (name, args=None, namespace=None, anonymous=False, log_level=None, enable_rosout=True, multithreaded=True, reentrant=False)
 Initializes rclpy and creates ROS2 node.
 
 rosros.ros2.init_params (defaults=None, **defaultkws)
 Declares all parameters on node from defaults dictionary.
 
 rosros.ros2.is_ros_message (val)
 Returns whether value is a ROS2 message or service request/response class or instance.
 
 rosros.ros2.is_ros_service (val)
 Returns whether value is a ROS2 service class object.
 
 rosros.ros2.is_ros_time (val)
 Returns whether value is a ROS2 time/duration class or instance.
 
 rosros.ros2.make_duration (secs=0, nsecs=0)
 Returns an rclpy.duration.Duration.
 
 rosros.ros2.make_time (secs=0, nsecs=0)
 Returns a ROS2 time, as rclpy.time.Time.
 
 rosros.ros2.ok ()
 Returns whether ROS2 has been initialized and is not shut down.
 
 rosros.ros2.on_shutdown (callback, *args, **kwargs)
 Registers function to be called on shutdown, after node has been torn down.
 
 rosros.ros2.register_init (node)
 Informs `rosros` of ROS2 having been initialized outside of `init_node()`.
 
 rosros.ros2.remap_name (name, namespace=None)
 Returns the absolute remapped topic/service name if mapping exists.
 
 rosros.ros2.resolve_name (name, namespace=None)
 Returns absolute remapped name, namespaced under current node if relative or private.
 
 rosros.ros2.scalar (typename)
 Returns unbounded scalar type from ROS2 message data type.
 
 rosros.ros2.serialize_message (msg)
 Returns ROS2 message or service request/response as a serialized binary of `bytes()`.
 
 rosros.ros2.set_param (name, value, descriptor=None)
 Sets a parameter on the node, auto-declaring it if unknown so far.
 
 rosros.ros2.shutdown (reason=None)
 Shuts down ROS2 execution, if any.
 
 rosros.ros2.sleep (duration)
 Sleeps for the specified duration in ROS time.
 
 rosros.ros2.spin ()
 Spins ROS2 node forever.
 
 rosros.ros2.spin_once (timeout=None)
 Executes one pending ROS2 operation or waits until timeout.
 
 rosros.ros2.spin_until_future_complete (future, timeout=None)
 Spins ROS2 until future complete or timeout reached or ROS shut down.
 
 rosros.ros2.start_spin ()
 Sets ROS2 node spinning forever in a background thread.
 
 rosros.ros2.time_message (val, to_message=True, clock_type=None)
 Converts ROS2 time/duration between `rclpy` and `builtin_interfaces` objects.
 
 rosros.ros2.to_duration (val)
 Returns value as ROS2 duration if convertible (int/float/time/datetime/decimal), else value.
 
 rosros.ros2.to_nsec (val)
 Returns value in nanoseconds if value is ROS2 time/duration, else value.
 
 rosros.ros2.to_sec (val)
 Returns value in seconds if value is ROS2 time/duration, else value.
 
 rosros.ros2.to_sec_nsec (val)
 Returns value as (seconds, nanoseconds) if value is ROS2 time/duration, else value.
 
 rosros.ros2.to_time (val)
 Returns value as ROS2 time if convertible, else value.
 
 rosros.ros2.wait_for_publisher (topic, timeout=None, cls_or_typename=None)
 Blocks until topic has at least one publisher.
 
 rosros.ros2.wait_for_service (service, timeout=None, cls_or_typename=None)
 Blocks until service is available.
 
 rosros.ros2.wait_for_subscriber (topic, timeout=None, cls_or_typename=None)
 Blocks until topic has at least one subscriber.
 

Variables

 rosros.ros2.AnyMsg = patch.AnyMsg
 Stand-in for `rospy.AnyMsg` with equivalent interface.
 
 rosros.ros2.args
 
 rosros.ros2.CALLBACK_GROUP = None
 `rclpy.callback_groups.CallbackGroup` instance
 
 rosros.ros2.called
 
dict rosros.ros2.DDS_TYPES
 Data Distribution Service types to ROS builtins.
 
 rosros.ros2.EXECUTOR = None
 `rclpy.executors.Executor` instance
 
str rosros.ros2.FAMILY = "rclpy"
 ROS Python module family, "rclpy".
 
 rosros.ros2.func
 
 rosros.ros2.kwargs
 
 rosros.ros2.NODE = None
 `rclpy.node.Node` instance
 
str rosros.ros2.PARAM_SEPARATOR = "."
 Separator char between ROS2 parameter namespace parts.
 
str rosros.ros2.PRIVATE_PREFIX = "~"
 Prefix for "private" names, auto-namespaced under current namespace.
 
dict rosros.ros2.ROS_ALIAS_TYPES = {"byte": "uint8", "char": "int8"}
 Mapping between ROS type aliases and real types, like {"byte": "uint8"}.
 
dict rosros.ros2.ROS_TIME_CLASSES
 ROS2 time/duration types and message types mapped to type names.
 
dict rosros.ros2.ROS_TIME_MESSAGES
 ROS2 time/duration types mapped to message types.
 
list rosros.ros2.ROS_TIME_TYPES = ["builtin_interfaces/Time", "builtin_interfaces/Duration"]
 ROS2 time/duration message types.
 
bool rosros.ros2.SHUTDOWN = False
 Flag for `shutdown()` been called.
 
list rosros.ros2.SHUTDOWN_CALLBACKS = []
 Callbacks registered with on_shutdown()
 
 rosros.ros2.SPINNER = None
 `threading.Thread` running `EXECUTOR.spin()`