Skip to content

Commit 729fd3c

Browse files
committed
Split implementation about get domain id according to ros distro
Signed-off-by: Taehun Lim <taehun.lim@42dot.ai>
1 parent fd7323a commit 729fd3c

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

rclrs/src/context.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,19 @@ impl Context {
8282
/// assert_eq!(domain_id, 11);
8383
/// # Ok::<(), RclrsError>(())
8484
/// ```
85-
#[cfg(not(ros_distro = "foxy"))]
8685
pub fn domain_id(&self) -> usize {
8786
let mut rcl_context = self.rcl_context_mtx.lock().unwrap();
8887
let mut domain_id: usize = 0;
88+
#[cfg(not(ros_distro = "foxy"))]
8989
let ret = unsafe {
9090
// SAFETY: No preconditions for this function.
9191
rcl_context_get_domain_id(&mut *rcl_context, &mut domain_id)
9292
};
93+
#[cfg(ros_distro = "foxy")]
94+
let ret = unsafe {
95+
// SAFETY: Getting the default domain ID, based on the environment
96+
rcl_get_default_domain_id(&mut domain_id)
97+
};
9398

9499
debug_assert_eq!(ret, 0);
95100
domain_id

0 commit comments

Comments
 (0)