Commit e65ba795 authored by Léo-Paul Géneau's avatar Léo-Paul Géneau 👾

software/js-drone: define netIf independently

Network interface can now be defined for each computer.
parent 91c13bb4
......@@ -13,8 +13,7 @@
* autopilotType: Select which autopilot wrapper should be used
* autopilotIp: IPv4 address to identify the autopilot from the companion board
* autopilotPort: Port on whichautopilot serviceis running
* droneGuidList: List of computer id on which flight script must be deployed
* droneNetIf: Drone network interface used for multicast traffic
* droneList: List of computer on which flight script must be deployed
* debug: Must be set to 'true' to send drone logs through OPC-UA
* multicastIp: IPv6 of the multicast group of the swarm
* operatorScript: URL of operator's script to prepare the flight
......@@ -22,8 +21,7 @@
* flightScript: URL of user's script to execute to fly drone swarm
* subscriptionScript: URL of the script which will be executed by subscribers
* loopPeriod: Minimal period (in milliseconds) between 2 executions of the flight script loop
* subscriberGuidList: List of computer id on which a GUI must be deployed
* subscriberNetIf: Subscriber network interface used for multicast traffic
* subscriberList: List of computer on which a GUI must be deployed
## How it works ##
......
......@@ -22,11 +22,11 @@ md5sum = 01425a1c77e79788e1948398b9136724
[instance-profile]
filename = instance.cfg.in
md5sum = 13a389530d919937901f6c4b12cfbc19
md5sum = 87968c91591db2c0778f41f7404700c7
[instance-root]
filename = instance-root.cfg.jinja2
md5sum = a217eddf949e6e838129e61cc2a48d34
md5sum = 2372a1cf3616ccbd97ada047a645cb32
[instance-subscriber]
filename = instance-subscriber.cfg.in
......
{
"$schema": "http://json-schema.org/draft-06/schema",
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"description": "Parameters to instantiate JS drone",
"additionalProperties": false,
"definitions": {
"entitie-list": {
"description": "List of entities able to listen/send OPC-UA messages from/to the swarm",
"type": "array",
"default": [],
"items": {
"type": "object",
"properties": {
"guid": {
"description": "Computer ID",
"type": "string"
},
"netIf": {
"description": "Interface used for multicast traffic.",
"type": "string",
"default": "eth0"
}
}
},
"uniqueItems": true
}
},
"properties": {
"autopilotType": {
"title": "Type of the drone's autopilot",
......@@ -26,17 +48,9 @@
"type": "integer",
"default": 7909
},
"droneGuidList": {
"title": "List of drones computer ID",
"description": "List of computer ID of drones in the swarm",
"type": "array",
"default": []
},
"droneNetIf": {
"title": "Drones Network interface",
"description": "Interface used for multicast traffic.",
"type": "string",
"default": "eth0"
"droneList": {
"$ref": "#/definitions/entitie-list",
"title": "List of drones in the swarm"
},
"debug": {
"title": "Set debug mode",
......@@ -80,17 +94,9 @@
"type": "integer",
"default": 200
},
"subscriberGuidList": {
"title": "List of subscribers computer ID",
"description": "List of computer ID of swarms subscribers (entities able to listen/send OPC-UA messages from/to the swarm)",
"type": "array",
"default": []
},
"subscriberNetIf": {
"title": "Subscribers Network interface",
"description": "Interface used for multicast traffic.",
"type": "string",
"default": "eth0"
"subscriberList": {
"$ref": "#/definitions/entitie-list",
"title": "List of swarm subscribers"
}
}
}
{% set parameter_dict = dict(default_parameter_dict, **parameter_dict) -%}
{% set guid_list = parameter_dict['droneGuidList'] + parameter_dict['subscriberGuidList'] -%}
{% set entitie_list = parameter_dict['droneList'] + parameter_dict['subscriberList'] -%}
{% set drone_id_list = [] -%}
{% set subscriber_id_list = [] -%}
{% set part_list = ['publish-connection-information'] -%}
{% for id, guid in enumerate(guid_list) -%}
{% for id, entitie in enumerate(entitie_list) -%}
{% set request_peer_section_title = 'request-peer' ~ id -%}
{% do part_list.append(request_peer_section_title) %}
{% set guid = entitie['guid'] %}
[{{ request_peer_section_title }}]
<= slap-connection
recipe = slapos.cookbook:request.serialised
{% if id < len(parameter_dict['droneGuidList']) -%}
{% if id < len(parameter_dict['droneList']) -%}
{% set sr_name = parameter_dict['autopilotType'] -%}
name = Drone{{ id }}_{{ guid }}
{% else -%}
{% set sr_name = 'subscriber' -%}
name = Subscriber{{ len(parameter_dict['droneGuidList']) - id }}_{{ guid }}
name = Subscriber{{ len(parameter_dict['droneList']) - id }}_{{ guid }}
{% endif -%}
software-url = {{ '/'.join(software_url.split('/')[:-1]) + '/software-%s.cfg' % sr_name }}
return = instance-path
sla-computer_guid = {{ guid }}
config-autopilotIp = {{ parameter_dict['autopilotIp'] }}
config-autopilotPort = {{ dumps(parameter_dict['autopilotPort']) }}
config-numberOfDrones = {{ dumps(len(parameter_dict['droneGuidList'])) }}
config-numberOfSubscribers = {{ dumps(len(parameter_dict['subscriberGuidList'])) }}
config-numberOfDrones = {{ dumps(len(parameter_dict['droneList'])) }}
config-numberOfSubscribers = {{ dumps(len(parameter_dict['subscriberList'])) }}
config-id = {{ dumps(id) }}
config-debug = {{ dumps(parameter_dict['debug']) }}
config-loopPeriod = {{ dumps(parameter_dict['loopPeriod']) }}
{% if id < len(parameter_dict['droneGuidList']) -%}
config-netIf = {{ entitie.get('netIf', 'eth0') }}
{% if id < len(parameter_dict['droneList']) -%}
{% do drone_id_list.append(id) %}
config-isADrone = {{ dumps(True) }}
config-flightScript = {{ parameter_dict['flightScript'] }}
config-netIf = {{ parameter_dict['droneNetIf'] }}
{% else -%}
{% do subscriber_id_list.append(id) %}
config-isADrone = {{ dumps(False) }}
config-operatorScript = {{ parameter_dict['operatorScript'] }}
config-mapJson = {{ parameter_dict['mapJson'] }}
config-flightScript = {{ parameter_dict['subscriptionScript'] }}
config-netIf = {{ parameter_dict['subscriberNetIf'] }}
{% endif -%}
config-multicastIp = {{ parameter_dict['multicastIp'] }}
{% endfor %}
......
......@@ -35,14 +35,12 @@ default-parameters =
"autopilotIp": "192.168.27.1",
"autopilotPort": 7909,
"debug": false,
"droneGuidList": [],
"droneNetIf": "eth0",
"droneList": [],
"operatorScript": "https://lab.nexedi.com/nexedi/flight-scripts/-/raw/operator_script/operator.js",
"mapJson": "https://lab.nexedi.com/nexedi/flight-scripts/-/raw/operator_script/map.json",
"flightScript": "https://lab.nexedi.com/nexedi/flight-scripts/-/raw/operator_script/default.js",
"subscriptionScript": "https://lab.nexedi.com/nexedi/flight-scripts/-/raw/operator_script/subscribe.js",
"loopPeriod": 200,
"multicastIp": "ff15::1111",
"subscriberGuidList":[],
"subscriberNetIf": "eth0"
"subscriberList":[]
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment