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!
How to make some Quadricopters fly in the path?
Re: How to make some Quadricopters fly in the path?
Hello,
have a look at Accessing objects programmatically (fromAssociatedCode), and how CoppeliaSim deals with duplicate objects.
Cheers
have a look at Accessing objects programmatically (fromAssociatedCode), and how CoppeliaSim deals with duplicate objects.
Cheers
Re: How to make some Quadricopters fly in the path?
Thank you for your advice! I've solved my problem. Thank you very much.