Only the collision-free model is output during simulation

Typically: "How do I... ", "How can I... " questions
Post Reply
qxy1020
Posts: 7
Joined: 04 May 2022, 14:21

Only the collision-free model is output during simulation

Post by qxy1020 »

Hello, I need to detect the collision between the manipulator and the object. When there is a collision, I need to replan the location of the collision point. Therefore, I use the "simxsetjointposition“ function to update the position of the manipulator, and then use the "simxcheckcollision" function to detect its collision, but the "simxsetjointposition" function seems to update the model in the display simulation environment. Now I want it to do collision detection without updating the display, and the final display is the collision-free model I want. What should I do?
Thanks!

coppelia
Site Admin
Posts: 10339
Joined: 14 Dec 2012, 00:25

Re: Only the collision-free model is output during simulation

Post by coppelia »

Hello,

if you need to independently check collision from the actually scene content, best would be to have e.g. 2 equivalent manipulators: one is actually doing the movement, the other one is invisible and used for collision checking in other configurations/situations, etc.

In order to have the invisible manipulator detect collisions with the environment but not the other (visible) robot, use a collection, e.g.:

Code: Select all

    invisibleRobotCollection=sim.createCollection(0)
    sim.addItemToCollection(invisibleRobotCollection,sim.handle_tree,invisibleRobotHandle,0)
    
    environenmentCollection=sim.createCollection(0)
    sim.addItemToCollection(environenmentCollection,sim.handle_all,-1,0)
    sim.addItemToCollection(environenmentCollection,sim.handle_tree,invisibleRobotHandle,1)
    sim.addItemToCollection(environenmentCollection,sim.handle_tree,visibleRobotHandle,1)

    -- Check for collision:
    sim.checkCollision(invisibleRobotCollection,environenmentCollection)
Also, try to use the ZeroMQ remote API, which is much easier and flexible than the legacy remote API.

Cheers

Post Reply