ROS2 testing (#12)
* add humble tests * simpler names * fix linking problem with r2r v0.7 * tidy and badges * cargo publish on release
This commit is contained in:
parent
1dedd9c3bb
commit
152fce79a3
|
|
@ -0,0 +1,22 @@
|
|||
on:
|
||||
release:
|
||||
types: [created]
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Setup Rust
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
override: true
|
||||
|
||||
- name: Publish to crates.io
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: publish
|
||||
args: --token ${{ secrets.CRATES_IO_TOKEN }}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
name: galactic_r2r_test
|
||||
name: r2r_galactic
|
||||
|
||||
on:
|
||||
push:
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
name: r2r_humble
|
||||
|
||||
on:
|
||||
push:
|
||||
pull_request:
|
||||
workflow_dispatch:
|
||||
|
||||
env:
|
||||
CARGO_TERM_COLOR: always
|
||||
|
||||
jobs:
|
||||
tests_humble:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- run: docker build . --file ./tests/Dockerfile_r2r_humble --tag r2r_humble
|
||||
- run: docker run r2r_humble cargo test --features r2r_msg
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
name: r2r_iron
|
||||
|
||||
on:
|
||||
push:
|
||||
pull_request:
|
||||
workflow_dispatch:
|
||||
|
||||
env:
|
||||
CARGO_TERM_COLOR: always
|
||||
|
||||
jobs:
|
||||
tests_humble:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- run: docker build . --file ./tests/Dockerfile_r2r_iron --tag r2r_iron
|
||||
- run: docker run r2r_iron cargo test --features r2r_msg
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
name: Ubuntu 20.04 Noetic from rosrust
|
||||
name: rosrust_noetic
|
||||
|
||||
on:
|
||||
push:
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
name: Pure latest Ubuntu without integrations
|
||||
name: Tests
|
||||
|
||||
on:
|
||||
push:
|
||||
|
|
@ -1,12 +1,12 @@
|
|||
[package]
|
||||
name = "ros_pointcloud2"
|
||||
version = "0.3.1"
|
||||
version = "0.3.2"
|
||||
edition = "2021"
|
||||
authors = ["Christopher Sieh <stelzo@steado.de>"]
|
||||
description = "Customizable conversions for working with sensor_msgs/PointCloud2."
|
||||
repository = "https://github.com/stelzo/ros_pointcloud2"
|
||||
license = "MIT"
|
||||
keywords = ["ros", "rosrust", "pointcloud2", "pointcloud", "message",]
|
||||
keywords = ["ros", "pointcloud2", "pointcloud", "message"]
|
||||
categories = ["science::robotics", "encoding", "data-structures", "api-bindings"]
|
||||
readme = "README.md"
|
||||
documentation = "https://docs.rs/ros_pointcloud2"
|
||||
|
|
@ -19,7 +19,7 @@ num-traits = "0.2.15"
|
|||
fallible-iterator = "0.3.0"
|
||||
rosrust_msg = { version = "0.1", optional = true }
|
||||
rosrust = { version = "0.9.11", optional = true }
|
||||
r2r = { version = "0.8.0", optional = true }
|
||||
r2r = { version = "0.8.4", optional = true }
|
||||
|
||||
[features]
|
||||
rosrust_msg = ["dep:rosrust_msg", "dep:rosrust"]
|
||||
|
|
|
|||
45
README.md
45
README.md
|
|
@ -1,19 +1,21 @@
|
|||
# ROS PointCloud2
|
||||
|
||||
Customizable conversions to and from the `sensor_msgs/PointCloud2` ROS message.
|
||||
<p align="center">
|
||||
<h3 align="center">ROS PointCloud2</h3>
|
||||
<p align="center">Customizable conversions to and from the PointCloud2 ROS message.</p>
|
||||
<p align="center"><a href="https://crates.io/crates/ros_pointcloud2"><img src="https://img.shields.io/crates/v/ros_pointcloud2.svg" alt=""></a> <a href="https://github.com/stelzo/ros_pointcloud2/tree/main/tests"><img src="https://github.com/stelzo/ros_pointcloud2/actions/workflows/tests.yml/badge.svg" alt=""></a>
|
||||
</p>
|
||||
</p>
|
||||
|
||||
Providing a memory efficient way for message conversion while allowing user defined types without the cost of iterations.
|
||||
Instead of converting the entire cloud into a `Vec`, you get an iterable type that converts each point from the message on the fly.
|
||||
|
||||
Instead of converting the entire cloud into a `Vec`, you get an `Iterator` that converts each point from the message on the fly.
|
||||
An example for using this crate is [this filter node](https://github.com/stelzo/cloudfilter). It is also a good starting point for
|
||||
implementing ROS1 nodes in Rust inside a catkin environment.
|
||||
|
||||
To keep the crate a general purpose library for the problem and support ROS1 and ROS2, it uses its own type for the message.
|
||||
To keep the crate a general purpose library for the problem and support ROS1 and ROS2, it uses its own type for the message `ros_types::PointCloud2Msg`.
|
||||
```rust
|
||||
use ros_pointcloud2::fallible_iterator::FallibleIterator;
|
||||
use ros_pointcloud2::pcl_utils::PointXYZ;
|
||||
use ros_pointcloud2::ros_types::PointCloud2Msg;
|
||||
use ros_pointcloud2::ConvertXYZ;
|
||||
use ros_pointcloud2::{
|
||||
fallible_iterator::FallibleIterator,
|
||||
pcl_utils::PointXYZ,
|
||||
ros_types::PointCloud2Msg,
|
||||
ConvertXYZ,
|
||||
};
|
||||
|
||||
// Your points (here using the predefined type PointXYZ).
|
||||
let cloud_points = vec![
|
||||
|
|
@ -29,9 +31,9 @@ let cloud_points = vec![
|
|||
},
|
||||
];
|
||||
|
||||
let cloud_copy = cloud_points.clone(); // Only for checking equality later.
|
||||
let cloud_copy = cloud_points.clone(); // For checking equality later.
|
||||
|
||||
// Vector -> Convert -> Message
|
||||
// Vector -> Converter -> Message
|
||||
let internal_msg: PointCloud2Msg = ConvertXYZ::try_from(cloud_points)
|
||||
.unwrap()
|
||||
.try_into()
|
||||
|
|
@ -43,13 +45,14 @@ let internal_msg: PointCloud2Msg = ConvertXYZ::try_from(cloud_points)
|
|||
// Back to this crate's message type.
|
||||
// let internal_msg: PointCloud2Msg = msg.into();
|
||||
|
||||
// Message -> Convert -> Vector
|
||||
// Message -> Converter -> Vector
|
||||
let convert: ConvertXYZ = ConvertXYZ::try_from(internal_msg).unwrap();
|
||||
let new_cloud_points = convert
|
||||
.map(|point: PointXYZ| {
|
||||
// Insert your point business logic here or use other methods like .for_each().
|
||||
// I will just copy the points into a vector as an example.
|
||||
// Also, since we are using a fallible iterator, we need to return a Result.
|
||||
// Insert your point business logic here
|
||||
// or use other methods like .for_each().
|
||||
|
||||
// We are using a fallible iterator so we need to return a Result.
|
||||
Ok(point)
|
||||
})
|
||||
.collect::<Vec<PointXYZ>>()
|
||||
|
|
@ -81,9 +84,13 @@ impl From<YourROSPointCloud2> for PointCloud2Msg {
|
|||
|
||||
## Integrations
|
||||
|
||||
There are currently 2 integrations for common ROS crates such as rosrust for ROS1 and R2R for ROS2 (Galactic).
|
||||
There are currently 2 integrations for common ROS crates such as rosrust for ROS1 and R2R for ROS2.
|
||||
- [rosrust_msg](https://github.com/adnanademovic/rosrust)
|
||||
- [](https://github.com/stelzo/ros_pointcloud2/actions/workflows/rosrust_noetic.yml)
|
||||
- [r2r_msg](https://github.com/sequenceplanner/r2r)
|
||||
- [](https://github.com/stelzo/ros_pointcloud2/actions/workflows/r2r_galactic.yml)
|
||||
- [](https://github.com/stelzo/ros_pointcloud2/actions/workflows/r2r_humble.yml)
|
||||
- [](https://github.com/stelzo/ros_pointcloud2/actions/workflows/r2r_iron.yml)
|
||||
|
||||
You can use them by enabling the corresponding feature. Example:
|
||||
```toml
|
||||
|
|
|
|||
|
|
@ -18,5 +18,5 @@ RUN curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf | bash -s -- -y
|
|||
RUN echo 'source $HOME/.cargo/env' >> $HOME/.bashrc
|
||||
|
||||
COPY . /r2r
|
||||
RUN chmod +x /r2r/tests/r2r_20.04_test.bash
|
||||
ENTRYPOINT [ "/r2r/tests/r2r_20.04_test.bash" ]
|
||||
RUN chmod +x /r2r/tests/r2r_test.bash
|
||||
ENTRYPOINT [ "/r2r/tests/r2r_test.bash" ]
|
||||
|
|
|
|||
|
|
@ -0,0 +1,22 @@
|
|||
# syntax=docker/dockerfile:1
|
||||
FROM ros:humble
|
||||
|
||||
# Update default packages
|
||||
RUN apt-get update
|
||||
|
||||
# Get Ubuntu packages
|
||||
RUN apt-get install -y \
|
||||
build-essential \
|
||||
curl \
|
||||
libclang-dev
|
||||
|
||||
# Get ros test messages
|
||||
RUN apt-get install -y ros-humble-test-msgs ros-humble-example-interfaces
|
||||
|
||||
# Get Rust
|
||||
RUN curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf | bash -s -- -y
|
||||
RUN echo 'source $HOME/.cargo/env' >> $HOME/.bashrc
|
||||
|
||||
COPY . /r2r
|
||||
RUN chmod +x /r2r/tests/r2r_test.bash
|
||||
ENTRYPOINT [ "/r2r/tests/r2r_test.bash" ]
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
# syntax=docker/dockerfile:1
|
||||
FROM ros:iron
|
||||
|
||||
# Update default packages
|
||||
RUN apt-get update
|
||||
|
||||
# Get Ubuntu packages
|
||||
RUN apt-get install -y \
|
||||
build-essential \
|
||||
curl \
|
||||
libclang-dev
|
||||
|
||||
# Get ros test messages
|
||||
RUN apt-get install -y ros-iron-test-msgs ros-iron-example-interfaces
|
||||
|
||||
# Get Rust
|
||||
RUN curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf | bash -s -- -y
|
||||
RUN echo 'source $HOME/.cargo/env' >> $HOME/.bashrc
|
||||
|
||||
COPY . /r2r
|
||||
RUN chmod +x /r2r/tests/r2r_test.bash
|
||||
ENTRYPOINT [ "/r2r/tests/r2r_test.bash" ]
|
||||
|
|
@ -5,6 +5,7 @@ fn convertxyz_r2r_msg() {
|
|||
use ros_pointcloud2::pcl_utils::PointXYZ;
|
||||
use ros_pointcloud2::ros_types::PointCloud2Msg;
|
||||
use ros_pointcloud2::ConvertXYZ;
|
||||
use r2r::sensor_msgs::msg::PointCloud2;
|
||||
|
||||
let cloud = vec![
|
||||
PointXYZ {
|
||||
|
|
@ -25,8 +26,8 @@ fn convertxyz_r2r_msg() {
|
|||
];
|
||||
let copy = cloud.clone();
|
||||
let internal_cloud: PointCloud2Msg = ConvertXYZ::try_from(cloud).unwrap().try_into().unwrap();
|
||||
let rosrust_msg_cloud: r2r::sensor_msgs::msg::PointCloud2 = internal_cloud.into();
|
||||
let convert_back_internal: PointCloud2Msg = rosrust_msg_cloud.into();
|
||||
let r2r_msg_cloud: PointCloud2 = internal_cloud.into();
|
||||
let convert_back_internal: PointCloud2Msg = r2r_msg_cloud.into();
|
||||
let to_convert: ConvertXYZ = ConvertXYZ::try_from(convert_back_internal).unwrap();
|
||||
let back_to_type = to_convert.map(|point| Ok(point)).collect::<Vec<PointXYZ>>();
|
||||
assert_eq!(copy, back_to_type.unwrap());
|
||||
|
|
|
|||
|
|
@ -5,15 +5,17 @@
|
|||
# run rustup to test with latest rust version
|
||||
rustup update
|
||||
|
||||
if [ -e "/opt/ros/iron/setup.bash" ]; then
|
||||
source "/opt/ros/iron/setup.bash"
|
||||
fi
|
||||
|
||||
if [ -e "/opt/ros/humble/setup.bash" ]; then
|
||||
source "/opt/ros/humble/setup.bash"
|
||||
fi
|
||||
|
||||
if [ -e "/opt/ros/galactic/setup.bash" ]; then
|
||||
source "/opt/ros/galactic/setup.bash"
|
||||
fi
|
||||
if [ -e "/opt/ros/foxy/setup.bash" ]; then
|
||||
source "/opt/ros/foxy/setup.bash"
|
||||
fi
|
||||
|
||||
cd /r2r/ || exit
|
||||
|
||||
Loading…
Reference in New Issue