webots - 使用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'
解决方案
您无法在另一个机器人中获取设备。
或者,您可以为另一个机器人创建自定义控制器,并使用发射器/接收器与主管交换命令。
推荐阅读
- php - 表未使用异步正确呈现 | PHP | API | 拉拉维尔
- android - Kotlin:为什么要转换 Int.toString?
- java - 如何为 ArrayList 实现归并排序?
- podman - Mac上的Podman错误:连接:没有这样的文件或目录
- javascript - 当我在 ts 代码中出现错误时,如何使用 tsconfig 文件强制 TypeScript 不编译为 JS?
- spring - 通过 spring 批处理监控当前正在运行的进程,并通知是否达到油门限制
- python - 从 python 3.x 中的外部文件应用框架?
- flutter - 如何检测图像上的屏幕?
- html - 为什么我的指向外部 CSS 的 HTML 链接不起作用?
- java - 如何在 for 循环测试中使用 UI 验证 Excel 中的匹配值并在范围报告中显示结果