[ROS2] Action client to control nav2 crashes after a while
If have a node that controls the navigation2 stack by sending goals randomly inside a map indefinitely. Once the robot gets to the goal, another goal is sent. This was implemented in python using the action /navigate_to_pose
. This works as expected for several minutes. But sometimes randomly after a while the node crashes with the following message after the goal was accepted (the robot continues going to the goal).
[INFO][goal_response_callback][347]: Goal accepted :)
Traceback (most recent call last):
File "/usr/src/app/dev_ws/install/navigation/lib/navigation/navigation_god", line 11, in <module>
load_entry_point('navigation', 'console_scripts', 'navigation_god')()
File "/usr/src/app/dev_ws/build/navigation/navigation/node_navigation_god.py", line 984, in main
rclpy.spin(god_node)
File "/opt/ros/foxy/lib/python3.8/site-packages/rclpy/__init__.py", line 191, in spin
executor.spin_once()
File "/opt/ros/foxy/lib/python3.8/site-packages/rclpy/executors.py", line 711, in spin_once
raise handler.exception()
File "/opt/ros/foxy/lib/python3.8/site-packages/rclpy/task.py", line 239, in __call__
self._handler.send(None)
File "/opt/ros/foxy/lib/python3.8/site-packages/rclpy/executors.py", line 419, in handler
arg = take_from_wait_list(entity)
File "/opt/ros/foxy/lib/python3.8/site-packages/rclpy/executors.py", line 610, in <lambda>
wt, node, lambda e: e.take_data(), self._execute_waitable)
File "/opt/ros/foxy/lib/python3.8/site-packages/rclpy/action/client.py", line 258, in take_data
taken_data = _rclpy_action.rclpy_action_take_feedback(
RuntimeError: Failed to take feedback with an action client: error not set
The code structure is roughly (simplified because it belongs to a Node class)
def goal_response_callback(future):
_goal_handle = future.result()
if not _goal_handle.accepted:
print("Goal rejected :(")
return
print("Goal accepted :)")
_get_result_future = _goal_handle.get_result_async()
_get_result_future.add_done_callback(get_result_callback)
def get_result_callback(future):
pass
action_client = ActionClient(self, NavigateToPose, "/navigate_to_pose")
_send_goal_future = action_client.send_goal_async(goal_msg)
_send_goal_future.add_done_callback(goal_response_callback)
Does anyone know what might be happening?
this never randomly happens for me but will always happen for me when my /navigate_to_pose action server dies and my client remains alive. It's very annoying, because the entire node becomes unresponsive when it does. Curious to see what your root cause ends up being
Why does your action server die? It shouldn't die. In my case the action server continues running and even it gets to the goal the client sent before dying.