Skip to content

Instantly share code, notes, and snippets.

@shivamMg
Created April 12, 2020 11:59
Show Gist options
  • Save shivamMg/135253d4a8a5a7d3b035e4777f64a28d to your computer and use it in GitHub Desktop.
Save shivamMg/135253d4a8a5a7d3b035e4777f64a28d to your computer and use it in GitHub Desktop.
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