'How to access the SUMO vehicles from highway_overtake.py in Webots?

I'm modifying the highway_overtake.py controller to be able to track the position and speed of the neighboring SUMO vehicles (the ones that are highlighted in transparent colored boxes). How can I access the SUMO vehicle information that is in close proximity of the Lincoln car? I want to get the position, acceleration, speed etc. of the SUMO cars highlighted near the Lincoln car. Here is what I have tried so far:

  • I have changed the 'supervisor' field to TRUE in the highway overtake world for the lincoln MKZ vehicle node.
  • I imported the Supervisor from controller in my higway_overtake.py controller file.
  • I tried calling the traci functions getIDList() and getPosition() but it gives an error that says controller doesn't have any such attributes.

I believe this information can be retrieved from the SumoSupervisor.py file which is the controller file for Sumo Interface. But I do not know how to access this file in my highway_overtake.py script either.

Any information that can help me solve this will be very helpful! Thanks in advance.



Solution 1:[1]

If it's for debugging, you could use this supervisor function to get the positon of all cars in the simulation, and then figure out which one is closed to your target car (which ID you know). https://cyberbotics.com/doc/guide/supervisor-programming#tracking-the-position-of-robots

Otherwise, if you want to use only functions that are available to actual machines, try the emitter/receiver devices. You might be able to use signal strength as a proxi for proximity, or, if there's a synced tick, use signal reception time as a proximity detector.

Or use GPS modules (with an high enough resolution) on each car and compare the coordinates.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1