cjy1992 / gym-carla

An OpenAI gym wrapper for CARLA simulator
MIT License
531 stars 111 forks source link

WARNING:sensor object went out of scope but the sensor is still alive in the simulation:Actor 42311(sensor.camera.rgb) #12

Open qiaoxianfeng opened 4 years ago

qiaoxianfeng commented 4 years ago

When I execute the environment, it appears: WARNING:sensor object went out of scope but the sensor is still alive in the simulation:Actor 42311(sensor.camera.rgb) How to solve this situation?

cjy1992 commented 4 years ago

Hello, You can just ignore this warning, it does not influence anything yet.

qiaoxianfeng commented 4 years ago

您好, 您可以忽略此警告,它不会影响任何内容。

When I was running on the designated route, I was unable to generate vehicles, and I was stuck in the loop all the time. Is there any way to solve it?

cjy1992 commented 4 years ago

Have you changed any part of the code? And are you running the test.py when you get stuck, or are you running something else?

qiaoxianfeng commented 4 years ago

您是否更改了代码的任何部分?当您卡住时是在运行test.py还是在运行其他内容?

I ran the program that I originally downloaded from github and I still can't execute it. It has been stuck in a loop of line 198 in the carla_env.py file.Unable to successfully create a car.Can you run successfully before?

cjy1992 commented 4 years ago

That's weird, I can always run it successfully. Although it might retry to spawn the ego vehicle for several times if its current position is occupied by other vehicles, there is a maximum spawn time and will only last for seconds, which is very rare. At the very most of time, it will be spawned successfully immediately. Maybe it's because of the slow computation time of your computer platform? Then that will look like stuck for a long time if it keeps trying spawn the vehicle for several times.

crazyleeth commented 3 years ago

Hello,I got the same problem.It does influence something.It seems that stimulator can't destroy some actors,which makes the actor_id list grow every episode.Every time it is added with 104 id(100wehicle+ego_vehicle+three sensors apparently) .when it grows to 70000 my program will be shut down. looking forward for your help sincerely.

lmc19970711 commented 2 years ago

Hello,I got the same problem.It does influence something.It seems that stimulator can't destroy some actors,which makes the actor_id list grow every episode.Every time it is added with 104 id(100wehicle+ego_vehicle+three sensors apparently) .when it grows to 70000 my program will be shut down. looking forward for your help sincerely.

hello, I got the same problem. How did you solve it?

atengwang99 commented 2 years ago

Hello,I got the same problem.It does influence something.It seems that stimulator can't destroy some actors,which makes the actor_id list grow every episode.Every time it is added with 104 id(100wehicle+ego_vehicle+three sensors apparently) .when it grows to 70000 my program will be shut down. looking forward for your help sincerely.

hello, I got the same problem. How did you solve it?

hello, I meet the same problem. Have you solved it?

Morphlng commented 1 year ago

I've solved this problem by calling sensor.stop() before entering _clear_all_actors function.

To elaborate, this is the original code:

https://github.com/cjy1992/gym-carla/blob/c01ae77d2729c618504595474b744a1641ec471f/gym_carla/envs/carla_env.py#L150-L157

Change it as below:

def reset(self): 
   # Clear sensor objects
   if self.collision_sensor is not None and self.collision_sensor.is_listening:
      self.collision_sensor.stop()
      self.lidar_sensor.stop()
      self.camera_sensor.stop()

   self.collision_sensor = None 
   self.lidar_sensor = None 
   self.camera_sensor = None 

   # Delete sensors, vehicles and walkers 
   self._clear_all_actors(['sensor.other.collision', 'sensor.lidar.ray_cast', 'sensor.camera.rgb', 'vehicle.*', 'controller.ai.walker', 'walker.*']) 

However, you also have to modify the __init__ function, otherwise accessing self.collision_sensor on the first call of env.reset() will be illegal:

def __init__(self, params):
   # add following lines
   self.collision_sensor = None 
   self.lidar_sensor = None 
   self.camera_sensor = None 

   # keep the rest...