Added a namespace method to the Node to get the namespace from the node.
This commit is contained in:
parent
8a80f26e6e
commit
576da3537b
|
|
@ -10,6 +10,7 @@ fn main() -> Result<(), Error> {
|
|||
|
||||
println!("node name: {}", node.name()?);
|
||||
println!("node fully qualified name: {}", node.fully_qualified_name()?);
|
||||
println!("node namespace: {}", node.namespace()?);
|
||||
|
||||
println!("node parameters");
|
||||
node.params.iter().for_each(|(k,v)| {
|
||||
|
|
|
|||
|
|
@ -536,6 +536,15 @@ impl Node {
|
|||
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<()> {
|
||||
let ctx = self.context.context_handle.lock().unwrap();
|
||||
let mut params: Box<*mut rcl_params_t> = Box::new(std::ptr::null_mut());
|
||||
|
|
|
|||
Loading…
Reference in New Issue