How to make some Quadricopters fly in the path?

Typically: "How do I... ", "How can I... " questions
Post Reply
starsdy
Posts: 2
Joined: 08 Apr 2020, 12:23

How to make some Quadricopters fly in the path?

Post by starsdy »

Hello! I am a green hand in V-REP. I'm using V-REP to do some research,but i find some problems which I can't understand.

In my scene, I put a cube and path. I use these codes that the cube will move along the path.(These codes comes from the V-REP website)

function sysCall_init()
cube=sim.getObjectAssociatedWithScript(sim.handle_self)
path=sim.getObjectHandle('Path1')
pathLength=sim.getPathLength(path)
velocity=1 -- m/s
posAlongPath=0
previousSimulationTime=0
end

function sysCall_actuation()
local t=sim.getSimulationTime()
posAlongPath=posAlongPath+velocity*(t-previousSimulationTime)
local relDistance=posAlongPath/pathLength
local p=sim.getPositionOnPath(path,relDistance)
sim.setObjectPosition(cube,-1,p)
previousSimulationTime=t
end

Then , I put a quadricopter, its name is ‘Quadricopter’ , through similar questions in the forum, I use the way "just attach the quadricopter "Quadricopter_target" to the dummy (i.e. make the "Quadricopter_target" object child of the dummy. Then, in the control script of the quadricopter, remove the command on line 10, which detaches the "Quadricopter_target" from its parent".

Then I find the first quadricopter(Its name is "Quadricopter") can track Cube.

Problem:
But when I put new quadricopter(its name is "Quadricopter#0") , using the same codes and way. There are some errors, and the uav can't fly.

I hope someone can give me some advice, thank you very much!

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

Re: How to make some Quadricopters fly in the path?

Post by coppelia »

Hello,

have a look at Accessing objects programmatically (fromAssociatedCode), and how CoppeliaSim deals with duplicate objects.

Cheers

starsdy
Posts: 2
Joined: 08 Apr 2020, 12:23

Re: How to make some Quadricopters fly in the path?

Post by starsdy »

Thank you for your advice! I've solved my problem. Thank you very much.

Post Reply