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

traci.vehicle.getContextSubscriptionResults(egoID) #7

Open
shuowang572875852 opened this issue Mar 25, 2019 · 0 comments
Open

traci.vehicle.getContextSubscriptionResults(egoID) #7

shuowang572875852 opened this issue Mar 25, 2019 · 0 comments

Comments

@shuowang572875852
Copy link

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.

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

1 participant