Struct safe_drive::node::Node

source ·
pub struct Node { /* private fields */ }
Expand description

Node of ROS2.

Implementations§

source§

impl Node

source

pub fn get_name(&self) -> RCLResult<String>

source

pub fn get_fully_qualified_name(&self) -> RCLResult<String>

source

pub fn get_namespace(&self) -> RCLResult<String>

source

pub fn create_parameter_server( self: &Arc<Self> ) -> Result<ParameterServer, DynError>

source

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()
}
source

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()
}
source

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()
}
source

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()
}
source

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()
}
source

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()
}

Trait Implementations§

source§

impl Drop for Node

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl Send for Node

source§

impl Sync for Node

Auto Trait Implementations§

§

impl !Freeze for Node

§

impl RefUnwindSafe for Node

§

impl Unpin for Node

§

impl UnwindSafe for Node

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.