Move multiple joints at one

Typically: "How do I... ", "How can I... " questions
Post Reply
shreyas7738
Posts: 19
Joined: 30 Dec 2020, 15:32

Move multiple joints at one

Post by shreyas7738 »

How can I move two revolute joints simultaneously?Lua follows a line-by-line approach and I was just wondering if there is a way to move two joints simultaneously.

fferri
Posts: 1193
Joined: 09 Sep 2013, 19:28

Re: Move multiple joints at one

Post by fferri »

Functions such as sim.setJointPosition or sim.setJointTargetPosition return immediately, so if you sequentially set position of joint 1 then position of joint 2, those will move simultaneously (if inside a threaded script, you need to momentarily disable thread switching to make sure simulation doesn't advance in-between the two calls)

shreyas7738
Posts: 19
Joined: 30 Dec 2020, 15:32

Re: Move multiple joints at one

Post by shreyas7738 »

How do I disable thread switching momentarily in remote API?

fferri
Posts: 1193
Joined: 09 Sep 2013, 19:28

Re: Move multiple joints at one

Post by fferri »

You can disable thread switching in embedded child scripts.

In case of remote API, you probably want to use synchronous operation.

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

Re: Move multiple joints at one

Post by coppelia »

to disable and enable again thread switching in a threaded script, do something like:

Code: Select all

-- temporarily disable thread switching:
fl=sim.setThreadSwitchAllowed(false)

-- enable thread switching again:
sim.setThreadSwitchAllowed(fl)
Cheers

Post Reply