lgsvl / simulator

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

Problem adding NPC vehicle #1336

Open rokon1014 opened 3 years ago

rokon1014 commented 3 years ago

Hello, I am trying to add an NPC vehicle on a simulation started with PythonApi. To be sure, I am running the script "08-create-npc.py" from the quickstart folder and getting an exception thrown. Following is the error message:

Python API Quickstart #8: Creating various NPCs
Traceback (most recent call last):
  File "single_car.py", line 38, in <module>
  sim.add_agent(name, lgsvl.AgentType.NPC, state)      
  File "C:\Users\Rokon\AppData\Roaming\Python\Python37\site-packages\lgsvl\utils.py", line 23, in new_f
    return f(*args, **kwargs)
  File "C:\Users\Rokon\AppData\Roaming\Python\Python37\site-packages\lgsvl\simulator.py", line 151, in add_agent
    uid = self.remote.command("simulator/add_agent", args)
  File "C:\Users\Rokon\AppData\Roaming\Python\Python37\site-packages\lgsvl\remote.py", line 69, in command
    raise Exception(data["error"])
Exception: Object reference not set to an instance of an object

What am I missing here? I am on windows 10 and built the simulator from the source. Any suggestion would be appreciated.

EricBoiseLGSVL commented 3 years ago

Did you add the NPC to the simulator? Is the NPC in the NPCSettings.asset, NPCManager.prefab?

Jiaqing-Cao commented 3 years ago

@EricBoiseLGSVL , I met same problem too, Even using the 2021.1.1 release exe file, the quickstart code shows the above error. Could you be more specific about how to add the NPC to the simulator?

EricBoiseLGSVL commented 3 years ago

Can you be more specific in what the issue is? Are you just trying to run the api quick script with existing npc's or trying to add a new npc?

Jiaqing-Cao commented 3 years ago

@EricBoiseLGSVL I am just trying to run the "10-npc-follow-the-lane.py: quick example with the release exe file on windows 10, it will raise error at line:

npc1 = sim.add_agent("Sedan", lgsvl.AgentType.NPC, state)

Exception: Object reference not set to an instance of an object

EricBoiseLGSVL commented 3 years ago

I have tested on windows both 08 and 10 quick scripts without errors. Do you have the correct EGO vehicle that the quick scripts referenced in your library as well as Borregas Ave environment? Also what is the single_car.py script referenced in the callstack? Also, are you using API Only simulation or pasted in WebUI? I recommend using APIonly and running script in powershell. See here.

Jiaqing-Cao commented 3 years ago

I was using the "python API" mode and running script in powershell before, after changing into "API Only', it works correctly. Thank you. @EricBoiseLGSVL

EricBoiseLGSVL commented 3 years ago

Excellent, seems we have a bug with WebUI PythonAPI mode. We hope to have a fix soon. Thanks for posting the issue