How Do I Load scenes using vrep-api-python ?

Typically: "How do I... ", "How can I... " questions
psychemedia
Posts: 2
Joined: 09 Sep 2017, 01:10

How Do I Load scenes using vrep-api-python ?

Postby psychemedia » 09 Sep 2017, 18:17

I'm new to V-REP, just trying to get to grips with it, and looking to use it from Python (to which end, I put together a VM containing VREP + Jupyter notebooks here: https://github.com/psychemedia/ou-robotics-vrep/tree/master/robotVM).

One thing I can't see to do offhand is open a scene into V-REP. Here's script I guessed at:

Code: Select all

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)


Repost of question on SO: https://stackoverflow.com/questions/461 ... api-python

Online
coppelia
Site Admin
Posts: 6047
Joined: 14 Dec 2012, 00:25

Re: How Do I Load scenes using vrep-api-python ?

Postby coppelia » 10 Sep 2017, 16:44

Hello,

what is the returned res? Also, did you try to specify the absolute path the the file. From what I remember, the path can be absolute, but also relative to the V-REP's installation folder.

Cheers

psychemedia
Posts: 2
Joined: 09 Sep 2017, 01:10

Re: How Do I Load scenes using vrep-api-python ?

Postby psychemedia » 11 Sep 2017, 15:31

Hi

I get response: 8

I am trying to load a file in using an absolute path.

If I try using a relative path to the simulator homedir (os.environ["VREP"]), I get error 32 (client side error).

Online
coppelia
Site Admin
Posts: 6047
Joined: 14 Dec 2012, 00:25

Re: How Do I Load scenes using vrep-api-python ?

Postby coppelia » 12 Sep 2017, 14:59

The first error code means there was an error on the server side (i.e. V-REP), the second error code means there was an error on the client side (i.e. remote API client).

Cheers


Return to “General questions”

Who is online

Users browsing this forum: Baidu [Spider], Bing [Bot], Google [Bot], nehagarg and 20 guests