我使用纹理(4.7)和相扑(0.32)来模拟事故场景中的变道行为。我使用下面的.ini配置成功地创建了这个意外事件;
#Accident vehciles and details
*.node[0].veinsmobility.accidentCount = 1
*.node[0].veinsmobility.accidentStart = 80s
*.node[0].veinsmobility.accidentDuration = 100s
其中Vehicle-0在85s左右开始停止。现在,我想使用traci命令将连接的车辆引导到特定车道(laneIndex);
traciVehicle->changeLane(laneIndex, 0.1);
void TraCICommandInterface::Vehicle::changeLane(uint8_t laneIndex, int32_t duration) {
uint8_t variableId = CMD_CHANGELANE;
uint8_t variableType = TYPE_COMPOUND;
int32_t count = 2;
uint8_t laneIndexT = TYPE_BYTE;
uint8_t timeT = TYPE_INTEGER;
int32_t time = duration*1000; //seconds to milliseconds
uint8_t durationT = TYPE_INTEGER;
TraCIBuffer buf = connection->query(CMD_SET_VEHICLE_VARIABLE, TraCIBuffer() << variableId << nodeId << variableType << count << laneIndexT << laneIndex << durationT << duration );
ASSERT(buf.eof());
}
但是,车辆不会改变车道。我知道相扑模拟的是非事故情况,因此,如果车辆在目标车道上或正在接近,则不会执行车道转换。你知道我怎么才能绕过这种行为吗?此外,如果我使用traci then命令创建随机性,以便为换道打开足够的间隙,则不会执行事故。
任何建议都是值得感谢的。
致以问候。
发布于 2019-02-08 05:50:31
根据Python的TraCI文档,持续时间是车辆在另一条车道上停留的时间,因此它不是执行实际车道转换所需的时间。
如果真是这样,你可能看不到UI中的车道变化,因为你的持续时间是0.1s,纹理中默认的相扑步长也是0.1s。
但是,此功能是在名为Plexe的静脉排成排扩展中实现的。在这里,通过TraCI实现车道的代码如下:
void TraCICommandInterface::Vehicle::changeLane(int lane, int duration)
{
uint8_t commandType = TYPE_COMPOUND;
int nParameters = 2;
uint8_t variableId = CMD_CHANGELANE;
TraCIBuffer buf = traci->connection.query(CMD_SET_VEHICLE_VARIABLE, TraCIBuffer() << variableId << nodeId << commandType << nParameters << static_cast<uint8_t>(TYPE_BYTE) << (uint8_t) lane << static_cast<uint8_t>(TYPE_INTEGER) << duration);
ASSERT(buf.eof());
}
https://stackoverflow.com/questions/54539824
复制相似问题