actionlib
actionlib copied to clipboard
GoalStatus.to_string(0) in action_client.py result the wrong key attribute
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