Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion rclrs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion rclrs/src/action.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down
2 changes: 1 addition & 1 deletion rclrs/src/action/action_client.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
5 changes: 4 additions & 1 deletion rclrs/src/action/action_client/goal_client.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -95,6 +95,8 @@ impl<A: Action> GoalClient<A> {
/// # Example
///
/// ```
/// # #[cfg(doctest)]
/// # {
/// use rclrs::*;
/// use ros_env::example_interfaces::action::Fibonacci;
/// use futures::StreamExt;
Expand All @@ -118,6 +120,7 @@ impl<A: Action> GoalClient<A> {
/// }
/// }
/// }
/// # }
/// ```
pub struct GoalClientStream<A: Action> {
stream_map: StreamMap<i32, Pin<Box<dyn Stream<Item = GoalEvent<A>> + Send>>>,
Expand Down
2 changes: 1 addition & 1 deletion rclrs/src/action/action_server.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
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,
RclPrimitiveKind, RclrsError, ReadyKind, TakeFailedAsNone, Waitable, WaitableLifecycle,
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,
Expand Down
8 changes: 4 additions & 4 deletions rclrs/src/action/action_server/cancellation_state.rs
Original file line number Diff line number Diff line change
@@ -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,
};
Expand All @@ -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,
Expand Down
15 changes: 12 additions & 3 deletions rclrs/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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 { ... }`
Expand All @@ -189,7 +192,9 @@ where
///
/// ### `fn`
///
/// ```
/// ```no_run
/// # #[cfg(doctest)]
/// # {
/// # use rclrs::*;
/// # use ros_env::test_msgs;
/// # use std::future::Future;
Expand All @@ -210,6 +215,7 @@ where
/// &request,
/// print_greeting)?;
/// # Ok::<(), RclrsError>(())
/// # }
/// ```
///
/// ### Closure
Expand All @@ -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()
Expand All @@ -236,6 +244,7 @@ where
/// }
/// })?;
/// # Ok::<(), RclrsError>(())
/// # }
/// ```
pub fn call_then_async<'a, Req, Args>(
&self,
Expand Down
28 changes: 23 additions & 5 deletions rclrs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
//! then tell the [`Executor`] to spin:
//!
//! ```no_run
//! # #[cfg(doctest)]
//! # {
//! use rclrs::*;
//! # use ros_env::example_interfaces;
//!
Expand All @@ -47,13 +49,16 @@
//!
//! executor.spin(SpinOptions::default()).first_error()?;
//! # Ok::<(), RclrsError>(())
//! # }
//! ```
//!
//! If your callback needs to interact with some state data, consider using a
//! [`Worker`], especially if that state data needs to be shared with other
//! callbacks:
//!
//! ```no_run
//! # #[cfg(doctest)]
//! # {
//! # use rclrs::*;
//! #
//! # let context = Context::default_from_env()?;
Expand Down Expand Up @@ -84,6 +89,7 @@
//!
//! # executor.spin(SpinOptions::default()).first_error()?;
//! # Ok::<(), RclrsError>(())
//! # }
//! ```
//!
//! # Parameters
Expand All @@ -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;
Expand All @@ -119,6 +127,7 @@
//!
//! executor.spin(SpinOptions::default()).first_error()?;
//! # Ok::<(), RclrsError>(())
//! # }
//! ```
//!
//! # Logging
Expand All @@ -128,6 +137,8 @@
//! performed.
//!
//! ```no_run
//! # #[cfg(doctest)]
//! # {
//! use rclrs::*;
//! # use ros_env::example_interfaces;
//! use std::time::Duration;
Expand Down Expand Up @@ -176,6 +187,7 @@
//! );
//! executor.spin(SpinOptions::default()).first_error()?;
//! # Ok::<(), RclrsError>(())
//! # }
//! ```

mod action;
Expand Down Expand Up @@ -205,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::*;
Expand Down
4 changes: 2 additions & 2 deletions rclrs/src/logging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!());
Expand Down Expand Up @@ -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,
Expand Down
Loading
Loading