Skip to content
Merged
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
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jobs:
run: |
mkdir -p ws/src
ln -s ../../rclcpp_async ws/src/rclcpp_async
ln -s ../../rclcpp_async_example ws/src/rclcpp_async_example
- name: Build and test
run: |
ROS_DISTRO=${{ matrix.ros_distro }} ./run.sh bash -c \
Expand Down
8 changes: 1 addition & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
# rclcpp_async

[![CI](https://github.com/otamachan/rclcpp_async/actions/workflows/ci.yml/badge.svg)](https://github.com/otamachan/rclcpp_async/actions/workflows/ci.yml)
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
![C++20](https://img.shields.io/badge/C%2B%2B-20-blue.svg)
![ROS 2 Jazzy](https://img.shields.io/badge/ROS%202-Jazzy-blue.svg)
![ROS 2 Rolling](https://img.shields.io/badge/ROS%202-Rolling-blue.svg)

A header-only C++20 coroutine library that brings `async/await` to ROS 2, inspired by [icey](https://github.com/iv461/icey).

Write asynchronous ROS 2 code that reads like sequential code -- no callback nesting, no deadlocks, no `std::mutex`, no state machines -- all on a single-threaded executor.
Expand Down Expand Up @@ -555,7 +549,7 @@ Task<void> run(CoContext & ctx)

A key advantage of coroutine-based I/O: nested service calls work without deadlocks, even on a single-threaded executor. For example, a service handler can `co_await` another service call, which can itself call yet another service -- all on the same thread.

See [`example/nested_demo.cpp`](rclcpp_async/example/nested_demo.cpp) for a full demonstration.
See [`nested_demo.cpp`](rclcpp_async_example/src/nested_demo.cpp) for a full demonstration.

## API Reference

Expand Down
26 changes: 0 additions & 26 deletions rclcpp_async/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,32 +60,6 @@ if(BUILD_TESTING)
find_package(std_srvs REQUIRED)
find_package(example_interfaces REQUIRED)

# Examples
add_executable(demo_server example/demo_server.cpp)
target_link_libraries(demo_server ${PROJECT_NAME}
${std_msgs_TARGETS} ${std_srvs_TARGETS} ${example_interfaces_TARGETS})

add_executable(subscriber example/subscriber.cpp)
target_link_libraries(subscriber ${PROJECT_NAME} ${std_msgs_TARGETS})

add_executable(service_client example/service_client.cpp)
target_link_libraries(service_client ${PROJECT_NAME} ${std_srvs_TARGETS})

add_executable(action_client example/action_client.cpp)
target_link_libraries(action_client ${PROJECT_NAME} ${example_interfaces_TARGETS})

add_executable(nested_demo example/nested_demo.cpp)
target_link_libraries(nested_demo ${PROJECT_NAME}
${std_srvs_TARGETS} ${example_interfaces_TARGETS})

install(TARGETS demo_server subscriber service_client action_client nested_demo
DESTINATION lib/${PROJECT_NAME}
)

install(DIRECTORY launch/
DESTINATION share/${PROJECT_NAME}/launch
)

# Level 1: Pure unit tests (no ROS2 runtime)
ament_add_gtest(test_result test/test_result.cpp)
target_link_libraries(test_result ${PROJECT_NAME})
Expand Down
2 changes: 0 additions & 2 deletions rclcpp_async/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
<test_depend>std_msgs</test_depend>
<test_depend>std_srvs</test_depend>
<test_depend>example_interfaces</test_depend>
<test_depend>ros2launch</test_depend>

<export>
<build_type>ament_cmake</build_type>
</export>
Expand Down
53 changes: 53 additions & 0 deletions rclcpp_async_example/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
cmake_minimum_required(VERSION 3.14)
project(rclcpp_async_example)

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 20)
endif()

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic -Werror=deprecated-declarations -fcoroutines)
endif()

find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(rclcpp_action REQUIRED)
find_package(rclcpp_async REQUIRED)
find_package(std_msgs REQUIRED)
find_package(std_srvs REQUIRED)
find_package(example_interfaces REQUIRED)

add_executable(demo_server src/demo_server.cpp)
target_link_libraries(demo_server rclcpp_async::rclcpp_async
${std_msgs_TARGETS} ${std_srvs_TARGETS} ${example_interfaces_TARGETS})

add_executable(subscriber src/subscriber.cpp)
target_link_libraries(subscriber rclcpp_async::rclcpp_async ${std_msgs_TARGETS})

add_executable(service_client src/service_client.cpp)
target_link_libraries(service_client rclcpp_async::rclcpp_async ${std_srvs_TARGETS})

add_executable(action_client src/action_client.cpp)
target_link_libraries(action_client rclcpp_async::rclcpp_async ${example_interfaces_TARGETS})

add_executable(nested_demo src/nested_demo.cpp)
target_link_libraries(nested_demo rclcpp_async::rclcpp_async
${std_srvs_TARGETS} ${example_interfaces_TARGETS})

install(TARGETS demo_server subscriber service_client action_client nested_demo
DESTINATION lib/${PROJECT_NAME}
)

install(DIRECTORY launch/
DESTINATION share/${PROJECT_NAME}/launch
)

if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
set(AMENT_LINT_AUTO_EXCLUDE ament_cmake_uncrustify ament_cmake_cppcheck)
ament_lint_auto_find_test_dependencies()
endif()

ament_package()
1 change: 1 addition & 0 deletions rclcpp_async_example/CPPLINT.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
filter=-build/include_order
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
def generate_launch_description():
return LaunchDescription([
Node(
package='rclcpp_async',
package='rclcpp_async_example',
executable='demo_server',
name='demo_server',
output='screen',
),
Node(
package='rclcpp_async',
package='rclcpp_async_example',
executable='action_client',
name='action_client',
output='screen',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
def generate_launch_description():
return LaunchDescription([
Node(
package='rclcpp_async',
package='rclcpp_async_example',
executable='demo_server',
name='demo_server',
output='screen',
),
Node(
package='rclcpp_async',
package='rclcpp_async_example',
executable='service_client',
name='service_client',
output='screen',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
def generate_launch_description():
return LaunchDescription([
Node(
package='rclcpp_async',
package='rclcpp_async_example',
executable='demo_server',
name='demo_server',
output='screen',
),
Node(
package='rclcpp_async',
package='rclcpp_async_example',
executable='subscriber',
name='async_subscriber',
output='screen',
Expand Down
29 changes: 29 additions & 0 deletions rclcpp_async_example/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>rclcpp_async_example</name>
<version>0.1.0</version>
<description>Example programs demonstrating rclcpp_async usage</description>
<maintainer email="nishino@todo.todo">nishino</maintainer>
<license>Apache-2.0</license>

<buildtool_depend>ament_cmake</buildtool_depend>

<depend>rclcpp</depend>
<depend>rclcpp_action</depend>
<depend>rclcpp_async</depend>
<depend>std_msgs</depend>
<depend>std_srvs</depend>
<depend>example_interfaces</depend>

<exec_depend>ros2launch</exec_depend>

<test_depend>ament_lint_auto</test_depend>
<test_depend>ament_lint_common</test_depend>
<test_depend>ament_cmake_clang_tidy</test_depend>
<test_depend>ament_cmake_clang_format</test_depend>

<export>
<build_type>ament_cmake</build_type>
</export>
</package>