Exemple #1
0
    def __init__(self):
        self._param = rocon_gateway.setup_ros_parameters()
        if self._param['disable_uuids']:
            self._unique_name = self._param['name']
            rospy.logwarn(
                "Gateway : uuid's disabled, using possibly non-unique name [%s]"
                % self._unique_name)
        else:  # append a unique hex string
            # random 16 byte string, alternatively uuid.getnode() returns a hash based
            # on the mac address, uuid.uid1() based on localhost and time
            key = uuid.uuid4()
            self._unique_name = self._param['name'] + key.hex
            rospy.loginfo("Gateway : generated unique hash name [%s]" %
                          self._unique_name)
        self._hub_manager = hub_manager.HubManager(
            hub_whitelist=self._param['hub_whitelist'],
            hub_blacklist=self._param['hub_blacklist'])
        # Be careful of the construction sequence here, parts depend on others.
        self._gateway_publishers = self._setup_ros_publishers()
        # self._publish_gateway_info needs self._gateway_publishers
        self._gateway = gateway.Gateway(self._hub_manager, self._param,
                                        self._unique_name,
                                        self._publish_gateway_info)
        self._gateway_services = self._setup_ros_services(
        )  # Needs self._gateway
        self._gateway_subscribers = self._setup_ros_subscribers(
        )  # Needs self._gateway
        # 'ip:port' : (error_code, error_code_str) dictionary of hubs that this gateway has tried to register,
        # but not been permitted (hub is not in whitelist, or is blacklisted)
        self._disallowed_hubs = {}
        self._disallowed_hubs_error_codes = [
            gateway_msgs.ErrorCodes.HUB_CONNECTION_NOT_IN_NONEMPTY_WHITELIST,
            gateway_msgs.ErrorCodes.HUB_CONNECTION_BLACKLISTED,
            gateway_msgs.ErrorCodes.HUB_NAME_NOT_FOUND,
            # this now has to be permitted as we will often have zeroconf failing for gateways
            # that have dropped out of wireless range.
            # gateway_msgs.ErrorCodes.HUB_CONNECTION_UNRESOLVABLE
        ]
        direct_hub_uri_list = [self._param['hub_uri']
                               ] if self._param['hub_uri'] != '' else []
        self._hub_discovery_thread = rocon_hub_client.HubDiscovery(
            self._register_gateway, direct_hub_uri_list,
            self._param['disable_zeroconf'], self._disallowed_hubs)

        # Shutdown hooks - allowing external triggers for shutting down
        if self._param['external_shutdown']:
            rospy.on_shutdown(self._wait_for_shutdown)
            unused_shutdown_service = rospy.Service('~shutdown',
                                                    std_srvs.Empty,
                                                    self.ros_service_shutdown)

        # Make local gateway information immediately available
        self._publish_gateway_info()
    def __init__(self):
        self._param = rocon_gateway.setup_ros_parameters()
        if self._param['disable_uuids']:
            self._unique_name = self._param['name']
            rospy.logwarn("Gateway : uuid's disabled, using possibly non-unique name [%s]" % self._unique_name)
        else:  # append a unique hex string
            # random 16 byte string, alternatively uuid.getnode() returns a hash based
            # on the mac address, uuid.uid1() based on localhost and time
            key = uuid.uuid4()
            self._unique_name = self._param['name'] + key.hex
            rospy.loginfo("Gateway : generated unique hash name [%s]" % self._unique_name)
        self._hub_manager = hub_manager.HubManager(
            hub_whitelist=self._param['hub_whitelist'],
            hub_blacklist=self._param['hub_blacklist']
        )
        # Be careful of the construction sequence here, parts depend on others.
        self._gateway_publishers = self._setup_ros_publishers()
        # self._publish_gateway_info needs self._gateway_publishers
        self._gateway = gateway.Gateway(self._hub_manager, self._param, self._unique_name, self._publish_gateway_info)
        self._gateway_services = self._setup_ros_services()  # Needs self._gateway
        self._gateway_subscribers = self._setup_ros_subscribers()  # Needs self._gateway
        # 'ip:port' : (error_code, error_code_str) dictionary of hubs that this gateway has tried to register,
        # but not been permitted (hub is not in whitelist, or is blacklisted)
        self._disallowed_hubs = {}
        self._disallowed_hubs_error_codes = [gateway_msgs.ErrorCodes.HUB_CONNECTION_NOT_IN_NONEMPTY_WHITELIST,
                                             gateway_msgs.ErrorCodes.HUB_CONNECTION_BLACKLISTED,
                                             gateway_msgs.ErrorCodes.HUB_NAME_NOT_FOUND,
                                             # this now has to be permitted as we will often have zeroconf failing for gateways
                                             # that have dropped out of wireless range.
                                             # gateway_msgs.ErrorCodes.HUB_CONNECTION_UNRESOLVABLE
                                             ]
        direct_hub_uri_list = [self._param['hub_uri']] if self._param['hub_uri'] != '' else []
        self._hub_discovery_thread = rocon_hub_client.HubDiscovery(
            self._register_gateway, direct_hub_uri_list, self._param['disable_zeroconf'], self._disallowed_hubs)

        # Shutdown hooks - allowing external triggers for shutting down
        if self._param['external_shutdown']:
            rospy.on_shutdown(self._wait_for_shutdown)
            unused_shutdown_service = rospy.Service('~shutdown', std_srvs.Empty, self.ros_service_shutdown)

        # Make local gateway information immediately available
        self._publish_gateway_info()
Exemple #3
0
    def __init__(self):
        self._param = rocon_gateway.setup_ros_parameters()
        key = uuid.uuid4(
        )  # random 16 byte string, alternatively uuid.getnode() returns a hash based on the mac address, uuid.uid1() based on localhost and time
        self._unique_name = self._param[
            'name'] + key.hex  # append a unique hex string
        rospy.loginfo("Gateway : generated unique hash name [%s]" %
                      self._unique_name)
        self._hub_manager = hub_manager.HubManager(
            hub_whitelist=self._param['hub_whitelist'],
            hub_blacklist=self._param['hub_blacklist'])
        self._gateway = gateway.Gateway(self._hub_manager, self._param,
                                        self._unique_name,
                                        self._publish_gateway_info)
        self._gateway_services = self._setup_ros_services()
        self._gateway_publishers = self._setup_ros_publishers()
        direct_hub_uri_list = [self._param['hub_uri']
                               ] if self._param['hub_uri'] != '' else []
        self._hub_discovery_thread = rocon_hub_client.HubDiscovery(
            self._register_gateway, direct_hub_uri_list,
            self._param['disable_zeroconf'])

        # aliases
        self.spin = self._gateway.spin