Robotics StackExchange | Archived questions

rosjava actionlib waitForResult() function

Hi All, Follwoing code is in a Callback, Each time Callback is executed I need to wait for the result from Action Server. I observed that only first time WaitForResult() works but then it does not wait at all. Can anyone help me fix this? Thanks

DiagnosisRepairActionNodeSpec spec = new DiagnosisRepairActionNodeSpec(); SimpleActionClient sac = (SimpleActionClient) spec.buildSimpleActionClient("abc");

System.out.println("[Test] Waiting for action server to start!"); sac.waitForServer(); System.out.println("Server started....");

DiagnosisRepairGoal repairGoal= spec.createGoalMessage();

ArrayList params = new ArrayList(); params.add("start_node"); repairGoal.parameter = params; sac.sendGoal(repairGoal);

SimpleClientGoalState state = sac.getState(); System.out.println("state before getting result:="+state.toString());

finishedbeforetimeout = sac.waitForResult(10, TimeUnit.SECONDS);

if (finishedbeforetimeout) { state = sac.getState(); System.out.println("state after getting result="+state.toString()); DiagnosisRepairResult res = sac.getResult(); System.out.println("Result is back in time is."+Integer.toString(res.result)); }else{ log.info("[Test] Action did not finish before the time out");
}

Asked by safzam on 2012-04-28 05:59:10 UTC

Comments

Answers