Initialization, Shutdown, and Spinning¶
-
rclpy.
create_node
(node_name, *, context=None, cli_args=None, namespace=None, use_global_arguments=True, start_parameter_services=True, initial_parameters=None)¶ Create an instance of
rclpy.node.Node
.Parameters: - node_name – A unique name to give to this node.
- context – The context to be associated with, or None for the default global context.
- cli_args – A list of strings of command line args to be used only by this node.
- namespace – The namespace to which relative topic and service names will be prefixed.
- use_global_arguments – False if the node should ignore process-wide command line args.
- start_parameter_services – False if the node should not create parameter services.
- initial_parameters – A list of rclpy.parameter.Parameters to be set during node creation.
Returns: An instance of a node
Return type:
-
rclpy.
get_global_executor
()¶
-
rclpy.
init
(*, args=None, context=None)¶
-
rclpy.
shutdown
(*, context=None)¶
-
rclpy.
spin
(node, executor=None)¶ Execute work blocking until the library is shutdown.
Callbacks will be executed in a SingleThreadedExecutor until shutdown() is called. This method blocks.
Parameters: - node – A node to add to the executor to check for work.
- executor – The executor to use, or the global executor if None is passed.
Returns: Always returns None regardless whether work executes or timeout expires.
Return type: None
-
rclpy.
spin_once
(node, *, executor=None, timeout_sec=None)¶ Execute one item of work or wait until timeout expires.
One callback will be executed in a SingleThreadedExecutor as long as that callback is ready before the timeout expires.
It is possible the work done may be for a node other than the one passed to this method if the global executor has a partially completed coroutine.
Parameters: - node – A node to add to the executor to check for work.
- executor – The executor to use, or the global executor if None is passed.
- timeout_sec – Seconds to wait. Block forever if None or negative. Don’t wait if 0
Returns: Always returns None regardless whether work executes or timeout expires.
Return type: None
-
rclpy.
spin_until_future_complete
(node, future, executor=None)¶ Execute work until the future is complete.
Callbacks and other work will be executed in a SingleThreadedExecutor until future.done() returns True or rclpy is shutdown.
Parameters: - node – A node to add to the executor to check for work.
- future (rclpy.task.Future) – The future object to wait on.
- executor – The executor to use, or the global executor if None is passed.