lgsvl / simulator

A ROS/ROS2 Multi-robot Simulator for Autonomous Vehicles
Other
2.27k stars 780 forks source link

How to find specific controllable with Python API #1928

Open krtt opened 2 years ago

krtt commented 2 years ago

Sim v2021.3 (Linux)

How to find one specific traffic light on a map (we have ~70 in total) if Python API only has the following information (documentation):

For a controllable object of interest, you can get following information:

signal = controllables[0]
print("Type:", signal.type)
print("Transform:", signal.transform)
print("Current state:", signal.current_state)
print("Valid actions:", signal.valid_actions)

But if I want to see in VSE where is the traffic light of my interest, then there is only this info per controllable:

{"uid":"310e0042-66ad-4f60-8029-66e6b54d6e47","policy":[],"spawned":false}

How to connect what is what if one has only transform and other only uid? Unity did not help to connect them either. How do you do it?

EricBoiseLGSVL commented 2 years ago

We connect them by noting the position of the map signal controllable. We compare the transform data.

From python api quick scripts 27-control-trafficlights.py

# # Get a list of controllable objects
controllables = sim.get_controllables("signal")
print("\n# List of controllable objects in {} scene:".format(lgsvl.wise.DefaultAssets.map_borregasave))
for c in controllables:
    print(c)

signal = sim.get_controllable(lgsvl.Vector(15.5, 4.7, -23.9), "signal")
print("\n# Signal of interest:")
print(signal)

Having 70+ map signals in a single map worries me that your map is too large. It's best to take map sections and test very specific use case test for small areas instead of a large map. You can have issues with memory with a large map.