【发布时间】:2022-12-22 22:40:39
【问题描述】:
我需要一些帮助:我正在尝试计算在模拟结束时在 SUMO 场景中添加到 TRACI4Matlab 中的车辆行驶的距离。
使用我的代码,我可以计算距离,但一旦通过最后一个节点,因为在 SUMO 场景中不再有我的车辆,就会抛出错误:
Error: Answered with error to command 0xa4: Vehicle 'prova' is not known.
这是我的 MATLAB 代码:
clear
close all
clc
import traci.constants
[scenarioPath,~,~] = fileparts(which(mfilename));
cd(scenarioPath);
traci.start('sumo-gui -c ./scenario1.sumocfg --start');
SIM_STEPS = [0 1000];
beginTime = SIM_STEPS(1);
duration = SIM_STEPS(2);
endTime = SIM_STEPS(1) + SIM_STEPS(2) - 1;
traci.vehicle.add('prova', 'percorso1', depart='100')
for i = 1 : duration
id{i}=(traci.vehicle.getIDList());
d1(i)=traci.vehicle.getDistance('prova');
traci.simulation.step();
end
traci.close()
我怎样才能继续模拟或避免错误?
【问题讨论】:
标签: matlab sumo vehicle-routing traffic-simulation