basic implementation of client/server for AERPAW, whole lot of mess included
This commit is contained in:
27
aerpaw/@uav/initialize.m
Normal file
27
aerpaw/@uav/initialize.m
Normal file
@@ -0,0 +1,27 @@
|
||||
function obj = initialize(obj, port, timeout, label)
|
||||
arguments (Input)
|
||||
obj (1, 1) {mustBeA(obj, "uav")};
|
||||
port (1, 1) double;
|
||||
timeout (1, 1) double;
|
||||
label (1, 1) string;
|
||||
end
|
||||
arguments (Output)
|
||||
obj (1, 1) {mustBeA(obj, "uav")};
|
||||
end
|
||||
obj.label = label;
|
||||
obj.port = port;
|
||||
obj.timeout = timeout;
|
||||
|
||||
% Branch here depending on environment
|
||||
if coder.target("MATLAB")
|
||||
obj.pos = [0, 0, 20] + rand(1, 3) * 10; % just put it somewhere so we can plot it
|
||||
|
||||
elseif coder.target("C++")
|
||||
% initialize ip/port
|
||||
coder.cinclude('udp_comm.h');
|
||||
coder.ceval('initComs', "ip", obj.port);
|
||||
end
|
||||
|
||||
obj.opMode = OPMODE.INITIALIZED;
|
||||
|
||||
end
|
||||
20
aerpaw/@uav/onYourMarks.m
Normal file
20
aerpaw/@uav/onYourMarks.m
Normal file
@@ -0,0 +1,20 @@
|
||||
function obj = onYourMarks(obj)
|
||||
arguments (Input)
|
||||
obj (1, 1) {mustBeA(obj, "uav")};
|
||||
end
|
||||
|
||||
arguments (Output)
|
||||
obj (1, 1) {mustBeA(obj, "uav")};
|
||||
end
|
||||
|
||||
% Receive initial position data
|
||||
initialPosition = read(obj.udp, 3, "double");
|
||||
|
||||
% Acknowledge message receipt
|
||||
|
||||
% teleport to desired position
|
||||
obj.pos = initialPosition;
|
||||
|
||||
keyboard
|
||||
|
||||
end
|
||||
22
aerpaw/@uav/uav.m
Normal file
22
aerpaw/@uav/uav.m
Normal file
@@ -0,0 +1,22 @@
|
||||
classdef uav
|
||||
properties
|
||||
label = "";
|
||||
|
||||
% Communications
|
||||
port;
|
||||
timeout;
|
||||
|
||||
% State
|
||||
opMode = OPMODE.INVALID;
|
||||
pos = NaN(1, 3);
|
||||
|
||||
% Commanding (not for codegen)
|
||||
commandOpMode = OPMODE.INVALID;
|
||||
commandPos = NaN(1, 3);
|
||||
end
|
||||
|
||||
methods (Access = public)
|
||||
obj = initialize(obj, port, timeout, label)
|
||||
obj = onYourMarks(obj);
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user