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

rclcpp_action Server implementation #593

Merged
merged 71 commits into from
Dec 6, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
5ffe3e8
Commiting to back up work, does not function
sloretz Nov 27, 2018
0967eda
Can call user callback when goal request received
sloretz Nov 27, 2018
c2338f0
fini action server in destructor
sloretz Nov 27, 2018
8854af3
rename user callback virtual functions
sloretz Nov 27, 2018
f752de0
handle_execute test passes
sloretz Nov 27, 2018
6962024
Remove out of date comment
sloretz Nov 27, 2018
5a4cc1b
Refactor execute into three functions
sloretz Nov 27, 2018
9e5d0d6
Remove unused file
sloretz Nov 27, 2018
36c3825
Add failing cancel test
sloretz Nov 27, 2018
c508c6d
Cancel test passes
sloretz Nov 28, 2018
6e603e9
Remove out of date comments
sloretz Nov 28, 2018
9565203
Make sure server publishes status when accepting a goal
sloretz Nov 28, 2018
d33fe65
Send status when goals transition to cancelling
sloretz Nov 28, 2018
f795ca8
Refactored sending goal request to its own function
sloretz Nov 28, 2018
387701d
Refactor cancel request into it's own function
sloretz Nov 28, 2018
ec7f1eb
Comment with remaining tests
sloretz Nov 28, 2018
04de5f4
Executing and terminal state statuses
sloretz Nov 28, 2018
e1d1006
publish feedback works
sloretz Nov 28, 2018
20fe2ac
server sends result to clients that request it
sloretz Nov 29, 2018
8dc5b84
Remove out of date comment
sloretz Nov 29, 2018
4a9819d
Add ServerGoalHandle::is_active()
sloretz Nov 29, 2018
a2c06a4
Cleanup when goals expire
sloretz Nov 29, 2018
da520be
Can pass in action server options
sloretz Nov 29, 2018
199d015
cpplint and uncrustify fixes
sloretz Nov 29, 2018
586b861
Fix clang warnings
sloretz Nov 29, 2018
d03e651
Copy rcl goal handle
sloretz Nov 29, 2018
ef65970
Fix clang warning
sloretz Nov 29, 2018
48c951d
Use intermediate value to avoid left shift on 32bit integer
sloretz Nov 29, 2018
283e39f
RCLCPP_ACTION_PUBLIC everwhere
sloretz Nov 29, 2018
a13933a
Change callback parameter from C type to C++
sloretz Nov 30, 2018
06d3842
Add accessors for request and uuid
sloretz Nov 30, 2018
eac6ddd
Feedback must include goal id
sloretz Nov 30, 2018
4038b15
Document Server<> and ServerBase<>
sloretz Nov 30, 2018
0606831
handle_execute -> handle_accepted
sloretz Nov 30, 2018
5922b59
Test deferred execution
sloretz Nov 30, 2018
8a4c4cf
only publish feedback if goal is executing
sloretz Nov 30, 2018
e75ce64
Documentation for ServerGoalHandle
sloretz Nov 30, 2018
ff542aa
document msg parameters
sloretz Nov 30, 2018
0005862
remove unnecessary fini
sloretz Dec 1, 2018
40b5dbd
notify_goal_done only takes server
sloretz Dec 1, 2018
994539f
Use unique_indentifier_msgs
sloretz Dec 4, 2018
057afa9
create_server accepts group and removes waitable
sloretz Dec 4, 2018
3405077
uncrustify
sloretz Dec 4, 2018
a0a1a91
Use weak ptr to avoid crash if goal handle lives longer than server
sloretz Dec 5, 2018
2965274
Handle goal callback const message
sloretz Dec 5, 2018
1003eed
Goal handle doesn't have server pointer anymore
sloretz Dec 5, 2018
379459f
Lock goal_handles_ on Server<>
sloretz Dec 5, 2018
2085366
rcl_action_server_t protected with mutex
sloretz Dec 5, 2018
4664398
ServerBase results protected with mutex
sloretz Dec 5, 2018
48a709e
protect rcl goal handle with mutex
sloretz Dec 5, 2018
e54b8a5
is_cancel_request -> is_canceling
sloretz Dec 5, 2018
69fba0c
Add missing include
sloretz Dec 5, 2018
c3f1ec6
use GoalID and change uuid -> goal_id
sloretz Dec 5, 2018
1c36fb8
Keep rcl goal handle alive until it expires on server
sloretz Dec 5, 2018
63eff6c
uncrustify
sloretz Dec 5, 2018
054b818
Move UUID hash
sloretz Dec 5, 2018
ac82e36
Log messages in server
sloretz Dec 5, 2018
ad570dc
ACTION -> ActionT
sloretz Dec 5, 2018
ec70b67
Cancel abandoned goal handles
sloretz Dec 6, 2018
f717e9b
Add convert() for C and C++ goal id
sloretz Dec 6, 2018
03c9cf0
Remove unused variable
sloretz Dec 6, 2018
ea33c88
Constant reference
sloretz Dec 6, 2018
8a21dec
Move variable declaration down
sloretz Dec 6, 2018
bf4797a
is_ready if goal expired
sloretz Dec 6, 2018
ae676d8
map[] default constructs if it doesn't exist
sloretz Dec 6, 2018
039854d
Use rcl_action_get_goal_status_array()
sloretz Dec 6, 2018
71c7100
Array -> GoalID
sloretz Dec 6, 2018
b7a3de1
Use reentrant mutex for everything
sloretz Dec 6, 2018
de1510b
comment
sloretz Dec 6, 2018
1c8c86d
scope exit to fini cancel response
sloretz Dec 6, 2018
9ec3f39
using GoalID
sloretz Dec 6, 2018
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 rclcpp_action/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ set(${PROJECT_NAME}_SRCS
src/client.cpp
src/server.cpp
src/server_goal_handle.cpp
src/types.cpp
)

add_library(${PROJECT_NAME}
Expand Down
66 changes: 56 additions & 10 deletions rclcpp_action/include/rclcpp_action/create_server.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,13 @@
#ifndef RCLCPP_ACTION__CREATE_SERVER_HPP_
#define RCLCPP_ACTION__CREATE_SERVER_HPP_

#include <rcl_action/action_server.h>

#include <rclcpp/node.hpp>
#include <rclcpp/node_interfaces/node_base_interface.hpp>
#include <rclcpp/node_interfaces/node_clock_interface.hpp>
#include <rclcpp/node_interfaces/node_logging_interface.hpp>
#include <rclcpp/node_interfaces/node_waitables_interface.hpp>

#include <memory>
#include <string>
Expand All @@ -25,19 +31,59 @@

namespace rclcpp_action
{
template<typename ACTION>
typename Server<ACTION>::SharedPtr
template<typename ActionT>
typename Server<ActionT>::SharedPtr
create_server(
rclcpp::Node * node,
rclcpp::Node::SharedPtr node,
const std::string & name,
typename Server<ACTION>::GoalCallback handle_goal,
typename Server<ACTION>::CancelCallback handle_cancel)
typename Server<ActionT>::GoalCallback handle_goal,
typename Server<ActionT>::CancelCallback handle_cancel,
typename Server<ActionT>::AcceptedCallback handle_accepted,
const rcl_action_server_options_t & options = rcl_action_server_get_default_options(),
rclcpp::callback_group::CallbackGroup::SharedPtr group = nullptr)
{
return Server<ACTION>::make_shared(
node->get_node_base_interface(),
name,
handle_goal,
handle_cancel);
std::weak_ptr<rclcpp::node_interfaces::NodeWaitablesInterface> weak_node =
node->get_node_waitables_interface();
std::weak_ptr<rclcpp::callback_group::CallbackGroup> weak_group = group;
bool group_is_null = (nullptr == group.get());

auto deleter = [weak_node, weak_group, group_is_null](Server<ActionT> * ptr)
{
if (nullptr == ptr) {
return;
}
auto shared_node = weak_node.lock();
if (!shared_node) {
return;
}
// API expects a shared pointer, give it one with a deleter that does nothing.
std::shared_ptr<Server<ActionT>> fake_shared_ptr(ptr, [](Server<ActionT> *) {});

if (group_is_null) {
// Was added to default group
shared_node->remove_waitable(fake_shared_ptr, nullptr);
} else {
// Was added to a specfic group
auto shared_group = weak_group.lock();
if (shared_group) {
shared_node->remove_waitable(fake_shared_ptr, shared_group);
}
}
delete ptr;
};

std::shared_ptr<Server<ActionT>> action_server(new Server<ActionT>(
node->get_node_base_interface(),
node->get_node_clock_interface(),
node->get_node_logging_interface(),
name,
options,
handle_goal,
handle_cancel,
handle_accepted), deleter);

node->get_node_waitables_interface()->add_waitable(action_server, group);
return action_server;
}
} // namespace rclcpp_action
#endif // RCLCPP_ACTION__CREATE_SERVER_HPP_
Loading