pub trait IntoNodeOptions<'a>: Sized {
// Required method
fn into_node_options(self) -> NodeOptions<'a>;
// Provided methods
fn namespace(self, namespace: &'a str) -> NodeOptions<'a> { ... }
fn use_global_arguments(self, enable: bool) -> NodeOptions<'a> { ... }
fn arguments<Args: IntoIterator>(self, arguments: Args) -> NodeOptions<'a>
where Args::Item: ToString { ... }
fn enable_rosout(self, enable: bool) -> NodeOptions<'a> { ... }
fn start_parameter_services(self, start: bool) -> NodeOptions<'a> { ... }
fn clock_type(self, clock_type: ClockType) -> NodeOptions<'a> { ... }
fn clock_qos(self, clock_qos: QoSProfile) -> NodeOptions<'a> { ... }
}
Expand description
This trait helps to build NodeOptions
which can be passed into
Executor::create_node
.
Required Methods§
Sourcefn into_node_options(self) -> NodeOptions<'a>
fn into_node_options(self) -> NodeOptions<'a>
Conver the object into NodeOptions
with default settings.
Provided Methods§
Sourcefn namespace(self, namespace: &'a str) -> NodeOptions<'a>
fn namespace(self, namespace: &'a str) -> NodeOptions<'a>
Sets the node namespace.
See the Node
docs for general information on namespaces.
§Rules for valid namespaces
The rules for a valid node namespace are based on the rules for a valid topic
and are checked by the rmw_validate_namespace()
function. However, a namespace
without a leading forward slash is automatically changed to have a leading forward slash
before it is checked with this function.
Thus, the effective rules are:
- Must contain only the
a-z
,A-Z
,0-9
,_
, and/
characters - Must not have a number at the beginning, or after a
/
- Must not contain two or more
/
characters in a row - Must not have a
/
character at the end, except if/
is the full namespace
Note that namespace validation is delayed until Executor::create_node
.
§Example
let executor = Context::default().create_basic_executor();
// This is a valid namespace
let options_ok_ns = "my_node".namespace("/some/nested/namespace");
assert!(executor.create_node(options_ok_ns).is_ok());
// This is an invalid namespace
assert!(matches!(
executor.create_node(
"my_node"
.namespace("/10_percent_luck/20_percent_skill")
).unwrap_err(),
RclrsError::RclError { code: RclReturnCode::NodeInvalidNamespace, .. }
));
// A missing forward slash at the beginning is automatically added
assert_eq!(
executor.create_node(
"my_node"
.namespace("foo")
)?.namespace(),
"/foo"
);
Sourcefn use_global_arguments(self, enable: bool) -> NodeOptions<'a>
fn use_global_arguments(self, enable: bool) -> NodeOptions<'a>
Enables or disables using global arguments.
The “global” arguments are those used in creating the context.
§Example
let context_args = ["--ros-args", "--remap", "__node:=your_node"]
.map(String::from);
let executor = Context::new(context_args, InitOptions::default())?.create_basic_executor();
// Ignore the global arguments:
let node_without_global_args = executor.create_node(
"my_node"
.use_global_arguments(false)
)?;
assert_eq!(node_without_global_args.name(), "my_node");
// Do not ignore the global arguments:
let node_with_global_args = executor.create_node(
"my_other_node"
.use_global_arguments(true)
)?;
assert_eq!(node_with_global_args.name(), "your_node");
Sourcefn arguments<Args: IntoIterator>(self, arguments: Args) -> NodeOptions<'a>
fn arguments<Args: IntoIterator>(self, arguments: Args) -> NodeOptions<'a>
Sets node-specific command line arguments.
These arguments are parsed the same way as those for Context::new()
.
However, the node-specific command line arguments have higher precedence than the arguments
used in creating the context.
For more details about command line arguments, see here.
§Example
// Usually, this would change the name of "my_node" to "context_args_node":
let context_args = ["--ros-args", "--remap", "my_node:__node:=context_args_node"]
.map(String::from);
let executor = Context::new(context_args, InitOptions::default())?.create_basic_executor();
// But the node arguments will change it to "node_args_node":
let node_args = ["--ros-args", "--remap", "my_node:__node:=node_args_node"]
.map(String::from);
let node = executor.create_node(
"my_node"
.arguments(node_args)
)?;
assert_eq!(node.name(), "node_args_node");
Sourcefn enable_rosout(self, enable: bool) -> NodeOptions<'a>
fn enable_rosout(self, enable: bool) -> NodeOptions<'a>
Enables or disables logging to rosout.
When enabled, log messages are published to the /rosout
topic in addition to
standard output.
This option is currently unused in rclrs
.
Sourcefn start_parameter_services(self, start: bool) -> NodeOptions<'a>
fn start_parameter_services(self, start: bool) -> NodeOptions<'a>
Enables or disables parameter services.
Parameter services can be used to allow external nodes to list, get and set parameters for this node.
Sourcefn clock_type(self, clock_type: ClockType) -> NodeOptions<'a>
fn clock_type(self, clock_type: ClockType) -> NodeOptions<'a>
Sets the node’s clock type.
Sourcefn clock_qos(self, clock_qos: QoSProfile) -> NodeOptions<'a>
fn clock_qos(self, clock_qos: QoSProfile) -> NodeOptions<'a>
Sets the QoSProfile for the clock subscription.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.