Finally I got the position of all nodes in the simulation and calculate their distance from a tagged car.
To do this I "translate" the answer of Ahmad Ahsan in the question How to get Coordinates of each vehicle in VEINS? to veins 5.0 in the following way:
void MessageGenerator::getMapping(){
// Get my position on the scenario
veins::Coord myPosition = mobility->getPositionAt(simTime());
EV << myPosition << endl;
// Get all available nodes in simulation
std::map<std::string, cModule*> allNodes = mobility->getManager()->getManagedHosts();
// Iterate through collection and find distance,
std::map<std::string, cModule*>::iterator it;
for(it = allNodes.begin(); it != allNodes.end(); it++)
{
TraCIMobility* auxMobility = TraCIMobilityAccess().get(it->second);
veins::Coord receiverPosition = auxMobility->getPositionAt(simTime());
//returns distance in meters
double dist = myPosition.distance(receiverPosition);
EV << "Distance: " << dist << endl;
}
}
The key change is in the getPositionAt(simTime()) method.
One additional comment, as discussed in this post the method of obtain all vehicles in simulation is a bad practice if this data is used for realistic simulation purposes, because it is rarely possible to obtain all positions in one time step. In my case, I used it for only evaluation purposes.