RosServerGoalHandleΒΆ

Inherits: RefCounted

The server-side handle for an accepted action goal.

DescriptionΒΆ

RosServerGoalHandle is handed to the execute callback of a RosActionServer for every accepted goal. It carries the goal message and is used to publish feedback and report the outcome.

Every goal must be driven to exactly one terminal state: succeed(), abort() or canceled(). Calling a second terminal method on the same handle is an error.

For long-running goals, spread the work over multiple frames with await and poll is_cancel_requested() so clients can cancel:

func _execute_goal(goal_handle: RosServerGoalHandle):
    var result = goal_handle.create_result()
    for step in range(goal_handle.get_goal().order):
        if goal_handle.is_cancel_requested():
            goal_handle.canceled(result)
            return
        var fb = goal_handle.create_feedback()
        goal_handle.publish_feedback(fb)
        await get_tree().process_frame
    goal_handle.succeed(result)

MethodsΒΆ

void

abort(result: RosMsg)

void

canceled(result: RosMsg)

RosMsg

create_feedback()

RosMsg

create_result()

RosMsg

get_goal() const

String

get_goal_id() const

bool

is_active() const

bool

is_cancel_requested() const

void

publish_feedback(feedback: RosMsg)

void

succeed(result: RosMsg)


Method DescriptionsΒΆ

void abort(result: RosMsg) πŸ”—

Terminates the goal as failed, sending result to the client (the client sees RosGoalHandle.STATUS_ABORTED).


void canceled(result: RosMsg) πŸ”—

Terminates the goal as canceled, sending result to the client (the client sees RosGoalHandle.STATUS_CANCELED). Call this in response to is_cancel_requested() becoming true.


RosMsg create_feedback() πŸ”—

Creates and returns an empty RosMsg of this action's feedback type, ready to be filled and passed to publish_feedback().


RosMsg create_result() πŸ”—

Creates and returns an empty RosMsg of this action's result type, ready to be filled and passed to one of the terminal methods.


RosMsg get_goal() const πŸ”—

Returns the goal message sent by the client.


String get_goal_id() const πŸ”—

Returns the unique identifier of this goal as a hexadecimal string. Useful for logging when handling several concurrent goals.


bool is_active() const πŸ”—

Returns true while the goal has not reached a terminal state yet.


bool is_cancel_requested() const πŸ”—

Returns true once a client has requested this goal to be canceled. Poll it inside long-running execute callbacks and finish with canceled().


void publish_feedback(feedback: RosMsg) πŸ”—

Publishes a feedback message for this goal. Clients receive it through the RosGoalHandle.feedback signal.


void succeed(result: RosMsg) πŸ”—

Terminates the goal successfully, sending result to the client (the client sees RosGoalHandle.STATUS_SUCCEEDED).