Skip to content

Commit 3c16ba4

Browse files
authored
Split examples and launch files into rclcpp_async_example package (#21)
1 parent 4093b0c commit 3c16ba4

15 files changed

Lines changed: 91 additions & 41 deletions

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ jobs:
1919
run: |
2020
mkdir -p ws/src
2121
ln -s ../../rclcpp_async ws/src/rclcpp_async
22+
ln -s ../../rclcpp_async_example ws/src/rclcpp_async_example
2223
- name: Build and test
2324
run: |
2425
ROS_DISTRO=${{ matrix.ros_distro }} ./run.sh bash -c \

README.md

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
# rclcpp_async
22

3-
[![CI](https://github.com/otamachan/rclcpp_async/actions/workflows/ci.yml/badge.svg)](https://github.com/otamachan/rclcpp_async/actions/workflows/ci.yml)
4-
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
5-
![C++20](https://img.shields.io/badge/C%2B%2B-20-blue.svg)
6-
![ROS 2 Jazzy](https://img.shields.io/badge/ROS%202-Jazzy-blue.svg)
7-
![ROS 2 Rolling](https://img.shields.io/badge/ROS%202-Rolling-blue.svg)
8-
93
A header-only C++20 coroutine library that brings `async/await` to ROS 2, inspired by [icey](https://github.com/iv461/icey).
104

115
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.
@@ -555,7 +549,7 @@ Task<void> run(CoContext & ctx)
555549
556550
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.
557551
558-
See [`example/nested_demo.cpp`](rclcpp_async/example/nested_demo.cpp) for a full demonstration.
552+
See [`nested_demo.cpp`](rclcpp_async_example/src/nested_demo.cpp) for a full demonstration.
559553
560554
## API Reference
561555

rclcpp_async/CMakeLists.txt

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -60,32 +60,6 @@ if(BUILD_TESTING)
6060
find_package(std_srvs REQUIRED)
6161
find_package(example_interfaces REQUIRED)
6262

63-
# Examples
64-
add_executable(demo_server example/demo_server.cpp)
65-
target_link_libraries(demo_server ${PROJECT_NAME}
66-
${std_msgs_TARGETS} ${std_srvs_TARGETS} ${example_interfaces_TARGETS})
67-
68-
add_executable(subscriber example/subscriber.cpp)
69-
target_link_libraries(subscriber ${PROJECT_NAME} ${std_msgs_TARGETS})
70-
71-
add_executable(service_client example/service_client.cpp)
72-
target_link_libraries(service_client ${PROJECT_NAME} ${std_srvs_TARGETS})
73-
74-
add_executable(action_client example/action_client.cpp)
75-
target_link_libraries(action_client ${PROJECT_NAME} ${example_interfaces_TARGETS})
76-
77-
add_executable(nested_demo example/nested_demo.cpp)
78-
target_link_libraries(nested_demo ${PROJECT_NAME}
79-
${std_srvs_TARGETS} ${example_interfaces_TARGETS})
80-
81-
install(TARGETS demo_server subscriber service_client action_client nested_demo
82-
DESTINATION lib/${PROJECT_NAME}
83-
)
84-
85-
install(DIRECTORY launch/
86-
DESTINATION share/${PROJECT_NAME}/launch
87-
)
88-
8963
# Level 1: Pure unit tests (no ROS2 runtime)
9064
ament_add_gtest(test_result test/test_result.cpp)
9165
target_link_libraries(test_result ${PROJECT_NAME})

rclcpp_async/package.xml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
<test_depend>std_msgs</test_depend>
2323
<test_depend>std_srvs</test_depend>
2424
<test_depend>example_interfaces</test_depend>
25-
<test_depend>ros2launch</test_depend>
26-
2725
<export>
2826
<build_type>ament_cmake</build_type>
2927
</export>
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
cmake_minimum_required(VERSION 3.14)
2+
project(rclcpp_async_example)
3+
4+
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
5+
6+
if(NOT CMAKE_CXX_STANDARD)
7+
set(CMAKE_CXX_STANDARD 20)
8+
endif()
9+
10+
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
11+
add_compile_options(-Wall -Wextra -Wpedantic -Werror=deprecated-declarations -fcoroutines)
12+
endif()
13+
14+
find_package(ament_cmake REQUIRED)
15+
find_package(rclcpp REQUIRED)
16+
find_package(rclcpp_action REQUIRED)
17+
find_package(rclcpp_async REQUIRED)
18+
find_package(std_msgs REQUIRED)
19+
find_package(std_srvs REQUIRED)
20+
find_package(example_interfaces REQUIRED)
21+
22+
add_executable(demo_server src/demo_server.cpp)
23+
target_link_libraries(demo_server rclcpp_async::rclcpp_async
24+
${std_msgs_TARGETS} ${std_srvs_TARGETS} ${example_interfaces_TARGETS})
25+
26+
add_executable(subscriber src/subscriber.cpp)
27+
target_link_libraries(subscriber rclcpp_async::rclcpp_async ${std_msgs_TARGETS})
28+
29+
add_executable(service_client src/service_client.cpp)
30+
target_link_libraries(service_client rclcpp_async::rclcpp_async ${std_srvs_TARGETS})
31+
32+
add_executable(action_client src/action_client.cpp)
33+
target_link_libraries(action_client rclcpp_async::rclcpp_async ${example_interfaces_TARGETS})
34+
35+
add_executable(nested_demo src/nested_demo.cpp)
36+
target_link_libraries(nested_demo rclcpp_async::rclcpp_async
37+
${std_srvs_TARGETS} ${example_interfaces_TARGETS})
38+
39+
install(TARGETS demo_server subscriber service_client action_client nested_demo
40+
DESTINATION lib/${PROJECT_NAME}
41+
)
42+
43+
install(DIRECTORY launch/
44+
DESTINATION share/${PROJECT_NAME}/launch
45+
)
46+
47+
if(BUILD_TESTING)
48+
find_package(ament_lint_auto REQUIRED)
49+
set(AMENT_LINT_AUTO_EXCLUDE ament_cmake_uncrustify ament_cmake_cppcheck)
50+
ament_lint_auto_find_test_dependencies()
51+
endif()
52+
53+
ament_package()

rclcpp_async_example/CPPLINT.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
filter=-build/include_order

rclcpp_async/launch/action_demo.launch.py renamed to rclcpp_async_example/launch/action_demo.launch.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@
1919
def generate_launch_description():
2020
return LaunchDescription([
2121
Node(
22-
package='rclcpp_async',
22+
package='rclcpp_async_example',
2323
executable='demo_server',
2424
name='demo_server',
2525
output='screen',
2626
),
2727
Node(
28-
package='rclcpp_async',
28+
package='rclcpp_async_example',
2929
executable='action_client',
3030
name='action_client',
3131
output='screen',

rclcpp_async/launch/service_demo.launch.py renamed to rclcpp_async_example/launch/service_demo.launch.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@
1919
def generate_launch_description():
2020
return LaunchDescription([
2121
Node(
22-
package='rclcpp_async',
22+
package='rclcpp_async_example',
2323
executable='demo_server',
2424
name='demo_server',
2525
output='screen',
2626
),
2727
Node(
28-
package='rclcpp_async',
28+
package='rclcpp_async_example',
2929
executable='service_client',
3030
name='service_client',
3131
output='screen',

rclcpp_async/launch/subscriber_demo.launch.py renamed to rclcpp_async_example/launch/subscriber_demo.launch.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@
1919
def generate_launch_description():
2020
return LaunchDescription([
2121
Node(
22-
package='rclcpp_async',
22+
package='rclcpp_async_example',
2323
executable='demo_server',
2424
name='demo_server',
2525
output='screen',
2626
),
2727
Node(
28-
package='rclcpp_async',
28+
package='rclcpp_async_example',
2929
executable='subscriber',
3030
name='async_subscriber',
3131
output='screen',

rclcpp_async_example/package.xml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?xml version="1.0"?>
2+
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
3+
<package format="3">
4+
<name>rclcpp_async_example</name>
5+
<version>0.1.0</version>
6+
<description>Example programs demonstrating rclcpp_async usage</description>
7+
<maintainer email="nishino@todo.todo">nishino</maintainer>
8+
<license>Apache-2.0</license>
9+
10+
<buildtool_depend>ament_cmake</buildtool_depend>
11+
12+
<depend>rclcpp</depend>
13+
<depend>rclcpp_action</depend>
14+
<depend>rclcpp_async</depend>
15+
<depend>std_msgs</depend>
16+
<depend>std_srvs</depend>
17+
<depend>example_interfaces</depend>
18+
19+
<exec_depend>ros2launch</exec_depend>
20+
21+
<test_depend>ament_lint_auto</test_depend>
22+
<test_depend>ament_lint_common</test_depend>
23+
<test_depend>ament_cmake_clang_tidy</test_depend>
24+
<test_depend>ament_cmake_clang_format</test_depend>
25+
26+
<export>
27+
<build_type>ament_cmake</build_type>
28+
</export>
29+
</package>

0 commit comments

Comments
 (0)