How to make two quadricopters follow two different paths

Typically: "How do I... ", "How can I... " questions
Post Reply
cpscps
Posts: 3
Joined: 09 Sep 2020, 11:37

How to make two quadricopters follow two different paths

Post by cpscps »

I am trying to make two quadricopters follow two different paths using the following code in Quadricopter_target file

Code: Select all

target=sim.getObjectAssociatedWithScript(sim.handle_self)
path=sim.getObjectHandle('Path1')

for i=1, 1 do
sim.followPath(target,path,1,0,0.2,0.5)
end
for the first quadricopter and the same code with 'Path2' instead of 'Path1' for the second one.

However, only the first quadricopter follows his path while the second one just stay on site. I guess that it is a consecuence of the #0 suffix that appears in the name of the second quadricopter. I tried to modify the code of the child script while renaming the quadricopter#0 files but, despite of the quadricopter#0 starts moving, it doesn't follow its path.

Thanks in advance

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

Re: How to make two quadricopters follow two different paths

Post by coppelia »

Hello,

make sure you understand how objects are accessed in CoppeliaSim.

Normally, you do not add a #n suffix to the object names, when you access them with sim.getObjectHandle: this ways, if you copy and paste your model/models, then the copy is automatically correctly accessing not the original objects, but the copies.

Of course you can always explicitely access a specific object by writing out its full name, including the suffix part (e.g. that would be object# for object, object#21 for object#21, etc.). However when you copy-paste models that use explicit naming, then the copy will access the original objects, not the copies.

Cheers

Post Reply