warn.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 
00003 import roslib; roslib.load_manifest('clearpath_bringup')
00004 
00005 import rospy
00006 from std_msgs.msg import String
00007 
00008 import time, sys, os
00009 
00010 DEFAULT_NS="/clearpath/robots/default/"
00011 
00012 class Warn:
00013     def announce(self, data):
00014         self.found.add(data.data)
00015 
00016     def __init__(self):
00017         clearpath_robot_env = os.environ.get("CLEARPATH_ROBOT")
00018 
00019         rospy.init_node('warn', anonymous=True)
00020 
00021         self.found = set()
00022         model = rospy.get_param('~model', 'husky')
00023         rospy.Subscriber("/clearpath/announce/robots", String, self.announce)
00024 
00025         time.sleep(0.5)
00026 
00027         if clearpath_robot_env == None:
00028             rospy.logwarn("Env $CLEARPATH_ROBOT not set, assuming %s" % DEFAULT_NS)
00029             clearpath_robot_env = DEFAULT_NS
00030 
00031         if clearpath_robot_env in self.found:
00032             rospy.loginfo("Clearpath robot announced in %s" % clearpath_robot_env)
00033             rospy.spin()
00034             exit(0)
00035         
00036         if len(self.found) >= 1:
00037             rospy.logerr("One or more Clearpath robots announced, but none in %s" % clearpath_robot_env)
00038             rospy.logerr("In your .bashrc file, try adding: export CLEARPATH_ROBOT=%s" % self.found.pop())
00039             exit(1)    
00040         else:
00041             rospy.logerr("No Clearpath announce found.")
00042             rospy.logerr("Bring up robot and try again: roslaunch {0}_bringup {0}.launch".format(model))
00043             exit(1)
00044             # rospy.logerr("sudo service husky start")
00045             # rospy.logerr("sudo rosrun husky_bringup install")
00046 
00047 
00048 if __name__=="__main__": Warn()


clearpath_bringup
Author(s): Mike Purvis
autogenerated on Sun Oct 5 2014 22:52:03