simxGetObjectPosition problem

Typically: "How do I... ", "How can I... " questions
Post Reply
lyz
Posts: 18
Joined: 07 Mar 2019, 07:34

simxGetObjectPosition problem

Post by lyz » 08 Apr 2019, 13:45

Hello,
I am working on a case and I want to use simxGetObjectPosition to get object position. This is my python code:

Code: Select all

    clientID = vrep.simxStart('127.0.0.1', 19997, True, True, 5000, 5)  # Connect to V-REP
    if clientID!=-1:
        # open sync mode
        vrep.simxSynchronous(clientID, True)
        # start simulation
        vrep.simxStartSimulation(clientID, vrep.simx_opmode_oneshot)
        _, baseHandle = vrep.simxGetObjectHandle(clientID, 'Vehicle', vrep.simx_opmode_blocking)

        _, jpos = vrep.simxGetObjectPosition(clientID, baseHandle, -1, vrep.simx_opmode_streaming)
        print ('jpos = ' + str(jpos))

But the output values are all zero. In the V-REP Forum, I find it is operation mode problem. So I try to modify the vrep.simx_opmode_streaming to vrep.simx_opmode_blocking. And it is work. In this webhttp://www.coppeliarobotics.com/helpFil ... barMessage, recommended operation modes for this function are simx_opmode_streaming (the first call) and simx_opmode_buffer (the following calls). Meanwhile, I have already seen the page viewtopic.php?f=9&t=7742&p=30182&hilit= ... ion#p30182, but I don't seem to understand. So Can you give me some advice. which mode can I use?

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

Re: simxGetObjectPosition problem

Post by coppelia » 09 Apr 2019, 08:09

Hello,

you need to carefully read this and that section. Have also a look how streaming is done in the simpleTest.cpp example.

Cheers

Post Reply