I'm using Veins 4.4 with Omnet 4.6 and Sumo 0.25.
I would like to get information about the altitude of the vehicles. I just found the method getLonLat() in TraCICommandInterface class. Is there a method regarding the altitude or some other way to get this kind of information? Thanks
I tried to modify the mentioned function as follows:
std::list<double> TraCICommandInterface::getLonLatAlt(const Coord& coord) {
TraCIBuffer request;
request << static_cast<uint8_t>(POSITION_CONVERSION) << std::string("sim0")
<< static_cast<uint8_t>(TYPE_COMPOUND) << static_cast<int32_t>(2)
<< connection.omnet2traci(coord)
<< static_cast<uint8_t>(TYPE_UBYTE) << static_cast<uint8_t>(POSITION_LON_LAT_ALT);
TraCIBuffer response = connection.query(CMD_GET_SIM_VARIABLE, request);
uint8_t cmdLength; response >> cmdLength;
if (cmdLength == 0) {
uint32_t cmdLengthX;
response >> cmdLengthX;
}
uint8_t responseId; response >> responseId;
ASSERT(responseId == RESPONSE_GET_SIM_VARIABLE);
uint8_t variable; response >> variable;
ASSERT(variable == POSITION_CONVERSION);
std::string id; response >> id;
uint8_t convPosType; response >> convPosType;
ASSERT(convPosType == POSITION_LON_LAT_ALT);
double convPosLon; response >> convPosLon;
double convPosLat; response >> convPosLat;
double convPosAlt; response >> convPosAlt;
std::list<double> geo_coordinates;
std::list<double>::iterator it;
geo_coordinates.insert(it,0,convPosLon);
geo_coordinates.insert(it,1,convPosLat);
geo_coordinates.insert(it,2,convPosAlt);
return geo_coordinates;
}
but running in debug mode, it returns this error:
Thread 1 "opp_run" received signal SIGSEGV, Segmentation fault. 0x00007ffff5ea5543 in std::__detail::_List_node_base::_M_transfer(std::__detail::_List_node_base*, std::__detail::_List_node_base*) () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6 Python Exception Cannot find type std::__cxx11::list >::const_iterator::_Node: Python Exception Cannot find type std::__cxx11::list >::const_iterator::_Node: Python Exception Cannot find type std::__cxx11::list >::const_iterator::_Node:
Your modification is semantically sound, but syntactically wrong.
You are using
std::list::insert
incorrectly. The form you use takes an insert position (here, your code seems to supply an uninitialized iterator), a repetition count (here your code seems to supply what seems to be a position offset), and a value to insert.Changing the
insert
statements to three statements usingpush_back
yields working code (though note that the demo simulation yields missing values as no position mapping and no altitude values are defined).