coordinate bug cleanup

This commit is contained in:
2026-05-03 09:23:21 -07:00
parent 81fe1b67c5
commit 4159a3a5cb
4 changed files with 22 additions and 2 deletions
+11
View File
@@ -0,0 +1,11 @@
function obj = clearRssCache(obj)
arguments (Input)
obj (1, 1) {mustBeA(obj, "rfSensor")};
end
arguments (Output)
obj (1, 1) {mustBeA(obj, "rfSensor")};
end
obj.rssCache = double.empty(0, 1);
end
+1
View File
@@ -24,6 +24,7 @@ classdef rfSensor
[d, t, a] = computePointToPoints(obj, agentPos, targetPos); [d, t, a] = computePointToPoints(obj, agentPos, targetPos);
[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
[f] = plotPerformance(obj, altitude, otherSensorsPos, otherSensors); % debug, plot SNR or SINR ground heatmap for a given geometry [f] = plotPerformance(obj, altitude, otherSensorsPos, otherSensors); % debug, plot SNR or SINR ground heatmap for a given geometry
obj = clearRssCache(obj);
end end
methods (Access = private) methods (Access = private)
x = RSS(obj, d, t, a); % Received signal strength (function of distance and tilt angle) x = RSS(obj, d, t, a); % Received signal strength (function of distance and tilt angle)
+1 -1
View File
@@ -15,7 +15,7 @@ function value = transmitterGain(obj, t, a)
% Angular offset from boresight via spherical law of cosines % Angular offset from boresight via spherical law of cosines
% Convention: t=0° nadir, t=90° horizon; a=0° +y, a=90° +x % Convention: t=0° nadir, t=90° horizon; a=0° +y, a=90° +x
cos_theta = sind(obj.tilt) .* sind(t) .* cosd(a - obj.tilt) + ... cos_theta = sind(obj.tilt) .* sind(t) .* cosd(a - obj.azimuth) + ...
cosd(obj.tilt) .* cosd(t); cosd(obj.tilt) .* cosd(t);
cos_theta = max(-1, min(1, cos_theta)); % clamp for numerical safety cos_theta = max(-1, min(1, cos_theta)); % clamp for numerical safety
theta = acosd(cos_theta); theta = acosd(cos_theta);
+9 -1
View File
@@ -30,10 +30,18 @@ classdef test_rfSensor < matlab.unittest.TestCase
f_c = 2e9; % Center frequency (Hz) f_c = 2e9; % Center frequency (Hz)
G_RX_dBi = 3; % Receiving Antenna Gain (dBi) G_RX_dBi = 3; % Receiving Antenna Gain (dBi)
tc.testClass = tc.testClass.initialize(P_TX, BW, f_c, G_RX_dBi, 0, 0); tc.testClass = tc.testClass.initialize(P_TX, BW, f_c, G_RX_dBi, 30, 135);
altitude = 30; altitude = 30;
% Boresight azimuth=135° (between +X at 90° and -Y at 180°) hotspot at +X,-Y.
% SNR at (5,-5) should be higher than at (5,+5).
agentPos = [0, 0, altitude];
[~, snrA] = tc.testClass.sensorPerformance(agentPos, [5, -5, 0]);
% tc.testClass = tc.testClass.clearRssCache();
[~, snrB] = tc.testClass.sensorPerformance(agentPos, [5, 5, 0]);
tc.assertGreaterThan(snrA, snrB, "SNR should be higher toward boresight (+X,-Y) than away from it (+X,+Y)");
tc.testClass.plotPerformance(altitude); tc.testClass.plotPerformance(altitude);
end end
function plot_SINR_one_interferer(tc) function plot_SINR_one_interferer(tc)