首页 > 解决方案 > 使用 TraCIcommandInterface 在 Veins 中添加函数

问题描述

我想添加一个getFollowSpeed在 Veins 中调用的函数,但出现错误。TraCIcommandInterface.cc我已经在和中定义了函数名TraCIcommandInterface.h

我还在TraCIconstant.h.

请参阅附件中的代码TraCIcommandInterface.cc

double TraCICommandInterface::Vehicle::getFollowSpeed(double speed, double gap, double leaderSpeed, double leaderMaxDecel, const std::string leaderID)
{

    uint8_t variableId = VAR_FOLLOW_SPEED;
    uint8_t variableType = TYPE_COMPOUND;
    int32_t count = 5;
    uint8_t speedType = TYPE_DOUBLE;
    uint8_t gapType = TYPE_DOUBLE;
    uint8_t leaderSpeedType = TYPE_DOUBLE;
    uint8_t leaderMaxDecelType = TYPE_DOUBLE;
    uint8_t LeaderIdType = TYPE_STRING;

    TraCIBuffer request;
    request << variableId << nodeId << variableType << speedType << speed << gapType << gap <<
            leaderSpeedType << leaderSpeed << leaderMaxDecelType << leaderMaxDecel << LeaderIdType << leaderID ;


    TraCIBuffer response = connection->query(CMD_GET_VEHICLE_VARIABLE,request);

    ASSERT(buf.eof());

}

这是我在通过静脉运行 Omnet++ 和 Sumo 时收到的错误消息。

TraCI 服务器报告错误执行命令 0xa4(“获取车辆变量:不支持的变量 0x1c 指定”)。-- 在模块 (TraCIDemo11p) RSUExampleScenario.node[0].appl (id=14) 中,在 t=1s,事件 #2

我正在使用 Veins 4.7.1 和 Omnet 5.3 和 sumo 0.32.0。

谁能帮我这个?为什么我收到此错误。我已经定义了函数。对此我将不胜感激。

提前致谢。

标签: omnet++veinssumo

解决方案


VAR_FOLLOW_SPEED在 SUMO 0.32.0 中不可用。功能getFollowSpeed最近添加到当前 GIT 版本的 SUMO。请参阅SUMO 更新日志


推荐阅读