Search code examples
omnet++veins

Calculate direction of a vehicle (Veins/Omnet++/Sumo)


Is it possible to calculate(get) direction of vehicle in Veins(via TraCIMobility)? I want to know if two vehicles are traveling in opposing directions or not. I think I can do that via getAngleRad() method (if they are moving in the same direction they fall in the same quadrant and if moving opposite they are in opposite quadrants), but I am not sure if its correct. (Sub-Question: Also, what are the exact values that getAngleRad() would return for each quadrant?)


Solution

  • You are correct: getAngleRad() returns the vehicle's heading in radians (from -pi up to, but excluding, +pi). A value of 0 means the vehicle is heading east; a value of pi/2 means it is heading north; etc.