began developing new sensor model
This commit is contained in:
@@ -0,0 +1,16 @@
|
|||||||
|
function value = RSS(obj, d, t)
|
||||||
|
arguments (Input)
|
||||||
|
obj (1, 1) {mustBeA(obj, "rfSensor")};
|
||||||
|
d (:, 1) double; % distance from agent to target
|
||||||
|
t (:, 1) double; % LOS tilt angle
|
||||||
|
end
|
||||||
|
arguments (Output)
|
||||||
|
value (:, 1) double
|
||||||
|
end
|
||||||
|
|
||||||
|
rho_dBm = 10*log10(obj.P_TX/1e-3);
|
||||||
|
|
||||||
|
% RSS = TX Power + Antenna Gain - Path Loss
|
||||||
|
value = rho_dBm + obj.antennaGain(t) - obj.pathLoss(d);
|
||||||
|
|
||||||
|
end
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
function value = antennaGain(obj, t)
|
||||||
|
arguments (Input)
|
||||||
|
obj (1, 1) {mustBeA(obj, "rfSensor")};
|
||||||
|
t (:, 1) double; % LOS tilt angle
|
||||||
|
end
|
||||||
|
arguments (Output)
|
||||||
|
value (:, 1) double
|
||||||
|
end
|
||||||
|
|
||||||
|
% TODO
|
||||||
|
value = 10*log10(1);
|
||||||
|
end
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
function obj = initialize(obj)
|
||||||
|
arguments (Input)
|
||||||
|
obj (1, 1) {mustBeA(obj, "rfSensor")}
|
||||||
|
end
|
||||||
|
arguments (Output)
|
||||||
|
obj (1, 1) {mustBeA(obj, "rfSensor")}
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
function L_FSPL_dB = pathLoss(obj, d)
|
||||||
|
arguments (Input)
|
||||||
|
obj (1, 1) {mustBeA(obj, "rfSensor")};
|
||||||
|
d (:, 1) double; % distance from TX to RX
|
||||||
|
end
|
||||||
|
arguments (Output)
|
||||||
|
L_FSPL_dB (:, 1) double
|
||||||
|
end
|
||||||
|
|
||||||
|
L_FSPL_dB = 20*log10(d) + 20*log10(obj.f_c) + 20*log10((4*pi)/obj.c);
|
||||||
|
|
||||||
|
end
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
function f = plotParameters(obj)
|
||||||
|
arguments (Input)
|
||||||
|
obj (1, 1) {mustBeA(obj, "rfSensor")};
|
||||||
|
end
|
||||||
|
arguments (Output)
|
||||||
|
f (1, 1) {mustBeA(f, "matlab.ui.Figure")};
|
||||||
|
end
|
||||||
|
|
||||||
|
% Distance and tilt sample points
|
||||||
|
d = [0.01, 0.1, 0.25, 0.5, 0.75, 1:1:100];
|
||||||
|
t = zeros(size(d));
|
||||||
|
|
||||||
|
% Sample RSS function by distances, tilts
|
||||||
|
r_x = obj.RSS(d', t');
|
||||||
|
|
||||||
|
% Sample SINR (SNR) function by distances, tilts
|
||||||
|
% using SINR method with no other transmitters defined is equivalent to SNR
|
||||||
|
s_x = NaN(size(r_x));
|
||||||
|
for ii = 1:size(s_x, 1)
|
||||||
|
s_x(ii) = obj.sensorPerformance([0, 0, d(ii)], zeros(1, 3)); % don't define other sensors
|
||||||
|
end
|
||||||
|
|
||||||
|
% Plot resultant sigmoid curves
|
||||||
|
f = figure;
|
||||||
|
tiledlayout(f, 2, 1, "TileSpacing", "tight", "Padding", "compact");
|
||||||
|
|
||||||
|
% RSS/Distance with 0 tilt
|
||||||
|
nexttile(1, [1, 1]);
|
||||||
|
grid("on");
|
||||||
|
title("RSS vs Distance");
|
||||||
|
xlabel("Distance (m)");
|
||||||
|
ylabel("RSS (dBm)");
|
||||||
|
hold("on");
|
||||||
|
plot(d, r_x, "LineWidth", 2);
|
||||||
|
hold("off");
|
||||||
|
% ylim([0, 1]);
|
||||||
|
|
||||||
|
% SNR/Distance with 0 tilt
|
||||||
|
nexttile(2, [1, 1]);
|
||||||
|
grid("on");
|
||||||
|
title("SNR vs Distance");
|
||||||
|
xlabel("Distance (m)");
|
||||||
|
ylabel("SNR (dB)");
|
||||||
|
hold("on");
|
||||||
|
plot(d, s_x, "LineWidth", 2);
|
||||||
|
hold("off");
|
||||||
|
end
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
classdef rfSensor
|
||||||
|
properties (SetAccess = private, GetAccess = public)
|
||||||
|
% Physical parameters
|
||||||
|
c = 3e8; % Speed of light (m/s)
|
||||||
|
k_B = 1.38e-23 % Boltzmann constant (W/Hz/K) for thermal noise model
|
||||||
|
T_0 = 300; % Ambient temperature (Kelvin) for thermal noise model
|
||||||
|
% Sensor parameters
|
||||||
|
P_TX = 10e-3; % Transmit power (Watts)
|
||||||
|
BW = 1e6; % Bandwidth (Hz)
|
||||||
|
f_c = 2e9; % Center frequency (Hz)
|
||||||
|
end
|
||||||
|
|
||||||
|
methods (Access = public)
|
||||||
|
[obj] = initialize(obj, alphaDist, betaDist, alphaTilt, betaTilt); % TODO initialize sensor, define parameters
|
||||||
|
[SINR] = sensorPerformance(obj, agentPos, agentPan, agentTilt, targetPos); % determine sensor performance for a given single sensor and target geometry
|
||||||
|
[f] = plotParameters(obj); % debug, plot sensor response as a function of distance and tilt angle
|
||||||
|
end
|
||||||
|
methods (Access = private)
|
||||||
|
x = RSS(obj, d, t); % Received signal strength (function of distance and tilt angle)
|
||||||
|
G_TX_dB = antennaGain(obj, agentPos, targetPos); % TODO Antenna gain for a given TX/RX pair
|
||||||
|
L_FSPL_dB = pathLoss(obj, agentPos, targetPos); % Free space path loss for a given TX/RX pair
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
function SINR = sensorPerformance(obj, agentPos, targetPos, otherSensors, otherSensorsPos)
|
||||||
|
arguments (Input)
|
||||||
|
obj (1, 1) {mustBeA(obj, "rfSensor")};
|
||||||
|
agentPos (1, 3) double;
|
||||||
|
targetPos (1, 3) double;
|
||||||
|
otherSensors (:, 1) cell = {};
|
||||||
|
otherSensorsPos (:, 3) double = NaN(0, 3);
|
||||||
|
end
|
||||||
|
arguments (Output)
|
||||||
|
SINR (:, 1) double;
|
||||||
|
end
|
||||||
|
assert(size(otherSensors, 1) == size(otherSensorsPos, 1), "Mismatch in length of other sensors (%d) and their positions (%d)", size(otherSensors, 1), size(otherSensorsPos, 1));
|
||||||
|
|
||||||
|
d = vecnorm(agentPos - targetPos, 2, 2); % distance from sensor to target
|
||||||
|
d_other = NaN(size(otherSensors));
|
||||||
|
|
||||||
|
x = vecnorm(agentPos(1:2) - targetPos(1, 1:2), 2, 2); % distance from sensor nadir to target nadir (i.e. distance ignoring height difference)
|
||||||
|
x_other = NaN(size(otherSensors));
|
||||||
|
|
||||||
|
t = (180 - atan2d(x, targetPos(1, 3) - agentPos(3))); % degrees
|
||||||
|
t_other = NaN(size(otherSensors));
|
||||||
|
|
||||||
|
% Performance is measured as SINR for this sensor
|
||||||
|
S = 10^(0.1 * obj.RSS(d, t)); % Signal
|
||||||
|
N = obj.k_B * obj.T_0 * obj.BW; % Thermal noise
|
||||||
|
I = 0; % Interference from other agents
|
||||||
|
for ii = 1:size(otherSensors, 1)
|
||||||
|
d_other(ii, 1) = vecnorm(otherSensorsPos(ii, 1:3) - targetPos, 2, 2);
|
||||||
|
|
||||||
|
x_other(ii, 1) = vecnorm(otherSensorsPos(ii, 3) - targetPos(1, 1:2), 2, 2);
|
||||||
|
t_other(ii, 1) = (180 - atan2d(x_other(ii, 1), targetPos(1, 3) - otherSensorsPos(ii, 3)));
|
||||||
|
|
||||||
|
I = I + 10 ^ (0.1 * otherSensors.RSS(otherSensors{ii}, d_other(ii), t_other(ii)));
|
||||||
|
end
|
||||||
|
SINR = 10*log10(S/(I + N));
|
||||||
|
end
|
||||||
@@ -8,12 +8,12 @@ classdef sigmoidSensor
|
|||||||
end
|
end
|
||||||
|
|
||||||
methods (Access = public)
|
methods (Access = public)
|
||||||
[obj] = initialize(obj, alphaDist, betaDist, alphaTilt, betaTilt);
|
[obj] = initialize(obj, alphaDist, betaDist, alphaTilt, betaTilt); % initialize sensor, define parameters
|
||||||
[value] = sensorPerformance(obj, agentPos, agentPan, agentTilt, targetPos);
|
[value] = sensorPerformance(obj, agentPos, agentPan, agentTilt, targetPos); % determine sensor performance for a given single sensor and target geometry
|
||||||
[f] = plotParameters(obj);
|
[f] = plotParameters(obj); % debug, plot sensor response as a function of distance and tilt angle
|
||||||
end
|
end
|
||||||
methods (Access = private)
|
methods (Access = private)
|
||||||
x = distanceMembership(obj, d);
|
x = distanceMembership(obj, d); % used in computing distance factor of sensor performance
|
||||||
x = tiltMembership(obj, t);
|
x = tiltMembership(obj, t); % used in computing tilt factor of sensor performance
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Info>
|
||||||
|
<Category UUID="FileClassCategory">
|
||||||
|
<Label UUID="test"/>
|
||||||
|
</Category>
|
||||||
|
</Info>
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Info location="test_rfSensor.m" type="File"/>
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Info>
|
||||||
|
<Category UUID="FileClassCategory">
|
||||||
|
<Label UUID="design"/>
|
||||||
|
</Category>
|
||||||
|
</Info>
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Info location="antennaGain.m" type="File"/>
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Info>
|
||||||
|
<Category UUID="FileClassCategory">
|
||||||
|
<Label UUID="design"/>
|
||||||
|
</Category>
|
||||||
|
</Info>
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Info location="rfSensor.m" type="File"/>
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Info>
|
||||||
|
<Category UUID="FileClassCategory">
|
||||||
|
<Label UUID="design"/>
|
||||||
|
</Category>
|
||||||
|
</Info>
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Info location="plotParameters.m" type="File"/>
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Info>
|
||||||
|
<Category UUID="FileClassCategory">
|
||||||
|
<Label UUID="design"/>
|
||||||
|
</Category>
|
||||||
|
</Info>
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Info location="sensorPerformance.m" type="File"/>
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Info>
|
||||||
|
<Category UUID="FileClassCategory">
|
||||||
|
<Label UUID="design"/>
|
||||||
|
</Category>
|
||||||
|
</Info>
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Info location="initialize.m" type="File"/>
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Info/>
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Info location="1" type="DIR_SIGNIFIER"/>
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Info>
|
||||||
|
<Category UUID="FileClassCategory">
|
||||||
|
<Label UUID="design"/>
|
||||||
|
</Category>
|
||||||
|
</Info>
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Info location="RSS.m" type="File"/>
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Info>
|
||||||
|
<Category UUID="FileClassCategory">
|
||||||
|
<Label UUID="design"/>
|
||||||
|
</Category>
|
||||||
|
</Info>
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Info location="pathLoss.m" type="File"/>
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Info/>
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Info location="@rfSensor" type="File"/>
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
classdef test_rfSensor < matlab.unittest.TestCase
|
||||||
|
properties (Access = private)
|
||||||
|
% System under test
|
||||||
|
testClass = sigmoidSensor;
|
||||||
|
end
|
||||||
|
|
||||||
|
methods (TestMethodSetup)
|
||||||
|
function tc = setup(tc)
|
||||||
|
% Reinitialize sensor with random parameters
|
||||||
|
tc.testClass = rfSensor;
|
||||||
|
% TODO
|
||||||
|
tc.testClass = tc.testClass.initialize();
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
methods (Test)
|
||||||
|
% Test methods
|
||||||
|
|
||||||
|
function test_SINR(tc)
|
||||||
|
tc.testClass.plotParameters();
|
||||||
|
% [SINR] = tc.testClass.sensorPerformance(obj, agentPos, agentPan, agentTilt, targetPos);
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user