sendPOSI command change (double for lat/lon/h) (#111)
* Updated POSI to use doubles for lat/lon/alt, as step size for floats was unacceptably large at high longitudes.
This commit is contained in:
committed by
Jason Watkins
parent
48656f2b4c
commit
0e493920fa
@@ -1,6 +1,6 @@
|
||||
function sendPOSI( posi, ac, socket )
|
||||
% sendPOSI Sets the position of the specified aircraft.
|
||||
%
|
||||
%
|
||||
% Inputs
|
||||
% posi: Position array where the elements are as follows:
|
||||
% 1. Latitiude (deg)
|
||||
@@ -12,14 +12,14 @@ function sendPOSI( posi, ac, socket )
|
||||
% 7. Gear (0=up, 1=down)
|
||||
% acft (optional): The aircraft to set. 0 for the player aircraft.
|
||||
% socket (optional): The client to use when sending the command.
|
||||
%
|
||||
%
|
||||
% Use
|
||||
% 1. import XPlaneConnect.*;
|
||||
% 2. sendPOSI([37.5242422, -122.06899, 2500, 0, 0, 0, 1], 1);
|
||||
%
|
||||
%
|
||||
% Note: send the value -998 to not overwrite that parameter. That is, if
|
||||
% -998 is sent, the parameter will stay at the current X-Plane value.
|
||||
%
|
||||
%
|
||||
% Contributors
|
||||
% [CT] Christopher Teubert (SGT, Inc.)
|
||||
% christopher.a.teubert@nasa.gov
|
||||
@@ -33,14 +33,14 @@ global clients;
|
||||
if ~exist('socket', 'var')
|
||||
assert(isequal(length(clients) < 2, 1), '[sendPOSI] ERROR: Multiple clients open. You must specify which client to use.');
|
||||
if isempty(clients)
|
||||
socket = openUDP();
|
||||
socket = openUDP();
|
||||
else
|
||||
socket = clients(1);
|
||||
end
|
||||
end
|
||||
|
||||
%% Validate input
|
||||
posi = single(posi);
|
||||
posi = double(posi);
|
||||
if ~exist('ac', 'var')
|
||||
ac = 0;
|
||||
end
|
||||
@@ -49,4 +49,4 @@ ac = logical(ac);
|
||||
%% Send command
|
||||
socket.sendPOSI(posi, ac);
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -11,9 +11,9 @@ Socket = openUDP();
|
||||
while 1
|
||||
posi = getPOSI(0, Socket);
|
||||
ctrl = getCTRL(0, Socket);
|
||||
|
||||
|
||||
fprintf('Loc: (%4f, %4f, %4f) Aileron:%2f Elevator:%2f Rudder:%2f\n', ...
|
||||
posi(1), posi(2), posi(3), ctrl(2), ctrl(1), ctrl(3));
|
||||
pause(0.1);
|
||||
end
|
||||
closeUDP(Socket);
|
||||
closeUDP(Socket);
|
||||
|
||||
Reference in New Issue
Block a user