2Partial stand-in for `rclpy.executors` in ROS1, providing `Executor` classes.
4------------------------------------------------------------------------------
5This file is part of rosros - simple unified interface to ROS1 / ROS2.
6Released under the BSD License.
11------------------------------------------------------------------------------
13## @namespace rosros.rclify.executors
17from . task import Task
21class TimeoutException(Exception):
22 """Signal that a timeout occurred."""
25 """Signal that executor was shut down."""
28 """Context has been shutdown."""
30class ConditionReachedException(
Exception):
31 """Future has been completed."""
36 """API stand-in for ROS2 compatibility, all spinning is performed by sleep."""
40 @param context ignored (ROS2 compatibility stand-
in)
50 """Returns context given in constructor, or None ((ROS2 compatibility stand-in)."""
55 Adds a callback or coroutine to be executed during spin, returns a Future.
57 Arguments to this function are passed to the callback.
59 @param callback a callback to be run
in the executor
61 return Task(callback, args, kwargs, executor=self)
63 def shutdown(self, timeout_sec=None):
67 @param timeout_sec ignored (ROS2 compatibility stand-
in)
78 Adds a node to this executor.
80 @param node the node to add to the executor
81 @return True if the node was added,
False if it already existed
85 result = node
in self.
_nodes
91 Stop managing this node's callbacks.
93 @param node the node to remove
from the executor
99 """Does nothing (ROS2 compatibility stand-in)."""
102 """Return nodes that have been added to this executor."""
107 """Waits until ROS shut down."""
112 Waits until future complete or timeout reached
or ROS shut down.
114 @param future the future to wait on until done.
115 @param timeout_sec maximum seconds to wait. Block forever
if None or negative.
118 ros1.spin_until_future_complete(future, timeout_sec)
122 Waits until timeout, or forever
if timeout
None or negative,
or until ROS shutdown.
124 @param timeout_sec seconds to wait. Block forever
if None or negative. Don
't wait if 0.
126 ros1.spin_once(timeout_sec)
130 Waits until future complete or timeout reached
or ROS shut down.
132 @param future the future to wait on until done.
133 @param timeout_sec maximum seconds to wait. Block forever
if None or negative.
136 ros1.spin_until_future_complete(future, timeout_sec)
141 """API stand-in for ROS2 compatibility."""
144class MultiThreadedExecutor(Executor):
145 """API stand-in for ROS2 compatibility."""
149 "ConditionReachedException",
"Executor",
"ExternalShutdownException",
150 "MultiThreadedExecutor",
"ShutdownException",
"SingleThreadedExecutor",
"TimeoutException"
add_node(self, node)
Adds a node to this executor.
remove_node(self, node)
Stop managing this node's callbacks.
shutdown(self, timeout_sec=None)
Shuts down ROS.
spin_once(self, timeout_sec=None)
Waits until timeout, or forever if timeout None or negative, or until ROS shutdown.
spin_until_future_complete(self, future, timeout_sec=None)
Waits until future complete or timeout reached or ROS shut down.
__init__(self, *context=None)
wake(self)
Does nothing (ROS2 compatibility stand-in).
context
Returns context given in constructor, or None ((ROS2 compatibility stand-in).
spin_once_until_future_complete(self, future, timeout_sec=None)
Waits until future complete or timeout reached or ROS shut down.
create_task(self, callback, *args, **kwargs)
Adds a callback or coroutine to be executed during spin, returns a Future.
Future has been completed.
Context has been shutdown.
API stand-in for ROS2 compatibility.
Executes a function or coroutine.
spin()
Spins ROS node forever.
get_nodes()
Returns all ROS nodes, as `[node full name, ]`.