Skip to content

Commit 1ec9f10

Browse files
committed
Fix documentation
Signed-off-by: Michael X. Grey <[email protected]>
1 parent 1b5c187 commit 1ec9f10

File tree

5 files changed

+35
-36
lines changed

5 files changed

+35
-36
lines changed

rclrs/src/context.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,13 @@ impl Context {
8383
/// Creates a new context.
8484
///
8585
/// * `args` - A sequence of strings that resembles command line arguments
86-
/// that users can pass into a ROS executable. See [the official tutorial][1]
87-
/// to know what these arguments may look like. To simply pass in the arguments
88-
/// that the user has provided from the command line, call [`Self::from_env`]
89-
/// or [`Self::default_from_env`] instead.
86+
/// that users can pass into a ROS executable. See [the official tutorial][1]
87+
/// to know what these arguments may look like. To simply pass in the arguments
88+
/// that the user has provided from the command line, call [`Self::from_env`]
89+
/// or [`Self::default_from_env`] instead.
9090
///
9191
/// * `options` - Additional options that your application can use to override
92-
/// settings that would otherwise be determined by the environment.
92+
/// settings that would otherwise be determined by the environment.
9393
///
9494
/// Creating a context will fail if `args` contains invalid ROS arguments.
9595
///

rclrs/src/node.rs

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,13 @@ unsafe impl Send for rcl_node_t {}
2828
/// Nodes are a core concept in ROS 2. Refer to the official ["Understanding ROS 2 nodes"][1]
2929
/// tutorial for an introduction.
3030
///
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.
3438
///
3539
/// # Naming
3640
/// A node has a *name* and a *namespace*.
@@ -48,16 +52,19 @@ unsafe impl Send for rcl_node_t {}
4852
/// In that sense, the parameters to the node creation functions are only the _default_ namespace and
4953
/// name.
5054
/// 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.
5256
///
5357
/// ## Rules for valid names
5458
/// 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].
5660
///
5761
/// [1]: https://docs.ros.org/en/rolling/Tutorials/Understanding-ROS2-Nodes.html
5862
/// [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
6168
#[derive(Clone)]
6269
pub struct Node {
6370
pub(crate) primitives: Arc<NodePrimitives>,
@@ -213,12 +220,11 @@ impl Node {
213220
/// Creates a [`GuardCondition`][1] with no callback.
214221
///
215222
/// 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.
219225
///
220226
/// [1]: crate::GuardCondition
221-
/// [2]: crate::spin_once
227+
/// [2]: crate::Executor::spin
222228
pub fn create_guard_condition(&self) -> Arc<GuardCondition> {
223229
let guard_condition = Arc::new(GuardCondition::new_with_context_handle(
224230
Arc::clone(&self.handle.context_handle),
@@ -232,12 +238,11 @@ impl Node {
232238
/// Creates a [`GuardCondition`][1] with a callback.
233239
///
234240
/// 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.
238243
///
239244
/// [1]: crate::GuardCondition
240-
/// [2]: crate::spin_once
245+
/// [2]: crate::Executor::spin
241246
pub fn create_guard_condition_with_callback<F>(&mut self, callback: F) -> Arc<GuardCondition>
242247
where
243248
F: Fn() + Send + Sync + 'static,
@@ -254,7 +259,6 @@ impl Node {
254259
/// Creates a [`Publisher`][1].
255260
///
256261
/// [1]: crate::Publisher
257-
// TODO: make publisher's lifetime depend on node's lifetime
258262
pub fn create_publisher<T>(
259263
&self,
260264
topic: &str,
@@ -270,7 +274,6 @@ impl Node {
270274
/// Creates a [`Service`][1].
271275
///
272276
/// [1]: crate::Service
273-
// TODO: make service's lifetime depend on node's lifetime
274277
pub fn create_service<T, F>(
275278
&self,
276279
topic: &str,
@@ -293,7 +296,6 @@ impl Node {
293296
/// Creates a [`Subscription`][1].
294297
///
295298
/// [1]: crate::Subscription
296-
// TODO: make subscription's lifetime depend on node's lifetime
297299
pub fn create_subscription<T, Args>(
298300
&self,
299301
topic: &str,

rclrs/src/node/node_options.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,9 @@ use crate::{
99
QoSProfile, RclrsError, TimeSource, ToResult, ENTITY_LIFECYCLE_MUTEX, QOS_PROFILE_CLOCK,
1010
};
1111

12-
/// A builder for creating a [`Node`][1].
12+
/// A set of options for creating a [`Node`][1].
1313
///
1414
/// The builder pattern allows selectively setting some fields, and leaving all others at their default values.
15-
/// This struct instance can be created via [`Node::builder()`][2].
1615
///
1716
/// The default values for optional fields are:
1817
/// - `namespace: "/"`
@@ -43,7 +42,6 @@ use crate::{
4342
/// ```
4443
///
4544
/// [1]: crate::Node
46-
/// [2]: crate::Node::builder
4745
pub struct NodeOptions {
4846
name: String,
4947
namespace: String,
@@ -68,7 +66,7 @@ impl NodeOptions {
6866
/// - Must not be empty and not be longer than `RMW_NODE_NAME_MAX_NAME_LENGTH`
6967
/// - Must not start with a number
7068
///
71-
/// Note that node name validation is delayed until [`NodeBuilder::build()`][3].
69+
/// Note that node name validation is delayed until [`Executor::create_node`][3].
7270
///
7371
/// # Example
7472
/// ```
@@ -88,7 +86,7 @@ impl NodeOptions {
8886
///
8987
/// [1]: crate::Node#naming
9088
/// [2]: https://docs.ros2.org/latest/api/rmw/validate__node__name_8h.html#a5690a285aed9735f89ef11950b6e39e3
91-
/// [3]: NodeBuilder::build
89+
/// [3]: crate::Executor::create_node
9290
pub fn new(name: impl ToString) -> NodeOptions {
9391
NodeOptions {
9492
name: name.to_string(),
@@ -119,7 +117,7 @@ impl NodeOptions {
119117
/// - Must not contain two or more `/` characters in a row
120118
/// - Must not have a `/` character at the end, except if `/` is the full namespace
121119
///
122-
/// Note that namespace validation is delayed until [`NodeBuilder::build()`][4].
120+
/// Note that namespace validation is delayed until [`Executor::create_node`][4].
123121
///
124122
/// # Example
125123
/// ```
@@ -150,7 +148,7 @@ impl NodeOptions {
150148
/// [1]: crate::Node#naming
151149
/// [2]: http://design.ros2.org/articles/topic_and_service_names.html
152150
/// [3]: https://docs.ros2.org/latest/api/rmw/validate__namespace_8h.html#a043f17d240cf13df01321b19a469ee49
153-
/// [4]: NodeBuilder::build
151+
/// [4]: crate::Executor::create_node
154152
pub fn namespace(mut self, namespace: impl ToString) -> Self {
155153
self.namespace = namespace.to_string();
156154
self
@@ -298,7 +296,7 @@ impl NodeOptions {
298296

299297
let handle = Arc::new(NodeHandle {
300298
rcl_node: Mutex::new(rcl_node),
301-
context_handle: Arc::clone(&context),
299+
context_handle: Arc::clone(context),
302300
});
303301
let parameter = {
304302
let rcl_node = handle.rcl_node.lock().unwrap();

rclrs/src/publisher.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ impl Drop for PublisherHandle {
5050
/// The underlying RMW will decide on the concrete delivery mechanism (network stack, shared
5151
/// memory, or intraprocess).
5252
///
53-
/// Sending messages does not require calling [`spin`][1] on the publisher's node.
53+
/// Sending messages does not require the node's executor to [spin][2].
5454
///
55-
/// [1]: crate::spin
55+
/// [2]: crate::Executor::spin
5656
pub struct Publisher<T>
5757
where
5858
T: Message,

rclrs/src/subscription.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,16 +66,15 @@ pub trait SubscriptionBase: Send + Sync {
6666
///
6767
/// There can be multiple subscriptions for the same topic, in different nodes or the same node.
6868
///
69-
/// Receiving messages requires calling [`spin_once`][1] or [`spin`][2] on the subscription's node.
69+
/// Receiving messages requires the node's executor to [spin][2].
7070
///
7171
/// When a subscription is created, it may take some time to get "matched" with a corresponding
7272
/// publisher.
7373
///
7474
/// The only available way to instantiate subscriptions is via [`Node::create_subscription()`][3], this
7575
/// is to ensure that [`Node`][4]s can track all the subscriptions that have been created.
7676
///
77-
/// [1]: crate::spin_once
78-
/// [2]: crate::spin
77+
/// [2]: crate::Executor::spin
7978
/// [3]: crate::Node::create_subscription
8079
/// [4]: crate::Node
8180
pub struct Subscription<T>

0 commit comments

Comments
 (0)