Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SimpleActionClient is tracking goal #40

Closed
jvgomez opened this issue Nov 6, 2015 · 6 comments · Fixed by #97
Closed

SimpleActionClient is tracking goal #40

jvgomez opened this issue Nov 6, 2015 · 6 comments · Fixed by #97

Comments

@jvgomez
Copy link

jvgomez commented Nov 6, 2015

I have reached a point in my application in which I would like to have a SimpleActionClient member which allows me to know if the server is currently pursuing a goal. Something like action_server.isTrackingGoal().

I guess is possible (I haven't checked in detail the SimpleActionClient implementation). Is there any reason not to do this? I think I could try out an implementation in case it is possible.

@esteve
Copy link
Member

esteve commented Dec 9, 2015

SimpleActionClient::getState()'s documentation says this:

Possible States Are: PENDING, ACTIVE, RECALLED, REJECTED, PREEMPTED, ABORTED, SUCCEEDED, LOST.
   * \return The goal's state. Returns LOST if this SimpleActionClient isn't tracking a goal.

Could you try this? I think this will work, let me know if it's not what you intended.

SimpleActionClient simple_action_client(...);
bool isTrackingGoal = simple_action_client.getState() != SimpleClientGoalState::LOST;

Thanks!

@esteve esteve removed their assignment Mar 9, 2016
@jvgomez
Copy link
Author

jvgomez commented Mar 11, 2016

I have finally checked that method but there is a problem: if the server is not tracking any goal it returns LOST (as you mention) but also shows an error:

ROS_ERROR("Trying to getState() when no goal is running. You are incorrectly using SimpleActionClient");

Which is annoying, because in my opinion this does not mean that we are incorrectly using it. The only solution I can see is to store an additional flag to know whether any goal has been sent, and update it when the result is received.

Any further ideas?

@luator
Copy link

luator commented Dec 21, 2016

I agree with jvgomez. Is there any reason to not simply remove the error message? I think this would be the easiest solution to the problem.

@collinsc
Copy link

I also agree with jgomez. It's useful if you need to have multiple action clients in the same node, and juggle in between the two.

@marcelinomalmeidan
Copy link

marcelinomalmeidan commented Oct 23, 2018

First of all, I would like to endorse this request!
For those who are impatient to wait until the codebase is changed, there is an alternative.
You can actually see what is the current state of the action server by subscribing to the topic
[action_name]/status
This topic returns a message of the type actionlib_msgs::GoalStatusArray. In your code, you can check whether the action server is busy by having the following (C++):

bool action_server_busy = false;
for (uint i = 0; i < current_status.status_list.size(); i++) {
	if (current_status.status_list[i].status == current_status.status_list[i].ACTIVE) {
		action_server_busy = true;
	}
}

The code above has the variable current_status as declared with the type actionlib_msgs::GoalStatusArray.

@doisyg
Copy link

doisyg commented Dec 3, 2018

Any progress on this topic?
PR here seems blocked : #97

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants