Page 1 of 1

Proxy option from sim.getObject does not work

Posted: 01 Dec 2023, 11:24
by RalfR
I have the strong suspicion that the 'proxy' option of sim.getObject doesn't work as intended - at least I can't get it to work.
I have a scenario with two robots '/R' (6DoF) and '/R_alt' (8DoF). I try now to get the number of joints attached to the robots by using a loop calling

robotBase=sim.getObject("/R")
for i=0,100,1 do
...
sim.getObject("/Joint_"..i,{proxy=robotBase,noError=true})
...

However, the command seems to ignore the proxy setting and always returns 8 joints (found from /R_alt). Playing around, it seems as if I can put any number or object into the proxy= statement, and nothing seems to have an effect - the function always finds all 8 joints.
However, if I use

sim.getObject("/R/*/Joint_"..i,{noError=true})

instead, I get the desired 6 joints from /R.

So either I use the proxy option in a wrong way, or it simply doesn't work.

Re: Proxy option from sim.getObject does not work

Posted: 01 Dec 2023, 11:45
by fferri
An object path starting with a '/' is an absolute path, so it works in the same way from any object. Passing the proxy option doesn't make sense with an absolute path (has no effect).

A proxy option makes sense only with a relative path, e.g.:

Code: Select all

-- get 'gripper' object found in this tree:
gripper = sim.getObject('./gripper')

-- get 'gripper' object found under object referenced by variable otherRobot
otherGripper = sim.getObject('./gripper', {proxy = otherRobot})
See Accessing scene objects programmatically

Re: Proxy option from sim.getObject does not work

Posted: 04 Dec 2023, 08:42
by RalfR
Ah, I see the point.
However, a hint for this in the documentation would be helpful, as there is not much for the proxy option, and the relative path requirement is not mentioned.

Anyway, thanks !