Home | Trees | Indices | Help |
---|
|
1 #!/usr/bin/env python 2 # 3 # Software License Agreement (BSD License) 4 # 5 # Copyright (c) 2012, Fraunhofer FKIE/US, Alexander Tiderko 6 # All rights reserved. 7 # 8 # Redistribution and use in source and binary forms, with or without 9 # modification, are permitted provided that the following conditions 10 # are met: 11 # 12 # * Redistributions of source code must retain the above copyright 13 # notice, this list of conditions and the following disclaimer. 14 # * Redistributions in binary form must reproduce the above 15 # copyright notice, this list of conditions and the following 16 # disclaimer in the documentation and/or other materials provided 17 # with the distribution. 18 # * Neither the name of Fraunhofer nor the names of its 19 # contributors may be used to endorse or promote products derived 20 # from this software without specific prior written permission. 21 # 22 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 25 # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 26 # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 27 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 28 # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 29 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 30 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 32 # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33 # POSSIBILITY OF SUCH DAMAGE. 34 35 import os 36 import signal 37 import sys 38 import traceback 39 40 import roslib 41 import rospy 42 43 from default_cfg import DefaultCfg 44 45 46 PROCESS_NAME = "default_cfg" 47 4850 ''' 51 Change the terminal name. 52 @param name: New name of the terminal 53 @type name: C{str} 54 ''' 55 sys.stdout.write("".join(["\x1b]2;", name, "\x07"]))56 5759 ''' 60 Change the process name. 61 @param name: New process name 62 @type name: C{str} 63 ''' 64 try: 65 from ctypes import cdll, byref, create_string_buffer 66 libc = cdll.LoadLibrary('libc.so.6') 67 buff = create_string_buffer(len(name) + 1) 68 buff.value = name 69 libc.prctl(15, byref(buff), 0, 0, 0) 70 except: 71 pass72 7375 ''' 76 Creates and runs the ROS node 77 ''' 78 # setup the loglevel 79 try: 80 log_level = getattr(rospy, rospy.get_param('/%s/log_level' % PROCESS_NAME, "INFO")) 81 except Exception as e: 82 print "Error while set the log level: %s\n->INFO level will be used!" % e 83 log_level = rospy.INFO 84 rospy.init_node(PROCESS_NAME, log_level=log_level) 85 set_terminal_name(PROCESS_NAME) 86 set_process_name(PROCESS_NAME) 87 try: 88 default_cfg = DefaultCfg() 89 default_cfg.load() 90 except: 91 # on load error the process will be killed to notify user in node_manager 92 # about error 93 rospy.logwarn("%s", traceback.format_exc()) 94 sys.stdout.write(traceback.format_exc()) 95 sys.stdout.flush() 96 os.kill(os.getpid(), signal.SIGKILL) 97 rospy.spin()98
Home | Trees | Indices | Help |
---|
Generated by Epydoc 3.0.1 on Sat Jul 18 03:25:07 2020 | http://epydoc.sourceforge.net |