Data manipulation/transformation

Data in CoppeliaSim can transformed in various ways:

  • data packing/unpacking
  • linear algebra functionality
  • image processing
  • path data transformation
  • sim.transformBuffer
  • other matrix/transformation related functions
  • Following example illustrates how to pack/unpack data:

    -- Packing/unpacking specific type of data, e.g. doubles: local data={1,2,3} local packedData=sim.packDoubleTable(data) -- packing data=sim.unpackDoubleTable(dpackedData) -- unpacking -- Packing/unpacking random data: local data={1,'hello',{value='world'},{1,{2,3}}} local packedData=sim.packTable(data) -- packing data=sim.unpackTable(dpackedData) -- unpacking

    Following example illustrates usage of the linear algebra functionality:

    -- Get the absolute transformation matrices of an object and its parent: local absObj=Matrix4x4:frompose(sim.getObjectPose(objectHandle,-1)) local absParentObj=Matrix4x4:frompose(sim.getObjectPose(parentHandle,-1)) -- Compute the relative transformation matrix of the object: local relObj=Matrix4x4:inv(absParentObj)*absObj -- Get the relative transformation matrix of the object directly: local relObj2=Matrix4x4:frompose(sim.getObjectPose(objectHandle,parentHandle)) -- Check that both matrices are same: print(relObj:sub(relObj2):abs():max())

    Following example illustrates how to convert to/from base64:

    local base64Buffer=sim.transformBuffer(buffer,sim.buffer_uint8,1,0,sim.buffer_base64) local originalBuffer=sim.transformBuffer(base64Buffer,sim.buffer_base64,1,0,sim.buffer_uint8)