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);
}
The solution to my problem was just to make setHostSpeed = true in the ini file.