You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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()
Hi juancagb,
I have the same problem.
I also tried to solve it by using the comand 'stChargingStationStop'. But it did not work either.
Both commands don't seem to work!
Maybe you have already found a solution?
Hi juancagb, I have the same problem. I also tried to solve it by using the comand 'stChargingStationStop'. But it did not work either. Both commands don't seem to work! Maybe you have already found a solution?
Best regards!
Hi tshhary,
I have not been able to solve this error, so I advise you to use python, where this function will work correctly.
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
The text was updated successfully, but these errors were encountered: