Context

class rclpy.context.Context

Encapsulates the lifecycle of init and shutdown.

Context objects should not be reused, and are finalized in their destructor.

Wraps the rcl_context_t type.

property handle
init(args=None, *, initialize_logging=True)

Initialize ROS communications for a given context.

Parameters

args (Optional[List[str]]) – List of command line arguments.

ok()

Check if context hasn’t been shut down.

on_shutdown(callback)

Add a callback to be called on shutdown.

shutdown()

Shutdown this context.

try_shutdown()

Shutdown this context, if not already shutdown.