Skip to content

Commit

Permalink
Merge pull request ernestmc#2 from fmessmer/enhancements
Browse files Browse the repository at this point in the history
enhancements
  • Loading branch information
fmessmer authored Sep 21, 2018
2 parents d5a7eaa + 1864836 commit 97b7a1a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public void detachListener(ActionClientListener target) {
*/
public ActionFuture<T_ACTION_GOAL, T_ACTION_FEEDBACK, T_ACTION_RESULT> sendGoal(T_ACTION_GOAL agMessage, String id) {
GoalID gid = getGoalId(agMessage);
if (id == "") {
if (id.equals("")) {
goalIdGenerator.generateID(gid);
} else {
gid.setId(id);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/github/rosjava_actionlib/ActionGoal.java
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,6 @@ public void setGoalMessage(Message gm) {
}

public boolean equalId(ActionGoal ag) {
return (this.getGoalId() == ag.getGoalId());
return (this.getGoalId().equals(ag.getGoalId()));
}
}
22 changes: 17 additions & 5 deletions src/main/java/com/github/rosjava_actionlib/ActionServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -255,12 +255,20 @@ public void sendStatusTick() {
GoalStatus goalStatus;
Vector<GoalStatus> goalStatusList = new Vector<GoalStatus>();

for (ServerGoal sg : goalTracker.values()) {
goalStatus = node.getTopicMessageFactory().newFromType(GoalStatus._TYPE);
goalStatus.setGoalId(getGoalId(sg.goal));
goalStatus.setStatus((byte) sg.state.getState());
goalStatusList.add(goalStatus);
try {
for(java.util.Iterator<ServerGoal> sgIterator = goalTracker.values().iterator(); sgIterator.hasNext();) {
ServerGoal sg = sgIterator.next();
goalStatus = node.getTopicMessageFactory().newFromType(GoalStatus._TYPE);
goalStatus.setGoalId(getGoalId(sg.goal));
goalStatus.setStatus((byte) sg.state.getState());
goalStatusList.add(goalStatus);
}
} catch (java.util.ConcurrentModificationException exception) {
exception.printStackTrace(System.out);
} catch (Throwable throwable) {
throwable.printStackTrace(System.out);
}

status.setStatusList(goalStatusList);
sendStatus(status);
}
Expand Down Expand Up @@ -316,6 +324,7 @@ public void setSucceed(String goalIdString) {
try {
goalTracker.get(goalIdString).state.transition(ServerStateMachine.Events.SUCCEED);
} catch (Exception e) {
e.printStackTrace(System.out);
}
}

Expand All @@ -327,6 +336,7 @@ public void setPreempt(String goalIdString) {
goalTracker.get(goalIdString).state.transition(ServerStateMachine.Events.CANCEL_REQUEST);
goalTracker.get(goalIdString).state.transition(ServerStateMachine.Events.CANCEL);
} catch (Exception e) {
e.printStackTrace(System.out);
}
}

Expand All @@ -337,6 +347,7 @@ public void setAbort(String goalIdString) {
try {
goalTracker.get(goalIdString).state.transition(ServerStateMachine.Events.ABORT);
} catch (Exception e) {
e.printStackTrace(System.out);
}
}

Expand All @@ -353,6 +364,7 @@ public void setGoalStatus(GoalStatus gstat, String gidString) {
gstat.setGoalId(getGoalId(serverGoal.goal));
gstat.setStatus((byte) serverGoal.state.getState());
} catch (Exception e) {
e.printStackTrace(System.out);
}
}

Expand Down

0 comments on commit 97b7a1a

Please sign in to comment.