diff --git a/.github/workflows/r2r_galactic.yml b/.github/workflows/r2r_galactic.yml deleted file mode 100644 index ae0ec96..0000000 --- a/.github/workflows/r2r_galactic.yml +++ /dev/null @@ -1,21 +0,0 @@ -name: r2r_galactic - -on: - push: - branches-ignore: - - rclrs - pull_request: - branches-ignore: - - rclrs - workflow_dispatch: - -env: - CARGO_TERM_COLOR: always - -jobs: - tests_galactic: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - run: docker build . --file ./rpcl2/tests/Dockerfile_r2r_galactic --tag r2r_galactic - - run: docker run r2r_galactic cargo test --features r2r_msg,derive,nalgebra,rayon diff --git a/.github/workflows/r2r_humble.yml b/.github/workflows/r2r_humble.yml deleted file mode 100644 index aa2ec11..0000000 --- a/.github/workflows/r2r_humble.yml +++ /dev/null @@ -1,21 +0,0 @@ -name: r2r_humble - -on: - push: - branches-ignore: - - rclrs - pull_request: - branches-ignore: - - rclrs - workflow_dispatch: - -env: - CARGO_TERM_COLOR: always - -jobs: - tests_humble: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - run: docker build . --file ./rpcl2/tests/Dockerfile_r2r_humble --tag r2r_humble - - run: docker run r2r_humble cargo test --features r2r_msg,derive,nalgebra,rayon diff --git a/.github/workflows/r2r_iron.yml b/.github/workflows/r2r_iron.yml deleted file mode 100644 index 61db09e..0000000 --- a/.github/workflows/r2r_iron.yml +++ /dev/null @@ -1,21 +0,0 @@ -name: r2r_iron - -on: - push: - branches-ignore: - - rclrs - pull_request: - branches-ignore: - - rclrs - workflow_dispatch: - -env: - CARGO_TERM_COLOR: always - -jobs: - tests_humble: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - run: docker build . --file ./rpcl2/tests/Dockerfile_r2r_iron --tag r2r_iron - - run: docker run r2r_iron cargo test --features r2r_msg,derive,nalgebra,rayon diff --git a/.github/workflows/rclrs_humble.yml b/.github/workflows/rclrs_humble.yml deleted file mode 100644 index 6102b2e..0000000 --- a/.github/workflows/rclrs_humble.yml +++ /dev/null @@ -1,21 +0,0 @@ -name: rclrs_humble - -on: - push: - branches: - - rclrs - pull_request: - branches: - - rclrs - workflow_dispatch: - -env: - CARGO_TERM_COLOR: always - -jobs: - tests_humble: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - run: docker build . --file ./rpcl2/tests/Dockerfile_rclrs_humble --tag rclrs_humble - - run: docker run rclrs_humble cargo test --features derive,nalgebra,rayon diff --git a/.github/workflows/rclrs_iron.yml b/.github/workflows/rclrs_iron.yml deleted file mode 100644 index 0259f63..0000000 --- a/.github/workflows/rclrs_iron.yml +++ /dev/null @@ -1,21 +0,0 @@ -name: rclrs_iron - -on: - push: - branches: - - rclrs - pull_request: - branches: - - rclrs - workflow_dispatch: - -env: - CARGO_TERM_COLOR: always - -jobs: - tests_iron: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - run: docker build . --file ./rpcl2/tests/Dockerfile_rclrs_iron --tag rclrs_iron - - run: docker run rclrs_iron cargo test --features derive,nalgebra,rayon diff --git a/.github/workflows/rosrust_noetic.yml b/.github/workflows/roslibrust_noetic.yml similarity index 90% rename from .github/workflows/rosrust_noetic.yml rename to .github/workflows/roslibrust_noetic.yml index bbf6403..1c671f0 100644 --- a/.github/workflows/rosrust_noetic.yml +++ b/.github/workflows/roslibrust_noetic.yml @@ -1,4 +1,4 @@ -name: rosrust_noetic +name: roslibrust_noetic on: push: @@ -23,7 +23,7 @@ jobs: PYTHONPATH: $PYTHONPATH:/usr/lib/python2.7/dist-packages:/usr/local/lib/python2.7/dist-packages ROS_DISTRO: noetic steps: - - name: rosrust + - name: roslibrust uses: actions/checkout@v1 - name: Install latest rust run: | @@ -50,7 +50,7 @@ jobs: sudo rosdep init rosdep update # --include-eol-distros # Support EOL distros. - name: Install ROS additional packages - # Does installing these mean rosrust_msg builds more messages, which is a better + # Does installing these mean roslibrust_msg builds more messages, which is a better # check? Or does it just slow down the action? run: | sudo apt-get install -y ros-$ROS_DISTRO-actionlib @@ -96,7 +96,7 @@ jobs: - name: build run: | source /opt/ros/$ROS_DISTRO/setup.bash - cargo build # --verbose + ROS_PACKAGE_PATH=`rospack find geometry_msgs`:`rospack find tf2_msgs`:`rospack find sensor_msgs`:`rospack find std_msgs`:`rospack find actionlib_msgs` cargo build # --verbose - name: Install ROS packages for tests run: | sudo apt-get install -y ros-$ROS_DISTRO-actionlib-tutorials @@ -105,4 +105,4 @@ jobs: - name: test run: | source /opt/ros/$ROS_DISTRO/setup.bash - cargo test --features rosrust_msg,derive,nalgebra,rayon + ROS_PACKAGE_PATH=`rospack find geometry_msgs`:`rospack find tf2_msgs`:`rospack find sensor_msgs`:`rospack find std_msgs`:`rospack find actionlib_msgs` cargo test --features roslibrust_msg,derive,nalgebra,rayon diff --git a/Cargo.toml b/Cargo.toml index bb3c954..ddbcf43 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [workspace] -members = [ "derive-test","rpcl2", "rpcl2-derive"] +members = ["derive-test", "ros_pointcloud2", "rpcl2-derive"] resolver = "2" diff --git a/README.md b/README.md index c6cd2ab..0d67f5c 100644 --- a/README.md +++ b/README.md @@ -43,8 +43,8 @@ let processed_cloud = in_msg.try_into_iter().unwrap() There are currently 3 integrations for common ROS crates. -- [rosrust_msg](https://github.com/adnanademovic/rosrust) - - [![Tests](https://github.com/stelzo/ros_pointcloud2/actions/workflows/rosrust_noetic.yml/badge.svg)](https://github.com/stelzo/ros_pointcloud2/actions/workflows/rosrust_noetic.yml) +- [roslibrust_msg](https://github.com/roslibrust/roslibrust) + - TBD roslibrust test to replace old rosrust one - [r2r_msg](https://github.com/sequenceplanner/r2r) - [![Tests](https://github.com/stelzo/ros_pointcloud2/actions/workflows/r2r_galactic.yml/badge.svg)](https://github.com/stelzo/ros_pointcloud2/actions/workflows/r2r_galactic.yml) - [![Tests](https://github.com/stelzo/ros_pointcloud2/actions/workflows/r2r_humble.yml/badge.svg)](https://github.com/stelzo/ros_pointcloud2/actions/workflows/r2r_humble.yml) @@ -55,13 +55,14 @@ There are currently 3 integrations for common ROS crates. - [![Tests](https://github.com/stelzo/ros_pointcloud2/actions/workflows/rclrs_iron.yml/badge.svg)](https://github.com/stelzo/ros_pointcloud2/actions/workflows/rclrs_iron.yml) - [![Tests](https://github.com/stelzo/ros_pointcloud2/actions/workflows/rclrs_jazzy.yml/badge.svg)](https://github.com/stelzo/ros_pointcloud2/actions/workflows/rclrs_jazzy.yml) -You can use `rosrust` and `r2r` by enabling the respective feature: +You can use `roslibrust` and `r2r` by enabling the respective feature: ```toml [dependencies] ros_pointcloud2 = { version = "*", features = ["r2r_msg"]} # or -ros_pointcloud2 = { version = "*", features = ["rosrust_msg"]} +# ros_pointcloud2 = { version = "*", features = ["roslibrust_msg"]} +ros_pointcloud2 = { version = "*", features = ["roslibrust_msg"]} ``` ### rclrs (ros2_rust) diff --git a/derive-test/Cargo.toml b/derive-test/Cargo.toml index 92b6f05..8aac038 100644 --- a/derive-test/Cargo.toml +++ b/derive-test/Cargo.toml @@ -15,5 +15,5 @@ categories = [ ] [dependencies] -ros_pointcloud2 = { path = "../rpcl2", features = ["std", "derive"] } +ros_pointcloud2 = { path = "../ros_pointcloud2", features = ["std", "derive"] } rpcl2-derive = { path = "../rpcl2-derive" } diff --git a/rpcl2/Cargo.toml b/ros_pointcloud2/Cargo.toml similarity index 82% rename from rpcl2/Cargo.toml rename to ros_pointcloud2/Cargo.toml index 60b9e9d..ef539d5 100644 --- a/rpcl2/Cargo.toml +++ b/ros_pointcloud2/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ros_pointcloud2" -version = "0.5.0" +version = "0.16.0" edition = "2021" authors = ["Christopher Sieh "] description = "Customizable conversions for working with sensor_msgs/PointCloud2." @@ -31,14 +31,23 @@ exclude = [ rust-version = "1.63" [dependencies] -rosrust_msg = { version = "0.1", optional = true } -rosrust = { version = "0.9.11", optional = true } r2r = { version = "0.9", optional = true } rayon = { version = "1", optional = true } nalgebra = { version = "0.33", optional = true, default-features = false } rpcl2-derive = { version = "0.3", optional = true, path = "../rpcl2-derive" } memoffset = { version = "0.9", optional = true } +[dependencies.roslibrust] +git = "https://github.com/lucasw/roslibrust" +branch = "get_rx_msg_def_v0_16" +features = ["ros1"] +optional = true + +[dependencies.roslibrust_util] +git = "https://github.com/lucasw/tf_roslibrust" +version = "0.16.0" +optional = true + [dev-dependencies] rand = "0.8" criterion = { version = "0.5", features = ["html_reports"] } @@ -50,7 +59,7 @@ harness = false path = "benches/roundtrip.rs" [features] -rosrust_msg = ["dep:rosrust_msg", "dep:rosrust"] +roslibrust_msg = ["dep:roslibrust", "dep:roslibrust_util"] r2r_msg = ["dep:r2r"] rayon = ["dep:rayon"] derive = ["dep:rpcl2-derive", "dep:memoffset"] diff --git a/rpcl2/benches/roundtrip.rs b/ros_pointcloud2/benches/roundtrip.rs similarity index 100% rename from rpcl2/benches/roundtrip.rs rename to ros_pointcloud2/benches/roundtrip.rs diff --git a/rpcl2/ensure_no_std/.gitignore b/ros_pointcloud2/ensure_no_std/.gitignore similarity index 100% rename from rpcl2/ensure_no_std/.gitignore rename to ros_pointcloud2/ensure_no_std/.gitignore diff --git a/rpcl2/ensure_no_std/Cargo.toml b/ros_pointcloud2/ensure_no_std/Cargo.toml similarity index 100% rename from rpcl2/ensure_no_std/Cargo.toml rename to ros_pointcloud2/ensure_no_std/Cargo.toml diff --git a/rpcl2/ensure_no_std/src/main.rs b/ros_pointcloud2/ensure_no_std/src/main.rs similarity index 100% rename from rpcl2/ensure_no_std/src/main.rs rename to ros_pointcloud2/ensure_no_std/src/main.rs diff --git a/rpcl2/examples/custom_enum_field_filter.rs b/ros_pointcloud2/examples/custom_enum_field_filter.rs similarity index 100% rename from rpcl2/examples/custom_enum_field_filter.rs rename to ros_pointcloud2/examples/custom_enum_field_filter.rs diff --git a/rpcl2/examples/rayon_bench.rs b/ros_pointcloud2/examples/rayon_bench.rs similarity index 100% rename from rpcl2/examples/rayon_bench.rs rename to ros_pointcloud2/examples/rayon_bench.rs diff --git a/rpcl2/examples/simple_distance_filter.rs b/ros_pointcloud2/examples/simple_distance_filter.rs similarity index 100% rename from rpcl2/examples/simple_distance_filter.rs rename to ros_pointcloud2/examples/simple_distance_filter.rs diff --git a/rpcl2/src/iterator.rs b/ros_pointcloud2/src/iterator.rs similarity index 98% rename from rpcl2/src/iterator.rs rename to ros_pointcloud2/src/iterator.rs index a17f4a9..0674380 100644 --- a/rpcl2/src/iterator.rs +++ b/ros_pointcloud2/src/iterator.rs @@ -15,15 +15,15 @@ use alloc::vec::Vec; /// When using within a ROS node, the PointCloud2 (created by the ROS crate) must be converted first. /// The cost of this operation is low, as it mostly moves ownership without iterating over the point data. /// -/// ROS1 with rosrust: -/// let msg: rosrust_msg::sensor_msgs::PointCloud2; // inside the callback +/// ROS1 with roslibrust: +/// let msg: roslibrust_msg::sensor_msgs::PointCloud2; // inside the callback /// let converted: ros_pointcloud2::PointCloud2Msg = msg.into(); /// /// ROS2 with r2r: /// let msg: r2r::sensor_msgs::msg::PointCloud2 = internal_msg.into(); /// let converted: ros_pointcloud2::PointCloud2Msg = msg.into(); /// -/// `ros_pointcloud2` supports r2r, rclrs and rosrust as conversion targets out of the box via feature flags. +/// `ros_pointcloud2` supports r2r, rclrs and roslibrust as conversion targets out of the box via feature flags. /// pub struct PointCloudIterator where diff --git a/rpcl2/src/lib.rs b/ros_pointcloud2/src/lib.rs similarity index 99% rename from rpcl2/src/lib.rs rename to ros_pointcloud2/src/lib.rs index b446dd4..968a5bf 100644 --- a/rpcl2/src/lib.rs +++ b/ros_pointcloud2/src/lib.rs @@ -54,7 +54,7 @@ //! //! # Features //! - r2r_msg — Integration for the ROS2 library [r2r](https://github.com/sequenceplanner/r2r). -//! - rosrust_msg — Integration with the [rosrust](https://github.com/adnanademovic/rosrust) library for ROS1 message types. +//! - roslibrust_msg — Integration with the [roslibrust](https://github.com/roslibrust/roslibrust) library for ROS1 message types. //! - (rclrs_msg) — Integration for ROS2 [rclrs](https://github.com/ros2-rust/ros2_rust) but it currently needs [this workaround](https://github.com/stelzo/ros_pointcloud2?tab=readme-ov-file#rclrs-ros2_rust). //! - derive — Offers implementations for the [`PointConvertible`] trait needed for custom points. //! - rayon — Parallel iterator support for `_par_iter` functions. diff --git a/rpcl2/src/points.rs b/ros_pointcloud2/src/points.rs similarity index 100% rename from rpcl2/src/points.rs rename to ros_pointcloud2/src/points.rs diff --git a/rpcl2/src/prelude.rs b/ros_pointcloud2/src/prelude.rs similarity index 100% rename from rpcl2/src/prelude.rs rename to ros_pointcloud2/src/prelude.rs diff --git a/rpcl2/src/ros.rs b/ros_pointcloud2/src/ros.rs similarity index 86% rename from rpcl2/src/ros.rs rename to ros_pointcloud2/src/ros.rs index b2b395b..17f740e 100644 --- a/rpcl2/src/ros.rs +++ b/ros_pointcloud2/src/ros.rs @@ -25,6 +25,15 @@ use alloc::string::String; +#[cfg(feature = "roslibrust_msg")] +use roslibrust::codegen::integral_types::Time as RosTime; + +#[cfg(feature = "roslibrust_msg")] +use roslibrust_util::sensor_msgs; + +#[cfg(feature = "roslibrust_msg")] +use roslibrust_util::std_msgs; + /// [Time](https://docs.ros2.org/latest/api/builtin_interfaces/msg/Time.html) representation for ROS messages. #[derive(Clone, Debug, Default)] pub struct TimeMsg { @@ -32,12 +41,12 @@ pub struct TimeMsg { pub nanosec: u32, } -#[cfg(feature = "rosrust_msg")] -impl From for TimeMsg { - fn from(time: rosrust::Time) -> Self { +#[cfg(feature = "roslibrust_msg")] +impl From for TimeMsg { + fn from(time: RosTime) -> Self { Self { - sec: time.sec as i32, - nanosec: time.nsec, + sec: time.secs as i32, + nanosec: time.nsecs as u32, } } } @@ -151,15 +160,15 @@ impl From for r2r::sensor_msgs::msg::PointCloud2 { } } -#[cfg(feature = "rosrust_msg")] -impl From for crate::PointCloud2Msg { - fn from(msg: rosrust_msg::sensor_msgs::PointCloud2) -> Self { +#[cfg(feature = "roslibrust_msg")] +impl From for crate::PointCloud2Msg { + fn from(msg: sensor_msgs::PointCloud2) -> Self { Self { header: HeaderMsg { seq: msg.header.seq, stamp: TimeMsg { - sec: msg.header.stamp.sec as i32, - nanosec: msg.header.stamp.nsec, + sec: msg.header.stamp.secs as i32, + nanosec: msg.header.stamp.nsecs as u32, }, frame_id: msg.header.frame_id, }, @@ -194,15 +203,15 @@ impl From for crate::PointCloud2Msg { } } -#[cfg(feature = "rosrust_msg")] -impl From for rosrust_msg::sensor_msgs::PointCloud2 { +#[cfg(feature = "roslibrust_msg")] +impl From for sensor_msgs::PointCloud2 { fn from(msg: crate::PointCloud2Msg) -> Self { - rosrust_msg::sensor_msgs::PointCloud2 { - header: rosrust_msg::std_msgs::Header { + sensor_msgs::PointCloud2 { + header: std_msgs::Header { seq: msg.header.seq, - stamp: rosrust::Time { - sec: msg.header.stamp.sec as u32, - nsec: msg.header.stamp.nanosec, + stamp: RosTime { + secs: msg.header.stamp.sec, + nsecs: msg.header.stamp.nanosec as i32, }, frame_id: msg.header.frame_id, }, @@ -211,7 +220,7 @@ impl From for rosrust_msg::sensor_msgs::PointCloud2 { fields: msg .fields .into_iter() - .map(|field| rosrust_msg::sensor_msgs::PointField { + .map(|field| sensor_msgs::PointField { name: field.name, offset: field.offset, datatype: field.datatype, diff --git a/rpcl2/tests/Dockerfile_r2r_galactic b/ros_pointcloud2/tests/Dockerfile_r2r_galactic similarity index 100% rename from rpcl2/tests/Dockerfile_r2r_galactic rename to ros_pointcloud2/tests/Dockerfile_r2r_galactic diff --git a/rpcl2/tests/Dockerfile_r2r_humble b/ros_pointcloud2/tests/Dockerfile_r2r_humble similarity index 100% rename from rpcl2/tests/Dockerfile_r2r_humble rename to ros_pointcloud2/tests/Dockerfile_r2r_humble diff --git a/rpcl2/tests/Dockerfile_r2r_iron b/ros_pointcloud2/tests/Dockerfile_r2r_iron similarity index 100% rename from rpcl2/tests/Dockerfile_r2r_iron rename to ros_pointcloud2/tests/Dockerfile_r2r_iron diff --git a/rpcl2/tests/Dockerfile_r2r_jazzy b/ros_pointcloud2/tests/Dockerfile_r2r_jazzy similarity index 100% rename from rpcl2/tests/Dockerfile_r2r_jazzy rename to ros_pointcloud2/tests/Dockerfile_r2r_jazzy diff --git a/rpcl2/tests/Dockerfile_rclrs_humble b/ros_pointcloud2/tests/Dockerfile_rclrs_humble similarity index 100% rename from rpcl2/tests/Dockerfile_rclrs_humble rename to ros_pointcloud2/tests/Dockerfile_rclrs_humble diff --git a/rpcl2/tests/Dockerfile_rclrs_iron b/ros_pointcloud2/tests/Dockerfile_rclrs_iron similarity index 100% rename from rpcl2/tests/Dockerfile_rclrs_iron rename to ros_pointcloud2/tests/Dockerfile_rclrs_iron diff --git a/rpcl2/tests/Dockerfile_rclrs_jazzy b/ros_pointcloud2/tests/Dockerfile_rclrs_jazzy similarity index 100% rename from rpcl2/tests/Dockerfile_rclrs_jazzy rename to ros_pointcloud2/tests/Dockerfile_rclrs_jazzy diff --git a/rpcl2/tests/e2e_test.rs b/ros_pointcloud2/tests/e2e_test.rs similarity index 100% rename from rpcl2/tests/e2e_test.rs rename to ros_pointcloud2/tests/e2e_test.rs diff --git a/rpcl2/tests/r2r_msg_test.rs b/ros_pointcloud2/tests/r2r_msg_test.rs similarity index 100% rename from rpcl2/tests/r2r_msg_test.rs rename to ros_pointcloud2/tests/r2r_msg_test.rs diff --git a/rpcl2/tests/r2r_test.bash b/ros_pointcloud2/tests/r2r_test.bash similarity index 100% rename from rpcl2/tests/r2r_test.bash rename to ros_pointcloud2/tests/r2r_test.bash diff --git a/rpcl2/tests/rclrs_test.bash b/ros_pointcloud2/tests/rclrs_test.bash similarity index 100% rename from rpcl2/tests/rclrs_test.bash rename to ros_pointcloud2/tests/rclrs_test.bash diff --git a/rpcl2/tests/rosrust_msg_test.rs b/ros_pointcloud2/tests/rosrust_msg_test.rs similarity index 72% rename from rpcl2/tests/rosrust_msg_test.rs rename to ros_pointcloud2/tests/rosrust_msg_test.rs index 2e7c795..be5514a 100644 --- a/rpcl2/tests/rosrust_msg_test.rs +++ b/ros_pointcloud2/tests/rosrust_msg_test.rs @@ -1,6 +1,6 @@ -#[cfg(feature = "rosrust_msg")] +#[cfg(feature = "roslibrust_msg")] #[test] -fn convertxyz_rosrust_msg() { +fn convertxyz_roslibrust_msg() { use ros_pointcloud2::{points::PointXYZ, PointCloud2Msg}; let cloud = vec![ @@ -22,8 +22,8 @@ fn convertxyz_rosrust_msg() { ]; let copy = cloud.clone(); let internal_cloud = PointCloud2Msg::try_from_iter(cloud).unwrap(); - let rosrust_msg_cloud: rosrust_msg::sensor_msgs::PointCloud2 = internal_cloud.into(); - let convert_back_internal: PointCloud2Msg = rosrust_msg_cloud.into(); + let roslibrust_msg_cloud: roslibrust_util::sensor_msgs::PointCloud2 = internal_cloud.into(); + let convert_back_internal: PointCloud2Msg = roslibrust_msg_cloud.into(); let to_convert = convert_back_internal.try_into_iter().unwrap(); let back_to_type = to_convert.collect::>(); assert_eq!(copy, back_to_type);