0

我正在使用 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)

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

4

1 回答 1

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();
}
于 2017-04-06T16:42:16.547 回答