diff --git a/rclrs/Cargo.toml b/rclrs/Cargo.toml index 93b277b5e..e58d3e91d 100644 --- a/rclrs/Cargo.toml +++ b/rclrs/Cargo.toml @@ -4,6 +4,8 @@ version = "0.2.0" # This project is not military-sponsored, Jacob's employment contract just requires him to use this email address authors = ["Esteve Fernandez ", "Nikolai Morin ", "Jacob Hassold "] edition = "2021" +license = "Apache-2.0" +description = "A ROS 2 client library for developing robotics applications in Rust" [lib] path = "src/lib.rs" @@ -16,7 +18,7 @@ libc = "0.2.43" # Provides better concurrency primitives than std parking_lot = "0.11.2" # Needed for the Message trait, among others -rosidl_runtime_rs = "*" +rosidl_runtime_rs = "0.2.0" # Needed for clients futures = "0.3" @@ -24,9 +26,6 @@ futures = "0.3" # Needed for e.g. writing yaml files in tests tempfile = "3.3.0" -[dev-dependencies.std_msgs] -version = "*" - [build-dependencies] # Needed for FFI bindgen = "0.59.1" diff --git a/rclrs/package.xml b/rclrs/package.xml index 7d3df951e..d22cb2bb9 100644 --- a/rclrs/package.xml +++ b/rclrs/package.xml @@ -17,8 +17,6 @@ rosidl_runtime_rs rcl - std_msgs - ament_cargo diff --git a/rclrs/src/lib.rs b/rclrs/src/lib.rs index af0429247..0f4f2e3e9 100644 --- a/rclrs/src/lib.rs +++ b/rclrs/src/lib.rs @@ -147,44 +147,3 @@ pub fn create_node(context: &Context, node_name: &str) -> Result NodeBuilder { Node::builder(context, node_name) } - -#[cfg(test)] -mod tests { - use super::*; - use std::sync::{Arc, Mutex}; - use std::time::Duration; - - #[test] - fn test_spin_once() -> Result<(), RclrsError> { - let context = Context::new(vec![]).unwrap(); - let mut subscriber_node = create_node(&context, "minimal_subscriber")?; - let num_messages = Arc::new(Mutex::new(0)); - let received_msg = Arc::new(Mutex::new(String::new())); - let n = num_messages.clone(); - let m = received_msg.clone(); - let publisher = subscriber_node - .create_publisher::("topic", QOS_PROFILE_DEFAULT)?; - let _subscription = subscriber_node.create_subscription::( - "topic", - QOS_PROFILE_DEFAULT, - move |msg: std_msgs::msg::String| { - let mut num_messages = n.lock().unwrap(); - let mut received_msg = m.lock().unwrap(); - - *num_messages += 1; - *received_msg = msg.data; - }, - )?; - - let message = std_msgs::msg::String { - data: String::from("Hello World"), - }; - publisher.publish(message)?; - spin_once(&subscriber_node, Some(Duration::from_millis(500)))?; - - assert_eq!(*num_messages.lock().unwrap(), 1); - assert_eq!(&*received_msg.lock().unwrap().as_str(), "Hello World"); - - Ok(()) - } -} diff --git a/rclrs/src/node.rs b/rclrs/src/node.rs index 39dc23c1b..48852be38 100644 --- a/rclrs/src/node.rs +++ b/rclrs/src/node.rs @@ -338,41 +338,3 @@ unsafe fn call_string_getter_with_handle( let cstr = CStr::from_ptr(char_ptr); cstr.to_string_lossy().into_owned() } - -#[cfg(test)] -mod tests { - use super::*; - use crate::{create_node, Context, Node, QOS_PROFILE_DEFAULT}; - - #[test] - fn test_new() -> Result<(), RclrsError> { - let context = - Context::new(vec![]).expect("Context instantiation is expected to be a success"); - let _ = Node::new(&context, "Bob")?; - - Ok(()) - } - - #[test] - fn test_create_subscription() -> Result<(), RclrsError> { - let context = - Context::new(vec![]).expect("Context instantiation is expected to be a success"); - let mut node = create_node(&context, "test_create_subscription")?; - let _subscription = node.create_subscription::( - "topic", - QOS_PROFILE_DEFAULT, - move |_: std_msgs::msg::String| {}, - )?; - Ok(()) - } - - #[test] - fn test_create_publisher() -> Result<(), RclrsError> { - let context = - Context::new(vec![]).expect("Context instantiation is expected to be a success"); - let node = create_node(&context, "test_create_publisher")?; - let _publisher = - node.create_publisher::("topic", QOS_PROFILE_DEFAULT)?; - Ok(()) - } -} diff --git a/rclrs/src/node/publisher.rs b/rclrs/src/node/publisher.rs index fc0ee2468..aa33a077f 100644 --- a/rclrs/src/node/publisher.rs +++ b/rclrs/src/node/publisher.rs @@ -163,37 +163,3 @@ impl<'a, T: Message> MessageCow<'a, T> for &'a T { Cow::Borrowed(self) } } - -#[cfg(test)] -mod tests { - use super::*; - use crate::{create_node, Context, Publisher, QOS_PROFILE_DEFAULT}; - - fn create_fixture(name: &str) -> (Context, Node) { - let context = - Context::new(vec![]).expect("Context instantiation is expected to be a success"); - let node = - create_node(&context, name).expect("Node instantiation is expected to be a success"); - - (context, node) - } - - #[test] - fn test_new_publisher() -> Result<(), RclrsError> { - let (_, node) = create_fixture("test_new_publisher"); - let _ = Publisher::::new(&node, "test", QOS_PROFILE_DEFAULT)?; - - Ok(()) - } - - #[test] - fn test_publish_message() -> Result<(), RclrsError> { - let (_, node) = create_fixture("test_publish_message"); - let publisher = - Publisher::::new(&node, "test", QOS_PROFILE_DEFAULT)?; - let message = std_msgs::msg::String { - data: "Hello world!".to_owned(), - }; - publisher.publish(&message) - } -} diff --git a/rclrs/src/node/subscription.rs b/rclrs/src/node/subscription.rs index fa27302b8..5f94c99f4 100644 --- a/rclrs/src/node/subscription.rs +++ b/rclrs/src/node/subscription.rs @@ -214,23 +214,3 @@ where Ok(()) } } - -#[cfg(test)] -mod tests { - use super::*; - use crate::{create_node, Context, QOS_PROFILE_DEFAULT}; - - #[test] - fn test_instantiate_subscriber() -> Result<(), RclrsError> { - let context = - Context::new(vec![]).expect("Context instantiation is expected to be a success"); - let mut node = create_node(&context, "test_new_subscriber")?; - let _subscriber = node.create_subscription::( - "test", - QOS_PROFILE_DEFAULT, - move |_: std_msgs::msg::String| {}, - )?; - - Ok(()) - } -} diff --git a/rclrs/src/wait.rs b/rclrs/src/wait.rs index 9489f9f86..b8d173343 100644 --- a/rclrs/src/wait.rs +++ b/rclrs/src/wait.rs @@ -289,42 +289,3 @@ impl WaitSet { Ok(ready_entities) } } - -#[cfg(test)] -mod tests { - use crate::{Context, Node, RclrsError, WaitSet, QOS_PROFILE_DEFAULT}; - use std::sync::Arc; - - #[test] - fn test_adding_waitable_to_wait_sets() -> Result<(), RclrsError> { - let context = Context::new([])?; - let mut node = Node::new(&context, "test_adding_waitable_to_wait_sets")?; - let subscription = node.create_subscription( - "test", - QOS_PROFILE_DEFAULT, - move |_: std_msgs::msg::String| {}, - )?; - let mut wait_set_1 = WaitSet::new(1, 0, 0, 0, 0, 0, &context)?; - let mut wait_set_2 = WaitSet::new(1, 0, 0, 0, 0, 0, &context)?; - - // Try to add the subscription to wait set 1 twice - wait_set_1.add_subscription(Arc::clone(&subscription) as _)?; - assert!(wait_set_1 - .add_subscription(Arc::clone(&subscription) as _) - .is_err()); - - // Try to add it to another wait set - assert!(wait_set_2 - .add_subscription(Arc::clone(&subscription) as _) - .is_err()); - - // It works as soon as it is not anymore part of wait_set_1 - wait_set_1.clear(); - wait_set_2.add_subscription(Arc::clone(&subscription) as _)?; - - // Dropping the wait set also frees up the subscription - drop(wait_set_2); - wait_set_1.add_subscription(Arc::clone(&subscription) as _)?; - Ok(()) - } -} diff --git a/rosidl_runtime_rs/Cargo.toml b/rosidl_runtime_rs/Cargo.toml index 82bf5bd5c..029546870 100644 --- a/rosidl_runtime_rs/Cargo.toml +++ b/rosidl_runtime_rs/Cargo.toml @@ -2,8 +2,10 @@ name = "rosidl_runtime_rs" version = "0.2.0" # This project is not military-sponsored, Jacob's employment contract just requires him to use this email address -authors = ["Jacob Hassold ", "Nikolai Morin "] +authors = ["Esteve Fernandez ", "Nikolai Morin ", "Jacob Hassold "] edition = "2021" +license = "Apache-2.0" +description = "Message generation code shared by Rust projects in ROS 2" [lib] path = "src/lib.rs"