0

In my simulation, I'm trying to use traCI to control vehicle type and traCI is invoked by receiving a beacon message sent by RSU. In addition, I add packet lost probability, as code shown below:

void MyVeinsAppCar::handleLowerMsg(cMessage* msg) {
    if( uniform(0,1) < 0.8)
    {                                 
        EV << "\"Losing\" message " << msg << endl;
        delete msg;
    }
    else
    {
        TraCIMobility* mobility = TraCIMobilityAccess().get(getParentModule());
        TraCICommandInterface* traci = mobility->getCommandInterface();
        TraCICommandInterface::Vehicle* traciVehicle = mobility->getVehicleCommandInterface();
        if (traciVehicle->getRouteId().substr(0,4)=="!FR.")
            {
                traciVehicle->setTypeId("vtype1");
            }
        else if (traciVehicle->getRouteId().substr(0,4)=="!RF.")
            {
                traciVehicle->setTypeId("vtype0");
            }
}

In this case, the vehicle type in sumo is initially set as default and traCI is used to change their vehicle type. When I run this simulation by setting different packet lost probability, the simulation gui will show different effects(different types of vehicles will show different colors), but the output speed are exactly the same. But my purpose is to study the influence of vehicle types on vehicle speed under different permeability. And when I run sumo alone, I set different proportions of vehicle types in sumo's route file, the output speed will be different. The following code is where I manually set vType0 and vType1 to 50%.

<routes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://sumo.dlr.de/xsd/routes_file.xsd">
    <vType id="vtype0" laneChangeModel="LC2013" lcStrategic="150" lcKeepRight="50"/>
    <vType id="vtype1" laneChangeModel="LC2013"  lcStrategic="1000" lcKeepRight="100"/>    

    <flow id="FR" begin="0.00" departLane="random" from="gneE0" to="gneE4" end="3600.00" vehsPerHour="270"/>
    <flow id="FR_C" type="vtype1" begin="0.00" departLane="random" color="magenta" from="gneE0" to="gneE4" end="3600.00" vehsPerHour="270"/>

    <flow id="RF" begin="0.00" departLane="random"  from="gneE3" to="gneE2" end="3600.00" vehsPerHour="624"/>
    <flow id="RF_C" type="vtype0" begin="0.00" departLane="random" color="red" from="gneE3" to="gneE2" end="3600.00" vehsPerHour="624"/>

</routes>

So why is this happening? Do I need to adjust any parameters in Omnet? Thank you in advance!

Tiffany
  • 43
  • 5
  • You did not specify which Veins version you are using, so I am assuming Veins 5.2. This version has no `TraCICommandInterface::Vehicle::setTypeId` method (see https://github.com/sommer/veins/blob/veins-5.2/src/veins/modules/mobility/traci/TraCICommandInterface.h#L129), so I am assuming that this is a method you wrote yourself and it is not working as expected – Christoph Sommer Jan 08 '22 at 15:02

1 Answers1

0

You can specify different values for accel and decel properties of a vehicle inside vType tag. For more information check sample route file in veins project. More details can be found on eclipse sumo website.

Pasha M.
  • 340
  • 1
  • 12