Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Action client implementation #319

Merged
merged 11 commits into from
Nov 15, 2018
14 changes: 14 additions & 0 deletions rcl_action/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ add_executable(test_compile_headers
)

set(rcl_action_sources
src/${PROJECT_NAME}/action_client.c
src/${PROJECT_NAME}/goal_handle.c
src/${PROJECT_NAME}/goal_state_machine.c
src/${PROJECT_NAME}/names.c
Expand Down Expand Up @@ -69,9 +70,22 @@ install(TARGETS ${PROJECT_NAME}
if(BUILD_TESTING)
find_package(ament_cmake_gtest REQUIRED)
find_package(ament_lint_auto REQUIRED)
find_package(test_msgs REQUIRED)
ament_lint_auto_find_test_dependencies()
ament_find_gtest()
# Gtests
ament_add_gtest(test_action_client
test/rcl_action/test_action_client.cpp
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test is only covering the default rmw impl. It would be good if the test would be invoked for every rmw impl.

if(TARGET test_action_client)
target_include_directories(test_action_client PUBLIC
include
)
target_link_libraries(test_action_client
${PROJECT_NAME}
)
ament_target_dependencies(test_action_client "rcl" "test_msgs")
endif()
ament_add_gtest(test_goal_handle
test/rcl_action/test_goal_handle.cpp
)
Expand Down
17 changes: 5 additions & 12 deletions rcl_action/include/rcl_action/action_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ extern "C"
{
#endif

// TODO(jacobperron): replace type support typedef with one defined in rosdl_generator_c
// #include "rosidl_generator_c/action_type_support_struct.h"
typedef struct rosidl_action_type_support_t rosidl_action_type_support_t;

#include "rcl_action/types.h"
#include "rcl_action/visibility_control.h"
#include "rcl/macros.h"
Expand Down Expand Up @@ -167,6 +163,7 @@ rcl_action_get_zero_initialized_client(void);
* \return `RCL_RET_OK` if action_client was initialized successfully, or
* \return `RCL_RET_INVALID_ARGUMENT` if any arguments are invalid, or
* \return `RCL_RET_NODE_INVALID` if the node is invalid, or
* \return `RCL_RET_ALREADY_INIT` if the action client is already initialized, or
* \return `RCL_RET_BAD_ALLOC` if allocating memory failed, or
* \return `RCL_RET_ACTION_NAME_INVALID` if the given action name is invalid, or
* \return `RCL_RET_ERROR` if an unspecified error occurs.
Expand All @@ -176,7 +173,7 @@ RCL_WARN_UNUSED
rcl_ret_t
rcl_action_client_init(
rcl_action_client_t * action_client,
const rcl_node_t * node,
rcl_node_t * node,
const rosidl_action_type_support_t * type_support,
const char * action_name,
const rcl_action_client_options_t * options);
Expand Down Expand Up @@ -355,9 +352,7 @@ rcl_action_take_goal_response(
* Lock-Free | Yes
* <i>[1] only if required when filling the feedback message, avoided for fixed sizes</i>
*
* \param[in] action_client handle to the client that will take the goal response
* \param[out] goal_info pointer to a struct for meta-data about the goal associated
* with taken feedback
* \param[in] action_client handle to the client that will take action feedback
* \param[out] ros_feedback pointer to the ROS feedback message.
* \return `RCL_RET_OK` if the response was taken successfully, or
* \return `RCL_RET_INVALID_ARGUMENT` if any arguments are invalid, or
Expand Down Expand Up @@ -661,7 +656,7 @@ RCL_WARN_UNUSED
const rcl_action_client_options_t *
rcl_action_client_get_options(const rcl_action_client_t * action_client);

/// Check that a rcl_action_clieint_t is valid.
/// Check that a rcl_action_client_t is valid.
/**
* The bool returned is `false` if `action_client` is invalid.
* The bool returned is `true` otherwise.
Expand All @@ -677,14 +672,12 @@ rcl_action_client_get_options(const rcl_action_client_t * action_client);
* Lock-Free | Yes
*
* \param[in] action_client pointer to the rcl action client
* \param[in] error_msg_allocator a valid allocator or `NULL`
* \return `true` if `action_client` is valid, otherwise `false`
*/
RCL_ACTION_PUBLIC
bool
rcl_action_client_is_valid(
const rcl_action_client_t * action_client,
rcl_allocator_t * error_msg_allocator);
const rcl_action_client_t * action_client);

#ifdef __cplusplus
}
Expand Down
4 changes: 0 additions & 4 deletions rcl_action/include/rcl_action/action_server.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ extern "C"
{
#endif

// TODO(jacobperron): replace type support typedef with one defined in rosdl_generator_c
// #include "rosidl_generator_c/action_type_support_struct.h"
typedef struct rosidl_action_type_support_t rosidl_action_type_support_t;

#include "rcl_action/goal_handle.h"
#include "rcl_action/types.h"
#include "rcl_action/visibility_control.h"
Expand Down
1 change: 1 addition & 0 deletions rcl_action/include/rcl_action/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ extern "C"
#include "rcl/macros.h"
#include "rcl/types.h"

#include "rosidl_generator_c/action_type_support_struct.h"

// rcl action specific ret codes in 2XXX
/// Action name does not pass validation return code.
Expand Down
8 changes: 5 additions & 3 deletions rcl_action/include/rcl_action/wait.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ extern "C"

/// Add a rcl_action_client_t to a wait set.
/**
* This function will add the underlying service clients and subscriber to the wait set.
* This function will add the underlying service clients and subscribers to the wait set.
*
* This function behaves similar to adding subscriptions to the wait set, but will add
* four elements:
* five elements:
*
* - Three service clients
* - One subscriber
* - Two subscribers
*
* \see rcl_wait_set_add_subscription
*
Expand Down Expand Up @@ -199,6 +199,8 @@ rcl_action_server_wait_set_get_num_entities(
* \param[out] is_result_response_ready `true` if there is a result response message ready
* to take, `false` otherwise
* \return `RCL_RET_OK` if call is successful, or
* \return `RCL_RET_WAIT_SET_INVALID` if the wait set is zero initialized or not used
* for the action client alone, or
* \return `RCL_RET_INVALID_ARGUMENT` if any arguments are invalid, or
* \return `RCL_RET_ACTION_CLIENT_INVALID` if the action client is invalid, or
* \return `RCL_RET_ERROR` if an unspecified error occurs.
Expand Down
1 change: 1 addition & 0 deletions rcl_action/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<test_depend>ament_cmake_gtest</test_depend>
<test_depend>ament_lint_common</test_depend>
<test_depend>ament_lint_auto</test_depend>
<test_depend>test_msgs</test_depend>

<export>
<build_type>ament_cmake</build_type>
Expand Down
Loading