setObjectPosition function doesn't work when called by UI

Typically: "How do I... ", "How can I... " questions
Post Reply
Thibs
Posts: 3
Joined: 08 Jan 2025, 10:52

setObjectPosition function doesn't work when called by UI

Post by Thibs »

Hello,

I'm facing an issue trying to use the setObjectPosition function with an UI.
I have a scene with a robotic arm, the base of the arm hierarchy is a non-dynamic cuboid, so if I'm changing the cuboid position and/or orientation in the scene all the arm is moved with its base.
Now, if I'm changing the position in a script, in the "sysCall_init" function using sim.setObjectPosition(hande of my cuboid, new position) it's working just fine.
But finally, if I'm creating a UI with a combobox item listing different dummy position, with a callback function on change setting the cuboid position to the one of the selected dummy, only the cuboid position is updated, the rest of the robot arm does not move, which doesn't make sense to me at all.
Am I missing something or is this some kind of bug ?

Thanks,

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

Re: setObjectPosition function doesn't work when called by UI

Post by coppelia »

Hello,

if you can share your scene it would be a bit easier to understand. What is probably happening is following: when you instantaneously move a dynamic object (or dynamic tree of objects) you are basically applying infinite constraints/forces, which is impossible in real life (i.e. teleportation). Things will/can break down in the physics engine. If you want to do that you'll need to make sure to reset all related dynamically enabled objects with sim.resetDynamicObject (at the same time, i.e. in the exact same simulation step). Have a look at the demo scene scenes/teleportDynamicModel.ttt that shows how to correctly handle these kind of situations.

btw why it is working when you do this in the init section is that at that time the physics engine hasn't yet been initialized (hasn't yet created its own representation of the world).

Cheers

Thibs
Posts: 3
Joined: 08 Jan 2025, 10:52

Re: setObjectPosition function doesn't work when called by UI

Post by Thibs »

Hello,

Ok, I totally understand why it wasn't working once the physic engine was on after initialisation, and I've been able to solve my problem thanks to the scene example you provided,

Thanks a lot,
Have a good day,

Post Reply