master.py
Go to the documentation of this file.
00001 #
00002 # License: BSD
00003 #   https://raw.github.com/robotics-in-concert/rocon_tools/license/LICENSE
00004 #
00005 ##############################################################################
00006 # Imports
00007 ##############################################################################
00008 
00009 import rospy
00010 import rocon_std_msgs.msg as rocon_std_msgs
00011 import rocon_python_utils
00012 
00013 ##############################################################################
00014 # Conductor
00015 ##############################################################################
00016 
00017 
00018 class RoconMaster(object):
00019     __slots__ = [
00020             'publishers',
00021             'param',
00022             'spin',
00023         ]
00024 
00025     def __init__(self):
00026         ##################################
00027         # Pubs, Subs and Services
00028         ##################################
00029         self.publishers = {}
00030         # efficient latched publisher, put in the public concert namespace.
00031         self.param = self._setup_ros_parameters()
00032         self.publishers["info"] = rospy.Publisher("info", rocon_std_msgs.MasterInfo, latch=True)
00033         master_info = rocon_std_msgs.MasterInfo()
00034         master_info.name = self.param['name']
00035         master_info.description = self.param['description']
00036         master_info.icon = rocon_python_utils.ros.icon_resource_to_msg(self.param['icon'])
00037         master_info.version = rocon_std_msgs.Strings.ROCON_VERSION
00038         self.publishers['info'].publish(master_info)
00039         # Aliases
00040         self.spin = rospy.spin
00041 
00042     def _setup_ros_parameters(self):
00043         '''
00044           Parameters that are configurable (overridable) are currently set via args in the
00045           concert master launcher where they are published as parameters. We grab those here.
00046 
00047           Parameters that are fixed (not configurable), we set here so we can access the message
00048           string constant and use that (also to avoid roslaunch clutter).
00049         '''
00050         param = {}
00051         param['name'] = rospy.get_param('name', 'Cybernetic Pirate')
00052         param['icon'] = rospy.get_param('icon', 'rocon_icons/cybernetic_pirate.png')
00053         param['description'] = rospy.get_param('description', 'A rocon system.')
00054         # a local version
00055         rospy.set_param('version', rocon_std_msgs.Strings.ROCON_VERSION)
00056         # and a global version (useful as a ping to check for a rocon master (e.g. by androids)
00057         rospy.set_param('/rocon/version', rocon_std_msgs.Strings.ROCON_VERSION)
00058         return param


rocon_master_info
Author(s): Daniel Stonier
autogenerated on Fri May 2 2014 10:35:44