Open KailinTong opened 6 years ago
Hello, I want to get the leader and follower vehicle acceleration in the target lane .So ,first I add traci.vehicle.subscribeContext to get ego vehicle context information ,and then I 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()
Can you give me some help and looking forward to your reply.
Hello,
I have got the same error as mentioned above when I ran traci.vehicle.moveToVTD:
The class traci.constants has no Constant property or Static method named 'VAR_MOVE_TO_VTD'.
I checked that the 'VAR_MOVE_TO_VTD' is not present in traci.constants
Can you please help me out, how to solve this issue?
Best regards, Sai Krishna
Hello,
I tried traci.vehicle.moveTo with different position parameters, but the car simply did not move.
And when I ran traci.vehicle.moveToVTD, it had an error:
The class traci.constants has no Constant property or Static method named 'VAR_MOVE_TO_VTD'.
Error in traci.vehicle.moveToVTD (line 12) traci.beginMessage(constants.CMD_SET_VEHICLE_VARIABLE, constants.VAR_MOVE_TO_VTD,...