sim.getObjectHandle('robot#0')
), but it fails to find any other objects other than the components of the duplicated robot. After I rename the duplicated robot from "robot#0" to "robot_2", the problem disappears. I doubt that the hashtag "#" is messing up with the sim.getObjectHandle.duplicated object script cannot find other objects by sim.getObjectHandle()
duplicated object script cannot find other objects by sim.getObjectHandle()
Hi, in CoppeliaSim 4.2.0 (I haven't tested this with 4.3.0), I found that when I duplicate a robot, the new one is appended a string '#0' (as expected). The child script can get the handle of the robot itself (such as
Re: duplicated object script cannot find other objects by sim.getObjectHandle()
Hello,
in CoppeliaSim versions prior to V4.3, you would use a unique object name to identify an object. Additionally, in order to enable scripts to automatically operate even after duplication, there was an automatic name adjustment mechanism, e.g.:
From script "robot#42" if you called:
In CoppeliaSim V4.3 and later, objects have non-unique aliases, and you can easily access any object via an absolute or relative path to the object. See here about details on how to access objects programmatically.
Cheers
in CoppeliaSim versions prior to V4.3, you would use a unique object name to identify an object. Additionally, in order to enable scripts to automatically operate even after duplication, there was an automatic name adjustment mechanism, e.g.:
From script "robot#42" if you called:
- handle=sim.getObjectHandle("sensor"), you would get the handle of object "sensor#42" (i.e. "#42" automatically appended)
- handle=sim.getObjectHandle("sensor#36"), you would get the handle of object "sensor#36"
In CoppeliaSim V4.3 and later, objects have non-unique aliases, and you can easily access any object via an absolute or relative path to the object. See here about details on how to access objects programmatically.
Cheers