【问题标题】:Difference between getCurrentPosition() and getPositionAt(time) in VeinsVeins 中 getCurrentPosition() 和 getPositionAt(time) 的区别
【发布时间】:2017-04-06 13:50:56
【问题描述】:

我正在使用 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) 有什么区别?

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

【问题讨论】:

    标签: omnet++ veins sumo


    【解决方案1】:

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

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

    似乎这些功能根本无法涵盖您的情况。


    您可以在Move.h 了解这些功能的工作原理。 cmets也够详细了

    /**
     * @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();
    }
    

    【讨论】:

    • 非常感谢您的明确答复。我知道车辆轨迹如下: listlist=traciVehicle->getPlannedRoadIds();字符串lanedeparture,lanearrival; lanedeparture=list.front(); lanearrival=list.back();但是在 FCD 文件sumo.dlr.de/wiki/Simulation/Output/FCDOutput 中,我仍然无法获得许多时间步长的车辆轨迹位置
    • 您的评论似乎是一个不同的问题。如果可以的话,请在单独的主题中提出这个问题
    猜你喜欢
    • 1970-01-01
    • 2013-01-17
    • 1970-01-01
    • 2015-07-11
    • 1970-01-01
    • 1970-01-01
    • 2023-01-10
    • 2012-08-15
    • 1970-01-01
    相关资源
    最近更新 更多