Closed JaneCheung closed 5 years ago
This issue should be closed with the latest version (844f0a6e61cdf5f239f5dea915f2a330fdff8505).
Best Regards.
Sorry to bother you, I'm new in traci4matlab ,can you give me some help for learning traci4matlab. I want to use traci.vehicle.subscribeContext to get status information about the vehicles on the left and right lanes of the current vehicle., but the return values are error,the following are my codes: 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(); % arrivedIDList= traci.simulation.getArrivedIDList(); for j=1:length(IDList{i,1}) [leaderVehicleID{i,1}, dist{i,1}] = traci.vehicle.getLeader(char(IDList{i,1}(1:end,j)),50); accel{i,1}(j)=traci.vehicle.getAcceleration(char(IDList{i,1}(1:end,j))); speed{i,1}(j)=traci.vehicle.getSpeed(char(IDList{i,1}(1:end,j))); laneID{i,1}=traci.vehicle.getLaneID(char(IDList{i,1}(1:end,j))); lastStepMeanSpeed{i,1}= traci.lane.getLastStepMeanSpeed(char(laneID{i,1})); % length{i,1} = traci.lane.getLength(char(laneID{i,1})); allowedSpeed{i,1}(j) = traci.vehicle.getAllowedSpeed(char(IDList{i,1}(1:end,j))); laneIndex{i,1} = traci.vehicle.getLaneIndex(char(IDList{i,1}(1:end,j))); roadID{i,1} = traci.vehicle.getRoadID(char(IDList{i,1}(1:end,j))); lanePosition{i,1}(j) = traci.vehicle.getLanePosition(char(IDList{i,1}(1:end,j))); minGap{i,1}(j) = traci.vehicle.getMinGap(char(IDList{i,1}(1:end,j))); angle{i,1}(j) = traci.vehicle.getAngle(char(IDList{i,1}(1:end,j)));
% Subscribe to the vehicle ID around the left lane of the current vehicle traci.vehicle.subscribeContext(char(IDList{i,1}(1:end,j)),traci.constants.CMD_GET_VEHICLE_VARIABLE,150,{traci.constants.VAR_LANEPOSITION, traci.constants.VAR_SPEED}); traci.vehicle.addSubscriptionFilterLanes(1); traci.vehicle.addSubscriptionFilterLeadFollow(1); leftcontextSubscriptionResults{i,1}=traci.vehicle.getContextSubscriptionResults(char(IDList{i,1}(1:end,j))); leftsurround_vehicle{i,1}=keys(leftcontextSubscriptionResults{i,1}); % Subscribe to the vehicle ID around the right lane of the current vehicle traci.vehicle.subscribeContext(char(IDList{i,1}(1:end,j)),traci.constants.CMD_GET_VEHICLE_VARIABLE,150,{traci.constants.VAR_LANEPOSITION, traci.constants.VAR_SPEED}); traci.vehicle.addSubscriptionFilterLanes(-1); traci.vehicle.addSubscriptionFilterLeadFollow(-1); rightcontextSubscriptionResults{i,1}=traci.vehicle.getContextSubscriptionResults(char(IDList{i,1}(1:end,j))); rightsurround_vehicle{i,1}=keys(rightcontextSubscriptionResults{i, 1}); % Subscribe to the vehicle ID around the current lane of the current vehicle traci.vehicle.subscribeContext(char(IDList{i,1}(1:end,j)),traci.constants.CMD_GET_VEHICLE_VARIABLE,150,{traci.constants.VAR_LANEPOSITION, traci.constants.VAR_SPEED}); traci.vehicle.addSubscriptionFilterLanes(0); traci.vehicle.addSubscriptionFilterLeadFollow(0); CurrentcontextSubscriptionResults{i,1}=traci.vehicle.getContextSubscriptionResults(char(IDList{i,1}(1:end,j))); Currentsurround_vehicle{i,1}=keys(CurrentcontextSubscriptionResults{i, 1}); end end traci.close() But the returned values of Currentsurround_vehicle, rightsurround_vehicle, leftsurround_vehicle are the same,can you give me some help for it. And can you leave a mailbox to discuss it?Looking forward to your reply.
Hi, I have downloaded the TRACI4MATLAB and SUMO 1.0.0 to simulate the traci_test1 which went well, however the traci_test2 could not simulate well . Something went wrong. Could someone help me to deal with the problem and the problem has been printed below.
wrong usage: traci.sendExact (line 46) 71 204 1 Not Implemented GUI is not running, command not implemented in command line sumo
Error: traci.sendDoubleCmd (line 14) traci.sendExact(); Error traci.gui.setZoom (line 11) traci.sendDoubleCmd(constants.CMD_SET_GUI_VARIABLE, constants.VAR_VIEW_ZOOM, viewID, zoom);
Error: traci_test2 (line 251) traci.gui.setZoom('View #0', 1000);
Thanks in advance !
Best regards!
Jane