0

I'm using Veins 4.4, OMNeT++ 5.0 and Sumo 0.25.

I use traci->getCurrentPosition() to get the actual position of the vehicle, i.e., traci->getCurrentPosition().x and traci->getCurrentPosition().y.

I want to estimate the position of the vehicle at a specific time in order to have some positions of the vehicle's trajectory.

So, I use the function traci->getPositionAt(time) and I set simtime_t time = simTime()+60 to get the position of the vehicle after 60 s. But I get the current position!

What is the difference between getCurrentPosition() and getPositionAt(time)?

How can I get some position of the vehicle's trajectory?

user4786271
  • 1,555
  • 13
  • 18

1 Answers1

1

Below you have all the implementations of the functions you have mentioned. As you can see in the first case the comment for getPositionAt() says:

It is intended to be passed simTime() as actualTime and returns the actual position.

Seems like these functions do not cover your case at all.


You can see how these functions work at Move.h. The comments are detailed enough too

/**
 * @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() is also implemented at TraCIMobility.h as:

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

and getCurrentPosition() is implemented at BaseMobility.h as:

/** @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();
}
user4786271
  • 1,555
  • 13
  • 18
  • thank you very much for your clear response. I know the vehicle trajectory as follow: listlist=traciVehicle->getPlannedRoadIds(); string lanedeparture,lanearrival; lanedeparture=list.front(); lanearrival=list.back(); But I still can’t get the position of the vehicle's trajectory for many timesteps like in the FCD file http://sumo.dlr.de/wiki/Simulation/Output/FCDOutput – user3531378 Apr 06 '17 at 17:59
  • Your comment seems to be a different question. Kindly ask this in a separate topic if you can – Christoph Sommer Apr 07 '17 at 13:12