静脉中getCurrentPosition()和getPositionAt(时间)之间的差异

时间:2017-04-06 13:50:57

标签: omnet++ veins sumo

我使用Veins 4.4,OMNeT ++ 5.0和Sumo 0.25。

我使用traci->getCurrentPosition()来获取车辆的实际位置,即traci->getCurrentPosition().xtraci->getCurrentPosition().y

我想估计车辆在特定时间的位置,以便获得车辆轨迹的某些位置。

因此,我使用函数traci->getPositionAt(time)并设置simtime_t time = simTime()+60以获取60 s之后车辆的位置。但我得到了现在的位置!

getCurrentPosition()getPositionAt(time)之间的区别是什么?

如何获得车辆轨迹的某些位置?

1 个答案:

答案 0 :(得分:1)

下面是您提到的所有功能的实现。正如您在第一种情况中所看到的,getPositionAt()的评论说:

  

它旨在作为simTime()传递actualTime并返回   实际位置。

似乎这些功能根本不包括你的情况。

您可以在Move.h查看这些功能的工作原理。评论也很详细

/**
 * @brief Returns the position of the Move (Host) at the specified point in time.
 * It is intended to be passed simTime() as actualTime and returns the actual position.
 *
 * Assumes that direction represents a normalized vector (length equals 1.0).
 * Further this function does not check whether the given time point is before
 * the startTime of the actual move pattern. So in this case one might obtain
 * an unintended result.
 *
 */
virtual Coord getPositionAt(simtime_t_cref actualTime = simTime()) const
{
    // if speed is very close to 0.0, the host is practically standing still
    if ( FWMath::close(speed, 0.0) ) return startPos;

    // otherwise: actualPos = startPos + ( direction * v * t )
    return startPos + ( direction * speed * SIMTIME_DBL(actualTime - startTime) );
}
virtual const Coord& getCurrentPosition() const
{
    if (lastPos.z != DBL_MAX)
        return lastPos;
    return startPos;
}

getPositionAt()也在TraCIMobility.h实施为:

    virtual Coord getPositionAt(const simtime_t& t) const {
        return move.getPositionAt(t) ;
    }

getCurrentPosition()BaseMobility.h实施为:

/** @brief Returns the current position at the current simulation time. */
virtual Coord getCurrentPosition(/*simtime_t_cref stWhen = simTime()*/) const {
    //return move.getPositionAt(stWhen);
    return move.getStartPos();
}