Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The duration field of the setStop function does not work #21

Open
juancagb opened this issue Jul 30, 2022 · 2 comments
Open

The duration field of the setStop function does not work #21

juancagb opened this issue Jul 30, 2022 · 2 comments

Comments

@juancagb
Copy link

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)
@tsahhary
Copy link

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!

@juancagb
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants