HARPLab / DReyeVR

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

'Actor' object has no attribute 'set_autopilot' #101

Closed whyhowie closed 1 year ago

whyhowie commented 1 year ago

Greetings,

I was trying to run the python scripts in the example folder (e.g. DreyeVR_AI.py). However, it looks like the set_autopilot attribute was missing for the vehicle created. Any possible reasons for this issue? Thanks!

(Currently I'm running the server without a VR headset and a steering wheel connected. Could this be related?)

Traceback (most recent call last): File "DReyeVR_AI.py", line 152, in main() File "DReyeVR_AI.py", line 131, in main ego_vehicle = set_DReyeVR_autopilot(world, traffic_manager) File "DReyeVR_AI.py", line 32, in set_DReyeVR_autopilot DReyeVR_vehicle.set_autopilot(True, traffic_manager.get_port()) AttributeError: 'Actor' object has no attribute 'set_autopilot'

GustavoSilvera commented 1 year ago

Interesting. You shouldn't need the VR headset nor steering wheel for this functionality to work.

According to the documentation all vehicles should have a set_autopilot, so what I believe is happening is that the find_ego_vehicle is returning a carla.libcarla.Actor rather than a carla.libcarla.Vehicle class.

Can you verify you are on the latest version of DReyeVR and print the DReyeVR_vehicle after obtaining this reference from find_ego_vehicle()?

Also, just as a sanity check, did you rebuild the PythonAPI after installing DReyeVR to Carla?

whyhowie commented 1 year ago

Thanks for your reply. Yes, it's quite odd... I just did make clean, and then make PythonAPI && make launch. However, I think the type of the ego_vehicle found is still Actor.

Here's what I printed out for the vehicle in set_DReyeVR_autopilot():

Actor(id=86, type=harplab.dreyevr_vehicle.model3) <class 'carla.libcarla.Actor'>

I'm currently running DReyeVR 0.1.2 and carla 0.9.13. The Unreal Engine server is up and running despite missing the steering wheel and the vr headset. image image

Thanks for your help!

GustavoSilvera commented 1 year ago

Interesting, this may be a bug so I can look into it.

First, can you check that your LibCarla/source/carla/client/detail/ActorFactory.cpp (used to communicate with PythonAPI) contains these lines:

    } else if (StringUtil::StartsWith(description.description.id, "harplab.dreyevr_vehicle.")) {
      return MakeActorImpl<Vehicle>(std::move(init), gc); // for DReyeVR vehicles!
    } else if (StringUtil::StartsWith(description.description.id, "harplab.dreyevr_sensor.")) {
      return MakeActorImpl<ServerSideSensor>(std::move(init), gc); // for DReyeVR sensors!

And for debugging purposes, can you add print statements that look like the following:

    } else if (description.HasAStream()) {
      return MakeActorImpl<ServerSideSensor>(std::move(init), gc);
    } else if (StringUtil::StartsWith(description.description.id, "vehicle.")) {
      return MakeActorImpl<Vehicle>(std::move(init), gc);
    } else if (StringUtil::StartsWith(description.description.id, "harplab.dreyevr_vehicle.")) {
      std::cout << "making VEHICLE with id: " << description.description.id << std::endl;
      return MakeActorImpl<Vehicle>(std::move(init), gc); // for DReyeVR vehicles!
    } else if (StringUtil::StartsWith(description.description.id, "harplab.dreyevr_sensor.")) {
      return MakeActorImpl<ServerSideSensor>(std::move(init), gc); // for DReyeVR sensors!
    } else if (StringUtil::StartsWith(description.description.id, "walker.")) {
      return MakeActorImpl<Walker>(std::move(init), gc);
    } else if (StringUtil::StartsWith(description.description.id, "traffic.traffic_light")) {
      return MakeActorImpl<TrafficLight>(std::move(init), gc);
    } else if (StringUtil::StartsWith(description.description.id, "traffic.")) {
      return MakeActorImpl<TrafficSign>(std::move(init), gc);
    } else if (description.description.id == "controller.ai.walker") {
      return MakeActorImpl<WalkerAIController>(std::move(init), gc);
    }
    std::cout << "making ACTOR with id: " << description.description.id << std::endl;
    return MakeActorImpl<Actor>(std::move(init), gc);

Then rebuild PythonAPI make PythonAPI and reinstall the .whl file as described in the documentation. You should now get some prints when the actor gets spawned and this can be indicative of which code path it decided to take.

whyhowie commented 1 year ago

Hi Gustavo,

Thanks! I --force-reinstall 'ed the .whl file and it seems that the error is gone. I might have never used the force reinstall option before. Hopefully the following output looks reasonable: image

However, not sure if it is relevant but I get a different error in schematic_mode.py, which involves number_of_wheels: image

GustavoSilvera commented 1 year ago

Yup, this looks correct now. (you can delete the std::cout prints and rebuild the PythonAPI if you want).

The number_of_wheels bug is a known issue that had been discussed here #100