core.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 
00003 # MIT License
00004 #
00005 # Copyright (c) <2015> <Ikergune, Etxetar>
00006 #
00007 # Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files
00008 # (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge,
00009 # publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
00010 # subject to the following conditions:
00011 #
00012 # The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
00013 #
00014 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00015 # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
00016 # FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
00017 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00018 
00019 
00020 # ROSPY LOGS
00021 # logdebug
00022 # logerr
00023 # logfatal
00024 # loginfo
00025 # logout
00026 # logwarn
00027 
00028 # Import required Python code.
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 # Main function.
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()


firos
Author(s): IƱigo Gonzalez, igonzalez@ikergune.com
autogenerated on Thu Jun 6 2019 17:51:04