gym-carla icon indicating copy to clipboard operation
gym-carla copied to clipboard

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

Open qiaoxianfeng opened this issue 4 years ago • 9 comments

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?

qiaoxianfeng avatar Jun 23 '20 02:06 qiaoxianfeng

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

cjy1992 avatar Jun 24 '20 03:06 cjy1992

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

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?

qiaoxianfeng avatar Jun 24 '20 03:06 qiaoxianfeng

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?

cjy1992 avatar Jun 24 '20 20:06 cjy1992

您是否更改了代码的任何部分?当您卡住时是在运行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?

qiaoxianfeng avatar Jun 26 '20 02:06 qiaoxianfeng

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.

cjy1992 avatar Jun 26 '20 20:06 cjy1992

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.

crazyleeth avatar Aug 24 '21 02:08 crazyleeth

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?

lmc19970711 avatar Dec 12 '21 03:12 lmc19970711

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?

atengwang99 avatar May 09 '22 14:05 atengwang99

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...

Morphlng avatar Nov 01 '22 06:11 Morphlng