Skip to content

Commit

Permalink
Backport Python Actions (#282)
Browse files Browse the repository at this point in the history
* Add Action Client (#262)

* Add rclpy_action module

With functions for creating and destroying action clients.

* Implement action client

* Move common conversion function and typedefs to shared header file (impl/common.h)

* Add tests using mock action server

* Add action module for aggregating action related submodules

* Extend Waitable API so executors are aware of Futures

* Move check_for_type_support() to its own module

Signed-off-by: Jacob Perron <[email protected]>

* Fix Executor not executing tasks if there are no ready entities in the wait set (#272)

If a task is created, then trigger the Executors guard condition. This will wake any blocking call to `rcl_wait()`.
In this scenario, no work is yielded, so we also have to move the check for 'in-progress' tasks into the wait loop.

Added a unit test to reproduce the issue.

This resolves an issue in some cases where the result response from the action server is never processed, therefore never reaching the action client.

Signed-off-by: Jacob Perron <[email protected]>

* Fix Node's reference to executor (#275)

Previously, if a `Node` was added to an `Executor` using the executors `add_node` method, then nodes `executor` property would return `None`.

Signed-off-by: Jacob Perron <[email protected]>

* Abstract type conversions into functions (#269)

* Abstract type conversions into functions

This helps with readability and maintainability.
Also eliminated use of assertions during conversions, defering to exceptions.

* Move common C functions to a shared library 'rclpy_common'

Signed-off-by: Jacob Perron <[email protected]>

* Add ActionServer (#270)

* Add Action server functions to extension module
    * Separated service related macros into separate request and response calls
* Add server goal handle functions to extension module
* Update Action extension module to use conversion functions
* Add implementation of Python ActionServer
    * Handles goal and cancel requests, responds, and calls user-defined functions for executing goals.
    * Handle result requests
    * Handle expired goals
    * Publish goal status array and feedback
* Add `handle_accepted_callback` to ActionServer

Upon accepting a goal, the provided `handle_accepted_callback` is called with a reference to the goal handle.
The user can then decide to execute the goal or defer.
If `handle_accepted_callback` is not provided, then the default behavior is to execute the goal handle immediately.

Signed-off-by: Jacob Perron <[email protected]>

* Enable test using MultiThreadedExecutor (#280)

Signed-off-by: Jacob Perron <[email protected]>

* Guard against failed take when taking action messages (#281)

Some middlewares (e.g. Connext and OpenSplice) send invalid messages to indicate an instance has been disposed which results in a 'failed take'.

Signed-off-by: Jacob Perron <[email protected]>
  • Loading branch information
jacobperron authored and nuclearsandwich committed Mar 10, 2019
1 parent f5c20af commit c8dca03
Show file tree
Hide file tree
Showing 20 changed files with 4,470 additions and 237 deletions.
45 changes: 45 additions & 0 deletions rclpy/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ endif()
find_package(ament_cmake REQUIRED)
find_package(ament_cmake_python REQUIRED)
find_package(rcl REQUIRED)
find_package(rcl_action REQUIRED)
find_package(rcl_yaml_param_parser REQUIRED)
find_package(rcutils REQUIRED)
find_package(rmw REQUIRED)
Expand Down Expand Up @@ -71,17 +72,61 @@ function(configure_python_c_extension_library _library_name)
)
endfunction()

add_library(rclpy_common
SHARED src/rclpy_common/src/common.c
)
target_link_libraries(rclpy_common
${PythonExtra_LIBRARIES}
)
target_include_directories(rclpy_common
PUBLIC
src/rclpy_common/include
${PythonExtra_INCLUDE_DIRS}
)
ament_target_dependencies(rclpy_common
"rmw"
)

# Causes the visibility macros to use dllexport rather than dllimport,
# which is appropriate when building the dll but not consuming it.
target_compile_definitions(rclpy_common PRIVATE "RCLPY_COMMON_BUILDING_DLL")

install(TARGETS rclpy_common
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
)

add_library(
rclpy
SHARED src/rclpy/_rclpy.c
)
target_link_libraries(rclpy
rclpy_common
)

configure_python_c_extension_library(rclpy)
ament_target_dependencies(rclpy
"rcl"
"rcl_yaml_param_parser"
"rcutils"
)

add_library(
rclpy_action
SHARED src/rclpy/_rclpy_action.c
)
target_link_libraries(rclpy_action
rclpy_common
)

configure_python_c_extension_library(rclpy_action)
ament_target_dependencies(rclpy_action
"rcl"
"rcl_action"
"rcutils"
)

# Logging support provided by rcutils
add_library(
rclpy_logging
Expand Down
2 changes: 2 additions & 0 deletions rclpy/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@

<depend>rmw_implementation</depend>
<depend>rcl</depend>
<depend>rcl_action</depend>
<depend>rcl_yaml_param_parser</depend>
<depend>unique_identifier_msgs</depend>

<exec_depend>ament_index_python</exec_depend>
<exec_depend>builtin_interfaces</exec_depend>
Expand Down
16 changes: 16 additions & 0 deletions rclpy/rclpy/action/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright 2019 Open Source Robotics Foundation, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from .client import ActionClient # noqa
from .server import ActionServer, CancelResponse, GoalResponse # noqa
Loading

0 comments on commit c8dca03

Please sign in to comment.