Struct ros2_client::Node
source · pub struct Node { /* private fields */ }
Expand description
Node in ROS2 network. Holds necessary readers and writers for rosout and parameter events topics internally.
These are produced by a Context
.
Implementations§
source§impl Node
impl Node
pub fn time_now_not_simulated(&self) -> ROSTime
sourcepub fn spinner(&mut self) -> CreateResult<Spinner>
pub fn spinner(&mut self) -> CreateResult<Spinner>
Create a Spinner object to execute Node backround tasks.
An async task should then be created to run the .spin()
function of
Spinner
.
E.g. executor.spawn(node.spinner().spin())
The .spin()
task runs until Node
is dropped.
sourcepub fn have_spinner(&self) -> bool
pub fn have_spinner(&self) -> bool
A heuristic to detect if a spinner has been created. But this does still not guarantee that it is running, i.e. an async excutor is runnning spinner.spin(), but this is the best we can do.
pub fn base_name(&self) -> &str
pub fn namespace(&self) -> &str
pub fn fully_qualified_name(&self) -> String
pub fn options(&self) -> &NodeOptions
pub fn domain_id(&self) -> u16
pub fn undeclare_parameter(&self, name: &str)
sourcepub fn has_parameter(&self, name: &str) -> bool
pub fn has_parameter(&self, name: &str) -> bool
Does the parameter exist?
sourcepub fn set_parameter(
&self,
name: &str,
value: ParameterValue
) -> Result<(), String>
pub fn set_parameter( &self, name: &str, value: ParameterValue ) -> Result<(), String>
Sets a parameter value. Parameter must be declared before setting.
pub fn allow_undeclared_parameters(&self) -> bool
sourcepub fn get_parameter(&self, name: &str) -> Option<ParameterValue>
pub fn get_parameter(&self, name: &str) -> Option<ParameterValue>
Gets the value of a parameter, or None is there is no such Parameter.
pub fn list_parameters(&self) -> Vec<String>
sourcepub fn status_receiver(&self) -> Receiver<NodeEvent>
pub fn status_receiver(&self) -> Receiver<NodeEvent>
Get an async Receiver for discovery events.
There must be an async task executing spin
to get any data.
sourcepub fn rosout_subscription(&self) -> Option<&Subscription<Log>>
pub fn rosout_subscription(&self) -> Option<&Subscription<Log>>
Borrow the Subscription to our ROSOut Reader.
Availability depends on Node configuration.
pub fn rosout_raw( &self, timestamp: Timestamp, level: LogLevel, log_name: &str, log_msg: &str, source_file: &str, source_function: &str, source_line: u32 )
sourcepub fn create_topic(
&self,
topic_name: &Name,
type_name: MessageTypeName,
qos: &QosPolicies
) -> CreateResult<Topic>
pub fn create_topic( &self, topic_name: &Name, type_name: MessageTypeName, qos: &QosPolicies ) -> CreateResult<Topic>
Creates ROS2 topic and handles necessary conversions from DDS to ROS2
§Arguments
-
domain_participant
- DomainParticipant -
name
- Name of the topic -
type_name
- What type the topic holds in string form -
qos
- Quality of Service parameters for the topic (not restricted only to ROS2)summary of all rules for topic and service names in ROS 2 (as of Dec 2020)
-
must not be empty
-
may contain alphanumeric characters ([0-9|a-z|A-Z]), underscores (_), or forward slashes (/)
-
may use balanced curly braces ({}) for substitutions
-
may start with a tilde (~), the private namespace substitution character
-
must not start with a numeric character ([0-9])
-
must not end with a forward slash (/)
-
must not contain any number of repeated forward slashes (/)
-
must not contain any number of repeated underscores (_)
-
must separate a tilde (~) from the rest of the name with a forward slash (/), i.e. ~/foo not ~foo
-
must have balanced curly braces ({}) when used, i.e. {sub}/foo but not {sub/foo nor /foo}
sourcepub fn create_subscription<D: 'static>(
&mut self,
topic: &Topic,
qos: Option<QosPolicies>
) -> CreateResult<Subscription<D>>
pub fn create_subscription<D: 'static>( &mut self, topic: &Topic, qos: Option<QosPolicies> ) -> CreateResult<Subscription<D>>
sourcepub fn create_publisher<D: Serialize>(
&mut self,
topic: &Topic,
qos: Option<QosPolicies>
) -> CreateResult<Publisher<D>>
pub fn create_publisher<D: Serialize>( &mut self, topic: &Topic, qos: Option<QosPolicies> ) -> CreateResult<Publisher<D>>
sourcepub fn create_client<S>(
&mut self,
service_mapping: ServiceMapping,
service_name: &Name,
service_type_name: &ServiceTypeName,
request_qos: QosPolicies,
response_qos: QosPolicies
) -> CreateResult<Client<S>>
pub fn create_client<S>( &mut self, service_mapping: ServiceMapping, service_name: &Name, service_type_name: &ServiceTypeName, request_qos: QosPolicies, response_qos: QosPolicies ) -> CreateResult<Client<S>>
Creates ROS2 Service Client
§Arguments
service_mapping
- ServiceMapping to be usedservice_name
-qos
-
sourcepub fn create_server<S>(
&mut self,
service_mapping: ServiceMapping,
service_name: &Name,
service_type_name: &ServiceTypeName,
request_qos: QosPolicies,
response_qos: QosPolicies
) -> CreateResult<Server<S>>
pub fn create_server<S>( &mut self, service_mapping: ServiceMapping, service_name: &Name, service_type_name: &ServiceTypeName, request_qos: QosPolicies, response_qos: QosPolicies ) -> CreateResult<Server<S>>
Creates ROS2 Service Server
§Arguments
service_mapping
- ServiceMapping to be used. See [Self.create_client
].service_name
-qos
-