30
30
import actionlib_msgs .GoalStatusArray ;
31
31
import actionlib_msgs .GoalID ;
32
32
import actionlib_msgs .GoalStatus ;
33
+ import org .apache .commons .logging .Log ;
34
+ import org .apache .commons .logging .LogFactory ;
35
+
33
36
34
37
/**
35
38
* Class to test the actionlib client.
38
41
public class TestClient extends AbstractNodeMain implements ActionClientListener <FibonacciActionFeedback , FibonacciActionResult > {
39
42
private ActionClient ac = null ;
40
43
private volatile boolean resultReceived = false ;
44
+ private Log log = LogFactory .getLog (ActionClient .class );
41
45
42
46
@ Override
43
47
public GraphName getDefaultNodeName () {
@@ -49,7 +53,7 @@ public void onStart(ConnectedNode node) {
49
53
ac = new ActionClient <FibonacciActionGoal , FibonacciActionFeedback , FibonacciActionResult >(node , "/fibonacci" , FibonacciActionGoal ._TYPE , FibonacciActionFeedback ._TYPE , FibonacciActionResult ._TYPE );
50
54
FibonacciActionGoal goalMessage ;
51
55
int repeat = 3 ;
52
- int i ;
56
+ int i = 0 ;
53
57
String goalId = "fibonacci_test_" ;
54
58
55
59
// Attach listener for the callbacks
@@ -66,20 +70,20 @@ public void onStart(ConnectedNode node) {
66
70
// set Fibonacci parameter
67
71
//fibonacciGoal.setOrder(6);
68
72
69
- for (i = 0 ; i < repeat ; i ++) {
73
+ /* for (i = 0; i < repeat; i++) {
70
74
//sleep(10000);
71
75
System.out.println("Sending goal #" + i + "...");
72
76
goalMessage = (FibonacciActionGoal)ac.newGoalMessage();
73
77
goalMessage.getGoal().setOrder(i*3);
74
78
ac.sendGoal(goalMessage, goalId + i);
75
79
System.out.println("Goal sent.");
76
80
resultReceived = false;
77
- }
81
+ }*/
78
82
79
83
// send another message and cancel it
80
84
goalId += i ;
81
85
goalMessage = (FibonacciActionGoal )ac .newGoalMessage ();
82
- goalMessage .getGoal ().setOrder (i );
86
+ goalMessage .getGoal ().setOrder (2 );
83
87
System .out .println ("Sending goal ID: " + goalId + "..." );
84
88
ac .sendGoal (goalMessage , goalId );
85
89
System .out .println ("Goal sent." );
@@ -122,8 +126,9 @@ public void feedbackReceived(FibonacciActionFeedback message) {
122
126
public void statusReceived (GoalStatusArray status ) {
123
127
List <GoalStatus > statusList = status .getStatusList ();
124
128
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 ());
126
130
}
131
+ log .info ("Current state of our goal: " + ClientStateMachine .ClientStates .translateState (ac .getGoalState ()));
127
132
}
128
133
129
134
void sleep (long msec ) {
0 commit comments