Why does Veins crash when commandSetSpeedMode() is used?

652 views Asked by At

I am trying to simulate a scenario in Veins where I want to disable the right of way checks at the road junctions. I looked up at the Sumo wiki and found that the bitset is 23 for the purpose. Another lookup in the TraCIMobility.h header bundled with Veins helped me to know that this can be done using the function commandSetSpeedMode() for a TraCIDemo11p node which models the vehicles in the Veins demo simulation. I am trying to build up my model using this demo bundled with Veins.

But as I am trying to do so, SUMO crashes. I am trying to initialize the nodes in the initialize() function of TraCIDemo11p through the following code:

void TraCIDemo11p::initialize(int stage) {
    BaseWaveApplLayer::initialize(stage);
    if (stage == 0) {
        traci = TraCIMobilityAccess().get(getParentModule());
        annotations = AnnotationManagerAccess().getIfExists();
        ASSERT(annotations);

        traci->commandSetSpeedMode(23);  // This is the point of modification

        sentMessage = false;
        lastDroveAt = simTime();
        findHost()->subscribe(parkingStateChangedSignal, this);
        isParking = false;
        sendWhileParking = par("sendWhileParking").boolValue();
    }
}

I tried to set the modes with other standard values such as 0 or 31, but every time I get SUMO crashed. I am unable to figure out where else I should place this command. I tried to set the mode in some other initialization stage by adding an else clause to it but it crashes still. What's more, eve nthe the debugger on, no error is being shown, either in the OMNeT++ window or the sumolaunchd.py output in OMNeT++ cmd. Please help to understand my error. Thanks.


EDIT: adding Error message info

To make things clear, I am not receiving any error message but the exit code. I searched for the code but got no help. The usual 'this app is not responding' window pops up and the sim ends, so I suspect SUMO to crash.

The OMNeT++ environment shows the following message:

Simulation terminated with exit code: -1073741819
Working directory: C:/Users/stes-2/veins-3.0/examples/Cross Roads
Command line: c:/Users/stes-2/omnetpp-4.4/bin/opp_run.exe -r 0 -n ../veins;../../src --tkenv-image-path=../../images -l ../../src/veins omnetpp.ini

Environment variables:
OMNETPP_ROOT=c:/Users/stes-2/omnetpp-4.4
PATH=;C:/Users/stes-2/veins-3.0/src;c:\Users\stes-2\omnetpp-4.4\bin;c:\Users\stes-2\omnetpp-4.4\msys\bin;c:\Users\stes-2\omnetpp-4.4\mingw\bin;c:/Users/stes-2/omnetpp-4.4/ide/jre/bin/client;c:/Users/stes-2/omnetpp-4.4/ide/jre/bin;c:/Users/stes-2/omnetpp-4.4/ide/jre/lib/i386;.;C:\Users\stes-2\omnetpp-4.4\msys\local\bin;c:\Users\stes-2\omnetpp-4.4\mingw\bin;C:\Users\stes-2\omnetpp-4.4\msys\bin;c:\Users\stes-2\omnetpp-4.4\bin;c:\ProgramData\Oracle\Java\javapath;c:\Windows\system32;c:\Windows;c:\Windows\System32\Wbem;c:\Windows\System32\WindowsPowerShell\v1.0\;c:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;c:\Python27;c:\Users\stes-2\sumo-0.21.0;c:\Users\stes-2\omnetpp-4.4;
OMNETPP_IMAGE_PATH=c:\Users\stes-2\omnetpp-4.4\images

Since I am running SUMO through the sumoLaunchd.py script, the error message that turns up at the MingW cmd of OMNeT++ is:

Starting SUMO (c:/Users/stes-2/sumo-0.21.0/bin/sumo-gui.exe -c cross.sumo.cfg) o
n port 64161, seed 0
Connecting to SUMO (c:/Users/stes-2/sumo-0.21.0/bin/sumo-gui.exe -c cross.sumo.c
fg) on port 64161 (try 1)
Releasing lock on port
Starting proxy mode
Done with proxy mode
Done with proxy mode, killing SUMO
SIGTERM
Done running SUMO
Cleaning up
Result: "<?xml version="1.0"?>
<status>
        <exit-code>15</exit-code>
        <start>1433944271</start>
        <end>1433944276</end>
        <status>Exited with error code 15</status>
        <stdout><![CDATA[Loading configuration... done.
]]></stdout>
        <stderr><![CDATA[]]></stderr>
</status>
"
Closing connection from 127.0.0.1 on port 64160
1

There are 1 answers

7
user4786271 On BEST ANSWER

I think you are missing some lines.

You have assigned the TraCIMobility to traci, and then you don't even consider the general commandInterface and the vehicleCommandInterface

TraCIMobility* mobility = TraCIMobilityAccess().get(getParentModule());
TraCICommandInterface* traci = mobility->getCommandInterface(); /* missing command interface */
TraCICommandInterface::Vehicle* traciVehicle = mobility->getVehicleCommandInterface(); /* missing vehicle command interface */
traciVehicle->setSpeedMode(someNumber);

I even tried to compile your code but it complains that there is no method available for TraCIMobility called commandSetSpeedMode(). But that could be due to difference in Veins versions.


Multi-stage initialization

A module/variable you are trying to access might not be ready, i.e. still has not been created, by the time you are trying to use it. In that case the multi-stage initialization feature of OMNeT++ can be used.

This means a "task" may be delayed to a later stage of the initialization of the current module:

void SomeModule::initialize(int stage)
{
    ApplicationBase::initialize(stage);  /* ignore if causes error */

    if(stage == 0)
    {
        /* do this */

    else if (stage == 3)
    {
        /* do this later */
    }
}