HARPLab / DReyeVR

VR driving 🚙 + eye tracking 👀 simulator based on CARLA for driving interaction research
https://arxiv.org/abs/2201.01931
MIT License
141 stars 37 forks source link

Setting autopilot for spawned vehicles leads to ego vehicle also being on autopilot #42

Closed shh1v closed 2 years ago

shh1v commented 2 years ago

I have no clue why this is happening. I tried to spawn vehicles on the road and set them on autopilot, however, the ego vehicle is also being set to autopilot. I have no clue why this is happening. To test that there is no problem in my python code, I also tried to run generate_traffic.py, but the same problem is occurring. Here is my repo link: https://github.com/shh1v/DReyeVROFR

GustavoSilvera commented 2 years ago

Can I ask how exactly you are setting the other vehicles' autopilot?

We had a similar issue here that got resolved. This was using scenario runner agents.

In this case you have to make sure to not call SetAutopilot to a vehicle that has "dreyevr" in the blueprint.id

shh1v commented 2 years ago

I am not sure how the ego vehicle will have autopilot mode on since it is not possible from my code. Can you have a look? This is the script I ran. I am not sure if this problem is just occurring for me, and if you would be able to reproduce the error or not. script.py.txt

GustavoSilvera commented 2 years ago

Hi, try replacing this line:

if blueprint.has_attribute("driver_id"):

With this

if blueprint.has_attribute("driver_id") and "dreyevr" not in blueprint.id:

Since when you call world.get_blueprint_library().filter("vehicle.*") this will include the singleton EgoVehicle blueprint (in vehicle.dreyevr.egovehicle since it is still a carla vehicle. But you don't want to set this vehicle's Autopilot so make sure not to with the check above.

shh1v commented 2 years ago

Unfortunately, this still does not solve the problem. The ego vehicle is still running in autonomous mode when the script is run.

shh1v commented 2 years ago

Also, note that the vehicle is running autonomously for some time. Then it stops and then does not move forward. Moreover, I am also not able to control the vehicle once the vehicle stops. So this definitely does not look like setting autopilot is the problem since the autopilot behavior does not continue.

shh1v commented 2 years ago

Update: I removed the dreyevr blueprint when getting all the blueprints to simplify my debug process. So, I did:

blueprints = get_actor_blueprints(world, args.filterv, args.generationv)
blueprints = [blueprint for blueprint in blueprints if "dreyevr" not in blueprint.id]

Your initial argument about setting autopilot for "dreyevr" was accurate and that was the reason why the ego vehicle was running autonomously. But, the solution you sent still didn't stop the code from spawning the ego vehicle (at least, that's what I interpreted from the code). Anyways, my issue is fixed now. I really appreciate your help!

GustavoSilvera commented 2 years ago

Ok, yeah this works to filter out the blueprints. Your solution ensures there is no EgoVehicle bp in the blueprints pool to begin with so it only deals with the non-ego vehicles.

Glad it works!