为什么 getSenderSpeed() 在 onBSM 中从 veins-SUMO-omnet++ 返回零(总是)?

Why the getSenderSpeed() is returning zero (always) in onBSM from veins-SUMO-omnet++?

我使用的是 veins 版本 5.2、omnetpp5.7、Eclipse SUMO 版本 1.4.0。 我正在尝试按照本教程实现 3 辆车的简单列队行驶: http://cse.iitkgp.ac.in/~soumya/micro/t2-4.pdf 我遵循了完全相同的步骤并建立了车辆之间的通信,但在 onBSM 函数中,getSenderSpeed 始终 return (0,0,0) 导致 getSenderSpeed.Length() = 0。 我尝试调试它并尝试从调试变量菜单中检查数据,当我打开发送到 onBSM 的对象时,有两个值是 getSenderPos 和 getSenderSpeed,当我打开 getSenderSpeed 时它为零,当我打开 getSenderPos 时,模拟终止。 任何解决方案? 我的初始化函数:

    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);
        }}}

我的onBSM功能代码:

void VehicleControlApp::onBSM(DemoSafetyMessage* bsm)
{
        double leadVehicleSpeed = bsm->getSenderSpeed().length();
        traciVehicle->setSpeedMode(0x1f);
        traciVehicle->setSpeed(leadVehicleSpeed);
}

我的问题的解决方案就是在 ini 文件中设置 setHostSpeed = true。