forked from ernestmc/rosjava_actionlib
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added cancel event to the state machine.
- Loading branch information
Ernesto Corbellini
committed
Jan 18, 2016
1 parent
08885ce
commit 1058131
Showing
1 changed file
with
20 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,10 +25,7 @@ | |
/** | ||
* State machine for the action client. | ||
* @author Ernesto Corbellini [email protected] | ||
* Comments: | ||
* - The state returned on a transition is actually a vector of states that should be transitioned in sequence. | ||
* TODO: change class name to ClientStateMachine | ||
*/ | ||
*/ | ||
public class ClientStateMachine { | ||
// Local class to hold the states | ||
public static class ClientStates { | ||
|
@@ -45,7 +42,6 @@ public static class ClientStates { | |
public final static int LOST = 8; | ||
} | ||
|
||
ActionGoal goal; | ||
int latestGoalStatus; | ||
int state; | ||
int nextState; | ||
|
@@ -61,14 +57,6 @@ public void ClientStateMachine() | |
//this.goal = actionGoal; | ||
} | ||
|
||
/* | ||
* Compare two objects. | ||
*/ | ||
public boolean equals(ClientStateMachine obj) { | ||
//return actionGoal.goalId.id == obj.actionGoal.goalId.id; | ||
return true; | ||
} | ||
|
||
public synchronized void setState(int state) { | ||
this.state = state; | ||
} | ||
|
@@ -422,6 +410,25 @@ public Vector<Integer> getTransition(int goalStatus) | |
return stateList; | ||
} | ||
|
||
/** | ||
* Cancel action goal. The goal can only be cancelled if its in certain | ||
* states. If it can be cancelled the state will be changed to | ||
* WAITING_FOR_CANCEL_ACK. | ||
* @return True if the goal can be cancelled, false otherwise. | ||
*/ | ||
public boolean cancel() { | ||
bolean ret = false; | ||
switch (stateMachine.getState()) { | ||
case ClientStates.WAITING_FOR_GOAL_ACK: | ||
case ClientStates.PENDING: | ||
case ClientStates.ACTIVE: | ||
this.state = ClientStates.WAITING_FOR_CANCEL_ACK; | ||
ret = true; | ||
break; | ||
} | ||
return ret; | ||
} | ||
|
||
public void markAsLost() | ||
{ | ||
} | ||
|