Class: Context

Context()

Encapsulates the lifecycle of an rcl environment from init to shutdown. A Context serves as a container for a ROS2 RCL environment that holds nodes and the resources created by the nodes, e.g., publishers, subscriptions, actions, services...v A context has 3 states: ``` new Context() --> uninitialized --> * | --------------------------- | v rcl.init(context) --> initialized -> | ---------------------------- | v rcl.shutdown(context) or context.shutdown() ---> shutdown ``` Must call rclnodejs.init(context) to initialize the context to the usable 'initialized' (valid) state be using.

Constructor

new Context()

Create a new instance in uninitialized state. Call rcl.init(context) to initialize this context state for use in creating nodes, etc.
Source:

Members

handle

Get the handle referencing the internal context object. Do not modify it yourself: only pass it to *rclnodejs* functions!
Source:

isOk

Check that the context is valid.
Deprecated:
  • since 0.18.0, Use Context.isValid()
Source:

nodes

Access the nodes managed by this context.
Source:

(static) instances

Access the list of usable (initialized/valid) contexts.
Source:

Methods

isDefaultContext() → {boolean}

Test if this context is the default one.
Source:
Returns:
whether this is the default context
Type
boolean

isInitialized() → {boolean}

Test if this context has been initialized, i.e., rcl.init(context), and not shutdown.
Source:
Returns:
True if context has been initialized; otherwise false
Type
boolean

isShutdown() → {boolean}

Test if this context has been shutdown, i.e., context.shutdown().
Source:
Returns:
True if context has been shutdown; otherwise false
Type
boolean

isUninitialized() → {boolean}

Test if this context has not been initialized by rcl.init(context).
Source:
Returns:
True if context has been initialized; otherwise false
Type
boolean

isValid() → {boolean}

Check that the context is in a usable state, i.e., it has been initialized and not yet shutdown.
Source:
Returns:
whether this context is (still) valid
Type
boolean

shutdown() → {undefined}

Shut down the context including destroying all nodes.
Source:
Throws:
If there is a problem shutting down the context.
Type
Error
Returns:
Type
undefined

tryShutdown() → {undefined}

Try to shut down the context.
Source:
Throws:
If there is a problem shutting down the context.
Type
Error
Returns:
Type
undefined

(static) defaultContext() → {Context}

Get the global default Context object.
Source:
Returns:
The default Context
Type
Context