new SINR threshold comms CBF constraint

This commit is contained in:
kdee committed 2026-06-26 22:13:51 -07:00
1 parent b53f62391b
commit efa251d747
18 files changed
+534 -66

No files matched your search

+2 -2
View File
@@ -1,2 +1,2 @@
timestep, maxIter, minAlt, discretizationStep, protectedRange, initialStepSize, barrierGain, barrierExponent, collisionRadius, comRange, alphaDist, betaDist, alphaTilt, betaTilt, domainMin, domainMax, objectivePos, objectiveVar, sensorPerformanceMinimum, initialPositions, numObstacles, obstacleMin, obstacleMax, useDoubleIntegrator, dampingCoeff, useFixedTopology
1, 80, 35.0, 0.1, 2.0, 6, 1, 1, "8.0, 8.0", "35.0, 35.0", "80.0, 50.0", "0.25, 1.0", "8.0, 25.0", "0.1, 0.02", "0.0, 0.0, 0.0", "100.0, 100.0, 100.0", "60.0, 80.0, 45.0, 70.0", "70, 15, 15, 20, 20, 15, 15, 70", 0.15, "15.0, 15.0, 50.0, 40.0, 10.0, 45.0", 8, "0.0, 30.0, 0.0, 42.0, 30.0, 0.0, 84.0, 30.0, 0.0, 13.0, 60.0, 0.0, 55.0, 60.0, 0.0, 0.0, 90, 0.0, 42.0, 90.0, 0.0, 84.0, 90.0, 0.0", "16.0, 40.0, 100.0, 58.0, 40.0, 100.0, 100.0, 40.0, 100.0, 29.0, 70.0, 100.0, 71.0, 70.0, 100.0, 16.0, 100.0, 100.0, 58.0, 100.0, 100.0, 100.0, 100.0, 100.0", 0, 2.0, 1
timestep, maxIter, minAlt, discretizationStep, protectedRange, initialStepSize, barrierGain, barrierExponent, collisionRadius, comRange, alphaDist, betaDist, alphaTilt, betaTilt, domainMin, domainMax, objectivePos, objectiveVar, sensorPerformanceMinimum, initialPositions, numObstacles, obstacleMin, obstacleMax, useDoubleIntegrator, dampingCoeff, useFixedTopology, txPower, useSinrComms, sinrThreshold, pathLossExponent, ambientTemp, centerFreq, bandwidth
1, 80, 35.0, 0.1, 2.0, 6, 1, 1, "8.0, 8.0", "35.0, 35.0", "80.0, 50.0", "0.25, 1.0", "8.0, 25.0", "0.1, 0.02", "0.0, 0.0, 0.0", "100.0, 100.0, 100.0", "60.0, 80.0, 45.0, 70.0", "70, 15, 15, 20, 20, 15, 15, 70", 0.15, "15.0, 15.0, 50.0, 40.0, 10.0, 45.0", 8, "0.0, 30.0, 0.0, 42.0, 30.0, 0.0, 84.0, 30.0, 0.0, 13.0, 60.0, 0.0, 55.0, 60.0, 0.0, 0.0, 90, 0.0, 42.0, 90.0, 0.0, 84.0, 90.0, 0.0", "16.0, 40.0, 100.0, 58.0, 40.0, 100.0, 100.0, 40.0, 100.0, 29.0, 70.0, 100.0, 71.0, 70.0, 100.0, 16.0, 100.0, 100.0, 58.0, 100.0, 100.0, 100.0, 100.0, 100.0", 0, 2.0, 1, "0.2, 0.1", 0, 5.0, 2.5, 290.0, 2.4e9, 20e6
1 timestep maxIter minAlt discretizationStep protectedRange initialStepSize barrierGain barrierExponent collisionRadius comRange alphaDist betaDist alphaTilt betaTilt domainMin domainMax objectivePos objectiveVar sensorPerformanceMinimum initialPositions numObstacles obstacleMin obstacleMax useDoubleIntegrator dampingCoeff useFixedTopology txPower useSinrComms sinrThreshold pathLossExponent ambientTemp centerFreq bandwidth
2 1 80 35.0 0.1 2.0 6 1 1 8.0, 8.0 35.0, 35.0 80.0, 50.0 0.25, 1.0 8.0, 25.0 0.1, 0.02 0.0, 0.0, 0.0 100.0, 100.0, 100.0 60.0, 80.0, 45.0, 70.0 70, 15, 15, 20, 20, 15, 15, 70 0.15 15.0, 15.0, 50.0, 40.0, 10.0, 45.0 8 0.0, 30.0, 0.0, 42.0, 30.0, 0.0, 84.0, 30.0, 0.0, 13.0, 60.0, 0.0, 55.0, 60.0, 0.0, 0.0, 90, 0.0, 42.0, 90.0, 0.0, 84.0, 90.0, 0.0 16.0, 40.0, 100.0, 58.0, 40.0, 100.0, 100.0, 40.0, 100.0, 29.0, 70.0, 100.0, 71.0, 70.0, 100.0, 16.0, 100.0, 100.0, 58.0, 100.0, 100.0, 100.0, 100.0, 100.0 0 2.0 1 0.2, 0.1 0 5.0 2.5 290.0 2.4e9 20e6
+1 -1
View File
@@ -50,7 +50,7 @@ else
end
% Load guidance scenario from CSV (parameters for guidance_step)
NUM_SCENARIO_PARAMS = 55;
NUM_SCENARIO_PARAMS = 65;
MAX_OBSTACLES_CTRL = int32(8);
scenarioParams = zeros(1, NUM_SCENARIO_PARAMS);
obstacleMin = zeros(MAX_OBSTACLES_CTRL, 3);
+32 -9
View File
@@ -17,7 +17,8 @@ function nextPositions = guidance_step(currentPositions, isInit, ...
% Flat array of guidance parameters (compiled path).
% On MATLAB path this is ignored; parameters are loaded
% from scenario.csv via initializeFromCsv instead.
% Index mapping (1-based):
% Index mapping (1-based; authoritative map in
% aerpaw/impl/controller_impl.h):
% 1 timestep 9-12 collisionRadius[1:4]
% 2 maxIter 13-16 comRange[1:4]
% 3 minAlt 17-20 alphaDist[1:4]
@@ -26,12 +27,20 @@ function nextPositions = guidance_step(currentPositions, isInit, ...
% 6 initialStepSize 29-32 betaTilt[1:4]
% 7 barrierGain 33-35 domainMin
% 8 barrierExponent 36-38 domainMax
% 39-40 objectivePos
% 41-44 objectiveVar (2x2, col-major)
% 45 sensorPerformanceMinimum
% 46 useDoubleIntegrator
% 47 dampingCoeff
% 48 useFixedTopology
% 39 numObjectiveComponents
% 40-43 objectivePos [x1,y1,x2,y2]
% 44-51 objectiveVar [per component]
% 52 sensorPerformanceMinimum
% 53 useDoubleIntegrator
% 54 dampingCoeff
% 55 useFixedTopology
% 56-59 txPower[1:4]
% 60 useSinrComms
% 61 sinrThreshold (dB)
% 62 pathLossExponent
% 63 ambientTemp (K)
% 64 centerFreq (Hz)
% 65 bandwidth (Hz)
% obstacleMin (MAX_OBSTACLES × 3) double column-major obstacle corners (compiled path)
% obstacleMax (MAX_OBSTACLES × 3) double
% numObstacles (1,1) int32 actual obstacle count
@@ -101,6 +110,13 @@ if isInit
USE_DOUBLE_INTEGRATOR = logical(scenarioParams(53));
DAMPING_COEFF = scenarioParams(54);
USE_FIXED_TOPOLOGY = logical(scenarioParams(55));
TX_POWER_VEC = scenarioParams(56:59); % per-UAV [1:MAX_CLIENTS] (W)
USE_SINR_COMMS = logical(scenarioParams(60));
SINR_THRESHOLD = scenarioParams(61); % dB
PATH_LOSS_EXPONENT = scenarioParams(62);
AMBIENT_TEMP = scenarioParams(63); % Kelvin
CENTER_FREQ = scenarioParams(64); % Hz
BANDWIDTH = scenarioParams(65); % Hz
% --- Build domain geometry ---
dom = rectangularPrism;
@@ -141,6 +157,7 @@ if isInit
ag = agent;
ag = ag.initialize(pos, geom, sensor, COMMS_RANGE_VEC(ii), MAX_ITER, ...
INITIAL_STEP_SIZE, sprintf("UAV %d", ii));
ag.txPower = TX_POWER_VEC(ii); % SINR comms model transmit power (W)
agentList{ii} = ag;
end
@@ -158,7 +175,8 @@ if isInit
sim = miSim;
sim = sim.initialize(dom, agentList, BARRIER_GAIN, BARRIER_EXPONENT, ...
MIN_ALT, TIMESTEP, MAX_ITER, obstacleList, false, false, ...
USE_DOUBLE_INTEGRATOR, DAMPING_COEFF, USE_FIXED_TOPOLOGY);
USE_DOUBLE_INTEGRATOR, DAMPING_COEFF, USE_FIXED_TOPOLOGY, false, ...
USE_SINR_COMMS, SINR_THRESHOLD, PATH_LOSS_EXPONENT, AMBIENT_TEMP, CENTER_FREQ, BANDWIDTH);
end
% On the init call return current positions unchanged
@@ -187,8 +205,13 @@ else
% 2. Advance timestep counter
sim.timestepIndex = sim.timestepIndex + 1;
% 3. Update communications topology (Lesser Neighbour Assignment)
% 3. Update communications topology (Lesser Neighbour Assignment).
% Refresh the adjacency graph from current positions first so connectivity
% (fixed-radius or SINR) tracks the agents as they move; otherwise the graph
% would be frozen at init on the compiled path (the MATLAB sim refreshes it
% in @miSim/run.m). Skip when topology is fixed.
if ~sim.useFixedTopology
sim = sim.updateAdjacency();
sim = sim.lesserNeighbor();
end
+65 -2
View File
@@ -238,8 +238,8 @@ int loadScenario(const char* filename, double* params) {
strncpy(copy, line, sizeof(copy) - 1);
copy[sizeof(copy) - 1] = '\0';
char* fields[32];
int nf = splitCSVRow(copy, fields, 32);
char* fields[40];
int nf = splitCSVRow(copy, fields, 40);
if (nf < 26) {
fprintf(stderr, "loadScenario: expected >=26 columns, got %d\n", nf);
return 0;
@@ -376,8 +376,71 @@ int loadScenario(const char* filename, double* params) {
params[54] = atof(trimField(tmp));
}
// ---- SINR communications model (columns 26–30; optional) ----
// Defaults mirror @miSim/initializeFromCsv.m so a CSV predating the SINR
// model still loads (useSinrComms stays 0 -> fixed-radius path is used).
// txPower[1:4] -> params[55:58]; useSinrComms -> 59;
// sinrThreshold (dB) -> 60; pathLossExponent -> 61; ambientTemp (K) -> 62;
// centerFreq (Hz) -> 63; bandwidth (Hz) -> 64.
params[55] = 0.1; params[56] = 0.1; params[57] = 0.1; params[58] = 0.1;
params[59] = 0.0; // useSinrComms
params[60] = 0.0; // sinrThreshold (dB)
params[61] = 2.0; // pathLossExponent
params[62] = 290.0; // ambientTemp (K)
params[63] = 2.4e9; // centerFreq (Hz)
params[64] = 20e6; // bandwidth (Hz)
// txPower: column 26 (per-UAV, up to MAX_CLIENTS_PER_PARAM values, zero-padded)
if (nf > 26) {
char tmp[256]; strncpy(tmp, fields[26], sizeof(tmp) - 1); tmp[sizeof(tmp)-1] = '\0';
char* t = trimField(tmp);
double vals[4] = {0, 0, 0, 0};
int count = 0;
char* tok = strtok(t, ",");
while (tok && count < MAX_CLIENTS_PER_PARAM) {
vals[count++] = atof(tok);
tok = strtok(nullptr, ",");
}
if (count > 0) {
for (int k = 0; k < MAX_CLIENTS_PER_PARAM; k++) params[55 + k] = vals[k];
}
}
// useSinrComms: column 27
if (nf > 27) {
char tmp[64]; strncpy(tmp, fields[27], sizeof(tmp) - 1); tmp[sizeof(tmp)-1] = '\0';
params[59] = atof(trimField(tmp));
}
// sinrThreshold: column 28 (dB)
if (nf > 28) {
char tmp[64]; strncpy(tmp, fields[28], sizeof(tmp) - 1); tmp[sizeof(tmp)-1] = '\0';
params[60] = atof(trimField(tmp));
}
// pathLossExponent: column 29
if (nf > 29) {
char tmp[64]; strncpy(tmp, fields[29], sizeof(tmp) - 1); tmp[sizeof(tmp)-1] = '\0';
params[61] = atof(trimField(tmp));
}
// ambientTemp: column 30 (K)
if (nf > 30) {
char tmp[64]; strncpy(tmp, fields[30], sizeof(tmp) - 1); tmp[sizeof(tmp)-1] = '\0';
params[62] = atof(trimField(tmp));
}
// centerFreq: column 31 (Hz)
if (nf > 31) {
char tmp[64]; strncpy(tmp, fields[31], sizeof(tmp) - 1); tmp[sizeof(tmp)-1] = '\0';
params[63] = atof(trimField(tmp));
}
// bandwidth: column 32 (Hz)
if (nf > 32) {
char tmp[64]; strncpy(tmp, fields[32], sizeof(tmp) - 1); tmp[sizeof(tmp)-1] = '\0';
params[64] = atof(trimField(tmp));
}
printf("Loaded scenario: domain [%g,%g,%g] to [%g,%g,%g], %d objective component(s)\n",
params[32], params[33], params[34], params[35], params[36], params[37], (int)params[38]);
printf("Comms model: %s (SINR threshold %g dB, path-loss exp %g, T=%g K, f_c=%g Hz, BW=%g Hz)\n",
params[59] != 0.0 ? "SINR" : "fixed-radius", params[60], params[61], params[62], params[63], params[64]);
return 1;
}
+8 -1
View File
@@ -34,7 +34,14 @@ int loadTargets(const char* filename, double* targets, int maxClients);
// 52 useDoubleIntegrator (0=single-integrator, 1=double-integrator)
// 53 dampingCoeff
// 54 useFixedTopology (0=dynamic lesser-neighbor, 1=fixed)
#define NUM_SCENARIO_PARAMS 55
// 55-58 txPower[1:4] (per-UAV transmit power, Watts; SINR comms model)
// 59 useSinrComms (0=fixed-radius comms, 1=SINR/path-loss comms)
// 60 sinrThreshold (SINR connectivity/CBF threshold, dB)
// 61 pathLossExponent (path-loss exponent n)
// 62 ambientTemp (ambient temperature, K; thermal noise)
// 63 centerFreq (carrier frequency, Hz; path-loss offset)
// 64 bandwidth (channel bandwidth, Hz; thermal noise)
#define NUM_SCENARIO_PARAMS 65
#define MAX_CLIENTS_PER_PARAM 4
// Maximum number of obstacles (upper bound for pre-allocated arrays).
#define MAX_OBSTACLES 8
+18 -2
View File
@@ -45,6 +45,9 @@ for ii = 1:size(agents, 1)
collisionGeometry = collisionGeometry.initialize(params.initialPositions((((ii - 1) * 3) + 1):(ii * 3)), params.collisionRadius(ii), REGION_TYPE.COLLISION, sprintf("Agent %d collision geometry", ii));
agents{ii} = agents{ii}.initialize(params.initialPositions((((ii - 1) * 3) + 1):(ii * 3)), collisionGeometry, sensorModel, params.comRange(ii), params.maxIter, params.initialStepSize, 5.0, sprintf("Agent %d", ii), plotCommsGeometry);
if isfield(params, 'txPower')
agents{ii}.txPower = params.txPower(ii); % SINR comms model transmit power (W)
end
end
% Create obstacles
@@ -54,9 +57,22 @@ for ii = 1:size(obstacles, 1)
obstacles{ii} = obstacles{ii}.initialize([params.obstacleMin((((ii - 1) * 3) + 1):(ii * 3)); params.obstacleMax((((ii - 1) * 3) + 1):(ii * 3))], "OBSTACLE", sprintf("Obstacle %d", ii));
end
% Set up simulation
% SINR communications model parameters (optional CSV columns; default to the
% fixed-radius path so existing scenarios are unaffected)
if isfield(params, 'useSinrComms'); useSinrComms = logical(params.useSinrComms); else; useSinrComms = false; end
if isfield(params, 'sinrThreshold'); sinrThreshold = params.sinrThreshold; else; sinrThreshold = 0; end
if isfield(params, 'pathLossExponent'); pathLossExponent = params.pathLossExponent; else; pathLossExponent = 2.0; end
if isfield(params, 'ambientTemp'); ambientTemp = params.ambientTemp; else; ambientTemp = 290.0; end
if isfield(params, 'centerFreq'); centerFreq = params.centerFreq; else; centerFreq = 2.4e9; end
if isfield(params, 'bandwidth'); bandwidth = params.bandwidth; else; bandwidth = 20e6; end
% Set up simulation. The four args after makeVideo (useDoubleIntegrator,
% dampingCoeff, useFixedTopology, optimizeSensorPointing) are kept at their
% prior effective defaults to preserve existing analysis behavior; only the
% SINR comms parameters are threaded through from the scenario.
sim = miSim;
sim = sim.initialize(domain, agents, params.barrierGain, params.barrierExponent, params.minAlt, params.timestep, params.maxIter, obstacles, makePlots, makeVideo);
sim = sim.initialize(domain, agents, params.barrierGain, params.barrierExponent, params.minAlt, params.timestep, params.maxIter, obstacles, makePlots, makeVideo, ...
false, 2.0, false, false, useSinrComms, sinrThreshold, pathLossExponent, ambientTemp, centerFreq, bandwidth);
% Save simulation parameters to output file
sim.writeInits();