rosjava actionlib waitForResult() function [closed]
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<diagnosisrepairactionfeedback, diagnosisrepairactiongoal,="" diagnosisrepairactionresult,="" diagnosisrepairfeedback,="" diagnosisrepairgoal,="" diagnosisrepairresult=""> 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<string> params = new ArrayList<string>(); params.add("start_node"); repairGoal.parameter = params; sac.sendGoal(repairGoal);
SimpleClientGoalState state = sac.getState(); System.out.println("state before getting result:="+state.toString());
finished_before_timeout = sac.waitForResult(10, TimeUnit.SECONDS);
if (finished_before_timeout) {
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");
}