Pedestrian Simulation in veins (omnet++/sumo)

2019-06-03 14:59发布

I'm trying to run a pedestrian simulation from sumo in omnet++. To keep it easy (i am a beginner) I decided to use the Erlangen example provided with veins and extend it with a couple of pedestrians. I added the pedestrians in sumo and ran it. It works perfectly fine: You can see the pedestrians and cars in this picture

Next I was trying to run the whole thing in omnet++. I also managed to do that but the pedestrians were not shown. Just the cars. I read these two topics:

and added these lines into the omnetpp.ini of the example:

*.manager.moduleType = "vtype0=org.car2x.veins.nodes.Car ped_pedestrian=org.car2x.veins.nodes.Pedestrian"
*.manager.moduleName = "vtype0=carNode ped_pedestrian=pedestrianNode"
*.manager.moduleDisplayString = "vtype0=carNode ped_pedestrian=pedestrianNode"

I also changed every appearance of "node" in omnetpp.ini to "carNode" and created new entries for "pedestrianNode" and I duplicated the Car.ned file and changed the file name to Pedestrian.ned and the module name to "Pedestrian". Then I ran the whole thing again but nothing changed except that the cars' image (as shown in the simulation) changed to a grey box.

Why are the pedestrians not shown? (Did I miss something?) Do I have to tell veins (or sumo) to communicate pedestrian positions to omnet++? Why did the icon of the cars in the simulation change to a grey box?

Here are the files that I added/modified:

Edit:

I researched the TraCI definition and debugged the [source code of veins]. I found these lines of code where subscriptions are done:

{
    // subscribe to list of departed and arrived vehicles, as well as simulation time
    simtime_t beginTime = 0;
    simtime_t endTime = SimTime::getMaxTime();
    std::string objectId = "";
    uint8_t variableNumber = 7;
    uint8_t variable1 = VAR_DEPARTED_VEHICLES_IDS;
    uint8_t variable2 = VAR_ARRIVED_VEHICLES_IDS;
    uint8_t variable3 = commandInterface->getTimeStepCmd();
    uint8_t variable4 = VAR_TELEPORT_STARTING_VEHICLES_IDS;
    uint8_t variable5 = VAR_TELEPORT_ENDING_VEHICLES_IDS;
    uint8_t variable6 = VAR_PARKING_STARTING_VEHICLES_IDS;
    uint8_t variable7 = VAR_PARKING_ENDING_VEHICLES_IDS;
    TraCIBuffer buf = connection->query(CMD_SUBSCRIBE_SIM_VARIABLE, TraCIBuffer() << beginTime << endTime << objectId << variableNumber << variable1 << variable2 << variable3 << variable4 << variable5 << variable6 << variable7);
    processSubcriptionResult(buf);
    ASSERT(buf.eof());
}

{
    // subscribe to list of vehicle ids
    simtime_t beginTime = 0;
    simtime_t endTime = SimTime::getMaxTime();
    std::string objectId = "";
    uint8_t variableNumber = 1;
    uint8_t variable1 = ID_LIST;
    TraCIBuffer buf = connection->query(CMD_SUBSCRIBE_VEHICLE_VARIABLE, TraCIBuffer() << beginTime << endTime << objectId << variableNumber << variable1);
    processSubcriptionResult(buf);
    ASSERT(buf.eof());
}

I compared that to the TraCI documentation on the sumo wiki:
* the first block for simulation subscriptions: https://sumo.dlr.de/wiki/TraCI/Simulation_Value_Retrieval
* the second block of code for vehicle subscription: https://sumo.dlr.de/wiki/TraCI/Vehicle_Value_Retrieval

It seems to me that pedestrians are not included there since the persons/pedestrians have a different api (https://sumo.dlr.de/wiki/TraCI/Person_Value_Retrieval) which is not listed on the subscription page (https://sumo.dlr.de/wiki/TraCI/Object_Variable_Subscription).

Is there something I missed in the source code of veins where person subscription is done?

Is it even possible to subscribe to persons in TraCI?

1条回答
霸刀☆藐视天下
2楼-- · 2019-06-03 15:31

You are absolutely right. As of Veins 5a1, Pedestrians (Persons in SUMO parlance) are not supported by Veins out of the box, meaning additional code needs to be written by the user.

For internal projects we have simply cloned the code handling vehicle subscriptions, substituting class and variable names where appropriate (i.e., CMD_SUBSCRIBE_PERSON_VARIABLE=0xde for ID_LIST, then subscribing to VAR_POSITION etc for every new person, and reacting to changes in these variables by calling addModule and nextPosition).

查看更多
登录 后发表回答