From 3905c5e4435b411b1e5a5894869ae23f0a8e299a Mon Sep 17 00:00:00 2001 From: Esteve Fernandez Date: Sun, 14 Jun 2026 15:02:35 +0200 Subject: [PATCH 1/2] build(vendor): gate test interfaces to tests and doctests Signed-off-by: Esteve Fernandez --- rclrs/src/action/action_client/goal_client.rs | 3 + rclrs/src/client.rs | 15 +++- rclrs/src/lib.rs | 12 +++ rclrs/src/node.rs | 81 +++++++++++++++---- rclrs/src/worker.rs | 10 ++- rclrs/vendor_interfaces.py | 73 ----------------- 6 files changed, 100 insertions(+), 94 deletions(-) delete mode 100755 rclrs/vendor_interfaces.py diff --git a/rclrs/src/action/action_client/goal_client.rs b/rclrs/src/action/action_client/goal_client.rs index f06f9d051..757b51aa0 100644 --- a/rclrs/src/action/action_client/goal_client.rs +++ b/rclrs/src/action/action_client/goal_client.rs @@ -95,6 +95,8 @@ impl GoalClient { /// # Example /// /// ``` +/// # #[cfg(doctest)] +/// # { /// use rclrs::*; /// use ros_env::example_interfaces::action::Fibonacci; /// use futures::StreamExt; @@ -118,6 +120,7 @@ impl GoalClient { /// } /// } /// } +/// # } /// ``` pub struct GoalClientStream { stream_map: StreamMap> + Send>>>, diff --git a/rclrs/src/client.rs b/rclrs/src/client.rs index a229bac13..0444b8ec0 100644 --- a/rclrs/src/client.rs +++ b/rclrs/src/client.rs @@ -161,7 +161,9 @@ where /// /// Define an `async fn` whose arguments are compatible with one of the above /// signatures and which returns a `()` (a.k.a. nothing). - /// ``` + /// ```no_run + /// # #[cfg(doctest)] + /// # { /// # use rclrs::*; /// # use ros_env::test_msgs; /// # let node = Context::default() @@ -176,6 +178,7 @@ where /// let request = test_msgs::srv::Empty_Request::default(); /// let promise = client.call_then_async(&request, print_hello)?; /// # Ok::<(), RclrsError>(()) + /// # } /// ``` /// /// ## 2. Function that returns an `async { ... }` @@ -189,7 +192,9 @@ where /// /// ### `fn` /// - /// ``` + /// ```no_run + /// # #[cfg(doctest)] + /// # { /// # use rclrs::*; /// # use ros_env::test_msgs; /// # use std::future::Future; @@ -210,6 +215,7 @@ where /// &request, /// print_greeting)?; /// # Ok::<(), RclrsError>(()) + /// # } /// ``` /// /// ### Closure @@ -218,7 +224,9 @@ where /// surrounding context. While the syntax for this is more complicated, it /// is also the most powerful option. /// - /// ``` + /// ```no_run + /// # #[cfg(doctest)] + /// # { /// # use rclrs::*; /// # use ros_env::test_msgs; /// # let node = Context::default() @@ -236,6 +244,7 @@ where /// } /// })?; /// # Ok::<(), RclrsError>(()) + /// # } /// ``` pub fn call_then_async<'a, Req, Args>( &self, diff --git a/rclrs/src/lib.rs b/rclrs/src/lib.rs index 086f58fd6..943fbb4ff 100644 --- a/rclrs/src/lib.rs +++ b/rclrs/src/lib.rs @@ -31,6 +31,8 @@ //! then tell the [`Executor`] to spin: //! //! ```no_run +//! # #[cfg(doctest)] +//! # { //! use rclrs::*; //! # use ros_env::example_interfaces; //! @@ -47,6 +49,7 @@ //! //! executor.spin(SpinOptions::default()).first_error()?; //! # Ok::<(), RclrsError>(()) +//! # } //! ``` //! //! If your callback needs to interact with some state data, consider using a @@ -54,6 +57,8 @@ //! callbacks: //! //! ```no_run +//! # #[cfg(doctest)] +//! # { //! # use rclrs::*; //! # //! # let context = Context::default_from_env()?; @@ -84,6 +89,7 @@ //! //! # executor.spin(SpinOptions::default()).first_error()?; //! # Ok::<(), RclrsError>(()) +//! # } //! ``` //! //! # Parameters @@ -98,6 +104,8 @@ //! //! The following is a simple example of using a mandatory parameter: //! ```no_run +//! # #[cfg(doctest)] +//! # { //! use rclrs::*; //! # use ros_env::example_interfaces; //! use std::sync::Arc; @@ -119,6 +127,7 @@ //! //! executor.spin(SpinOptions::default()).first_error()?; //! # Ok::<(), RclrsError>(()) +//! # } //! ``` //! //! # Logging @@ -128,6 +137,8 @@ //! performed. //! //! ```no_run +//! # #[cfg(doctest)] +//! # { //! use rclrs::*; //! # use ros_env::example_interfaces; //! use std::time::Duration; @@ -176,6 +187,7 @@ //! ); //! executor.spin(SpinOptions::default()).first_error()?; //! # Ok::<(), RclrsError>(()) +//! # } //! ``` mod action; diff --git a/rclrs/src/node.rs b/rclrs/src/node.rs index 8fdccad79..0a54a3e62 100644 --- a/rclrs/src/node.rs +++ b/rclrs/src/node.rs @@ -272,7 +272,9 @@ impl NodeState { /// callbacks. /// /// In some cases the payload type can be inferred by Rust: - /// ``` + /// ```no_run + /// # #[cfg(doctest)] + /// # { /// # use rclrs::*; /// # use ros_env::example_interfaces; /// let executor = Context::default().create_basic_executor(); @@ -287,6 +289,7 @@ impl NodeState { /// } /// )?; /// # Ok::<(), RclrsError>(()) + /// # } /// ``` /// /// If the compiler complains about not knowing the payload type, you can @@ -307,7 +310,9 @@ impl NodeState { /// ``` /// /// The data given to the worker can be any custom data type: - /// ``` + /// ```no_run + /// # #[cfg(doctest)] + /// # { /// # use rclrs::*; /// # use ros_env::example_interfaces; /// # let executor = Context::default().create_basic_executor(); @@ -319,6 +324,7 @@ impl NodeState { /// } /// /// let worker = node.create_worker(MyNodeData::default()); + /// # } /// ``` /// /// In the above example, `addition_client` and `result_publisher` can be @@ -340,7 +346,9 @@ impl NodeState { /// Creates a [`Client`]. /// /// Pass in only the service name for the `options` argument to use all default client options: - /// ``` + /// ```no_run + /// # #[cfg(doctest)] + /// # { /// # use rclrs::*; /// # use ros_env::test_msgs; /// # let executor = Context::default().create_basic_executor(); @@ -349,12 +357,15 @@ impl NodeState { /// "my_service" /// ) /// .unwrap(); + /// # } /// ``` /// /// Take advantage of the [`IntoPrimitiveOptions`] API to easily build up the /// client options: /// - /// ``` + /// ```no_run + /// # #[cfg(doctest)] + /// # { /// # use rclrs::*; /// # use ros_env::test_msgs; /// # let executor = Context::default().create_basic_executor(); @@ -366,6 +377,7 @@ impl NodeState { /// .transient_local() /// ) /// .unwrap(); + /// # } /// ``` /// /// Any quality of service options that you explicitly specify will override @@ -422,7 +434,9 @@ impl NodeState { /// Creates a [`Publisher`]. /// /// Pass in only the topic name for the `options` argument to use all default publisher options: - /// ``` + /// ```no_run + /// # #[cfg(doctest)] + /// # { /// # use rclrs::*; /// # use ros_env::test_msgs; /// # let executor = Context::default().create_basic_executor(); @@ -431,12 +445,15 @@ impl NodeState { /// "my_topic" /// ) /// .unwrap(); + /// # } /// ``` /// /// Take advantage of the [`IntoPrimitiveOptions`] API to easily build up the /// publisher options: /// - /// ``` + /// ```no_run + /// # #[cfg(doctest)] + /// # { /// # use rclrs::*; /// # use ros_env::test_msgs; /// # let executor = Context::default().create_basic_executor(); @@ -453,6 +470,7 @@ impl NodeState { /// .reliable() /// ) /// .unwrap(); + /// # } /// ``` /// pub fn create_publisher<'a, T>( @@ -483,6 +501,7 @@ impl NodeState { /// .keep_last(100) /// ) /// .unwrap(); + /// ``` pub fn create_dynamic_publisher<'a>( self: &Arc, topic_type: MessageTypeName, @@ -509,7 +528,9 @@ impl NodeState { /// # Service Options /// /// Pass in only the service name for the `options` argument to use all default service options: - /// ``` + /// ```no_run + /// # #[cfg(doctest)] + /// # { /// # use rclrs::*; /// # use ros_env::test_msgs; /// # let executor = Context::default().create_basic_executor(); @@ -521,12 +542,15 @@ impl NodeState { /// test_msgs::srv::Empty_Response::default() /// }, /// ); + /// # } /// ``` /// /// Take advantage of the [`IntoPrimitiveOptions`] API to easily build up the /// service options: /// - /// ``` + /// ```no_run + /// # #[cfg(doctest)] + /// # { /// # use rclrs::*; /// # use ros_env::test_msgs; /// # let executor = Context::default().create_basic_executor(); @@ -540,6 +564,7 @@ impl NodeState { /// test_msgs::srv::Empty_Response::default() /// }, /// ); + /// # } /// ``` /// /// Any quality of service options that you explicitly specify will override @@ -565,7 +590,9 @@ impl NodeState { /// will need to be wrapped in [`Mutex`] to ensure it is synchronized across /// multiple simultaneous runs of the callback. For example: /// - /// ``` + /// ```no_run + /// # #[cfg(doctest)] + /// # { /// # use rclrs::*; /// # use ros_env::example_interfaces; /// # let executor = Context::default().create_basic_executor(); @@ -586,12 +613,15 @@ impl NodeState { /// } /// )?; /// # Ok::<(), RclrsError>(()) + /// # } /// ``` /// To share the internal state outside of the callback you will need to /// wrap it in [`Arc`] or `Arc>` and then clone the [`Arc`] before /// capturing it in the closure: /// - /// ``` + /// ```no_run + /// # #[cfg(doctest)] + /// # { /// # use rclrs::*; /// # use ros_env::example_interfaces; /// # let executor = Context::default().create_basic_executor(); @@ -622,6 +652,7 @@ impl NodeState { /// } /// }); /// # Ok::<(), RclrsError>(()) + /// # } /// ``` /// /// In general, when you need to manage some state within a blocking service, @@ -685,7 +716,9 @@ impl NodeState { /// [`Worker`]s into the closure, run tasks on them, and await the outcome. /// This allows one async service to share state data across multiple workers. /// - /// ``` + /// ```no_run + /// # #[cfg(doctest)] + /// # { /// # use rclrs::*; /// # use ros_env::example_interfaces; /// # let executor = Context::default().create_basic_executor(); @@ -721,6 +754,7 @@ impl NodeState { /// } /// )?; /// # Ok::<(), RclrsError>(()) + /// # } /// ``` pub fn create_async_service<'a, T, Args>( self: &Arc, @@ -757,7 +791,9 @@ impl NodeState { /// # Subscription Options /// /// Pass in only the topic name for the `options` argument to use all default subscription options: - /// ``` + /// ```no_run + /// # #[cfg(doctest)] + /// # { /// # use rclrs::*; /// # use ros_env::test_msgs; /// # let executor = Context::default().create_basic_executor(); @@ -768,12 +804,15 @@ impl NodeState { /// println!("Received message!"); /// }, /// ); + /// # } /// ``` /// /// Take advantage of the [`IntoPrimitiveOptions`] API to easily build up the /// subscription options: /// - /// ``` + /// ```no_run + /// # #[cfg(doctest)] + /// # { /// # use rclrs::*; /// # use ros_env::test_msgs; /// # let executor = Context::default().create_basic_executor(); @@ -794,6 +833,7 @@ impl NodeState { /// println!("Received message!"); /// }, /// ); + /// # } /// ``` /// /// # Subscription Callbacks @@ -816,7 +856,9 @@ impl NodeState { /// wrapped in [`Mutex`] to ensure it is synchronized across multiple /// simultaneous runs of the callback. For example: /// - /// ``` + /// ```no_run + /// # #[cfg(doctest)] + /// # { /// # use rclrs::*; /// # use ros_env::example_interfaces; /// # let executor = Context::default().create_basic_executor(); @@ -833,13 +875,16 @@ impl NodeState { /// }, /// )?; /// # Ok::<(), RclrsError>(()) + /// # } /// ``` /// /// To share the internal state outside of the callback you will need to /// wrap it in [`Arc`] (or `Arc>` for mutability) and then clone /// the [`Arc`] before capturing it in the closure: /// - /// ``` + /// ```no_run + /// # #[cfg(doctest)] + /// # { /// # use rclrs::*; /// # use ros_env::example_interfaces; /// # let executor = Context::default().create_basic_executor(); @@ -865,6 +910,7 @@ impl NodeState { /// } /// }); /// # Ok::<(), RclrsError>(()) + /// # } /// ``` /// /// You can change the subscription at any time by calling @@ -1070,7 +1116,9 @@ impl NodeState { /// outcome. This allows one async subscription to share state data across /// multiple workers. /// - /// ``` + /// ```no_run + /// # #[cfg(doctest)] + /// # { /// # use rclrs::*; /// # use ros_env::example_interfaces; /// # let executor = Context::default().create_basic_executor(); @@ -1105,6 +1153,7 @@ impl NodeState { /// } /// )?; /// # Ok::<(), RclrsError>(()) + /// # } /// ``` /// /// You can change the subscription at any time by calling diff --git a/rclrs/src/worker.rs b/rclrs/src/worker.rs index dd411399a..11f51edb9 100644 --- a/rclrs/src/worker.rs +++ b/rclrs/src/worker.rs @@ -232,7 +232,9 @@ impl WorkerState { /// Additionally your callback can get mutable access to the worker's /// payload by setting the first argument of the callback to `&mut Payload`. /// - /// ``` + /// ```no_run + /// # #[cfg(doctest)] + /// # { /// # use rclrs::*; /// # use ros_env::example_interfaces; /// # let executor = Context::default().create_basic_executor(); @@ -254,6 +256,7 @@ impl WorkerState { /// }, /// )?; /// # Ok::<(), RclrsError>(()) + /// # } /// ``` pub fn create_subscription<'a, T, Args>( &self, @@ -382,7 +385,9 @@ impl WorkerState { /// Additionally your callback can get mutable access to the worker's /// payload by setting the first argument of the callback to `&mut Payload`. /// - /// ``` + /// ```no_run + /// # #[cfg(doctest)] + /// # { /// # use rclrs::*; /// # use ros_env::example_interfaces; /// # let executor = Context::default().create_basic_executor(); @@ -416,6 +421,7 @@ impl WorkerState { /// } /// )?; /// # Ok::<(), RclrsError>(()) + /// # } /// ``` pub fn create_service<'a, T, Args>( &self, diff --git a/rclrs/vendor_interfaces.py b/rclrs/vendor_interfaces.py deleted file mode 100755 index 29b4becc8..000000000 --- a/rclrs/vendor_interfaces.py +++ /dev/null @@ -1,73 +0,0 @@ -#!/usr/bin/env python3 -# This script produces the `vendor` module inside `rclrs` by copying the -# generated code for the `rosgraph_msgs`, `rcl_interfaces`, and `action_msgs` -# packages and their dependencies `builtin_interfaces` and -# `unique_identifier_msgs` and adjusting the submodule paths in the code. -# If these packages, or the `rosidl_generator_rs`, get changed, you can -# update the `vendor` module by running this script. -# The purpose is to avoid an external dependency on these message packages, -# which are not published on crates.io. - -import argparse -from pathlib import Path -import shutil -import subprocess - -vendored_packages = [ - "action_msgs", - "builtin_interfaces", - "example_interfaces", - "rcl_interfaces", - "rosgraph_msgs", - "test_msgs", - "unique_identifier_msgs", -] - -def get_args(): - parser = argparse.ArgumentParser(description='Vendor interface packages into rclrs') - parser.add_argument('install_base', metavar='install_base', type=Path, - help='the install base (must have non-merged layout)') - return parser.parse_args() - -def adjust(current_package, text): - for pkg in vendored_packages: - text = text.replace(f'{pkg}::', f'crate::vendor::{pkg}::') - text = text.replace('crate::msg', f'crate::vendor::{current_package}::msg') - text = text.replace('crate::srv', f'crate::vendor::{current_package}::srv') - text = text.replace('crate::action', f'crate::vendor::{current_package}::action') - return text - -def copy_adjusted(pkg, src, dst): - dst.write_text(adjust(pkg, src.read_text())) - subprocess.check_call(['rustfmt', str(dst)]) - -def main(): - args = get_args() - assert args.install_base.is_dir(), "Install base does not exist" - for pkg in vendored_packages: - assert (args.install_base / pkg).is_dir(), f"Install base does not contain {pkg}" - rclrs_root = Path(__file__).parent - vendor_dir = rclrs_root / 'src' / 'vendor' - if vendor_dir.exists(): - shutil.rmtree(vendor_dir) - for pkg in vendored_packages: - src = args.install_base / pkg / 'share' / pkg / 'rust' / 'src' - dst = vendor_dir / pkg - dst.mkdir(parents=True) - copy_adjusted(pkg, src / 'msg.rs', dst / 'msg.rs') - if (src / 'srv.rs').is_file(): - copy_adjusted(pkg, src / 'srv.rs', dst / 'srv.rs') - if (src / 'action.rs').is_file(): - copy_adjusted(pkg, src / 'action.rs', dst / 'action.rs') - copy_adjusted(pkg, src / 'lib.rs', dst / 'mod.rs') # Rename lib.rs to mod.rs - - mod_contents = "//! Created by {}\n".format(Path(__file__).name) - mod_contents += "#![allow(dead_code)]\n" - mod_contents += "#![allow(missing_docs)]\n" - mod_contents += "\n" - for pkg in vendored_packages: - mod_contents += f"pub mod {pkg};\n" - (vendor_dir / 'mod.rs').write_text(mod_contents) - -if __name__ == '__main__': - main() From 053a9ada532ee74a3c31547c4af5918c0892a260 Mon Sep 17 00:00:00 2001 From: Esteve Fernandez Date: Sun, 14 Jun 2026 16:46:39 +0200 Subject: [PATCH 2/2] build: use selective ros-env interfaces Signed-off-by: Esteve Fernandez --- rclrs/Cargo.toml | 4 +++- rclrs/src/action.rs | 2 +- rclrs/src/action/action_client.rs | 2 +- rclrs/src/action/action_client/goal_client.rs | 2 +- rclrs/src/action/action_server.rs | 2 +- .../action/action_server/cancellation_state.rs | 8 ++++---- rclrs/src/lib.rs | 16 +++++++++++----- rclrs/src/logging.rs | 4 ++-- rclrs/src/parameter.rs | 2 +- rclrs/src/parameter/range.rs | 2 +- rclrs/src/parameter/service.rs | 6 +++--- rclrs/src/parameter/value.rs | 2 +- rclrs/src/time.rs | 2 +- rclrs/src/time_source.rs | 2 +- 14 files changed, 32 insertions(+), 24 deletions(-) diff --git a/rclrs/Cargo.toml b/rclrs/Cargo.toml index 430f3c3af..06730122e 100644 --- a/rclrs/Cargo.toml +++ b/rclrs/Cargo.toml @@ -35,7 +35,7 @@ async-std = "1.13" # Needed for dynamic messages libloading = "0.8" -ros-env = "0.2" +ros-env = { version = "0.2", default-features = false, features = ["rclrs_core"] } # Needed for the Message trait, among others rosidl_runtime_rs = "0.6" @@ -63,6 +63,8 @@ paste = { version = "1", optional = true} tempfile = "3.3.0" # Needed for parameter service tests tokio = { version = "1", features = ["rt", "time", "macros"] } +# Needed for docs/tests that exercise generated interfaces without enabling them in normal builds +ros-env = { version = "0.2", default-features = false, features = ["rclrs_core", "example_interfaces", "test_msgs"] } [build-dependencies] # Needed for uploading documentation to docs.rs diff --git a/rclrs/src/action.rs b/rclrs/src/action.rs index b123e0440..9a4227361 100644 --- a/rclrs/src/action.rs +++ b/rclrs/src/action.rs @@ -9,8 +9,8 @@ pub use action_goal_receiver::*; pub(crate) mod action_server; pub use action_server::*; +use crate::builtin_interfaces::msg::Time; use crate::{log_error, rcl_bindings::*, DropGuard}; -use ros_env::builtin_interfaces::msg::Time; use std::fmt; #[cfg(feature = "serde")] diff --git a/rclrs/src/action/action_client.rs b/rclrs/src/action/action_client.rs index 0d2967dab..8fda20b6a 100644 --- a/rclrs/src/action/action_client.rs +++ b/rclrs/src/action/action_client.rs @@ -1,11 +1,11 @@ use super::empty_goal_status_array; +use crate::{action_msgs::srv::CancelGoal_Response, builtin_interfaces::msg::Time}; use crate::{ log_warn, rcl_bindings::*, CancelResponse, CancelResponseCode, DropGuard, GoalStatus, GoalStatusCode, GoalUuid, MultiCancelResponse, Node, NodeHandle, QoSProfile, RclPrimitive, RclPrimitiveHandle, RclPrimitiveKind, RclrsError, ReadyKind, TakeFailedAsNone, ToResult, Waitable, WaitableLifecycle, ENTITY_LIFECYCLE_MUTEX, }; -use ros_env::{action_msgs::srv::CancelGoal_Response, builtin_interfaces::msg::Time}; use rosidl_runtime_rs::{Action, Message, RmwFeedbackMessage, RmwGoalResponse, RmwResultResponse}; use std::{ any::Any, diff --git a/rclrs/src/action/action_client/goal_client.rs b/rclrs/src/action/action_client/goal_client.rs index 757b51aa0..950a3e1b1 100644 --- a/rclrs/src/action/action_client/goal_client.rs +++ b/rclrs/src/action/action_client/goal_client.rs @@ -1,7 +1,7 @@ +use crate::builtin_interfaces::msg::Time; use crate::{ CancellationClient, FeedbackClient, GoalStatus, GoalStatusCode, ResultClient, StatusWatcher, }; -use ros_env::builtin_interfaces::msg::Time; use rosidl_runtime_rs::Action; use std::{ pin::Pin, diff --git a/rclrs/src/action/action_server.rs b/rclrs/src/action/action_server.rs index 468eff101..4c1691d21 100644 --- a/rclrs/src/action/action_server.rs +++ b/rclrs/src/action/action_server.rs @@ -1,4 +1,5 @@ use super::empty_goal_status_array; +use crate::action_msgs::srv::CancelGoal_Response; use crate::{ action::GoalUuid, error::ToResult, rcl_bindings::*, ActionGoalReceiver, CancelResponseCode, DropGuard, GoalStatusCode, Node, NodeHandle, QoSProfile, RclPrimitive, RclPrimitiveHandle, @@ -6,7 +7,6 @@ use crate::{ ENTITY_LIFECYCLE_MUTEX, }; use futures::future::BoxFuture; -use ros_env::action_msgs::srv::CancelGoal_Response; use rosidl_runtime_rs::{Action, Message, RmwGoalRequest, RmwResultRequest}; use std::{ any::Any, diff --git a/rclrs/src/action/action_server/cancellation_state.rs b/rclrs/src/action/action_server/cancellation_state.rs index e34c043c9..3bb83e15e 100644 --- a/rclrs/src/action/action_server/cancellation_state.rs +++ b/rclrs/src/action/action_server/cancellation_state.rs @@ -1,4 +1,8 @@ use super::ActionServerHandle; +use crate::{ + action_msgs::{msg::GoalInfo, srv::CancelGoal_Response}, + unique_identifier_msgs::msg::UUID, +}; use crate::{ log_error, rcl_bindings::*, CancelResponseCode, GoalUuid, Node, RclrsErrorFilter, ToResult, }; @@ -7,10 +11,6 @@ use futures::{ pin_mut, }; use futures_lite::future::race; -use ros_env::{ - action_msgs::{msg::GoalInfo, srv::CancelGoal_Response}, - unique_identifier_msgs::msg::UUID, -}; use rosidl_runtime_rs::{Action, Message}; use std::{ borrow::Cow, diff --git a/rclrs/src/lib.rs b/rclrs/src/lib.rs index 943fbb4ff..872029c92 100644 --- a/rclrs/src/lib.rs +++ b/rclrs/src/lib.rs @@ -217,12 +217,18 @@ mod test_helpers; mod rcl_bindings; -#[cfg(feature = "use_ros_shim")] -#[allow(missing_docs)] -pub mod vendor; +cfg_if::cfg_if! { + if #[cfg(feature = "use_ros_shim")] { + #[allow(missing_docs)] + pub mod vendor; -#[cfg(feature = "use_ros_shim")] -pub use vendor::*; + pub use vendor::*; + } else { + pub use ros_env::{ + action_msgs, builtin_interfaces, rcl_interfaces, rosgraph_msgs, unique_identifier_msgs, + }; + } +} pub use action::*; pub use arguments::*; diff --git a/rclrs/src/logging.rs b/rclrs/src/logging.rs index d5cd989c5..d762c4105 100644 --- a/rclrs/src/logging.rs +++ b/rclrs/src/logging.rs @@ -671,7 +671,7 @@ mod tests { #[test] fn test_rosout_publishing_default() -> Result<(), RclrsError> { use crate::rcl_bindings::rcl_logging_rosout_enabled; - use ros_env::rcl_interfaces::msg::rmw::Log; + use crate::rcl_interfaces::msg::rmw::Log; use std::sync::{Arc, Mutex}; let namespace = format!("/test_rosout_publishing_default_{}", line!()); @@ -794,7 +794,7 @@ mod tests { #[test] fn test_rosout_disabled() -> Result<(), RclrsError> { - use ros_env::rcl_interfaces::msg::rmw::Log; + use crate::rcl_interfaces::msg::rmw::Log; use std::sync::{ atomic::{AtomicBool, Ordering}, Arc, diff --git a/rclrs/src/parameter.rs b/rclrs/src/parameter.rs index 1ff3415ae..1bab22686 100644 --- a/rclrs/src/parameter.rs +++ b/rclrs/src/parameter.rs @@ -8,7 +8,7 @@ pub use range::*; use service::*; pub use value::*; -use ros_env::rcl_interfaces::msg::rmw::{ParameterType, ParameterValue as RmwParameterValue}; +use crate::rcl_interfaces::msg::rmw::{ParameterType, ParameterValue as RmwParameterValue}; use crate::{ call_string_getter_with_rcl_node, rcl_bindings::*, Node, RclrsError, ENTITY_LIFECYCLE_MUTEX, diff --git a/rclrs/src/parameter/range.rs b/rclrs/src/parameter/range.rs index fbbe55e9c..2b2df162a 100644 --- a/rclrs/src/parameter/range.rs +++ b/rclrs/src/parameter/range.rs @@ -1,5 +1,5 @@ +use crate::rcl_interfaces::msg::rmw::{FloatingPointRange, IntegerRange}; use crate::{DeclarationError, ParameterValue, ParameterVariant}; -use ros_env::rcl_interfaces::msg::rmw::{FloatingPointRange, IntegerRange}; use rosidl_runtime_rs::{seq, BoundedSequence}; impl From> for ParameterRanges { diff --git a/rclrs/src/parameter/service.rs b/rclrs/src/parameter/service.rs index 79ea85e96..d71f289f9 100644 --- a/rclrs/src/parameter/service.rs +++ b/rclrs/src/parameter/service.rs @@ -3,7 +3,7 @@ use std::{ sync::{Arc, Mutex}, }; -use ros_env::rcl_interfaces::{msg::rmw::*, srv::rmw::*}; +use crate::rcl_interfaces::{msg::rmw::*, srv::rmw::*}; use rosidl_runtime_rs::Sequence; use super::{OnChangeCallback, ParameterMap}; @@ -341,11 +341,11 @@ impl ParameterService { #[cfg(test)] mod tests { - use crate::*; - use ros_env::rcl_interfaces::{ + use crate::rcl_interfaces::{ msg::rmw::{Parameter as RmwParameter, ParameterType, ParameterValue as RmwParameterValue}, srv::rmw::*, }; + use crate::*; fn validate_multiple_of_5(value: &i64) -> Result<(), String> { if *value % 5 != 0 { diff --git a/rclrs/src/parameter/value.rs b/rclrs/src/parameter/value.rs index e646b30eb..53bca831c 100644 --- a/rclrs/src/parameter/value.rs +++ b/rclrs/src/parameter/value.rs @@ -6,7 +6,7 @@ use crate::{ ParameterValueError, }; -use ros_env::rcl_interfaces::msg::rmw::{ParameterType, ParameterValue as RmwParameterValue}; +use crate::rcl_interfaces::msg::rmw::{ParameterType, ParameterValue as RmwParameterValue}; /// A parameter value. /// diff --git a/rclrs/src/time.rs b/rclrs/src/time.rs index 6bd526f85..717b87e23 100644 --- a/rclrs/src/time.rs +++ b/rclrs/src/time.rs @@ -1,5 +1,5 @@ +use crate::builtin_interfaces; use crate::rcl_bindings::*; -use ros_env::builtin_interfaces; use std::{ num::TryFromIntError, ops::{Add, Sub}, diff --git a/rclrs/src/time_source.rs b/rclrs/src/time_source.rs index a3c27bb8c..1ed0d8295 100644 --- a/rclrs/src/time_source.rs +++ b/rclrs/src/time_source.rs @@ -1,9 +1,9 @@ +use crate::rosgraph_msgs::msg::Clock as ClockMsg; use crate::{ clock::{Clock, ClockSource, ClockType}, IntoPrimitiveOptions, Node, NodeState, QoSProfile, ReadOnlyParameter, Subscription, QOS_PROFILE_CLOCK, }; -use ros_env::rosgraph_msgs::msg::Clock as ClockMsg; use std::sync::{Arc, Mutex, RwLock, Weak}; /// Time source for a node that drives the attached clock.