Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 import sys
00030 import copy
00031 import rospy
00032 import signal
00033
00034 from setup import launchSetup
00035
00036 from include.constants import *
00037
00038 from include import confManager
00039 from include.logger import Log
00040 from include.mapServer import MapServer
00041 from include.server.firosServer import FirosServer
00042
00043 from include.ros.topicHandler import TopicHandler, loadMsgHandlers, connectionListeners
00044 from include.rcm import topicManager
00045
00046
00047 if __name__ == '__main__':
00048
00049 Log("INFO", "Initializing ROS node: " + NODE_NAME)
00050 rospy.init_node(NODE_NAME)
00051 Log("INFO", "Initialized")
00052
00053 port = None
00054
00055 args = copy.deepcopy(sys.argv)
00056 args.pop(0)
00057
00058 for i in range(len(args)-1):
00059 if args[i].upper() == "-P":
00060 i = i + 1
00061 port = int(args[i])
00062
00063 if port is None:
00064 port = SERVER_PORT
00065
00066 try:
00067 server = FirosServer("0.0.0.0", port)
00068 except Exception as ex:
00069 sys.stderr.write('CB_COMMUNICATION_FAILED')
00070 exit(1)
00071 else:
00072 def signal_handler(signal, frame):
00073 Log("INFO", ('\nExiting from the application'))
00074 TopicHandler.unregisterAll()
00075 topicManager.removeListeners()
00076 server.close()
00077 Log("INFO", ('\nExit'))
00078 sys.exit(0)
00079 signal.signal(signal.SIGINT, signal_handler)
00080 signal.signal(signal.SIGTERM, signal_handler)
00081
00082 launchSetup()
00083
00084 Log("INFO", "\nStarting Firos...")
00085 Log("INFO", "---------------------------------\n")
00086
00087 loadMsgHandlers(confManager.getRobots(True, True))
00088 connectionListeners()
00089 topicManager.setListeners()
00090
00091 MapServer.load()
00092
00093 Log("INFO", "\nPress Ctrl+C to Exit\n")
00094 server.start()