获取机器人引用时出现 Webots 属性错误

问题描述

我想重现以下教程,但是当我尝试获取机器人引用时,总是出现此错误

"AttributeError: 'CartpoleRobot' object has no attribute 'getSelf'"

我重建了本教程:https://github.com/aidudezzz/deepbots-tutorials/blob/master/robotSupervisorSchemeTutorial/README.md

在其他控制器中,当我尝试获取机器人引用时,我收到类似的错误消息。我认为错误在于机器人模拟和控制器之间的通信。 我曾尝试导入主管并通过 supervisor.get 获取功能。但是这里出现了另一个错误"Only one instance of the Robot class should be created"

但是,我对网络机器人和机器人/信息学总体上还是个新手。任何帮助将不胜感激!

回溯的整个错误

INFO: robotSupervisorController: Starting controller: python.exe -u robotSupervisorController.py
Traceback (most recent call last):
  File "D:\Webots Projekte\controllers\robotSupervisorController\robotSupervisorController.py",line 88,in <module>
    env = CartpoleRobot()
  File "D:\Webots Projekte\controllers\robotSupervisorController\robotSupervisorController.py",line 16,in __init__
    self.robot = self.getSelf()  # Grab the robot reference from the supervisor to access varIoUs robot methods
AttributeError: 'CartpoleRobot' object has no attribute 'getSelf'
WARNING: 'robotSupervisorController' Controller beendet mit Status: 1 

代码与教程中显示的相同。 产生错误的简短部分:

self.robot = self.getSelf()  # Grab the robot reference from the supervisor to access varIoUs robot methods
self.positionSensor = self.getDevice("polePosSensor")
self.positionSensor.enable(self.timestep)

如果我注释掉第一个,下一行返回类似的错误

每个答案都非常感谢!谢谢!

解决方法

我遇到了同样的问题。我使用 deepbots-0.1.2 和 webotsR2021a。

尝试卸载 deepbots,然后使用以下命令安装它们:

pip install -i https://test.pypi.org/simple/ deepbots