main.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 #
3 # License: BSD
4 # https://raw.github.com/robotics-in-concert/rocon_multimaster/license/LICENSE
5 #
6 ##############################################################################
7 # Imports
8 ##############################################################################
9 
10 import sys
11 
12 # Ros imports
13 import rospy
14 import std_srvs.srv as std_srvs
15 
16 # Local imports
17 from . import utils
18 from . import redis_server
19 from . import ros_parameters
20 from . import watcher
21 from . import zeroconf
22 
23 ##############################################################################
24 # Variables
25 ##############################################################################
26 
27 redi = None
28 timeout = 15
29 
30 
31 def shutdown():
32  global redi
33  if redi is not None:
34  rospy.loginfo("Hub : shutting down.")
35  redi.shutdown()
36  redi = None
37 
38 
39 ##############################################################################
40 # Main
41 ##############################################################################
42 
43 
44 def main():
45  global redi
46  global timeout
47  while not utils.check_master():
48  rospy.logerr("Unable to communicate with master!")
49  rospy.rostime.wallsleep(1.0)
50  if rospy.is_shutdown():
51  sys.exit(utils.red_string("Unable to communicate with master!"))
52  rospy.init_node('hub')
53  param = ros_parameters.load()
54 
55  # Installation checks - sys exits if the process if not installed.
56  utils.check_if_executable_available('redis-server')
57  if param['zeroconf']:
58  utils.check_if_executable_available('avahi-daemon')
59 
60  redi = redis_server.RedisServer(param)
61  redi.start() # sys exits if server connection is unavailable or incorrect version
62 
63  if param['zeroconf']:
64  zeroconf.advertise_port_to_avahi(param['port'], param['name']) # sys exits if running avahi-daemon not found
65 
66  watcher_thread = watcher.WatcherThread('localhost', param['port'])
67  watcher_thread.start()
68  rospy.spin()
69  shutdown()
def shutdown()
Definition: main.py:31
Main watcher thread.
Definition: watcher.py:27
def main()
Main.
Definition: main.py:44


rocon_hub
Author(s): Daniel Stonier , Jihoon Lee , Piyush Khandelwal
autogenerated on Mon Jun 10 2019 14:40:12