-
Notifications
You must be signed in to change notification settings - Fork 412
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] Action client implementation #594
Merged
Merged
Changes from 50 commits
Commits
Show all changes
56 commits
Select commit
Hold shift + click to select a range
ecf8b5f
WIP
hidmic ad227d4
Added basic waitable interface to action client
sservulo 584ab25
Updated waitable execute from action client
sservulo e221967
Added throw for rcl calls in action client
sservulo ce1b068
Removed duplicated ready flags from action client
sservulo ffcb8bb
Minor fix
sservulo d888fd5
Added header to action ClientBaseImpl execute
sservulo 440ee03
Mich's update to action client interface
sservulo 0c7dfd8
Removed async_cancel from action ClintGoalHandle API
sservulo a94ca35
Added status handler to action client goal handler
sservulo 7fbb253
Added result handler to action client goal handler
sservulo 1a1f79a
Identation fix
sservulo 17a7a8d
Added get/set for action client goal handler
sservulo bcf1553
Changed action client goal handler attrs from rcl to cpp versions
sservulo 5b2bc4c
Added check methods to action client goal handler
sservulo 6b3482f
Removed rcl_client pointer from action client goal handler
sservulo 5967df8
Added trailing suffix to client pimpl attrs
sservulo 58215f3
Towards a consistent action client
hidmic 1e9d56e
Misc fixes for the action client
hidmic 5ec7562
Yet more misc fixes for the action client
hidmic 68a2e17
Few more fixes and shortcuts to deal with missing type support.
hidmic 4275ce7
Fixed lint errors in action headers and client
hidmic 9545a0b
Fixes to action client internal workflow.
hidmic ab5df90
Misc fixes to get client example to build
sloretz 4825f95
More misck client fixes
sloretz f04a50e
Remove debug print
sloretz 750e19b
replace logging with throw_from_rcl_error
sloretz af831b3
Wrap result object given by client to user
sloretz da9d530
Fix a couple bugs trying to cancel goals
sloretz 65fa041
Use unique_indentifier_msgs
sloretz 2faa4b7
create_client accepts group and removes waitable
sloretz 7fa9a14
Uncrustify fixes
sloretz 7c2c69e
[rclcpp_action] Adds tests for action client.
sservulo 927115c
[WIP] Failing action client tests.
hidmic c2c6775
[rclcpp_action] Action client tests passing.
hidmic ed1af61
Spin both executors to make tests pass on my machine
sloretz 923564b
Feedback callback uses shared pointer
sloretz 9e74ca4
comment about why make_result_aware is called
sloretz f7a52eb
Client documentation
sloretz 8b173d5
Execute one thing at a time
sloretz f1ed490
Return nullptr instead of throwing RejectedGoalError
sloretz 4dc00d9
ClientGoalHandle worries about feedback awareness
sloretz 7489e75
cpplint + uncrustify
sloretz f2dc2ab
Use node logging interface
sloretz 8e0da8f
ACTION -> ActionT
sloretz 62c27a4
Make ClientBase constructor protected
sloretz cc2d038
Return types on different line
sloretz 5797e51
Avoid passing const reference to temporary
sloretz df0a3fa
Child logger rclcpp_action
sloretz fa391a1
Child logger rclcpp_action
sloretz 175213e
possible windows fixes
sloretz 7cb39d8
remove excess space
sloretz 05cfd8e
swap argument order
sloretz 9b63b47
Misc test additions
sloretz a4b1cb4
Windows independent_bits_engine can't do uint8_t
sloretz ffa4dce
Windows link issues
sloretz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -17,35 +17,138 @@ | |||||
|
||||||
#include <rcl_action/types.h> | ||||||
|
||||||
#include <memory> | ||||||
|
||||||
#include "rclcpp_action/exceptions.hpp" | ||||||
|
||||||
namespace rclcpp_action | ||||||
{ | ||||||
template<typename ACTION> | ||||||
ClientGoalHandle<ACTION>::ClientGoalHandle( | ||||||
rcl_action_client_t * rcl_client, | ||||||
const rcl_action_goal_info_t rcl_info | ||||||
) | ||||||
: rcl_client_(rcl_client), rcl_info_(rcl_info) | ||||||
|
||||||
template<typename ActionT> | ||||||
ClientGoalHandle<ActionT>::ClientGoalHandle( | ||||||
const GoalInfo & info, FeedbackCallback callback) | ||||||
: info_(info), result_future_(result_promise_.get_future()), feedback_callback_(callback) | ||||||
{ | ||||||
} | ||||||
|
||||||
template<typename ActionT> | ||||||
ClientGoalHandle<ActionT>::~ClientGoalHandle() | ||||||
{ | ||||||
} | ||||||
|
||||||
template<typename ActionT> | ||||||
const GoalID & | ||||||
ClientGoalHandle<ActionT>::get_goal_id() const | ||||||
{ | ||||||
// return info_.goal_id; | ||||||
return info_.goal_id.uuid; | ||||||
} | ||||||
|
||||||
template<typename ActionT> | ||||||
rclcpp::Time | ||||||
ClientGoalHandle<ActionT>::get_goal_stamp() const | ||||||
{ | ||||||
return info_.stamp; | ||||||
} | ||||||
|
||||||
template<typename ACTION> | ||||||
ClientGoalHandle<ACTION>::~ClientGoalHandle() | ||||||
|
||||||
template<typename ActionT> | ||||||
std::shared_future<typename ClientGoalHandle<ActionT>::Result> | ||||||
ClientGoalHandle<ActionT>::async_result() | ||||||
{ | ||||||
std::lock_guard<std::mutex> guard(handle_mutex_); | ||||||
if (!is_result_aware_) { | ||||||
throw exceptions::UnawareGoalHandleError(); | ||||||
} | ||||||
return result_future_; | ||||||
} | ||||||
|
||||||
template<typename ACTION> | ||||||
std::future<bool> | ||||||
ClientGoalHandle<ACTION>::async_cancel() | ||||||
template<typename ActionT> | ||||||
void | ||||||
ClientGoalHandle<ActionT>::set_result(const Result & result) | ||||||
{ | ||||||
throw std::runtime_error("Failed to cancel goal"); | ||||||
std::lock_guard<std::mutex> guard(handle_mutex_); | ||||||
status_ = static_cast<int8_t>(result.code); | ||||||
result_promise_.set_value(result); | ||||||
} | ||||||
|
||||||
template<typename ACTION> | ||||||
std::future<typename ACTION::Result> | ||||||
ClientGoalHandle<ACTION>::async_result() | ||||||
template<typename ActionT> | ||||||
void | ||||||
ClientGoalHandle<ActionT>::set_feedback_callback(FeedbackCallback callback) | ||||||
{ | ||||||
throw std::runtime_error("Failed to get result future"); | ||||||
std::lock_guard<std::mutex> guard(handle_mutex_); | ||||||
feedback_callback_ = callback; | ||||||
} | ||||||
|
||||||
template<typename ActionT> | ||||||
int8_t | ||||||
ClientGoalHandle<ActionT>::get_status() | ||||||
{ | ||||||
std::lock_guard<std::mutex> guard(handle_mutex_); | ||||||
return status_; | ||||||
} | ||||||
|
||||||
template<typename ActionT> | ||||||
void | ||||||
ClientGoalHandle<ActionT>::set_status(int8_t status) | ||||||
{ | ||||||
std::lock_guard<std::mutex> guard(handle_mutex_); | ||||||
status_ = status; | ||||||
} | ||||||
|
||||||
template<typename ActionT> | ||||||
bool | ||||||
ClientGoalHandle<ActionT>::is_feedback_aware() | ||||||
{ | ||||||
std::lock_guard<std::mutex> guard(handle_mutex_); | ||||||
return feedback_callback_ != nullptr; | ||||||
} | ||||||
|
||||||
template<typename ActionT> | ||||||
bool | ||||||
ClientGoalHandle<ActionT>::is_result_aware() | ||||||
{ | ||||||
std::lock_guard<std::mutex> guard(handle_mutex_); | ||||||
return is_result_aware_; | ||||||
} | ||||||
|
||||||
template<typename ActionT> | ||||||
void | ||||||
ClientGoalHandle<ActionT>::set_result_awareness(bool awareness) | ||||||
{ | ||||||
std::lock_guard<std::mutex> guard(handle_mutex_); | ||||||
is_result_aware_ = awareness; | ||||||
} | ||||||
|
||||||
template<typename ActionT> | ||||||
void | ||||||
ClientGoalHandle<ActionT>::invalidate() | ||||||
{ | ||||||
std::lock_guard<std::mutex> guard(handle_mutex_); | ||||||
status_ = GoalStatus::STATUS_UNKNOWN; | ||||||
result_promise_.set_exception(std::make_exception_ptr( | ||||||
exceptions::UnawareGoalHandleError())); | ||||||
} | ||||||
|
||||||
template<typename ActionT> | ||||||
void | ||||||
ClientGoalHandle<ActionT>::call_feedback_callback( | ||||||
ClientGoalHandle<ActionT>::SharedPtr shared_this, | ||||||
typename std::shared_ptr<const Feedback> feedback_message) | ||||||
{ | ||||||
if (shared_this.get() != this) { | ||||||
RCLCPP_ERROR(rclcpp::get_logger("rclcpp_action"), "Sent feedback to wrong goal handle."); | ||||||
return; | ||||||
} | ||||||
std::lock_guard<std::mutex> guard(handle_mutex_); | ||||||
if (feedback_callback_ == nullptr) { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||
// Normal, some feedback messages may arrive after the goal result. | ||||||
RCLCPP_DEBUG(rclcpp::get_logger("rclcpp_action"), "Received feedback but goal ignores it."); | ||||||
return; | ||||||
} | ||||||
feedback_callback_(shared_this, feedback_message); | ||||||
} | ||||||
|
||||||
} // namespace rclcpp_action | ||||||
|
||||||
#endif // RCLCPP_ACTION__CLIENT_GOAL_HANDLE_IMPL_HPP_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Copyright 2018 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. | ||
|
||
#ifndef RCLCPP_ACTION__EXCEPTIONS_HPP_ | ||
#define RCLCPP_ACTION__EXCEPTIONS_HPP_ | ||
|
||
#include <stdexcept> | ||
|
||
namespace rclcpp_action | ||
{ | ||
namespace exceptions | ||
{ | ||
class UnknownGoalHandleError : public std::invalid_argument | ||
{ | ||
public: | ||
UnknownGoalHandleError() | ||
: std::invalid_argument("Goal handle is not know to this client.") | ||
{ | ||
} | ||
}; | ||
|
||
class UnawareGoalHandleError : public std::runtime_error | ||
{ | ||
public: | ||
UnawareGoalHandleError() | ||
: std::runtime_error("Goal handle is not tracking the goal result.") | ||
{ | ||
} | ||
}; | ||
|
||
} // namespace exceptions | ||
|
||
} // namespace rclcpp_action | ||
|
||
#endif // RCLCPP_ACTION__EXCEPTIONS_HPP_ |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
excess space
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
7cb39d8