Skip to content

Commit 921ce0e

Browse files
Merge branch 'main' into main
2 parents 6782c50 + a604ad7 commit 921ce0e

File tree

15 files changed

+1486
-36
lines changed

15 files changed

+1486
-36
lines changed

Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,10 @@ RUN apt-get update && apt-get install -y \
2828
&& rm -rf /var/lib/apt/lists/*
2929

3030
# Install Rust and the cargo-ament-build plugin
31+
3132
USER $CONTAINER_USER
3233
WORKDIR /home/${CONTAINER_USER}
33-
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --default-toolchain 1.74.0 -y
34+
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --default-toolchain 1.75.0 -y
3435
ENV PATH="/home/${CONTAINER_USER}/.cargo/bin:$PATH"
3536
RUN cargo install cargo-ament-build
3637

rclrs/build.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ fn main() {
3535
}
3636
};
3737

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

4041
let mut builder = bindgen::Builder::default()

rclrs/src/context.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use std::{
66
vec::Vec,
77
};
88

9-
use crate::{rcl_bindings::*, RclrsError, ToResult};
9+
use crate::{rcl_bindings::*, LoggingLifecycle, RclrsError, ToResult};
1010

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

7381
impl Context {
@@ -143,9 +151,16 @@ impl Context {
143151
// Move the check after the last fini()
144152
ret?;
145153
}
154+
155+
// TODO: "Auto set-up logging" is forced but should be configurable as per rclcpp and rclpy
156+
// SAFETY: We created this context a moment ago and verified that it is valid.
157+
// No other conditions are needed.
158+
let logging = unsafe { LoggingLifecycle::configure(&rcl_context)? };
159+
146160
Ok(Self {
147161
handle: Arc::new(ContextHandle {
148162
rcl_context: Mutex::new(rcl_context),
163+
logging,
149164
}),
150165
})
151166
}

rclrs/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ mod clock;
1111
mod context;
1212
mod error;
1313
mod executor;
14+
mod logging;
1415
mod node;
1516
mod parameter;
1617
mod publisher;
@@ -38,6 +39,7 @@ pub use clock::*;
3839
pub use context::*;
3940
pub use error::*;
4041
pub use executor::*;
42+
pub use logging::*;
4143
pub use node::*;
4244
pub use parameter::*;
4345
pub use publisher::*;

0 commit comments

Comments
 (0)