Struct safe_drive::node::Node
source · pub struct Node { /* private fields */ }
Expand description
Node of ROS2.
Implementations§
source§impl Node
impl Node
pub fn get_name(&self) -> RCLResult<String>
pub fn get_fully_qualified_name(&self) -> RCLResult<String>
pub fn get_namespace(&self) -> RCLResult<String>
pub fn create_parameter_server( self: &Arc<Self> ) -> Result<ParameterServer, DynError>
sourcepub fn create_publisher<T: TypeSupport>(
self: &Arc<Self>,
topic_name: &str,
qos: Option<Profile>
) -> RCLResult<Publisher<T>>
pub fn create_publisher<T: TypeSupport>( self: &Arc<Self>, topic_name: &str, qos: Option<Profile> ) -> RCLResult<Publisher<T>>
Create a publisher.
If qos
is specified None
,
the default profile is used.
T
is the type of messages the created publisher send.
§Example
use safe_drive::{msg::common_interfaces::std_msgs, node::Node, topic::publisher::Publisher};
use std::sync::Arc;
fn create_new_publisher(node: Arc<Node>) -> Publisher<std_msgs::msg::Bool> {
node.create_publisher("topic_name", None).unwrap()
}
sourcepub fn create_publisher_disable_loaned_message<T: TypeSupport>(
self: &Arc<Self>,
topic_name: &str,
qos: Option<Profile>
) -> RCLResult<Publisher<T>>
pub fn create_publisher_disable_loaned_message<T: TypeSupport>( self: &Arc<Self>, topic_name: &str, qos: Option<Profile> ) -> RCLResult<Publisher<T>>
Create a publisher.
If qos
is specified None
,
the default profile is used.
T
is the type of messages the created publisher send.
This function is the same as create_publisher
but it disables loaned message.
§Example
use safe_drive::{msg::common_interfaces::std_msgs, node::Node, topic::publisher::Publisher};
use std::sync::Arc;
fn create_publisher_disable_loaned_message(node: Arc<Node>) -> Publisher<std_msgs::msg::Bool> {
node.create_publisher_disable_loaned_message("topic_name", None).unwrap()
}
sourcepub fn create_subscriber<T: TypeSupport>(
self: &Arc<Self>,
topic_name: &str,
qos: Option<Profile>
) -> RCLResult<Subscriber<T>>
pub fn create_subscriber<T: TypeSupport>( self: &Arc<Self>, topic_name: &str, qos: Option<Profile> ) -> RCLResult<Subscriber<T>>
Create a subscriber.
If qos
is specified None
,
the default profile is used.
T
is the type of messages the created subscriber receive.
§Example
use safe_drive::{msg::common_interfaces::std_msgs, node::Node, topic::subscriber::Subscriber};
use std::sync::Arc;
fn create_new_subscriber(node: Arc<Node>) -> Subscriber<std_msgs::msg::Bool> {
node.create_subscriber("topic_name", None).unwrap()
}
sourcepub fn create_subscriber_disable_loaned_message<T: TypeSupport>(
self: &Arc<Self>,
topic_name: &str,
qos: Option<Profile>
) -> RCLResult<Subscriber<T>>
pub fn create_subscriber_disable_loaned_message<T: TypeSupport>( self: &Arc<Self>, topic_name: &str, qos: Option<Profile> ) -> RCLResult<Subscriber<T>>
Create a subscriber.
If qos
is specified None
,
the default profile is used.
T
is the type of messages the created subscriber receive.
§Example
use safe_drive::{msg::common_interfaces::std_msgs, node::Node, topic::subscriber::Subscriber};
use std::sync::Arc;
fn create_subscriber_disable_loaned_message(node: Arc<Node>) -> Subscriber<std_msgs::msg::Bool> {
node.create_subscriber_disable_loaned_message("topic_name", None).unwrap()
}
sourcepub fn create_server<T: ServiceMsg>(
self: &Arc<Self>,
service_name: &str,
qos: Option<Profile>
) -> RCLResult<Server<T>>
pub fn create_server<T: ServiceMsg>( self: &Arc<Self>, service_name: &str, qos: Option<Profile> ) -> RCLResult<Server<T>>
Create a server.
If qos
is specified None
,
the default profile is used.
A server must receive ServiceMsg::Request
and send ServiceMsg::Response
.
§Example
use safe_drive::{msg::common_interfaces::std_srvs, node::Node, service::server::Server};
use std::sync::Arc;
fn create_new_server(node: Arc<Node>) -> Server<std_srvs::srv::Empty> {
node.create_server("service_name", None).unwrap()
}
sourcepub fn create_client<T: ServiceMsg>(
self: &Arc<Self>,
service_name: &str,
qos: Option<Profile>
) -> RCLResult<Client<T>>
pub fn create_client<T: ServiceMsg>( self: &Arc<Self>, service_name: &str, qos: Option<Profile> ) -> RCLResult<Client<T>>
Create a client.
If qos
is specified None
,
the default profile is used.
A client must send ServiceMsg::Request
and receive ServiceMsg::Response
.
§Example
use safe_drive::{msg::common_interfaces::std_srvs, node::Node, service::client::Client};
use std::sync::Arc;
fn create_new_client(node: Arc<Node>) -> Client<std_srvs::srv::Empty> {
node.create_client("service_name", None).unwrap()
}