Created
April 12, 2020 11:59
-
-
Save shivamMg/135253d4a8a5a7d3b035e4777f64a28d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import sys | |
| from collections import defaultdict | |
| import rospy | |
| from actionlib_msgs.msg import GoalID, GoalStatus, GoalStatusArray | |
| statuses = defaultdict(list) | |
| status_strs = [ | |
| 'PENDING', | |
| 'ACTIVE', | |
| 'PREEMPTED', | |
| 'SUCCEEDED', | |
| 'ABORTED', | |
| 'REJECTED', | |
| 'PREEMPTING', | |
| 'RECALLING', | |
| 'RECALLED', | |
| 'LOST', | |
| ] | |
| def cb(msg): | |
| for status in msg.status_list: | |
| print status.goal_id.id, status_strs[status.status] | |
| if __name__ == '__main__': | |
| if len(sys.argv) < 2: | |
| print 'pass action name as arg' | |
| sys.exit(1) | |
| rospy.init_node('action_status', anonymous=True) | |
| status_topic = '/{}/status'.format(sys.argv[1].lstrip('/')) | |
| sub = rospy.Subscriber(status_topic, GoalStatusArray, cb, queue_size=1) | |
| rospy.spin() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment