Merge branch 'master' of github.com:sequenceplanner/r2r
This commit is contained in:
commit
11496de6fd
|
|
@ -10,6 +10,7 @@ fn main() -> Result<(), Error> {
|
||||||
|
|
||||||
println!("node name: {}", node.name()?);
|
println!("node name: {}", node.name()?);
|
||||||
println!("node fully qualified name: {}", node.fully_qualified_name()?);
|
println!("node fully qualified name: {}", node.fully_qualified_name()?);
|
||||||
|
println!("node namespace: {}", node.namespace()?);
|
||||||
|
|
||||||
println!("node parameters");
|
println!("node parameters");
|
||||||
node.params.iter().for_each(|(k,v)| {
|
node.params.iter().for_each(|(k,v)| {
|
||||||
|
|
|
||||||
17
src/lib.rs
17
src/lib.rs
|
|
@ -605,6 +605,15 @@ impl Node {
|
||||||
Ok(s.to_str().unwrap_or("").to_owned())
|
Ok(s.to_str().unwrap_or("").to_owned())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn namespace(&self) -> Result<String> {
|
||||||
|
let cstr = unsafe { rcl_node_get_namespace(self.node_handle.as_ref()) };
|
||||||
|
if cstr == std::ptr::null() {
|
||||||
|
return Err(Error::RCL_RET_NODE_INVALID);
|
||||||
|
}
|
||||||
|
let s = unsafe { CStr::from_ptr(cstr as *const i8) };
|
||||||
|
Ok(s.to_str().unwrap_or("").to_owned())
|
||||||
|
}
|
||||||
|
|
||||||
fn load_params(&mut self) -> Result<()> {
|
fn load_params(&mut self) -> Result<()> {
|
||||||
let ctx = self.context.context_handle.lock().unwrap();
|
let ctx = self.context.context_handle.lock().unwrap();
|
||||||
let mut params: Box<*mut rcl_params_t> = Box::new(std::ptr::null_mut());
|
let mut params: Box<*mut rcl_params_t> = Box::new(std::ptr::null_mut());
|
||||||
|
|
@ -632,6 +641,7 @@ impl Node {
|
||||||
};
|
};
|
||||||
|
|
||||||
let qualified_name = self.fully_qualified_name()?;
|
let qualified_name = self.fully_qualified_name()?;
|
||||||
|
let name = self.name()?;
|
||||||
|
|
||||||
for (nn, np) in node_names.iter().zip(node_params) {
|
for (nn, np) in node_names.iter().zip(node_params) {
|
||||||
let node_name_cstr = unsafe { CStr::from_ptr(*nn as *mut i8) };
|
let node_name_cstr = unsafe { CStr::from_ptr(*nn as *mut i8) };
|
||||||
|
|
@ -640,7 +650,12 @@ impl Node {
|
||||||
// This is copied from rclcpp, but there is a comment there suggesting
|
// This is copied from rclcpp, but there is a comment there suggesting
|
||||||
// that more wildcards will be added in the future. Take note and mimic
|
// that more wildcards will be added in the future. Take note and mimic
|
||||||
// their behavior.
|
// their behavior.
|
||||||
if !(node_name == "/**" || qualified_name == node_name) {
|
if !(
|
||||||
|
node_name == "/**" ||
|
||||||
|
node_name == "**" ||
|
||||||
|
qualified_name == node_name ||
|
||||||
|
name == node_name
|
||||||
|
) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue