Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ public interface ActionServerGoalHandle<T extends ActionDefinition> extends Disp
*/
public boolean isCanceling();

/**
* Transition the goal to the EXECUTING state.
*
* Pre-condition: the goal must be in the ACCEPTED state.
*/
public void execute();

/**
* Transition the goal to the SUCCEEDED state.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,8 @@ private ActionServerGoalHandle<T> executeGoalRequest(
// Call user callback
GoalCallback.GoalResponse response = this.goalCallback.handleGoal(requestMessage);

boolean accepted = GoalCallback.GoalResponse.ACCEPT == response;
boolean accepted = GoalCallback.GoalResponse.ACCEPT_AND_DEFER == response
|| GoalCallback.GoalResponse.ACCEPT_AND_EXECUTE == response;
responseMessage.accept(accepted);

System.out.println("Goal request handled " + accepted);
Expand All @@ -334,6 +335,10 @@ private ActionServerGoalHandle<T> executeGoalRequest(
GoalHandleImpl goalHandle = this.new GoalHandleImpl(
this, goalInfo, requestMessage.getGoal());
this.goalHandles.put(requestMessage.getGoalUuid(), goalHandle);
if (GoalCallback.GoalResponse.ACCEPT_AND_EXECUTE == response) {
goalHandle.execute();
this.acceptedCallback.accept(goalHandle);
}
return goalHandle;
}

Expand Down Expand Up @@ -467,9 +472,6 @@ public void execute() {
this.handle, rmwRequestId,
responseFromJavaConverterHandle, responseToJavaConverterHandle,
responseDestructorHandle, responseMessage);
if (goalHandle != null) {
this.acceptedCallback.accept(goalHandle);
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
public interface GoalCallback<T extends GoalRequestDefinition> {
public enum GoalResponse {
REJECT,
ACCEPT,
ACCEPT_AND_EXECUTE,
ACCEPT_AND_DEFER,
};

/**
Expand Down
2 changes: 1 addition & 1 deletion rcljava/src/main/java/org/ros2/rcljava/node/Node.java
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ <T extends ServiceDefinition> Client<T> createClient(final Class<T> serviceType,
* @param goalCallback The callback that will be called when the @{link ActionServer}
* receives a new goal request.
* @param cancelCallback The callback that will be called when the @{link ActionServer}
* receives a cancle request for an active goal.
* receives a cancel request for an active goal.
* @param acceptedCallback The callback that will be called when the @{link ActionServer}
* accepts a goal request.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class MockGoalCallback implements GoalCallback<test_msgs.action.Fibonacci.SendGo
public test_msgs.action.Fibonacci_Goal goal;
public GoalResponse handleGoal(test_msgs.action.Fibonacci.SendGoalRequest goal) {
this.goal = goal.getGoal();
return GoalResponse.ACCEPT;
return GoalResponse.ACCEPT_AND_EXECUTE;
}
}

Expand Down