mirror of
https://github.com/valmojr/armatak.git
synced 2026-06-13 13:23:28 +00:00
Added initial Laser Ranger Finder simulator on port 17211 (as default) emulate digital pointer for in game laser designators
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
PREP(convertClientLocation);
|
||||
PREP(extractClientPosition);
|
||||
PREP(sendLaserRangeFinder);
|
||||
PREP(startUDPSocket);
|
||||
|
||||
@@ -6,3 +6,4 @@ _local_address = "armatak" callExtension ["local_ip", []] select 0;
|
||||
|
||||
SETVAR(player,GVAR(localAddress),_local_address);
|
||||
SETVAR(player,GVAR(eudConnected),false);
|
||||
SETVAR(player,GVAR(lrfEnabled),false);
|
||||
|
||||
@@ -12,7 +12,7 @@ class armatak_udp_socket_start_dialog {
|
||||
x = "0.386562 * safezoneW + safezoneX";
|
||||
y = "0.357 * safezoneH + safezoneY";
|
||||
w = "0.216563 * safezoneW";
|
||||
h = "0.418 * safezoneH";
|
||||
h = "0.495 * safezoneH";
|
||||
colorBackground[]={0,0,0,0.45};
|
||||
};
|
||||
};
|
||||
@@ -48,12 +48,22 @@ class armatak_udp_socket_start_dialog {
|
||||
idc = 16969;
|
||||
text = "";
|
||||
x = "0.391719 * safezoneW + safezoneX";
|
||||
y = "0.632 * safezoneH + safezoneY";
|
||||
y = "0.709 * safezoneH + safezoneY";
|
||||
w = "0.20625 * safezoneW";
|
||||
h = "0.044 * safezoneH";
|
||||
colorBackground[]={0,0,0,0.5};
|
||||
tooltip = "Optional shared feed URL. If empty, the UAV 3DEN URL is used first, then a local RTP fallback.";
|
||||
};
|
||||
class armatak_gui_module_udp_socket_dialog_lrf_port_edit: RscEdit {
|
||||
idc = 16971;
|
||||
text = "17211";
|
||||
x = "0.391719 * safezoneW + safezoneX";
|
||||
y = "0.632 * safezoneH + safezoneY";
|
||||
w = "0.20625 * safezoneW";
|
||||
h = "0.044 * safezoneH";
|
||||
colorBackground[]={0,0,0,0.5};
|
||||
tooltip = "ATAK local Laser Range Finder UDP input. Leave empty to disable.";
|
||||
};
|
||||
class armatak_gui_module_udp_socket_dialog_address_text: RscText {
|
||||
idc = 16963;
|
||||
text = "EUD's Address";
|
||||
@@ -82,6 +92,14 @@ class armatak_udp_socket_start_dialog {
|
||||
idc = 16970;
|
||||
text = "Video Feed URL (Optional)";
|
||||
x = "0.391719 * safezoneW + safezoneX";
|
||||
y = "0.676 * safezoneH + safezoneY";
|
||||
w = "0.20625 * safezoneW";
|
||||
h = "0.033 * safezoneH";
|
||||
};
|
||||
class armatak_gui_module_udp_socket_dialog_lrf_port_text: RscText {
|
||||
idc = 16972;
|
||||
text = "Laser Range Finder Port";
|
||||
x = "0.391719 * safezoneW + safezoneX";
|
||||
y = "0.599 * safezoneH + safezoneY";
|
||||
w = "0.20625 * safezoneW";
|
||||
h = "0.033 * safezoneH";
|
||||
@@ -91,7 +109,7 @@ class armatak_udp_socket_start_dialog {
|
||||
text = "Cancel";
|
||||
action = "closeDialog 2;";
|
||||
x = "0.551563 * safezoneW + safezoneX";
|
||||
y = "0.709 * safezoneH + safezoneY";
|
||||
y = "0.786 * safezoneH + safezoneY";
|
||||
w = "0.0464063 * safezoneW";
|
||||
h = "0.055 * safezoneH";
|
||||
};
|
||||
@@ -100,7 +118,7 @@ class armatak_udp_socket_start_dialog {
|
||||
text = "Ok";
|
||||
action = QUOTE(call FUNC(startUDPSocket));
|
||||
x = "0.5 * safezoneW + safezoneX";
|
||||
y = "0.709 * safezoneH + safezoneY";
|
||||
y = "0.786 * safezoneH + safezoneY";
|
||||
w = "0.0464063 * safezoneW";
|
||||
h = "0.055 * safezoneH";
|
||||
};
|
||||
|
||||
52
addons/client/functions/fnc_sendLaserRangeFinder.sqf
Normal file
52
addons/client/functions/fnc_sendLaserRangeFinder.sqf
Normal file
@@ -0,0 +1,52 @@
|
||||
#include "..\script_component.hpp"
|
||||
|
||||
params ["_unit"];
|
||||
|
||||
private _lrfEnabled = player getVariable [QGVAR(lrfEnabled), false];
|
||||
|
||||
private _uid = format ["%1.LRF", _unit call armatak_fnc_extract_uuid];
|
||||
private _laserTarget = laserTarget _unit;
|
||||
|
||||
if (!isNull _laserTarget) exitWith {
|
||||
private _originASL = getPosASL _unit;
|
||||
private _targetASL = getPosASL _laserTarget;
|
||||
private _delta = _targetASL vectorDiff _originASL;
|
||||
|
||||
private _dx = _delta select 0;
|
||||
private _dy = _delta select 1;
|
||||
private _dz = _delta select 2;
|
||||
private _horizontalDistance = sqrt ((_dx * _dx) + (_dy * _dy));
|
||||
private _slantDistance = (_originASL vectorDistance _targetASL) max 1;
|
||||
private _azimuth = (((_dx atan2 _dy) + 360) mod 360);
|
||||
private _elevation = _dz atan2 (_horizontalDistance max 0.001);
|
||||
private _lastTargetASL = player getVariable [QGVAR(lrfLastTargetASL), []];
|
||||
private _lastSentAt = player getVariable [QGVAR(lrfLastSentAt), -1000];
|
||||
private _targetMoved = _lastTargetASL isEqualTo [] || {(_lastTargetASL vectorDistance _targetASL) > 5};
|
||||
private _sendCooldownElapsed = (time - _lastSentAt) >= 2.5;
|
||||
|
||||
player setVariable [QGVAR(lrfWasActive), true];
|
||||
player setVariable [QGVAR(lrfLostAt), -1];
|
||||
player setVariable [QGVAR(lrfClearSent), false];
|
||||
|
||||
if (_lrfEnabled && {_targetMoved} && {_sendCooldownElapsed}) then {
|
||||
"armatak" callExtension ["udp_socket:send_lrf", [[_uid, _slantDistance, _azimuth, _elevation]]];
|
||||
player setVariable [QGVAR(lrfLastTargetASL), _targetASL];
|
||||
player setVariable [QGVAR(lrfLastSentAt), time];
|
||||
};
|
||||
};
|
||||
|
||||
if !(player getVariable [QGVAR(lrfWasActive), false]) exitWith {};
|
||||
|
||||
private _lostAt = player getVariable [QGVAR(lrfLostAt), -1];
|
||||
if (_lostAt < 0) then {
|
||||
player setVariable [QGVAR(lrfLostAt), time];
|
||||
};
|
||||
|
||||
private _clearSent = player getVariable [QGVAR(lrfClearSent), false];
|
||||
if (_lrfEnabled && {!_clearSent} && {(time - (player getVariable [QGVAR(lrfLostAt), time])) >= 6}) then {
|
||||
"armatak" callExtension ["udp_socket:clear_lrf", [_uid]];
|
||||
player setVariable [QGVAR(lrfWasActive), false];
|
||||
player setVariable [QGVAR(lrfClearSent), true];
|
||||
player setVariable [QGVAR(lrfLastTargetASL), []];
|
||||
player setVariable [QGVAR(lrfLastSentAt), -1000];
|
||||
};
|
||||
@@ -14,24 +14,38 @@ disableSerialization;
|
||||
private _eud_address = ctrlText 16961;
|
||||
private _gnss_port = ctrlText 16962;
|
||||
private _mavlink_port = ctrlText 16967;
|
||||
private _lrf_port = ctrlText 16971;
|
||||
private _video_feed_url = ctrlText 16969;
|
||||
|
||||
private _udp_socket_fulladdress = _eud_address + ":" + _gnss_port;
|
||||
private _mavlink_address = _eud_address + ":" + _mavlink_port;
|
||||
private _lrf_port_trimmed = trim _lrf_port;
|
||||
private _lrf_enabled = _lrf_port_trimmed isNotEqualTo "";
|
||||
private _lrf_address = _eud_address + ":" + _lrf_port_trimmed;
|
||||
|
||||
player setVariable [QGVAR(udp_socket_address), _udp_socket_fulladdress];
|
||||
player setVariable [QGVAR(mavlink_address), _mavlink_address];
|
||||
player setVariable [QGVAR(lrf_address), _lrf_address];
|
||||
player setVariable [QGVAR(lrfEnabled), _lrf_enabled];
|
||||
player setVariable [QGVAR(lrfWasActive), false];
|
||||
player setVariable [QGVAR(lrfLostAt), -1];
|
||||
player setVariable [QGVAR(lrfClearSent), false];
|
||||
player setVariable [QGVAR(lrfLastTargetASL), []];
|
||||
player setVariable [QGVAR(lrfLastSentAt), -1000];
|
||||
player setVariable [QGVAR(video_feed_url), trim _video_feed_url];
|
||||
player setVariable [QGVAR(eudConnected), true];
|
||||
player setVariable [QGVAR(eudConnected), true, true];
|
||||
|
||||
private _advertised_video_uri = [objNull] call EFUNC(uav,resolveVideoUri);
|
||||
|
||||
"armatak" callExtension ["udp_socket:start", [_udp_socket_fulladdress]];
|
||||
"armatak" callExtension ["uas:start_endpoint", [parseNumber _mavlink_port]];
|
||||
if (_lrf_enabled) then {
|
||||
"armatak" callExtension ["udp_socket:start_lrf", [_lrf_address]];
|
||||
};
|
||||
|
||||
private _mdnsInstanceName = format ["ArmaTAK-%1", name player];
|
||||
"armatak" callExtension ["mdns:start_uas_advertisement", [_mdnsInstanceName, parseNumber _mavlink_port, _advertised_video_uri]];
|
||||
"armatak" callExtension ["log", [["info", format ["Client UDP socket started for %1, MAVLink target set to %2 and advertised video URI set to %3", _udp_socket_fulladdress, _mavlink_address, _advertised_video_uri]]]];
|
||||
"armatak" callExtension ["log", [["info", format ["Client UDP socket started for %1, MAVLink target set to %2, LRF target set to %3 and advertised video URI set to %4. Digital pointer uses ATAK LRF when enabled.", _udp_socket_fulladdress, _mavlink_address, _lrf_address, _advertised_video_uri]]]];
|
||||
|
||||
call EFUNC(uav,startMavlinkBroadcast);
|
||||
|
||||
@@ -41,5 +55,11 @@ call EFUNC(uav,startMavlinkBroadcast);
|
||||
"armatak" callExtension ["udp_socket:send_gps_cot", [player call FUNC(extractClientPosition)]];
|
||||
}, 0.5, []] call CBA_fnc_addPerFrameHandler;
|
||||
|
||||
[{
|
||||
if !(player getVariable [QGVAR(eudConnected), false]) exitWith {};
|
||||
|
||||
[player] call FUNC(sendLaserRangeFinder);
|
||||
}, 0.25, []] call CBA_fnc_addPerFrameHandler;
|
||||
|
||||
deleteVehicle _logic;
|
||||
closeDialog 1;
|
||||
|
||||
@@ -9,10 +9,11 @@ addMissionEventHandler ["ExtensionCallback", {
|
||||
|
||||
switch (_function) do {
|
||||
case "EUD Connected": {
|
||||
SETVAR(player,EGVAR(client,eudConnected),true);
|
||||
player setVariable [QEGVAR(client,eudConnected), true, true];
|
||||
};
|
||||
case "EUD Disconnected": {
|
||||
SETVAR(player,EGVAR(client,eudConnected),false);
|
||||
player setVariable [QEGVAR(client,eudConnected), false, true];
|
||||
SETVAR(player,EGVAR(client,lrfEnabled),false);
|
||||
call EFUNC(uav,stopMavlinkBroadcast);
|
||||
"armatak" callExtension ["uas:stop_endpoint", []];
|
||||
"armatak" callExtension ["mdns:stop", []];
|
||||
@@ -27,14 +28,16 @@ addMissionEventHandler ["ExtensionCallback", {
|
||||
[_function, "error", _name] call FUNC(notify);
|
||||
|
||||
if (_function == "UDP Socket is not running") then {
|
||||
SETVAR(player,EGVAR(client,eudConnected),false);
|
||||
player setVariable [QEGVAR(client,eudConnected), false, true];
|
||||
SETVAR(player,EGVAR(client,lrfEnabled),false);
|
||||
call EFUNC(uav,stopMavlinkBroadcast);
|
||||
"armatak" callExtension ["uas:stop_endpoint", []];
|
||||
"armatak" callExtension ["mdns:stop", []];
|
||||
};
|
||||
|
||||
if (_function == "failed to bind UDP socket") then {
|
||||
SETVAR(player,EGVAR(client,eudConnected),false);
|
||||
player setVariable [QEGVAR(client,eudConnected), false, true];
|
||||
SETVAR(player,EGVAR(client,lrfEnabled),false);
|
||||
call EFUNC(uav,stopMavlinkBroadcast);
|
||||
"armatak" callExtension ["uas:stop_endpoint", []];
|
||||
"armatak" callExtension ["mdns:stop", []];
|
||||
|
||||
Reference in New Issue
Block a user