@@ -28,9 +28,13 @@ unsafe impl Send for rcl_node_t {}
28
28
/// Nodes are a core concept in ROS 2. Refer to the official ["Understanding ROS 2 nodes"][1]
29
29
/// tutorial for an introduction.
30
30
///
31
- /// Ownership of the node is shared with all [`Publisher`]s and [`Subscription`]s created from it.
32
- /// That means that even after the node itself is dropped, it will continue to exist and be
33
- /// displayed by e.g. `ros2 topic` as long as its publishers and subscriptions are not dropped.
31
+ /// Ownership of the node is shared with all the primitives such as [`Publisher`]s and [`Subscription`]s
32
+ /// that are created from it. That means that even after the `Node` itself is dropped, it will continue
33
+ /// to exist and be displayed by e.g. `ros2 topic` as long as any one of its primitives is not dropped.
34
+ ///
35
+ /// # Creating
36
+ /// Use [`Executor::create_node`][7] to create a new node. Pass in [`NodeOptions`] to set all the different
37
+ /// options for node creation, or just pass in a string for the node's name if the default options are okay.
34
38
///
35
39
/// # Naming
36
40
/// A node has a *name* and a *namespace*.
@@ -48,16 +52,19 @@ unsafe impl Send for rcl_node_t {}
48
52
/// In that sense, the parameters to the node creation functions are only the _default_ namespace and
49
53
/// name.
50
54
/// See also the [official tutorial][1] on the command line arguments for ROS nodes, and the
51
- /// [`Node::namespace()`] and [`Node::name()`] functions for examples.
55
+ /// [`Node::namespace()`][3] and [`Node::name()`][4 ] functions for examples.
52
56
///
53
57
/// ## Rules for valid names
54
58
/// The rules for valid node names and node namespaces are explained in
55
- /// [`NodeBuilder ::new()`][3 ] and [`NodeBuilder ::namespace()`][4 ].
59
+ /// [`NodeOptions ::new()`][5 ] and [`NodeOptions ::namespace()`][6 ].
56
60
///
57
61
/// [1]: https://docs.ros.org/en/rolling/Tutorials/Understanding-ROS2-Nodes.html
58
62
/// [2]: https://docs.ros.org/en/rolling/How-To-Guides/Node-arguments.html
59
- /// [3]: crate::NodeBuilder::new
60
- /// [4]: crate::NodeBuilder::namespace
63
+ /// [3]: Node::namespace
64
+ /// [4]: Node::name
65
+ /// [5]: crate::NodeOptions::new
66
+ /// [6]: crate::NodeOptions::namespace
67
+ /// [7]: crate::Executor::create_node
61
68
#[ derive( Clone ) ]
62
69
pub struct Node {
63
70
pub ( crate ) primitives : Arc < NodePrimitives > ,
@@ -213,12 +220,11 @@ impl Node {
213
220
/// Creates a [`GuardCondition`][1] with no callback.
214
221
///
215
222
/// A weak pointer to the `GuardCondition` is stored within this node.
216
- /// When this node is added to a wait set (e.g. when calling `spin_once`[2]
217
- /// with this node as an argument), the guard condition can be used to
218
- /// interrupt the wait.
223
+ /// When this node is added to a wait set (e.g. when its executor is [spinning][2]),
224
+ /// the guard condition can be used to interrupt the wait.
219
225
///
220
226
/// [1]: crate::GuardCondition
221
- /// [2]: crate::spin_once
227
+ /// [2]: crate::Executor::spin
222
228
pub fn create_guard_condition ( & self ) -> Arc < GuardCondition > {
223
229
let guard_condition = Arc :: new ( GuardCondition :: new_with_context_handle (
224
230
Arc :: clone ( & self . handle . context_handle ) ,
@@ -232,12 +238,11 @@ impl Node {
232
238
/// Creates a [`GuardCondition`][1] with a callback.
233
239
///
234
240
/// A weak pointer to the `GuardCondition` is stored within this node.
235
- /// When this node is added to a wait set (e.g. when calling `spin_once`[2]
236
- /// with this node as an argument), the guard condition can be used to
237
- /// interrupt the wait.
241
+ /// When this node is added to a wait set (e.g. when its executor is [spinning][2]),
242
+ /// the guard condition can be used to interrupt the wait.
238
243
///
239
244
/// [1]: crate::GuardCondition
240
- /// [2]: crate::spin_once
245
+ /// [2]: crate::Executor::spin
241
246
pub fn create_guard_condition_with_callback < F > ( & mut self , callback : F ) -> Arc < GuardCondition >
242
247
where
243
248
F : Fn ( ) + Send + Sync + ' static ,
@@ -254,7 +259,6 @@ impl Node {
254
259
/// Creates a [`Publisher`][1].
255
260
///
256
261
/// [1]: crate::Publisher
257
- // TODO: make publisher's lifetime depend on node's lifetime
258
262
pub fn create_publisher < T > (
259
263
& self ,
260
264
topic : & str ,
@@ -270,7 +274,6 @@ impl Node {
270
274
/// Creates a [`Service`][1].
271
275
///
272
276
/// [1]: crate::Service
273
- // TODO: make service's lifetime depend on node's lifetime
274
277
pub fn create_service < T , F > (
275
278
& self ,
276
279
topic : & str ,
@@ -293,7 +296,6 @@ impl Node {
293
296
/// Creates a [`Subscription`][1].
294
297
///
295
298
/// [1]: crate::Subscription
296
- // TODO: make subscription's lifetime depend on node's lifetime
297
299
pub fn create_subscription < T , Args > (
298
300
& self ,
299
301
topic : & str ,
0 commit comments