Skip to content

Commit

Permalink
Modified test client to test only one goal at a time.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ernesto Corbellini committed Jan 20, 2016
1 parent 95b5c6b commit 01ef7c8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ public synchronized void setState(int s) {

public synchronized int transition(int event) throws Exception {
int nextState = state;

switch (state) {
case GoalStatus.PENDING:
switch (event) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
import actionlib_msgs.GoalStatusArray;
import actionlib_msgs.GoalID;
import actionlib_msgs.GoalStatus;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;


/**
* Class to test the actionlib client.
Expand All @@ -38,6 +41,7 @@
public class TestClient extends AbstractNodeMain implements ActionClientListener<FibonacciActionFeedback, FibonacciActionResult> {
private ActionClient ac = null;
private volatile boolean resultReceived = false;
private Log log = LogFactory.getLog(ActionClient.class);

@Override
public GraphName getDefaultNodeName() {
Expand All @@ -49,7 +53,7 @@ public void onStart(ConnectedNode node) {
ac = new ActionClient<FibonacciActionGoal, FibonacciActionFeedback, FibonacciActionResult>(node, "/fibonacci", FibonacciActionGoal._TYPE, FibonacciActionFeedback._TYPE, FibonacciActionResult._TYPE);
FibonacciActionGoal goalMessage;
int repeat = 3;
int i;
int i = 0;
String goalId = "fibonacci_test_";

// Attach listener for the callbacks
Expand All @@ -66,20 +70,20 @@ public void onStart(ConnectedNode node) {
// set Fibonacci parameter
//fibonacciGoal.setOrder(6);

for (i = 0; i < repeat; i++) {
/*for (i = 0; i < repeat; i++) {
//sleep(10000);
System.out.println("Sending goal #" + i + "...");
goalMessage = (FibonacciActionGoal)ac.newGoalMessage();
goalMessage.getGoal().setOrder(i*3);
ac.sendGoal(goalMessage, goalId + i);
System.out.println("Goal sent.");
resultReceived = false;
}
}*/

// send another message and cancel it
goalId += i;
goalMessage = (FibonacciActionGoal)ac.newGoalMessage();
goalMessage.getGoal().setOrder(i);
goalMessage.getGoal().setOrder(2);
System.out.println("Sending goal ID: " + goalId + "...");
ac.sendGoal(goalMessage, goalId);
System.out.println("Goal sent.");
Expand Down Expand Up @@ -122,8 +126,9 @@ public void feedbackReceived(FibonacciActionFeedback message) {
public void statusReceived(GoalStatusArray status) {
List<GoalStatus> statusList = status.getStatusList();
for(GoalStatus gs:statusList) {
//System.out.println("GoalID: " + gs.getGoalId().getId() + " -- GoalStatus: " + gs.getStatus() + " -- " + gs.getText());
log.info("GoalID: " + gs.getGoalId().getId() + " -- GoalStatus: " + gs.getStatus() + " -- " + gs.getText());
}
log.info("Current state of our goal: " + ClientStateMachine.ClientStates.translateState(ac.getGoalState()));
}

void sleep(long msec) {
Expand Down

0 comments on commit 01ef7c8

Please sign in to comment.