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
Hello,
I want to add traci.vehicle.getContextSubscriptionResults(egoID) to get the surround vehicle ID, but the output “ans” is 1*1Map ,the follow is my code:
for i = 1:duration
traci.simulation.step();
IDList{i,1} = traci.vehicle.getIDList();
for j=1:length(IDList{i,1})
accel{i,1}(j)=traci.vehicle.getAcceleration(char(IDList{i,1}(1:end,j)));
laneID{i,1}=traci.vehicle.getLaneID(char(IDList{i,1}(1:end,j)));
traci.vehicle.subscribeContext(char(IDList{i,1}(1:end,j)), traci.constants.CMD_GET_VEHICLE_VARIABLE,150,{traci.constants.VAR_POSITION, traci.constants.VAR_SPEED});
traci.vehicle.addSubscriptionFilterLeadFollow('1');
contextSubscriptionResults=traci.vehicle.getContextSubscriptionResults(char(IDList{i,1}(1:end,j)));
end
end
traci.close()
looking forward to your reply.
The text was updated successfully, but these errors were encountered:
Hello,
I want to add traci.vehicle.getContextSubscriptionResults(egoID) to get the surround vehicle ID, but the output “ans” is 1*1Map ,the follow is my code:
clear
close all
clc
import traci.constants
scenarioPath=['F:\software\SUMO配置文件\bin\quickstart\quickstart.sumocfg'];
system(['sumo-gui -c ' '"' scenarioPath '"' ' --remote-port 8813 --start&']);
traci.init
SIM_STEPS = [1 900];
beginTime = SIM_STEPS(1);
duration = SIM_STEPS(2);
endTime = SIM_STEPS(1) + SIM_STEPS(2) - 1;
for i = 1:duration
traci.simulation.step();
IDList{i,1} = traci.vehicle.getIDList();
for j=1:length(IDList{i,1})
accel{i,1}(j)=traci.vehicle.getAcceleration(char(IDList{i,1}(1:end,j)));
laneID{i,1}=traci.vehicle.getLaneID(char(IDList{i,1}(1:end,j)));
traci.vehicle.subscribeContext(char(IDList{i,1}(1:end,j)), traci.constants.CMD_GET_VEHICLE_VARIABLE,150,{traci.constants.VAR_POSITION, traci.constants.VAR_SPEED});
traci.vehicle.addSubscriptionFilterLeadFollow('1');
contextSubscriptionResults=traci.vehicle.getContextSubscriptionResults(char(IDList{i,1}(1:end,j)));
end
end
traci.close()
looking forward to your reply.
The text was updated successfully, but these errors were encountered: