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

GoalStatus.to_string(0) in action_client.py result the wrong key attribute #209

Open
tutorgaming opened this issue Jan 31, 2023 · 0 comments

Comments

@tutorgaming
Copy link

tutorgaming commented Jan 31, 2023

while I've been working with custom action client
I found that in function to_string (in "action_client.py")

https://github.com/ros/actionlib/blob/noetic-devel/actionlib/src/actionlib/action_client.py#L64

def get_name_of_constant(C, n):
    for k, v in C.__dict__.items():
        if isinstance(v, int) and v == n:
            return k
    return "NO_SUCH_STATE_%d" % n

to be used in this definition in line 92

GoalStatus.to_string = classmethod(get_name_of_constant)
CommState.to_string = classmethod(get_name_of_constant)
TerminalState.to_string = classmethod(get_name_of_constant)

If I run the following code with python3,

> python3
> import action_client
> action_client.GoalStatus.to_string(0) 
'_has_header'   # THE RESULT

I got the "_has_header" as the result instead of "PENDING"

So, the suggestion might be putting the condition of the dict 's key not to start with an underscore ("_") would solve this problem and get the CONSTANT "PENDING" as the key in string type (that we're asking for)


ROS1 Noetic
Ubuntu 20.04

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

No branches or pull requests

1 participant