Skip to content

Commit 01ef7c8

Browse files
author
Ernesto Corbellini
committed
Modified test client to test only one goal at a time.
1 parent 95b5c6b commit 01ef7c8

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

src/rosjava_actionlib/rosjava_actionlib/src/main/java/com/github/ekumen/rosjava_actionlib/ServerStateMachine.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ public synchronized void setState(int s) {
5050

5151
public synchronized int transition(int event) throws Exception {
5252
int nextState = state;
53-
5453
switch (state) {
5554
case GoalStatus.PENDING:
5655
switch (event) {

src/rosjava_actionlib/rosjava_actionlib/src/main/java/com/github/ekumen/rosjava_actionlib/TestClient.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@
3030
import actionlib_msgs.GoalStatusArray;
3131
import actionlib_msgs.GoalID;
3232
import actionlib_msgs.GoalStatus;
33+
import org.apache.commons.logging.Log;
34+
import org.apache.commons.logging.LogFactory;
35+
3336

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

4246
@Override
4347
public GraphName getDefaultNodeName() {
@@ -49,7 +53,7 @@ public void onStart(ConnectedNode node) {
4953
ac = new ActionClient<FibonacciActionGoal, FibonacciActionFeedback, FibonacciActionResult>(node, "/fibonacci", FibonacciActionGoal._TYPE, FibonacciActionFeedback._TYPE, FibonacciActionResult._TYPE);
5054
FibonacciActionGoal goalMessage;
5155
int repeat = 3;
52-
int i;
56+
int i = 0;
5357
String goalId = "fibonacci_test_";
5458

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

69-
for (i = 0; i < repeat; i++) {
73+
/*for (i = 0; i < repeat; i++) {
7074
//sleep(10000);
7175
System.out.println("Sending goal #" + i + "...");
7276
goalMessage = (FibonacciActionGoal)ac.newGoalMessage();
7377
goalMessage.getGoal().setOrder(i*3);
7478
ac.sendGoal(goalMessage, goalId + i);
7579
System.out.println("Goal sent.");
7680
resultReceived = false;
77-
}
81+
}*/
7882

7983
// send another message and cancel it
8084
goalId += i;
8185
goalMessage = (FibonacciActionGoal)ac.newGoalMessage();
82-
goalMessage.getGoal().setOrder(i);
86+
goalMessage.getGoal().setOrder(2);
8387
System.out.println("Sending goal ID: " + goalId + "...");
8488
ac.sendGoal(goalMessage, goalId);
8589
System.out.println("Goal sent.");
@@ -122,8 +126,9 @@ public void feedbackReceived(FibonacciActionFeedback message) {
122126
public void statusReceived(GoalStatusArray status) {
123127
List<GoalStatus> statusList = status.getStatusList();
124128
for(GoalStatus gs:statusList) {
125-
//System.out.println("GoalID: " + gs.getGoalId().getId() + " -- GoalStatus: " + gs.getStatus() + " -- " + gs.getText());
129+
log.info("GoalID: " + gs.getGoalId().getId() + " -- GoalStatus: " + gs.getStatus() + " -- " + gs.getText());
126130
}
131+
log.info("Current state of our goal: " + ClientStateMachine.ClientStates.translateState(ac.getGoalState()));
127132
}
128133

129134
void sleep(long msec) {

0 commit comments

Comments
 (0)