0

我将 Veins 4.4 与 Omnet 4.6 和 Sumo 0.25 一起使用。

我想获得有关车辆高度的信息。我刚刚在 TraCICommandInterface 类中找到了 getLonLat() 方法。有没有关于高度的方法或其他方式来获取这种信息?谢谢

我试图修改上述功能如下:

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

但在调试模式下运行,它返回此错误:

线程 1“opp_run”收到信号 SIGSEGV,分段错误。0x00007ffff5ea5543 in std::__detail::_List_node_base::_M_transfer(std::__detail::_List_node_base*, std::__detail::_List_node_base*) () 来自 /usr/lib/x86_64-linux-gnu/libstdc++.so.6 Python Exception 找不到 std::__cxx11::list >::const_iterator::_Node 类型:Python Exception 找不到 std::__cxx11::list >::const_iterator::_Node 类型:Python Exception 找不到 std::__cxx11 类型: :list >::const_iterator::_Node:

4

1 回答 1

0

您的修改在语义上是合理的,但在语法上是错误的。

您使用std::list::insert不正确。您使用的表单需要一个插入位置(在这里,您的代码似乎提供了一个未初始化的迭代器)、一个重复计数(在这里您的代码似乎提供了一个位置偏移量)和一个要插入的值。

使用产生工作代码将语句更改insert为三个语句push_back(但请注意,演示模拟会产生缺失值,因为没有定义位置映射和高度值)。

于 2016-12-28T23:23:56.347 回答