I'm currently using the simxLoadModel C++ remote api to load multiple quadricopter models in a 25x25m V-REP scene.
As they are all loaded at the center of the floor, I would then invoke the following lua function using simxCallScriptFunction twice to move it to the desired starting point. The first API call positions the quadricopter's target orb and the second API call positions the quadricopter itself.
Code: Select all
function SetRobotPose_function(inInts,inFloats,inStrings,inBuffer)
-- inInts[2]: set object position if = 1
-- inFloats[1]: xcoordinate
-- inFloats[2]: ycoordinate
-- inFloats[3]: zcoordinate
-- inInts[3]: set object orientation when non-zero
-- inFloats[4]: xorientation
-- inFloats[5]: yorientation
-- inFloats[6]: zorientation
local functionCode
--Get Model Base Handle
local ModelBaseHandle = inInts[1]
--Get initial configuration of the model
local initConf=simGetConfigurationTree(ModelBaseHandle)
--Dynamic reset the model
local objects=simGetObjectsInTree(ModelBaseHandle,sim_handle_all,0)
for i=1,#objects,1 do
functionCode = simResetDynamicObject(objects[i])
if functionCode==-1 then
simDisplayDialog('From remoteAPICommandServer', 'Failed to ResetDynamicObject...',sim_dlgstyle_ok,false)
return {functionCode},{},{},''
end
end
--Restore configuration of model
simSetConfigurationTree(initConf)
--if position values are available
if #inInts>=2 then
if inInts[2] == 1 then
local SetPosition = {inFloats[1], inFloats[2], inFloats[3]}
simSetObjectPosition(ModelBaseHandle,-1, SetPosition)
end
end
--if orientation values are available
if #inInts>=3 then
if inInts[3] == 1 then
local SetOrientation = {inFloats[4], inFloats[5], inFloats[6]}
simSetObjectOrientation(ModelBaseHandle,-1, SetOrientation)
end
end
--return function code
return {functionCode},{},{},''
end
Here's a sample video:
https://drive.google.com/file/d/1T_t9OH ... ziYyWzYEaN
Thanks!