Code: Select all
Lua runtime error: [string "CHILD SCRIPT Quadricopter_target#0"]:1: Object does not exist. (sim.getObjectHandle)
stack traceback:
[C]: in function 'getObjectHandle'
[string "CHILD SCRIPT Quadricopter_target#0"]:1: in main chunk
Code: Select all
--drone 1 - Quadricopter_target
path = simGetObjectHandle('Path0')
object = sim.getObjectHandle('Quadricopter_target')
pathLength = sim.getPathLength(path)
posOnPath = 0
v = 0.5
movement = v
while true do
l = posOnPath/pathLength
if(posOnPath > pathLength) then
movement = -v
end
if (posOnPath < 0) then
movement = v
end
position = sim.getPositionOnPath(path, l)
orientation = sim.getOrientationOnPath(path, l)
position[3] = 0.9
sim.setObjectPosition(object, -1, position)
sim.setObjectOrientation(object, -1, orientation)
posOnPath = posOnPath+movement*sim.getSimulationTimeStep()
sim.switchThread()
end
Code: Select all
--drone 2 - Quadricopter_target#0
path = sim.getObjectHandle('Path0')
object = sim.getObjectHandle('Quadricopter_target#0')
pathLength = sim.getPathLength(path)
posOnPath = 0
v = 0.5
movement = v
while true do
l = posOnPath/pathLength
if(posOnPath > pathLength) then
movement = -v
end
if (posOnPath < 0) then
movement = v
end
position = sim.getPositionOnPath(path, l)
orientation = sim.getOrientationOnPath(path, l)
position[3] = 0.9
sim.setObjectPosition(object, -1, position)
sim.setObjectOrientation(object, -1, orientation)
posOnPath = posOnPath+movement*sim.getSimulationTimeStep()
sim.switchThread()
end