如何使用vrepapipython将场景加载到VREP中?

2024-09-27 21:35:09 发布

您现在位置:Python中文网/ 问答频道 /正文

使用vrep-api-pythonPython包装器来处理V-REP robot simulator时,我正在尝试(但失败了)使用包装的^{}函数在模拟器中加载一个场景,其中包含一个服务器端文件:

from pyrep import VRep
from pyrep.vrep.vrep import simxLoadScene
from pyrep.vrep import vrep as v
from pyrep.common import ReturnCommandError

class sceneloader:

    def __init__(self, api: VRep):
        self._api = api
        self._def_op_mode = v.simx_opmode_oneshot_wait
        self.id = api._id

    def loadScene(self,path):
        clientID=self.id
        res = simxLoadScene(clientID, path, 0xFF, self._def_op_mode)
        print(res)

        if res != v.simx_return_ok:
            raise ReturnCommandError(res)

scene='/vagrant/scenes/Pioneer.ttt'
with VRep.connect("127.0.0.1", 19997) as api:
    r=sceneloader(api)
    r.loadScene(scene)

但它只是抛出一个服务器错误?在


Tags: fromimportselfapiiddefasres

热门问题