1

I am using veins version 5.2, omnetpp5.7, Eclipse SUMO Version 1.4.0. I am trying to implement a simple platooning of 3 vehicles following this tutorial: http://cse.iitkgp.ac.in/~soumya/micro/t2-4.pdf I followed exactly the same steps and the communication between the vehicles are established, but in onBSM function, the getSenderSpeed always return (0,0,0) resulting in getSenderSpeed.Length() = 0. I tried to debug it and tried to check the data from the debug variables menu, when I open the object that is sent to onBSM, there are two values which are getSenderPos and getSenderSpeed, when I open getSenderSpeed its zero, when I open getSenderPos, the simulation gets terminated. Any solutions? my Initialization Function:

    void VehicleControlApp::initialize(int stage)
{
    DemoBaseApplLayer::initialize(stage);
    if (stage == 0) {
        // Initializing members and pointers of your application goes here
        EV << "Initializing " << par("appName").stringValue() << std::endl;
        //new
        currentOfferedServiceId = 7;
        //       currentSubscribedServiceId = -1;
        wsaInterval = 5; // Period Interval of the service message
        beaconInterval = 0.1;
    }
    else if (stage == 1) {
        // Initializing members that require initialized other modules goes here

        //Initializing members that require initialized other modules goes here
        int id_2=getId();
        int id=myId;
        if (getId() == 15){
            // this is the head vehicle%WSA
            startService(Channel::sch2, currentOfferedServiceId, "Platoon Lead Vehicle Service");
            scheduleAt(computeAsynchronousSendingTime(beaconInterval, ChannelType::control),sendBeaconEvt);
        }}}

My onBSM function code:

void VehicleControlApp::onBSM(DemoSafetyMessage* bsm)
{
        double leadVehicleSpeed = bsm->getSenderSpeed().length();
        traciVehicle->setSpeedMode(0x1f);
        traciVehicle->setSpeed(leadVehicleSpeed);
}
  • from linked pdf i can getId()==14, why its getId()==15 in above code – Pasha M. Feb 28 '22 at 06:49
  • Thank you for your comment. I followed the same steps he did, the first vehicle in my simulation was with id=15, I checked the debugger aswell and when the first vehicle enters, the if statement is executed, so I am certain there is no problem with the vehicle ID. – Anas Ashraf Feb 28 '22 at 07:45
  • seems you are not using setSenderSpeed() to set its value from the bsm sender node – Pasha M. Feb 28 '22 at 19:05
  • Yes I dont do that, and I dont know where exactly I should do that. If you can point me, I would be much thankful. – Anas Ashraf Mar 01 '22 at 07:20
  • Thanks for your help, I tracked down where set sender in the deeper layers, and I saw that its not updated because setHostSpeed = False, the solution to my problem was just to make setHostSpeed = true in the ini file. Thanks for your time. – Anas Ashraf Mar 01 '22 at 09:59
  • Hi. Please post the answer yourself. – Pasha M. Mar 04 '22 at 14:24

1 Answers1

1

The solution to my problem was just to make setHostSpeed = true in the ini file.