Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
roboticswithjulia authored Nov 27, 2024
2 parents 6782c50 + a604ad7 commit 921ce0e
Show file tree
Hide file tree
Showing 15 changed files with 1,486 additions and 36 deletions.
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@ RUN apt-get update && apt-get install -y \
&& rm -rf /var/lib/apt/lists/*

# Install Rust and the cargo-ament-build plugin

USER $CONTAINER_USER
WORKDIR /home/${CONTAINER_USER}
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --default-toolchain 1.74.0 -y
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --default-toolchain 1.75.0 -y
ENV PATH="/home/${CONTAINER_USER}/.cargo/bin:$PATH"
RUN cargo install cargo-ament-build

Expand Down
1 change: 1 addition & 0 deletions rclrs/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ fn main() {
}
};

println!("cargo:rustc-check-cfg=cfg(ros_distro, values(\"humble\", \"iron\", \"jazzy\", \"rolling\"))");
println!("cargo:rustc-cfg=ros_distro=\"{ros_distro}\"");

let mut builder = bindgen::Builder::default()
Expand Down
17 changes: 16 additions & 1 deletion rclrs/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::{
vec::Vec,
};

use crate::{rcl_bindings::*, RclrsError, ToResult};
use crate::{rcl_bindings::*, LoggingLifecycle, RclrsError, ToResult};

/// This is locked whenever initializing or dropping any middleware entity
/// because we have found issues in RCL and some RMW implementations that
Expand Down Expand Up @@ -56,6 +56,10 @@ unsafe impl Send for rcl_context_t {}
/// - middleware-specific data, e.g. the domain participant in DDS
/// - the allocator used (left as the default by `rclrs`)
///
/// The context also configures the rcl_logging_* layer to allow publication to /rosout
/// (as well as the terminal). TODO: This behaviour should be configurable using an
/// "auto logging initialise" flag as per rclcpp and rclpy.
///
pub struct Context {
pub(crate) handle: Arc<ContextHandle>,
}
Expand All @@ -68,6 +72,10 @@ pub struct Context {
/// bindings in this library.
pub(crate) struct ContextHandle {
pub(crate) rcl_context: Mutex<rcl_context_t>,
/// This ensures that logging does not get cleaned up until after this ContextHandle
/// has dropped.
#[allow(unused)]
logging: Arc<LoggingLifecycle>,
}

impl Context {
Expand Down Expand Up @@ -143,9 +151,16 @@ impl Context {
// Move the check after the last fini()
ret?;
}

// TODO: "Auto set-up logging" is forced but should be configurable as per rclcpp and rclpy
// SAFETY: We created this context a moment ago and verified that it is valid.
// No other conditions are needed.
let logging = unsafe { LoggingLifecycle::configure(&rcl_context)? };

Ok(Self {
handle: Arc::new(ContextHandle {
rcl_context: Mutex::new(rcl_context),
logging,
}),
})
}
Expand Down
2 changes: 2 additions & 0 deletions rclrs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ mod clock;
mod context;
mod error;
mod executor;
mod logging;
mod node;
mod parameter;
mod publisher;
Expand Down Expand Up @@ -38,6 +39,7 @@ pub use clock::*;
pub use context::*;
pub use error::*;
pub use executor::*;
pub use logging::*;
pub use node::*;
pub use parameter::*;
pub use publisher::*;
Expand Down
Loading

0 comments on commit 921ce0e

Please sign in to comment.