首页 > 解决方案 > 使用supervisor时如何获取设备?

问题描述

在我的 webots 环境中有一个传送带和一个 ur10e 机器人,我将 ur10e 的控制器设置为extern,我想获取传送带上的孩子 kinect 图像。 ur10e

输送带

我的python代码如下:

from controller import Camera
from controller import PositionSensor
from controller import Supervisor

robot = Supervisor()

# Get the time step of the current world.
timestep = int(robot.getBasicTimeStep())

conveyor_belt = robot.getFromDef("CONVEYOR_BELT")
assert(conveyor_belt != None)
conveyor_kinectcolor = conveyor_belt.getDevice("kinect color")
conveyor_kinectcolor.enable(int(1000/24))
conveyor_kinectcolor.getImage()

但我收到错误:

   conveyor_kinectcolor = conveyor_belt.getDevice("kinect color")
  File "/usr/local/webots/lib/controller/python27/controller.py", line 1756, in <lambda>
    __getattr__ = lambda self, name: _swig_getattr(self, Node, name)
  File "/usr/local/webots/lib/controller/python27/controller.py", line 96, in _swig_getattr
    raise AttributeError("'%s' object has no attribute '%s'" % (class_type.__name__, name))
AttributeError: 'Node' object has no attribute 'getDevice'

标签: webots

解决方案


您无法在另一个机器人中获取设备。

或者,您可以为另一个机器人创建自定义控制器,并使用发射器/接收器与主管交换命令。


推荐阅读