Page 1 of 1

Collection does not exist

Posted: 07 Feb 2018, 09:45
by mash2612
Hi,

I am new to Vrep and have started working on it recently.Going through the forum I found a file which was trying something same as I intend to do. I have modified the file and am working on it now.I want to create Collision Pairs and want to avoid the 'self Collisions' happening in UR5 linkages. I tried adding the collision pair.However, it says the Collection is missing.
It might be something very trivial that I am missing.Any help would be greatly appreciated.
Following is the link to model:
https://drive.google.com/file/d/1vb_fnF ... sp=sharing

Also,
jointPositions=simGetConfigForTipPose(number ikGroupHandle,table jointHandles,number distanceThreshold,number maxTimeInMs,table collisionPairs)
is allthat has to be added.Am I correct in this interpretation of syntax?

Thanks in advance!

Re: Collection does not exist

Posted: 08 Feb 2018, 08:22
by coppelia
Hello,

first, make sure there is no other collection with the same name when trying to create one. Next, make sure to carefully read this page, the section Access from associated code: since your script is attached to an object named UR5#0, your code should rather look like:

Code: Select all

collisionPairs={sim.getCollectionHandle('CollectionName#'),sim.handle_all}
If you specify a collection name CollectionName, it will try to retrieve CollectionName#0, which doesn't exist.

Finally, make sure to destroy the collection at the end of simulation with:

Code: Select all

function sysCall_cleanup()
    sim.emptyCollection(UR5Collision)
    sim.removeCollection(UR5Collision)
end
There is however a bug with threaded scripts, since they will be destroyed without running the sysCall_cleanup section in some situations, as I just noticed... looking into it.

Cheers

Re: Collection does not exist

Posted: 08 Feb 2018, 09:10
by coppelia
Hello again,

actually, it should work fine in V-REP V3.5.0, if you format your threaded child script like:

Code: Select all

applyJoints=function(jointHandles,joints)
    -- ...
end


IKMovement=function(x,y,z)
    -- ...
end


function sysCall_threadmain()
    vel=180
    accel=40
    jerk=80
    currentVel={0,0,0,0,0,0,0}
    currentAccel={0,0,0,0,0,0,0}
    maxVel={vel*math.pi/180,vel*math.pi/180,vel*math.pi/180,vel*math.pi/180,vel*math.pi/180,vel*math.pi/180}
    maxAccel={accel*math.pi/180,accel*math.pi/180,accel*math.pi/180,accel*math.pi/180,accel*math.pi/180,accel*math.pi/180}
    maxJerk={jerk*math.pi/180,jerk*math.pi/180,jerk*math.pi/180,jerk*math.pi/180,jerk*math.pi/180,jerk*math.pi/180}
    targetVel={0,0,0,0,0,0}

    jointHandles={-1,-1,-1,-1,-1,-1}
    for i=1,6,1 do
        jointHandles[i]=sim.getObjectHandle('UR5_joint'..i)
    end

    IKHandle=sim.getIkGroupHandle('UR5_IK#')
    dummyHandle=sim.getObjectHandle('UR5_target#')

    console_mode=1+2+4
    ConsoleHandle=sim.auxiliaryConsoleOpen("Debug Console",5,console_mode)
    UR5Collision=sim.createCollection('CollectionName',0)
    sim.addObjectToCollection(UR5Collision,sim.getObjectHandle('UR5#0'),sim.handle_tree,0)
    collisionPairs={sim.getCollectionHandle('CollectionName#'),sim.handle_all}
    print(collisionPairs)

    for i=-0.55,0.95,0.05 do
        a=math.sin(2*math.pi/90*i)
        IKMovement(i,a,1.3)

    end

end

function sysCall_cleanup()
    sim.emptyCollection(UR5Collision)
    sim.removeCollection(UR5Collision)
end
Which is the new and better way of doing, starting with V-REP V3.5.0: i.e. using nothing else but functions in scripts.

Cheers