goal_status.py
Go to the documentation of this file.
00001 #! /usr/bin/env python
00002 
00003 import roslib; roslib.load_manifest('elektron_navigation')
00004 import rospy
00005 from actionlib_msgs.msg import GoalStatusArray
00006 
00007 from sound_play.msg import SoundRequest
00008 from sound_play.libsoundplay import SoundClient
00009 
00010 
00011 state = -1
00012 state_info = ""
00013 
00014 def goal_status():
00015     global state
00016     global state_info
00017     sub  = rospy.Subscriber('move_base/status', GoalStatusArray, status_cb)
00018     soundhandle = SoundClient()
00019     last_state = -1
00020 
00021     snd_failed = rospy.get_param("~snd_failed", "")
00022     snd_accepted = rospy.get_param("~snd_accepted", "")
00023     snd_success = rospy.get_param("~snd_success", "")
00024 
00025     while not rospy.is_shutdown():
00026         
00027        # print "s: %d, l: %d" % (state, last_state)
00028         
00029         if state != last_state and last_state != -1:
00030             # Failed
00031             if state == 4:
00032                 soundhandle.playWave(snd_failed)
00033             # Accepted
00034             if state == 1:
00035                 soundhandle.playWave(snd_accepted)
00036             # Success
00037             if state == 3:
00038                 soundhandle.playWave(snd_success)
00039             
00040             rospy.loginfo("State changed to: [%d] %s" % (state, state_info))
00041                 
00042         last_state = state
00043         rospy.sleep(2)
00044         
00045         
00046 def status_cb(msg):
00047     global state
00048     global state_info
00049     if (len(msg.status_list) > 0):
00050         state = msg.status_list[0].status
00051         state_info = msg.status_list[0].text
00052 
00053 if __name__ == '__main__':
00054     try:
00055         # Initializes a rospy node so that the SimpleActionClient can
00056         # publish and subscribe over ROS.
00057         rospy.init_node('goal_status')
00058         goal_status()
00059     except rospy.ROSInterruptException:
00060         print "program interrupted before completion"
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Friends


elektron_navigation
Author(s): Maciej Stefanczyk
autogenerated on Thu Nov 14 2013 11:58:40