The duration field of the setStop function does not work
I am trying to carry out a simulation of electric vehicles with traci4matlab. In the simulation I put charging stations and when I try to make the stop to charge (through the function setStop), my vehicles stop but do not start moving again even though the time in the duration field has elapsed. In conclusion, the setStop function does not work correctly. Could you help me please? This is the code of Matlab:
%% En este fichero se consigue que 2 flujos de 2 vehículos
%depurar codigo
clear
close all
clc
import traci.constants
% esto se incluye siempre para poder importar las constantes
% Get the filename of the example scenario
[scenarioPath,~,~] = fileparts(which(mfilename));
% scenarioPath = [scenarioPath '\inter_palmas'];
cd(scenarioPath);
%se utiliza para poner en marcha sumo por medio del fichero
%sumocfg que he generado previamente
traci.start('sumo-gui -c ./circles.sumocfg --start');
%definimos los tiempos de simulación en ms1
N=2000;
SIM_STEPS = [1 N];
beginTime = SIM_STEPS(1);
duration = SIM_STEPS(2);
endTime = SIM_STEPS(1) + SIM_STEPS(2) - 1;
%Variable que indica que el vehículo ha entrado en la estación de carga
carga1=1;
n1=1;
%Matrcices de posición
posi1=zeros(2,N);
%Indica que el vehículo debe salir de la estación
cargado1=0;
%hago esto para que se le de el valor a la variable ID y poder saber el
%número de coches
for i=1:10
traci.simulation.step();
ID=traci.vehicle.getIDList();
%se tiene que incializar fuera del bucle la matriz de parada
n=length(ID);
parada=0;
end
%bucle principal
for i = 1: duration-1
traci.simulation.step();%se realiza un paso de simulación
%bucle para trabajar con los diferentes vehículos
for j=n1:n
vehID=ID{j};
%matriz 2 por N nos aporta la posición x e y en todo isntante
posi1(:,i)=traci.vehicle.getPosition(ID{1})';
if i>451
parada=1;
end
if posi1(1,i)>=20 && posi1(1,i)<65 && posi1(2,i)>200 && posi1(2,i)<300
if parada==1 & carga1==1
display(i);
traci.vehicle.setStop(ID{1},'station1',20,0,400,'32',60,0);
carga1=0;
end
end
end
end
traci.close()
[e1.zip](https://github.com/pipeacosta/traci4matlab/files/9225936/e1.zip)
I can't reproduce this - though tried only the python script equivalent below:
import os
import sys
if "SUMO_HOME" in os.environ:
sys.path.append(os.path.join(os.environ["SUMO_HOME"], "tools"))
import traci # noqa
import sumolib # noqa
traci.start([sumolib.checkBinary('sumo-gui'), "-c", "circles.sumocfg"] + sys.argv[1:])
for i in range(10):
traci.simulationStep()
vehicleIDs = traci.vehicle.getIDList()
charge = True
for i in range(2000):
traci.simulationStep()
vehPosLead = traci.vehicle.getPosition(vehicleIDs[0])
if i > 451 and 20 >= vehPosLead[0] < 65 and 200 < vehPosLead[1] < 300:
if charge:
traci.vehicle.setStop(vehicleIDs[0], 'station1',20,0,400,32,60,0)
charge = False
traci.close()
to diagnose the state of the vehicle, right-click on the stopped vehicle in sumo-gui and select 'show-route'. The current reason for stopping should then be written next to the vehicle in the gui.
Closing for lack of feedback. Feel free to add another comment here, if problems persist