Hello,
the easiest is to probably look at the demo scene
scenes/movingAlongAPath-lua.ttt, and open the child script attached to the red cube:
The path object contains the path data tha is read with:
Code: Select all
pathData=sim.unpackDoubleTable(sim.readCustomDataBlock(path,'PATH'))
Path data is basically just a successions of poses (x1, y1, z1, qx1, qy1, qz1, qz1, x2, y2, z2, ...). Those are split in 2 in order to separate positions and quaternions:
Code: Select all
local m=Matrix(#pathData//7,7,pathData)
pathPositions=m:slice(1,1,m:rows(),3):data()
pathQuaternions=m:slice(1,4,m:rows(),7):data()
Next, it is important to have one additional information: the relative distance between individual position points:
Code: Select all
pathLengths,totalLength=sim.getPathLengths(pathPositions,3)
And now you can extract an interpolated position or quaternion from the pathPositions and pathQuaternions with sim.getPathInterpolatedConfig:
Code: Select all
local pos=sim.getPathInterpolatedConfig(pathPositions, pathLengths, posAlongPath)
local quat=sim.getPathInterpolatedConfig(pathQuaternions ,pathLengths, posAlongPath, nil, {2, 2, 2, 2})
(in above, {2, 2, 2, 2} indicates the data is quaternion data)
Cheers