RF antenna azimuth, plotting improvements
This commit is contained in:
+4
-3
@@ -1,14 +1,15 @@
|
|||||||
function value = RSS(obj, d, t)
|
function value = RSS(obj, d, t, a)
|
||||||
arguments (Input)
|
arguments (Input)
|
||||||
obj (1, 1) {mustBeA(obj, "rfSensor")};
|
obj (1, 1) {mustBeA(obj, "rfSensor")};
|
||||||
d (:, 1) double; % distance from agent to target
|
d (:, 1) double; % distance from agent to target
|
||||||
t (:, 1) double; % LOS tilt angle
|
t (:, 1) double; % LOS tilt angle
|
||||||
|
a (:, 1) double; % LOS azimuth angle
|
||||||
end
|
end
|
||||||
arguments (Output)
|
arguments (Output)
|
||||||
value (:, 1) double
|
value (:, 1) double
|
||||||
end
|
end
|
||||||
assert(size(d, 1) == size(t, 1), "Mismatch in number of distances (%d) and tilts (%d) provided", size(d, 1), size(t, 1));
|
assert(size(d, 1) == size(t, 1), "Mismatch in number of distances (%d) and tilts (%d) provided", size(d, 1), size(t, 1));
|
||||||
|
|
||||||
% RSS (dBm) = TX Power (dBm) + Antenna Gain (dB) - Path Loss (dB)
|
% RSS (dBm) = TX Power (dBm) + TX Antenna Gain (dB) + RX Antenna Gain (dBi) - Path Loss (dB)
|
||||||
value = obj.P_TX_dBm + obj.antennaGain(t) - obj.pathLoss(d);
|
value = obj.P_TX_dBm + obj.transmitterGain(t, a) + obj.G_RX_dBi - obj.pathLoss(d);
|
||||||
end
|
end
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
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
|
|
||||||
|
|
||||||
% Temporary logic to make nadir-pointing most effective
|
|
||||||
value = 10*log10(cosd(t) .^ 8);
|
|
||||||
|
|
||||||
% % Temporary logic for 0 dB at all tilt angles
|
|
||||||
% value = zeros(size(t));
|
|
||||||
end
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
function [d, t] = computePointToPoints(obj, agentPos, targetPos)
|
function [d, t, a] = computePointToPoints(obj, agentPos, targetPos)
|
||||||
arguments (Input)
|
arguments (Input)
|
||||||
obj (1, 1) {mustBeA(obj, "rfSensor")};
|
obj (1, 1) {mustBeA(obj, "rfSensor")};
|
||||||
agentPos (1, 3) double;
|
agentPos (1, 3) double;
|
||||||
@@ -7,6 +7,7 @@ function [d, t] = computePointToPoints(obj, agentPos, targetPos)
|
|||||||
arguments (Output)
|
arguments (Output)
|
||||||
d (:, 1) double;
|
d (:, 1) double;
|
||||||
t (:, 1) double;
|
t (:, 1) double;
|
||||||
|
a (:, 1) double;
|
||||||
end
|
end
|
||||||
|
|
||||||
% distance from sensor to target
|
% distance from sensor to target
|
||||||
@@ -15,7 +16,9 @@ function [d, t] = computePointToPoints(obj, agentPos, targetPos)
|
|||||||
% distance from sensor nadir to target nadir (i.e. distance ignoring altitude)
|
% distance from sensor nadir to target nadir (i.e. distance ignoring altitude)
|
||||||
x = vecnorm(agentPos(1:2) - targetPos(:, 1:2), 2, 2);
|
x = vecnorm(agentPos(1:2) - targetPos(:, 1:2), 2, 2);
|
||||||
|
|
||||||
% tilt angle (degrees)
|
% tilt angle (degrees) (-90, 0 (down), 90)
|
||||||
t = (180 - atan2d(x, targetPos(:, 3) - agentPos(3)));
|
t = (180 - atan2d(x, targetPos(:, 3) - agentPos(3)));
|
||||||
|
|
||||||
|
% azimuth angle (degrees) (0 (+y) clockwise to 360)
|
||||||
|
a = mod(atan2d(targetPos(:,1) - agentPos(1), targetPos(:,2) - agentPos(2)), 360);
|
||||||
end
|
end
|
||||||
@@ -1,9 +1,10 @@
|
|||||||
function obj = initialize(obj, txPower, bandwidth, centerFreq)
|
function obj = initialize(obj, txPower, bandwidth, centerFreq, rxGain_dBi)
|
||||||
arguments (Input)
|
arguments (Input)
|
||||||
obj (1, 1) {mustBeA(obj, "rfSensor")}
|
obj (1, 1) {mustBeA(obj, "rfSensor")}
|
||||||
txPower (1, 1) double;
|
txPower (1, 1) double;
|
||||||
bandwidth (1, 1) double;
|
bandwidth (1, 1) double;
|
||||||
centerFreq (1, 1) double;
|
centerFreq (1, 1) double;
|
||||||
|
rxGain_dBi (1, 1) double;
|
||||||
end
|
end
|
||||||
arguments (Output)
|
arguments (Output)
|
||||||
obj (1, 1) {mustBeA(obj, "rfSensor")}
|
obj (1, 1) {mustBeA(obj, "rfSensor")}
|
||||||
@@ -13,6 +14,7 @@ function obj = initialize(obj, txPower, bandwidth, centerFreq)
|
|||||||
obj.P_TX = txPower; % Transmit power (W)
|
obj.P_TX = txPower; % Transmit power (W)
|
||||||
obj.BW = bandwidth; % Bandwidth (Hz)
|
obj.BW = bandwidth; % Bandwidth (Hz)
|
||||||
obj.f_c = centerFreq; % Center frequency (Hz)
|
obj.f_c = centerFreq; % Center frequency (Hz)
|
||||||
|
obj.G_RX_dBi = rxGain_dBi; % Receiving Antenna Gain (dBi)
|
||||||
|
|
||||||
% Computed values
|
% Computed values
|
||||||
obj.P_TX_dBm = 10*log10(obj.P_TX/1e-3); % Transmit power in dBm
|
obj.P_TX_dBm = 10*log10(obj.P_TX/1e-3); % Transmit power in dBm
|
||||||
|
|||||||
+37
-20
@@ -7,32 +7,49 @@ function f = plotParameters(obj)
|
|||||||
end
|
end
|
||||||
|
|
||||||
% Distance and tilt sample points
|
% Distance and tilt sample points
|
||||||
d_values = [0.01, 0.1, 0.25, 0.5, 0.75, 1, 2, 3, 4, 5:5:100];
|
d_values = [0.1, 0.5, 1:1:9, 10:2:19, 20:5:49, 50:10:100];
|
||||||
% t = zeros(size(d));
|
t_values = -90:0.5:90;
|
||||||
t_values = -90:15:90;
|
a_values = 0:0.5:360;
|
||||||
|
|
||||||
% Make grid of values of distances and tilts
|
% Make grid of values of distances and tilts
|
||||||
[d_mg, t_mg] = meshgrid(d_values, t_values);
|
[d_mg, t_mg, a_mg] = meshgrid(d_values, t_values, a_values);
|
||||||
d = d_mg(:); t = t_mg(:); % flatten
|
d = d_mg(:); t = t_mg(:); a = a_mg(:); % flatten
|
||||||
|
|
||||||
% Sample SINR (SNR) function by distances, tilts
|
% Sample received signal strength (no interference or noise)
|
||||||
% using SINR method with no other transmitters defined is equivalent to SNR
|
s_x = obj.RSS(d, t, a);
|
||||||
s_x = obj.sensorPerformance(d, t); % don't define other sensors
|
|
||||||
s_x = reshape(s_x, size(d_mg));
|
s_x = reshape(s_x, size(d_mg));
|
||||||
|
|
||||||
% Plot resultant sigmoid curves
|
[T, A] = meshgrid(t_values, a_values); % Naz x Nel
|
||||||
|
Tr = deg2rad(T);
|
||||||
|
Ar = deg2rad(A);
|
||||||
|
|
||||||
figure;
|
figure;
|
||||||
plot(d_values.', s_x(repmat((t_values == 0).', 1, size(d_values, 2))), "LineWidth", 2);
|
hold("on");
|
||||||
grid("on");
|
|
||||||
title("SNR vs Distance at 0 tilt");
|
|
||||||
xlabel("Distance (m)");
|
|
||||||
ylabel("SNR (dB)");
|
|
||||||
|
|
||||||
figure;
|
for ii = 1:numel(d_values)
|
||||||
surf(d_mg, t_mg, s_x);
|
% geometry (your "tilt from nadir, stack by distance")
|
||||||
|
X = d_values(ii) * cos(Ar) .* sin(Tr);
|
||||||
|
Y = d_values(ii) * sin(Ar) .* sin(Tr);
|
||||||
|
Z = d_values(ii) * ones(size(X));
|
||||||
|
|
||||||
|
% evaluate or extract this slice
|
||||||
|
Fslice = squeeze(s_x(:, ii, :))';
|
||||||
|
|
||||||
|
% plot as its own surface
|
||||||
|
h = surf(X, Y, Z, Fslice);
|
||||||
|
h.EdgeColor = 'none';
|
||||||
|
h.FaceColor = 'interp';
|
||||||
|
h.FaceAlpha = 0.25;
|
||||||
|
end
|
||||||
|
|
||||||
|
colormap(turbo);
|
||||||
|
colorbar;
|
||||||
|
daspect([1 1 0.2]) % Separate Z further for more distinct layers
|
||||||
|
xlabel('X'); ylabel('Y'); zlabel('Distance (m)');
|
||||||
|
set(gca,'ZDir','reverse');
|
||||||
|
view(3);
|
||||||
|
axis("vis3d");
|
||||||
grid("on");
|
grid("on");
|
||||||
title("SNR vs Distance and Tilt");
|
scatter3(0, 0, 0, 'rx');
|
||||||
xlabel("Distance (m)");
|
hold("off");
|
||||||
ylabel("Tilt (deg)");
|
|
||||||
zlabel("SNR (dB)");
|
|
||||||
end
|
end
|
||||||
@@ -8,20 +8,21 @@ classdef rfSensor
|
|||||||
P_TX = NaN; % Transmit power (Watts)
|
P_TX = NaN; % Transmit power (Watts)
|
||||||
BW = NaN; % Bandwidth (Hz)
|
BW = NaN; % Bandwidth (Hz)
|
||||||
f_c = NaN; % Center frequency (Hz)
|
f_c = NaN; % Center frequency (Hz)
|
||||||
|
G_RX_dBi = NaN; % Receiver antenna gain
|
||||||
% Values computed at initialization
|
% Values computed at initialization
|
||||||
P_TX_dBm = NaN; % Transmit power (dBm)
|
P_TX_dBm = NaN; % Transmit power (dBm)
|
||||||
N = NaN; % Thermal noise
|
N = NaN; % Thermal noise
|
||||||
end
|
end
|
||||||
|
|
||||||
methods (Access = public)
|
methods (Access = public)
|
||||||
[obj] = initialize(obj, txPower, bandwidth, centerFreq); % TODO initialize sensor, define parameters
|
[obj] = initialize(obj, txPower, bandwidth, centerFreq, rxGain); % initialize sensor, define parameters
|
||||||
[SINR] = sensorPerformance(obj, agentPos, agentPan, agentTilt, targetPos); % determine sensor performance for a given single sensor and target geometry
|
[SINR] = sensorPerformance(obj, agentPos, targetPos, otherSensorsPos, otherSensors); % 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
|
[f] = plotParameters(obj); % debug, plot sensor response as a function of distance and tilt angle
|
||||||
[d, t] = computePointToPoints(obj, agentPos, targetPos);
|
[d, t, a] = computePointToPoints(obj, agentPos, targetPos);
|
||||||
end
|
end
|
||||||
methods (Access = private)
|
methods (Access = private)
|
||||||
x = RSS(obj, d, t); % Received signal strength (function of distance and tilt angle)
|
x = RSS(obj, d, t, a); % 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
|
G_TX_dB = transmitterGain(obj, t, a); % 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
|
L_FSPL_dB = pathLoss(obj, d); % Free space path loss for a given TX/RX pair
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -1,25 +1,24 @@
|
|||||||
function SINR = sensorPerformance(obj, d, t, d_other, t_other, otherSensors)
|
function SINR = sensorPerformance(obj, agentPos, targetPos, otherSensorsPos, otherSensors)
|
||||||
arguments (Input)
|
arguments (Input)
|
||||||
obj (1, 1) {mustBeA(obj, "rfSensor")};
|
obj (1, 1) {mustBeA(obj, "rfSensor")};
|
||||||
d (:, 1) double;
|
agentPos (1, 3) double;
|
||||||
t(:, 1) double;
|
targetPos (:, 3) double;
|
||||||
d_other (:, :) double = [];
|
otherSensorsPos (:, 3) double = [];
|
||||||
t_other (:, :) double = [];
|
otherSensors (:, 1) cell = {};
|
||||||
otherSensors (1, :) cell = {};
|
|
||||||
end
|
end
|
||||||
arguments (Output)
|
arguments (Output)
|
||||||
SINR (:, 1) double;
|
SINR (:, 1) double;
|
||||||
end
|
end
|
||||||
assert(size(d, 1) == size(t, 1), "Mismatch in number of distance (%d) and angle (%d) pairs provided", size(d, 1), size(t, 1));
|
assert(size(otherSensorsPos, 1) == size(otherSensors, 1), "Mismatch in number of other sensor positions (%d) and number of other sensors (%d) provided", size(otherSensorsPos, 1), size(otherSensors, 1));
|
||||||
assert(size(d_other, 1) == size(t_other, 1), "Mismatch in number of distances (%d) and tilts (%d) provided to other sensors", size(t, 1), size(t_other, 1));
|
|
||||||
assert(size(d_other, 2) == size(t_other, 2), "Mismatch in number of other sensors given distances (%d) and tilts (%d)", size(d_other, 1), size(t_other, 1));
|
[d, t, a] = obj.computePointToPoints(agentPos, targetPos);
|
||||||
assert(size(otherSensors, 2) == size(d_other, 2), "Mismatch in number of distances from other sensors (%d) and number of other sensors (%d) provided", size(d_other, 2), size(otherSensors, 2));
|
|
||||||
|
|
||||||
% Performance is measured as SINR for this sensor
|
% Performance is measured as SINR for this sensor
|
||||||
S = 10 .^ (0.1 * obj.RSS(d, t)); % Signal
|
S = 10 .^ (0.1 .* obj.RSS(d, t, a)); % Signal
|
||||||
I = zeros(size(d)); % Interference from other agents
|
I = zeros(size(d)); % Interference from other agents
|
||||||
for ii = 1:size(otherSensors, 2)
|
for ii = 1:size(otherSensors, 2)
|
||||||
I = I + 10 .^ (0.1 * otherSensors{ii}.RSS(d_other(:, ii), t_other(:, ii)));
|
[d_other, t_other, a_other] = otherSensors{ii}.computePointToPoints(otherSensorsPos(ii, 1:3), targetPos);
|
||||||
|
I = I + 10 .^ (0.1 .* otherSensors{ii}.RSS(d_other, t_other, a_other));
|
||||||
end
|
end
|
||||||
|
|
||||||
SINR = 10*log10(S ./ (I + obj.N));
|
SINR = 10*log10(S ./ (I + obj.N));
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
function value = transmitterGain(obj, t, a)
|
||||||
|
arguments (Input)
|
||||||
|
obj (1, 1) {mustBeA(obj, "rfSensor")};
|
||||||
|
t (:, 1) double; % LOS tilt angle
|
||||||
|
a (:, 1) double; % LOS azimuth angle
|
||||||
|
end
|
||||||
|
arguments (Output)
|
||||||
|
value (:, 1) double
|
||||||
|
end
|
||||||
|
if ~isequal(size(t), size(a))
|
||||||
|
error("t and a must be the same size");
|
||||||
|
end
|
||||||
|
|
||||||
|
% Temporary logic to make nadir-pointing most effective
|
||||||
|
value = 10 .* log10(cosd(t) .^ 2) + 10 .* log10((0.5 + 0.5 .* cosd(a)) .^ 4);
|
||||||
|
end
|
||||||
@@ -9,7 +9,7 @@ classdef sigmoidSensor
|
|||||||
|
|
||||||
methods (Access = public)
|
methods (Access = public)
|
||||||
[obj] = initialize(obj, alphaDist, betaDist, alphaTilt, betaTilt); % initialize sensor, define parameters
|
[obj] = initialize(obj, alphaDist, betaDist, alphaTilt, betaTilt); % initialize sensor, define parameters
|
||||||
[value] = sensorPerformance(obj, agentPos, agentPan, agentTilt, targetPos); % determine sensor performance for a given single sensor and target geometry
|
[value] = sensorPerformance(obj, agentPos, 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
|
[f] = plotParameters(obj); % debug, plot sensor response as a function of distance and tilt angle
|
||||||
end
|
end
|
||||||
methods (Access = private)
|
methods (Access = private)
|
||||||
|
|||||||
@@ -1,2 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<Info location="antennaGain.m" type="File"/>
|
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Info location="transmitterGain.m" type="File"/>
|
||||||
@@ -17,8 +17,9 @@ classdef test_rfSensor < matlab.unittest.TestCase
|
|||||||
P_TX = 1e-3; % Transmit power (Watts)
|
P_TX = 1e-3; % Transmit power (Watts)
|
||||||
BW = 20e6; % Bandwidth (Hz)
|
BW = 20e6; % Bandwidth (Hz)
|
||||||
f_c = 2e9; % Center frequency (Hz)
|
f_c = 2e9; % Center frequency (Hz)
|
||||||
|
G_RX_dBi = 3; % Receiving Antenna Gain (dBi)
|
||||||
|
|
||||||
tc.testClass = tc.testClass.initialize(P_TX, BW, f_c);
|
tc.testClass = tc.testClass.initialize(P_TX, BW, f_c, G_RX_dBi);
|
||||||
|
|
||||||
tc.testClass.plotParameters();
|
tc.testClass.plotParameters();
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user