Package master_sync_fkie
[frames] | no frames]

Source Code for Package master_sync_fkie

 1  #!/usr/bin/env python 
 2  # Software License Agreement (BSD License) 
 3  # 
 4  # Copyright (c) 2012, Fraunhofer FKIE/US, Alexander Tiderko 
 5  # All rights reserved. 
 6  # 
 7  # Redistribution and use in source and binary forms, with or without 
 8  # modification, are permitted provided that the following conditions 
 9  # are met: 
10  # 
11  #  * Redistributions of source code must retain the above copyright 
12  #    notice, this list of conditions and the following disclaimer. 
13  #  * Redistributions in binary form must reproduce the above 
14  #    copyright notice, this list of conditions and the following 
15  #    disclaimer in the documentation and/or other materials provided 
16  #    with the distribution. 
17  #  * Neither the name of Fraunhofer nor the names of its 
18  #    contributors may be used to endorse or promote products derived 
19  #    from this software without specific prior written permission. 
20  # 
21  # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
22  # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
23  # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
24  # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
25  # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
26  # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
27  # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
28  # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
29  # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
30  # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 
31  # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
32  # POSSIBILITY OF SUCH DAMAGE. 
33   
34  __author__ = "Alexander Tiderko (Alexander.Tiderko@fkie.fraunhofer.de)" 
35  __copyright__ = "Copyright (c) 2012 Alexander Tiderko, Fraunhofer FKIE" 
36  __license__ = "BSD" 
37  __version__ = "0.3.0" 
38  __date__ = "2012-02-01" 
39   
40   
41  import sys 
42   
43  import roslib; roslib.load_manifest('master_sync_fkie') 
44  import rospy 
45   
46  import master_sync 
47   
48  NODE_NAME = "master_sync" 
49   
50   
51 -def setTerminalName(name):
52 ''' 53 Change the terminal name. 54 @param name: New name of the terminal 55 @type name: C{str} 56 ''' 57 sys.stdout.write("".join(["\x1b]2;",name,"\x07"]))
58
59 -def setProcessName(name):
60 ''' 61 Change the process name. 62 @param name: New process name 63 @type name: C{str} 64 ''' 65 try: 66 from ctypes import cdll, byref, create_string_buffer 67 libc = cdll.LoadLibrary('libc.so.6') 68 buff = create_string_buffer(len(name)+1) 69 buff.value = name 70 libc.prctl(15, byref(buff), 0, 0, 0) 71 except: 72 pass
73 74
75 -def main():
76 ''' 77 Creates and runs the ROS node. 78 ''' 79 rospy.init_node(NODE_NAME, log_level=rospy.DEBUG) 80 setTerminalName(rospy.get_name()) 81 setProcessName(rospy.get_name()) 82 # time to initialize the topics to receive these in rxconsole 83 discoverer = master_sync.Main() 84 if not rospy.is_shutdown(): 85 rospy.spin()
86 87 88 #if __name__ == '__main__': 89 # main() 90