Issue setting new Pioneer object position calling server function

Typically: "How do I... ", "How can I... " questions
Post Reply
lostgoatonhill
Posts: 1
Joined: 11 Oct 2019, 22:38

Issue setting new Pioneer object position calling server function

Post by lostgoatonhill » 29 Oct 2019, 23:26

Hi,

V-REP Edu using Python (legacy API). After many challenges attempting to set new object position for Pioneer P3DX (robot explodes, wheels get left behind), and pouring over available similar forum posts, I took a new apporach, as suggest by Coppelia.

I looked at the example server-side script remoteApiCommandServer, and attached this as non-threaded child script to dummy object in simple scene. I proved call from client side Python to this server script with the displayText function - all good.

I then within my Python script called executeCode_function with the following:

code = "simSetObjectPosition(" + str(self.robot.handle) + ", -1, {-1.2445,-5.3750,0.1388})"

It too moves the Pioneer body but leaves the wheels behind.

If I put the same command in the init() function of the serverside remoteApiCommandServer, the setting of new object position for the robot works perfectly:

function sysCall_init()
simRemoteApi.start(19999)
handle=sim.getObjectHandle('Pioneer_p3dx')
sim.setObjectPosition(handle, -1, {-1.2445, -5.3750, 0.1388})
end


Grateful for help as pulling my hair out for hours on this, and now seem so very close!

Thanks ever so much.

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

Re: Issue setting new Pioneer object position calling server function

Post by coppelia » 01 Nov 2019, 11:56

Hello,

the problem is that you are trying to instantaneously move a dynamically enabled model. It is similar to if you would instantaneously move a car by a few meters: the body might move, but the wheels and all the rest will break because of the inertia.

So what you need to do is following:
This is telling the physics engine to remove all those objects from its dynamic representation.

It is important that above setps are executed inside the same simulation step. This means that if you are doing this from a threaded child script, you'll have to enclose above code inside of:

Code: Select all

sim.setThreadAutomaticSwitch(false)
... (above code)
sim.setThreadAutomaticSwitch(true)
Cheers

Post Reply