Rosanswers logo

Hi All,

I have to simulate a planning environment where objects whose poses are randomly determined are added.

It is obvious to check if the just-added object is in collision with the robot, as in here.

How to check if it is in collision with the other existing objects?

Thanks a lot.

Originally posted by tor on ROS Answers with karma: 277 on 2012-09-13

Post score: 0


1 Answer 1


Rosanswers logo

you need this method:

bool isObjectInCollision(const std::string& object_name);

it's a public method of planning_environment::CollisionModels.

besides, if you want to know exactly which objects are in collision with the target object, use this method:

void getAllEnvironmentCollisionsForObject(const std::string& object_name, 
                        std::vector<arm_navigation_msgs::ContactInformation>& contacts,
                        unsigned int num_per_pair = 1);

Originally posted by yangyangcv with karma: 741 on 2012-11-01

This answer was ACCEPTED on the original site

Post score: 0

Original comments

Comment by tor on 2012-11-05:
Please note that the goal is to check whether an object is in collision with another object, not with a robot. AFAIK, your answer works for the latter. Anyway, thanks.

Comment by yangyangcv on 2012-11-05:
i don't agree with you. getAllEnvironmentCollisionsForObject() will return all the collisions for the specified object, no matter it is a robot link, or another object. you can check the src of this method.

Comment by tor on 2012-11-08:
Well, to call isObjectInCollision(), we need an instance of CollisionModel whose constructor needs a robot description. Therefore, even if we have the object cm from rbt_desc, cm.isObjectInCollision("obj") will tell whether "obj" is in collision with the rbt_desc's robot. CMIIW.

Comment by yangyangcv on 2012-11-09:
well, i have not test the function isObjectInCollision(), but i do test the function getAllEnvironmentCollisionsForObject() and it does work. and of course, you need an instance of CollisionModel.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.