0
$\begingroup$

I'm working on a bigger project where an ActionServer controls an robot. It is not working 100% as intended and therefore I'm trying again on the tutorial for actions. Turns out I'm not able to get it working properly there too :D

I'm following the example for simple action server + client: Tutorial

I've modified the execute_callback function to reject goals if the order < 1:

def execute_callback(self, goal_handle):
    """
    Main routine for goal execution.
    """
    order = goal_handle.request.order
    self.get_logger().info(f"execute_callback() | {order=}")
    result = Fibonacci.Result()

    if order < 1:
        goal_handle.abort()
        self.get_logger().warn(f"Goal aborted order < 1: {order}")
        return result

    ... # Execute & return goal

If I use the cli now: ros2 action send_goal .. with a negative order, it returns

Waiting for an action server to become available... Sending goal: order: -5

Goal accepted with ID: 633d5b9be44a4280b4babf582d608456

Result: sequence: []

Goal finished with status: ABORTED

So, the goal was accepted but immediatly rejected. Thats fine. I'm not able to get this behavior in the client.

def goal_response_callback(self, future):
    """
    Callback after server received goal. Goal could have been accepted or rejected. 
    """
    self.get_logger().info("goal_response_callback()")
    goal_handle = future.result()

    if not goal_handle.accepted:
        self.get_logger().info("Goal rejected")
        return

So, goal_handle.accepted is ALWAYS true. As one would assume but the answer the CLI got. But there is no field like rejected? How can the client react if accepted is always true?

BTW: For me the tutorial is misleading, b/c the log 'Goal rejected' appears below .accepted, although it appears to be always true, even in the CLI.

/EDIT1: The goal_handle's status is always 0 which corresponds to GoalStatus.STATUS_UNKNOWN, with order > 1 and < 1. (action_msgs.msg/GoalStatus)

$\endgroup$

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.