Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Collisions Tutorial is Outdated #732

Open
johnrowlay opened this issue Jun 3, 2016 · 2 comments
Open

Collisions Tutorial is Outdated #732

johnrowlay opened this issue Jun 3, 2016 · 2 comments

Comments

@johnrowlay
Copy link

I'm trying to determine whether two particular objects are in collision with each other. In the tutorial on your webpage (http://dart.readthedocs.io/en/release-6.0/tutorials/collisions/#lesson-3c-compute-collisions), it suggests to do the following:

dart::collision::CollisionDetector* detector = mWorld->getConstraintSolver()->getCollisionDetector();
detector->detectCollision(true, true);

bool collision = false;
size_t collisionCount = detector->getNumContacts();
for(size_t i = 0; i < collisionCount; ++i)
{
    const dart::collision::Contact& contact = detector->getContact(i);
    if(contact.bodyNode1.lock()->getSkeleton() == object || contact.bodyNode2.lock()->getSkeleton() == object)
    {
        collision = true;
        break;
    }
}

This seems fairly straighforward to me. You loop through all the detected contacts, and check whether the skeletons associated with these contacts are the two skeletons which you are looking for.

However, in the latest version of the code, this tutorial actually does things differently:

auto collisionEngine = mWorld->getConstraintSolver()->getCollisionDetector();
auto collisionGroup = mWorld->getConstraintSolver()->getCollisionGroup();
auto newGroup = collisionEngine->createCollisionGroup(newDomino.get());

dart::collision::CollisionOption option;
dart::collision::CollisionResult result;
bool dominoCollision = collisionGroup->collide(newGroup.get(), option, &result);

This is much less easy to follow. I don't really understand what a CollisionGroup is, nor how to tell whether two particular objects have collided. However, there doesn't seem to be any documentation on this, because the only tutorial on collisions uses an outdated version of the code.

Please could somebody explain how I can achieve this, or update the tutorial to reflect the new code?

Thanks!

@jturner65
Copy link

This solution to this tutorial also throws a segmentation fault on windows since it uses make_shared to instance shared ptrs to classes containing vectorizable constructs vs using Eigen::make_aligned_shared. This is similar to #513

@stale
Copy link

stale bot commented Feb 13, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Feb 13, 2018
@stale stale bot removed the stale label Feb 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants