Skip to content

Commit 640d091

Browse files
committed
Fix merge conflicts
Signed-off-by: Michael X. Grey <[email protected]>
2 parents a872cd6 + c463201 commit 640d091

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+2364
-4118
lines changed

.github/workflows/rust-minimal.yml

+7-12
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,12 @@ jobs:
2020
matrix:
2121
ros_distribution:
2222
- humble
23-
- iron
2423
- rolling
2524
include:
2625
# Humble Hawksbill (May 2022 - May 2027)
2726
- docker_image: rostooling/setup-ros-docker:ubuntu-jammy-ros-humble-ros-base-latest
2827
ros_distribution: humble
2928
ros_version: 2
30-
# Iron Irwini (May 2023 - November 2024)
31-
- docker_image: rostooling/setup-ros-docker:ubuntu-jammy-ros-iron-ros-base-latest
32-
ros_distribution: iron
33-
ros_version: 2
3429
# Rolling Ridley (June 2020 - Present)
3530
- docker_image: rostooling/setup-ros-docker:ubuntu-jammy-ros-rolling-ros-base-latest
3631
ros_distribution: rolling
@@ -45,7 +40,11 @@ jobs:
4540
- name: Search packages in this repository
4641
id: list_packages
4742
run: |
48-
echo ::set-output name=package_list::$(colcon list --names-only)
43+
{
44+
echo 'package_list<<EOF'
45+
colcon list --names-only
46+
echo EOF
47+
} >> "$GITHUB_OUTPUT"
4948
5049
- name: Setup ROS environment
5150
uses: ros-tooling/[email protected]
@@ -72,10 +71,6 @@ jobs:
7271
cd -
7372
done
7473
75-
- name: Install cargo-ament-build
76-
run: |
77-
cargo install --debug cargo-ament-build
78-
7974
- name: Build and test
8075
id: build
8176
uses: ros-tooling/[email protected]
@@ -93,9 +88,9 @@ jobs:
9388
echo "Running clippy in $path"
9489
# Run clippy for all features except generate_docs (needed for docs.rs)
9590
if [ "$(basename $path)" = "rclrs" ]; then
96-
cargo clippy --all-targets -F default,dyn_msg -- -D warnings
91+
cargo clippy --no-deps --all-targets -F default,dyn_msg -- -D warnings
9792
else
98-
cargo clippy --all-targets --all-features -- -D warnings
93+
cargo clippy --no-deps --all-targets --all-features -- -D warnings
9994
fi
10095
cd -
10196
done

.github/workflows/rust-stable.yml

+7-12
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,12 @@ jobs:
2020
matrix:
2121
ros_distribution:
2222
- humble
23-
- iron
2423
- rolling
2524
include:
2625
# Humble Hawksbill (May 2022 - May 2027)
2726
- docker_image: rostooling/setup-ros-docker:ubuntu-jammy-ros-humble-ros-base-latest
2827
ros_distribution: humble
2928
ros_version: 2
30-
# Iron Irwini (May 2023 - November 2024)
31-
- docker_image: rostooling/setup-ros-docker:ubuntu-jammy-ros-iron-ros-base-latest
32-
ros_distribution: iron
33-
ros_version: 2
3429
# Rolling Ridley (June 2020 - Present)
3530
- docker_image: rostooling/setup-ros-docker:ubuntu-jammy-ros-rolling-ros-base-latest
3631
ros_distribution: rolling
@@ -45,7 +40,11 @@ jobs:
4540
- name: Search packages in this repository
4641
id: list_packages
4742
run: |
48-
echo ::set-output name=package_list::$(colcon list --names-only)
43+
{
44+
echo 'package_list<<EOF'
45+
colcon list --names-only
46+
echo EOF
47+
} >> "$GITHUB_OUTPUT"
4948
5049
- name: Setup ROS environment
5150
uses: ros-tooling/[email protected]
@@ -72,10 +71,6 @@ jobs:
7271
cd -
7372
done
7473
75-
- name: Install cargo-ament-build
76-
run: |
77-
cargo install --debug cargo-ament-build
78-
7974
- name: Build and test
8075
id: build
8176
uses: ros-tooling/[email protected]
@@ -93,9 +88,9 @@ jobs:
9388
echo "Running clippy in $path"
9489
# Run clippy for all features except generate_docs (needed for docs.rs)
9590
if [ "$(basename $path)" = "rclrs" ]; then
96-
cargo clippy --all-targets -F default,dyn_msg -- -D warnings
91+
cargo clippy --no-deps --all-targets -F default,dyn_msg -- -D warnings
9792
else
98-
cargo clippy --all-targets --all-features -- -D warnings
93+
cargo clippy --no-deps --all-targets --all-features -- -D warnings
9994
fi
10095
cd -
10196
done

Dockerfile

+6-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
ARG ROS_DISTRO=humble
2-
FROM ros:$ROS_DISTRO as base
2+
FROM ros:$ROS_DISTRO AS base
33
ARG DEBIAN_FRONTEND=noninteractive
44

55
# Install dependencies
@@ -11,15 +11,14 @@ RUN apt-get update && apt-get install -y \
1111
python3-pip \
1212
&& rm -rf /var/lib/apt/lists/*
1313

14-
# Install Rust and the cargo-ament-build plugin
15-
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --default-toolchain 1.74.0 -y
14+
# Install Rust
15+
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --default-toolchain 1.75.0 -y
1616
ENV PATH=/root/.cargo/bin:$PATH
17-
RUN cargo install cargo-ament-build
18-
19-
RUN pip install --upgrade pytest
2017

2118
# Install the colcon-cargo and colcon-ros-cargo plugins
22-
RUN pip install git+https://github.com/colcon/colcon-cargo.git git+https://github.com/colcon/colcon-ros-cargo.git
19+
RUN if [ "$ROS_DISTRO" = "humble" ] ; \
20+
then pip install --upgrade pytest && pip install colcon-ros-cargo ; \
21+
else pip install --break-system-packages pytest colcon-ros-cargo ; fi
2322

2423
RUN mkdir -p /workspace && echo "Did you forget to mount the repository into the Docker container?" > /workspace/HELLO.txt
2524
WORKDIR /workspace

README.md

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
11
ROS 2 for Rust
22
==============
33

4-
| Target | Status |
5-
|----------|--------|
6-
| **Ubuntu 20.04** | [![Build Status](https://github.com/ros2-rust/ros2_rust/actions/workflows/rust.yml/badge.svg?branch=main)](https://github.com/ros2-rust/ros2_rust/actions/workflows/rust.yml?branch=main) |
4+
[![Minimal Version Status](https://github.com/ros2-rust/ros2_rust/actions/workflows/rust-minimal.yml/badge.svg?branch=main)](https://github.com/ros2-rust/ros2_rust/actions/workflows/rust-minimal.yml)
5+
[![Stable CI Status](https://github.com/ros2-rust/ros2_rust/actions/workflows/rust-stable.yml/badge.svg?branch=main)](https://github.com/ros2-rust/ros2_rust/actions/workflows/rust-stable.yml)
6+
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
77

88
Introduction
99
------------
1010

1111
This is a set of projects (the `rclrs` client library, code generator, examples and more) that
1212
enables developers to write ROS 2 applications in Rust.
1313

14+
Installation
15+
------------
16+
17+
Follow the [instructions in the documentation directory](docs/building.md).
18+
1419
Features and limitations
1520
------------------------
1621

@@ -37,7 +42,6 @@ Here are the steps for building the `ros2_rust` examples in a vanilla Ubuntu Foc
3742
# Assuming you installed the minimal version of ROS 2, you need these additional packages:
3843
sudo apt install -y git libclang-dev python3-pip python3-vcstool # libclang-dev is required by bindgen
3944
# Install these plugins for cargo and colcon:
40-
cargo install --debug cargo-ament-build # --debug is faster to install
4145
pip install git+https://github.com/colcon/colcon-cargo.git
4246
pip install git+https://github.com/colcon/colcon-ros-cargo.git
4347

docs/building.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ The exact steps may differ between platforms, but as an example, here is how you
4343
# Assuming you installed the minimal version of ROS 2, you need these additional packages:
4444
sudo apt install -y git libclang-dev python3-pip python3-vcstool # libclang-dev is required by bindgen
4545
# Install these plugins for cargo and colcon:
46-
cargo install cargo-ament-build
4746
pip install git+https://github.com/colcon/colcon-cargo.git
4847
pip install git+https://github.com/colcon/colcon-ros-cargo.git
4948
```
@@ -54,8 +53,8 @@ Build the Docker image with
5453

5554
```shell
5655
# Make sure to run this in the workspace directory
57-
# ROS_DISTRO can be humble|iron|rolling
58-
docker build -f src/ros2_rust/Dockerfile --build-arg "ROS_DISTRO=humble" -t ros2_rust_dev
56+
# ROS_DISTRO can be humble|rolling
57+
docker build -f src/ros2_rust/Dockerfile --build-arg "ROS_DISTRO=humble" -t ros2_rust_dev .
5958
```
6059

6160
and then run it with

docs/writing_a_simple_publisher_and_subscriber.md

+3-4
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ To construct a node, replace the code in your `main.rs` file with the following:
9292
```rust
9393
/// Creates a SimplePublisherNode, initializes a node and publisher, and provides
9494
/// methods to publish a simple "Hello World" message on a loop in separate threads.
95-
9695
use rclrs::{create_node, Context, Node, Publisher, RclrsError, QOS_PROFILE_DEFAULT};
9796
use std::{env, sync::Arc, thread, time::Duration};
9897
use std_msgs::msg::String as StringMsg;
@@ -103,12 +102,12 @@ struct SimplePublisherNode {
103102
publisher: Arc<Publisher<StringMsg>>,
104103
}
105104
impl SimplePublisherNode {
106-
fn new(context: &context) -> result<self, RclrsError> {
105+
fn new(context: &Context) -> Result<Self, RclrsError> {
107106
let node = create_node(context, "simple_publisher").unwrap();
108107
let publisher = node
109-
.create_publisher("publish_hello", qos_profile_default)
108+
.create_publisher("publish_hello", QOS_PROFILE_DEFAULT)
110109
.unwrap();
111-
ok(self { node, publisher })
110+
Ok(Self { node, publisher })
112111
}
113112
fn publish_data(&self, increment: i32) -> Result<i32, RclrsError> {
114113
let msg: StringMsg = StringMsg {

examples/message_demo/src/message_demo.rs

+8-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
use std::{convert::TryInto, env, sync::Arc};
1+
use std::convert::TryInto;
22

33
use anyhow::{Error, Result};
44
use rosidl_runtime_rs::{seq, BoundedSequence, Message, Sequence};
55

6+
use rclrs::*;
7+
68
fn check_default_values() {
79
let msg = rclrs_example_msgs::msg::rmw::VariousTypes::default();
810
assert!(msg.bool_member);
@@ -15,7 +17,7 @@ fn check_default_values() {
1517
assert_eq!(msg.float_seq_unbounded, seq![6.0]);
1618
assert_eq!(msg.string_member.to_string(), "Χαίρετε 你好");
1719
assert_eq!(msg.wstring_member.to_string(), "αντίο σου 再见");
18-
assert_eq!(msg.bounded_string_member.to_string(), "äöü");
20+
assert_eq!(msg.bounded_string_member.to_string(), "aou");
1921
assert_eq!(msg.bounded_wstring_member.to_string(), "äöü");
2022
assert_eq!(
2123
msg.string_array.clone().map(|s| s.to_string()),
@@ -138,8 +140,8 @@ fn demonstrate_sequences() {
138140
fn demonstrate_pubsub() -> Result<(), Error> {
139141
println!("================== Interoperability demo ==================");
140142
// Demonstrate interoperability between idiomatic and RMW-native message types
141-
let context = rclrs::Context::new(env::args())?;
142-
let node = rclrs::create_node(&context, "message_demo")?;
143+
let mut executor = Context::default_from_env()?.create_basic_executor();
144+
let node = executor.create_node("message_demo")?;
143145

144146
let idiomatic_publisher =
145147
node.create_publisher::<rclrs_example_msgs::msg::VariousTypes>("topic")?;
@@ -160,10 +162,10 @@ fn demonstrate_pubsub() -> Result<(), Error> {
160162
)?;
161163
println!("Sending idiomatic message.");
162164
idiomatic_publisher.publish(rclrs_example_msgs::msg::VariousTypes::default())?;
163-
rclrs::spin_once(Arc::clone(&node), None)?;
165+
executor.spin(SpinOptions::spin_once()).first_error()?;
164166
println!("Sending RMW-native message.");
165167
direct_publisher.publish(rclrs_example_msgs::msg::rmw::VariousTypes::default())?;
166-
rclrs::spin_once(Arc::clone(&node), None)?;
168+
executor.spin(SpinOptions::spin_once()).first_error()?;
167169

168170
Ok(())
169171
}

examples/minimal_client_service/src/minimal_client.rs

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
use std::env;
2-
31
use anyhow::{Error, Result};
2+
use rclrs::*;
43

54
fn main() -> Result<(), Error> {
6-
let context = rclrs::Context::new(env::args())?;
5+
let mut executor = Context::default_from_env()?.create_basic_executor();
76

8-
let node = rclrs::create_node(&context, "minimal_client")?;
7+
let node = executor.create_node("minimal_client")?;
98

109
let client = node.create_client::<example_interfaces::srv::AddTwoInts>("add_two_ints")?;
1110

@@ -30,5 +29,8 @@ fn main() -> Result<(), Error> {
3029
std::thread::sleep(std::time::Duration::from_millis(500));
3130

3231
println!("Waiting for response");
33-
rclrs::spin(node).map_err(|err| err.into())
32+
executor
33+
.spin(SpinOptions::default())
34+
.first_error()
35+
.map_err(|err| err.into())
3436
}

examples/minimal_client_service/src/minimal_client_async.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
use std::env;
2-
31
use anyhow::{Error, Result};
2+
use rclrs::*;
43

54
#[tokio::main]
65
async fn main() -> Result<(), Error> {
7-
let context = rclrs::Context::new(env::args())?;
6+
let mut executor = Context::default_from_env()?.create_basic_executor();
87

9-
let node = rclrs::create_node(&context, "minimal_client")?;
8+
let node = executor.create_node("minimal_client")?;
109

1110
let client = node.create_client::<example_interfaces::srv::AddTwoInts>("add_two_ints")?;
1211

@@ -22,7 +21,7 @@ async fn main() -> Result<(), Error> {
2221

2322
println!("Waiting for response");
2423

25-
let rclrs_spin = tokio::task::spawn_blocking(move || rclrs::spin(node));
24+
let rclrs_spin = tokio::task::spawn_blocking(move || executor.spin(SpinOptions::default()));
2625

2726
let response = future.await?;
2827
println!(
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
use std::env;
2-
31
use anyhow::{Error, Result};
2+
use rclrs::*;
43

54
fn handle_service(
65
_request_header: &rclrs::rmw_request_id_t,
@@ -13,13 +12,16 @@ fn handle_service(
1312
}
1413

1514
fn main() -> Result<(), Error> {
16-
let context = rclrs::Context::new(env::args())?;
15+
let mut executor = Context::default_from_env()?.create_basic_executor();
1716

18-
let node = rclrs::create_node(&context, "minimal_service")?;
17+
let node = executor.create_node("minimal_service")?;
1918

2019
let _server = node
2120
.create_service::<example_interfaces::srv::AddTwoInts, _>("add_two_ints", handle_service)?;
2221

2322
println!("Starting server");
24-
rclrs::spin(node).map_err(|err| err.into())
23+
executor
24+
.spin(SpinOptions::default())
25+
.first_error()
26+
.map_err(|err| err.into())
2527
}

examples/minimal_pub_sub/src/minimal_publisher.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
use std::env;
2-
31
use anyhow::{Error, Result};
2+
use rclrs::*;
43

54
fn main() -> Result<(), Error> {
6-
let context = rclrs::Context::new(env::args())?;
5+
let context = Context::default_from_env()?;
6+
let executor = context.create_basic_executor();
77

8-
let node = rclrs::create_node(&context, "minimal_publisher")?;
8+
let node = executor.create_node("minimal_publisher")?;
99

1010
let publisher = node.create_publisher::<std_msgs::msg::String>("topic")?;
1111

Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
use std::env;
2-
31
use anyhow::{Error, Result};
2+
use rclrs::*;
43

54
fn main() -> Result<(), Error> {
6-
let context = rclrs::Context::new(env::args())?;
5+
let context = Context::default_from_env()?;
6+
let mut executor = context.create_basic_executor();
77

8-
let node = rclrs::create_node(&context, "minimal_subscriber")?;
8+
let node = executor.create_node("minimal_subscriber")?;
99

1010
let mut num_messages: usize = 0;
1111

@@ -18,5 +18,8 @@ fn main() -> Result<(), Error> {
1818
},
1919
)?;
2020

21-
rclrs::spin(node).map_err(|err| err.into())
21+
executor
22+
.spin(SpinOptions::default())
23+
.first_error()
24+
.map_err(|err| err.into())
2225
}

0 commit comments

Comments
 (0)