1

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.

Bot_potato
  • 25
  • 2

1 Answers1

2

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.

Aerodynamic
  • 782
  • 5
  • 19
  • The code in the link you've shared is "WbNodeRef robot_node = wb_supervisor_node_get_from_def("MY_ROBOT");". I have tried its equivalent in python as "node = driver.getFromDef("SUMO INTERFACE")". I looked for the DEF name for sumo interface in the highway-overtake.wbt but couldn't find it so I just gave "SUMO INTERFACE" a shot. Here's more information about the driver object: it is declared as "driver = Car()" and for this I have imported "from vehicle import Car". – Bot_potato Feb 11 '20 at 06:03
  • I'm guessing the DEF name that I should be passing is that of the Lincoln car but since I'm actually interested in the data of SumoSupervisor/Sumo Interface it didn't make sense to get the object handle of the car instead of sumo interface. I'm actually interested in tracking the sumo cars in real time with their speed, acceleration, position etc. Can you please tell me how exactly I must call the function to get the handle? Thanks in advance! – Bot_potato Feb 11 '20 at 06:03
  • @Bot_potato Please mark this as completed, as I think the initial question was answered, and If you need help with parcing nodes, add a new question for that issue instead to allow others to help you as well. – Aerodynamic Feb 11 '20 at 16:26
  • Still unclear as to how to use the supervisor function but I'll mark this as complete. :/ – Bot_potato Feb 14 '20 at 05:13