12 from gateway_msgs.msg
import Rule, RemoteRule
23 Returns the gateway parameters from the ros param server. 24 Most of these should be fairly self explanatory. 30 custom_configuration_file = rospy.get_param(
'~custom_rules_file')
31 if custom_configuration_file:
32 if os.path.isfile(custom_configuration_file):
33 loaded_parameters = rosparam.load_file(custom_configuration_file, default_namespace=rospy.resolve_name(rospy.get_name()))
34 for params, ns
in loaded_parameters:
36 existing_parameters = rosparam.get_param(ns)
37 for p, v
in params.iteritems():
38 if p
in [
'default_flips',
'default_advertisements',
'default_pulls']
and p
in existing_parameters:
39 existing_parameters[p] += v
41 existing_parameters[p] = v
42 rosparam.upload_params(ns, existing_parameters, verbose=
True)
44 rospy.logwarn(
"Gateway : user provided configuration file could not be found [%s]" % custom_configuration_file)
50 param[
'hub_uri'] = rospy.get_param(
'~hub_uri',
'')
53 param[
'hub_whitelist'] = rospy.get_param(
'~hub_whitelist', [])
54 param[
'hub_blacklist'] = rospy.get_param(
'~hub_blacklist', [])
57 param[
'name'] = rospy.get_param(
'~name',
'gateway')
58 param[
'watch_loop_period'] = rospy.get_param(
'~watch_loop_period', 10)
61 param[
'default_blacklist'] = rospy.get_param(
'~default_blacklist', [])
64 param[
'firewall'] = rospy.get_param(
'~firewall',
True)
67 param[
'disable_zeroconf'] = rospy.get_param(
'~disable_zeroconf',
False)
72 param[
'disable_uuids'] = rospy.get_param(
'~disable_uuids',
False)
75 param[
'advertise_all'] = rospy.get_param(
'~advertise_all', [])
78 param[
'default_advertisements'] = rospy.get_param(
'~default_advertisements', [])
79 param[
'default_flips'] = rospy.get_param(
'~default_flips', [])
80 param[
'default_pulls'] = rospy.get_param(
'~default_pulls', [])
83 param[
'network_interface'] = rospy.get_param(
'~network_interface',
'')
90 Converts a param of the suitable type (see default_blacklist.yaml) 91 into a dictionary of Rule types. 93 @return all rules as gateway_msgs.msg.Rule objects in our usual keyed dictionary format 94 @rtype type keyed dictionary of Rule lists 96 rules = utils.create_empty_connection_type_dictionary()
99 rule.name = value[
'name']
101 pattern = re.compile(
"None", re.IGNORECASE)
102 if pattern.match(value[
'node']):
105 rule.node = value[
'node']
106 rule.type = value[
'type']
107 rules[rule.type].append(rule)
113 Converts a param of the suitable type (default_flips, default_pulls) into 114 a list of RemoteRule objects and a list of target gateways for flip_all/pull_all. 119 @return list of remote rules 124 pattern = re.compile(
"None", re.IGNORECASE)
125 for remote_rule
in param:
126 if 'rule' in remote_rule:
128 node =
None if pattern.match(remote_rule[
'rule'][
'node'])
else remote_rule[
'rule'][
'node']
129 remote_rules.append(RemoteRule(remote_rule[
'gateway'],
130 Rule(remote_rule[
'rule'][
'type'],
131 remote_rule[
'rule'][
'name'],
137 all_targets.append(remote_rule[
'gateway'])
138 return remote_rules, all_targets
def setup_ros_parameters()
Functions.
def generate_remote_rules(param)
def generate_rules(param)