eclipse-sumo / sumo

Eclipse SUMO is an open source, highly portable, microscopic and continuous traffic simulation package designed to handle large networks. It allows for intermodal simulation including pedestrians and comes with a large set of tools for scenario creation.
https://eclipse.dev/sumo
Eclipse Public License 2.0
2.56k stars 1.43k forks source link

Get Individual Rail Carriage Locations via TraCI #7049

Open patmalcolm91 opened 4 years ago

patmalcolm91 commented 4 years ago

Hello,

I'm trying to extract the coordinates of individual carriages of a rail vehicle using TraCI, or at the very least, be able to estimate them from the shape of the train as a whole. However, looking through the API documentation, I can only see how to get the vehicle position as a single point, even though it appears the entire train shape is calculated internally somewhere (the display in "real world" mode shows rail vehicles correctly, for example). Is there currently any way to get coordinates along a rail vehicle (particularly one spanning multiple edges or going around curves) using TraCI?

Thanks in advance

namdre commented 4 years ago

Right, SUMO does not simulation individual carriages. What you are seeing is basically a graphical hack to make the train look nice. sumo-gui uses the geometry of the track and the length of the rail vehicle (along with parameters for carriageLength and carriageGap) to draw the carriages onto the tracks.

It could make sense to return the "shape" of the train (i.e. the list front and back position of the locomotive and carriages) in a new traci position traci.vehicle.getShape(vehID)

Right now you could replicate the sumo-gui computations by retrieving the shape of the current train edge an all the predecessor edges within the length of the train.

patmalcolm91 commented 4 years ago

Thanks for the fast response, @namdre. It would be great to have such an API function in a future release. In the meantime, I will follow your suggestion of taking the predecessor edges from the vehicle route. Thanks again!

namdre commented 8 months ago

work on rail car shape API has improved in the context of JuPedSim handling of train doors (#14334)