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

reset goal_handle to avoid attempt to cancel #254

Merged
merged 2 commits into from
May 23, 2019
Merged
Changes from all commits
Commits
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
11 changes: 8 additions & 3 deletions ros2action/ros2action/verb/send_goal.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,12 @@ def send_goal(action_name, action_type, goal_values, feedback_callback):

if goal_handle is None:
raise RuntimeError(
'Exeception while sending goal: {!r}'.format(goal_future.exception()))
'Exception while sending goal: {!r}'.format(goal_future.exception()))

if not goal_handle.accepted:
print('Goal was rejected.')
# no need to potentially cancel the goal anymore
goal_handle = None
return

print('Goal accepted with ID: {}\n'.format(bytes(goal_handle.goal_id.uuid).hex()))
Expand All @@ -128,7 +130,10 @@ def send_goal(action_name, action_type, goal_values, feedback_callback):

if result is None:
raise RuntimeError(
'Exeception while getting result: {!r}'.format(result_future.exception()))
'Exception while getting result: {!r}'.format(result_future.exception()))

# no need to potentially cancel the goal anymore
goal_handle = None

print('Result:\n {}'.format(message_to_yaml(result.result, None)))
print('Goal finished with status: {}'.format(_goal_status_to_string(result.status)))
Expand All @@ -145,7 +150,7 @@ def send_goal(action_name, action_type, goal_values, feedback_callback):

if cancel_response is None:
raise RuntimeError(
'Exeception while canceling goal: {!r}'.format(cancel_future.exception()))
'Exception while canceling goal: {!r}'.format(cancel_future.exception()))

if len(cancel_response.goals_canceling) == 0:
raise RuntimeError('Failed to cancel goal')
Expand Down