Dear Babangida:
Context subscriptions return a dictionary whose elements are the objects
close to the vehicle to which the context subscription was made, in this
case, the same vehicle. Furthermore, once you have retrieved the object of
interest, another dictionary is returned, which contains the values of the
variables the subscription was made to. Therefore, your code should be
something like:
veh = '-3801.9';
contextSubsToVeh = 0;
if ~ischar(veh) %if it is not of char type,
veh = char(veh); %this line convert to the char type so that the
ischar passing in traci4matlab is satisfied.
end
vehicles = traci.vehicle.getIDList();
if ismember(veh,vehicles)
if ~contextSubsToVeh
traci.vehicle.subscribeContext(veh,constants.CMD_GET_VEHICLE_VARIABLE,20,...
{constants.VAR_WAITING_TIME});
contextSubsToTestVeh = 1;
end
if contextSubsToVeh
vehContextSubscriptionResults =
traci.vehicle.getContextSubscriptionResults(veh);
if ~strcmp(vehContextSubscriptionResults,'None')
testVehSubsResults = vehContextSubscriptionResults(veh);
testVehWaitingTime =
testVehSubsResults(constants.VAR_WAITING_TIME)
end
end
>
> Message: 1
> Date: Sun, 24 Jan 2016 18:37:59 +0800
> From: BABANGIDA ZACHARIAH <[email protected]>
> Subject: Re: [sumo-user] Traci4Matlab Waiting Time of Vehicles
> To: Andres Felipe Acosta Gil <[email protected]>, sumo-user
> <[email protected]>
> Message-ID:
> <CAP7bCf2ONDD+d56We=
> [email protected]>
> Content-Type: text/plain; charset=UTF-8
>
> Hi Fellow SUMO & Traci4Matlab Users,
>
> Thank you Mr. Andres for your continued response for every of my query
> concerning traci4matlab.
>
> I found the problem I was having with the:
>
> Error using vehicle.subscribeContext
> Argument 'vehID' failed validation ischar.
>
> Error in traci.vehicle.subscribeContext (line 34)
> p.parse(vehID, domain, dist, varargin{:})
>
> Error in signalizedControl (line 108)
>
>
> traci.vehicle.subscribeContext(veh,constants.CMD_GET_VEHICLE_VARIABLE,20,{constants.VAR_WAITING_TIME});
>
> it was because the matlab variables are often cell array type which must be
> converted to char type to satisfy the ischar condition when being passed in
> the subscribe or subscriptionContext methods.
>
> Therefore, the correct way to do it and not get the failed ischar error is:
>
> veh = '-3801.9';
> if ~ischar(veh) %if it is not of char type,
> veh = char(veh); %this line convert to the char type so that the
> ischar passing in traci4matlab is satisfied.
> end
>
>
> vehicles = traci.vehicle.getIDList();
>
> if ismember(veh,vehicles)
>
> traci.vehicle.subscribeContext(veh,constants.CMD_GET_VEHICLE_
> VARIABLE,20,{constants.VAR_WAITING_TIME});
>
> end
>
>
> However, I still have a little challenge with the following lines of code:
>
>
> veh = '-3801.9';
> if ~ischar(veh) %if it is not of char type,
> veh = char(veh); %this line convert to the char type so that the
> ischar passing in traci4matlab is satisfied.
> end
> vehicles = traci.vehicle.getIDList();
>
> if ismember(veh ,vehicles)
>
> traci.vehicle.subscribeContext(
> veh ,constants.CMD_GET_VEHICLE_VARIABLE,20,{constants.VAR_WAITING_TIME});
>
> testVehicleHandle = traci.vehicle.getSubscriptionResults(veh);
> display(testVehicleHandle);
>
> end
>
>
> which I hoped it should return the waiting time of the vehicle, but it
> returned "None" instead. What could I be doing wrongly?
>
> Thank You.
>
> Babangida
>
>
> --
Andres Felipe Acosta Gil, MSc student - Software developer
Universidad Nacional de Colombia - MedellĂn
Facultad de Minas
Tel: +57 (4) 4255295
Institutional e-mail: [email protected]
------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140
_______________________________________________
sumo-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sumo-user