Thanks Jakob,
That looks like exactly what I need.
I'm struggling to get it to work though. After a single call to
send_commandSubscribeObjectVariable I'm just receiving a single response
rather than many.
In a class derived from TraCIAPI, I have set up a separate thread which
loops around a call to receiveExact(inMsg) and decodes all the received
messages.
and rather than calling simulationStep, I am calling
send_commandSimulationStep, so that bit doesn't block and wait for a
response.
I don't know whether my problem is related to the objID parameter of
send_commandSubscribeObjectVariable. Why does it need that as I would just
expect send_commandSubscribeObjectContext to need that. or I am
misunderstanding.
or it could be to do with beginTime/endTime, but I think I have it right
(and I do get one message).
Related to this, I thought maybe I had to have my own dynamically added
vehicle to use as objID, but am having difficulty to add a vehicle and it
return a valid Position. I can take over a vehicle defined in the scenario
and move it, but my dynamically added one always returns
INVALID_DOUBLE_VALUE.
My gash code is roughly as follows. It only starts the receive thread near
the end:
mStartTime = simulation.getCurrentTime();
// Run until we get some vehicles
auto IDs = vehicle.getIDList();
while (IDs.empty())
{
simulationStep();
IDs = vehicle.getIDList();
}
std::vector<std::string> routes = route.getIDList();
// This (and variations of it) don't work
vehicle.add("Ego", routes[0], "CarA"); //, "DEFAULT_VEHTYPE", "-1",
"first", "base", 0);
vehicle.moveToXY("Ego", "", 0, 15,995.05, 0, false);
simulationStep();
auto posEgo = vehicle.getPosition("Ego");
// This does
auto pos1 = vehicle.getPosition(IDs[0]);
vehicle.moveToXY(IDs[0], "", 0, 998.50,995.05, 0, false);
simulationStep();
auto pos2 = vehicle.getPosition(IDs[0]);
hUDPThread = CreateThread(NULL, 0, StartNetworkReceiveThread, this,
0, &dwGenericThread);
std::vector<int> vars;
vars.push_back(VAR_POSITION3D);
vars.push_back(VAR_ANGLE);
send_commandSubscribeObjectVariable(CMD_SUBSCRIBE_VEHICLE_VARIABLE,
"veh0", mStartTime, mStartTime+60000, vars);
Any help with any of this would be fantastic, thanks.
Cheers,
Erik
--
Erik Newton
Model Integration Engineer
rFactor Pro
e: [email protected]
w: http://www.rfpro.com
m: +44 (0) 7967 270693
This e-mail and any files transmitted with it are private and confidential.
If you have received this email in error please notify the sender
immediately and delete this e-mail from your system. The recipient should
check this email and any attachments for the presence of viruses. rFactor
Pro accepts no liability for any damage caused by any virus transmitted by
this email. rFactor Pro is the trading name of Kangaloosh Limited,
registered in England No. 06427019.
On 27 April 2016 at 07:23, Jakob Erdmann <[email protected]> wrote:
> Hello,
> there is a more efficient mechanism for retrieving data continuously via
> TraCI, called subscriptions:
> http://sumo.dlr.de/wiki/TraCI/Object_Variable_Subscription
> http://sumo.dlr.de/wiki/TraCI/Object_Context_Subscription
> Basically, you can retrieve all vehicle positions with a single request.
> However, at 1Khz the simulation itself will become quite slow. I think you
> are better of running the simulation at 10Hz and interpolating positional
> data yourself.
>
> regards,
> Jakob
>
> 2016-04-26 21:48 GMT+02:00 Erik Newton <[email protected]>:
>
>> Hi,
>> I am currently investigating the possibility of linking SUMO with our 3D
>> visualisation software.
>> Basically I need a high frequency (1KHz) stream of all vehicle positions
>> (and maybe a lower frequency stream of vehicle types) I have been
>> evaluating the TraCI API but am finding it a bit limited for real-time
>> use.
>>
>> E.g. It would appear I have to request each vehicle's position
>> individually.
>>
>> The API is all based on a TCP request and then waiting for a response,
>> which is killing my real-time application. I have made some progress with
>> creating a new class which inherits from TraCIAPI and splitting all the
>> receipts into a separate thread, but it seems a bit silly to have to keep
>> requesting the same information each time-step.
>>
>> Am I missing an obvious way of doing this?
>>
>> Could we extend the API to have a mechanism to register an interest in
>> particular data and it be continually broadcast? Possibly register an
>> interest in any vehicles within a user-defined radius of the ego vehicle?
>>
>> Alternatively, is there a way to write plugins for SUMO? So I could just
>> write my own bespoke output stream of the data I require.
>>
>> Thanks in advance for any guidance,
>>
>> Erik Newton
>> Model Integration Engineer
>> rFactor Pro
>>
>> ------------------------------------------------------------------------------
>> Find and fix application performance issues faster with Applications
>> Manager
>> Applications Manager provides deep performance insights into multiple
>> tiers of
>> your business applications. It resolves application problems quickly and
>> reduces your MTTR. Get your free trial!
>> https://ad.doubleclick.net/ddm/clk/302982198;130105516;z
>> _______________________________________________
>> sumo-devel mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/sumo-devel
>>
>
>
------------------------------------------------------------------------------
Find and fix application performance issues faster with Applications Manager
Applications Manager provides deep performance insights into multiple tiers of
your business applications. It resolves application problems quickly and
reduces your MTTR. Get your free trial!
https://ad.doubleclick.net/ddm/clk/302982198;130105516;z
_______________________________________________
sumo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sumo-devel