解决Carla同步模式下Runtime Error的问题(tick hangs)

解决Carla同步模式下Runtime Error的问题(RuntimeError: time-out of 10000ms while waiting for the simulator, make sure the simulator is ready and connected to localhost:2000)

问题描述

Carla仿真平台下,使用同步模式更新服务器进行渲染,在运行一段时间后可能会在world.tick( )处报错无法连接simulator,出现Runtime Error导致程序终止。
该错误出现版本从8到9,从Ubuntu到Windows,是普遍且严重的Bug。
Synchronous mode
Traceback (most recent call last):
File “tick_hang.py”, line 17, in
world.tick()
RuntimeError: time-out of 10000ms while waiting for the simulator, make sure the simulator is ready and connected to localhost:2000
更多类似问题可见GitHub issue 链接
Synchronous mode - tick hangs #2809

出现该问题的源头

Carla采用的是客户端-服务器架构,client发送tick请求更新,并接收server的渲染成功的信号。
当client接收server的信号失败后,将会等待一段时间,最终报错Runtime Error,这种情况大多数是因为Server的返回信号丢失,而并不是没有渲染,client未接收到返回信号会默认服务器已不存在,从而产生该错误。

解决方案

参考上述issue链接,会发现并官方没有完美的解决的方案,我的思路是,使用python的异常处理语句忽略掉该异常。
给每一次的tick( )语句,添加try语句进行异常处理。

try:
		self.world.tick( )
expect:
		print("tick 丢失,重新发送")
		time.sleep(2)
		self.world.tick( )

若要保证你的代码不会停止,或许再加一层While True循环也可以

While True:
	try:
					self.world.tick()
					break
	expect:
					print("tick 丢失,重新发送")
					time.sleep(2)

在我的情形下,该问题得到了解决!

  • 5
    点赞
  • 20
    收藏
    觉得还不错? 一键收藏
  • 5
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值