gazebosim / gazebo-classic

Gazebo classic. For the latest version, see https://github.com/gazebosim/gz-sim
http://classic.gazebosim.org/
Other
1.18k stars 479 forks source link

Collision WorldPose does not get updated. #1124

Open osrf-migration opened 10 years ago

osrf-migration commented 10 years ago

Original report (archived issue) by Andrei Haidu (Bitbucket: ahaidu).


During simulation Collision::GetWolrdPose does not get updated.

Here is a testing piece of code:

#!c++
        physics::Link_V _links = this->world->GetModel("box")->GetLinks();

        for (unsigned int i = 0; i < _links.size(); i++)
        {
            std::cout << "link name: " << _links.at(i)->GetName() << " pose: " << _links.at(i)->GetWorldPose().pos << std::endl;

            physics::Collision_V _colls = _links.at(i)->GetCollisions();

            for (unsigned int i = 0; i < _colls.size(); i++)
            {
                std::cout << "coll name: " << _colls.at(i)->GetName() << " pose: " << _colls.at(i)->GetWorldPose().pos << std::endl;
            }
        }

During the simulation while the object is moving the link poses change, and the collisions maintain their original position.

Testing works with a simple box model.

osrf-migration commented 10 years ago

Original comment by Steve Peters (Bitbucket: Steven Peters, GitHub: scpeters).


Does the model have multiple links? I'm asking because I see different Entity::SetWorldPose* functions used for models, canonical links, and everything else (see end of Entity::Load).

So I'm wondering if SetWorldPoseDefault is broken, in which case non-canonical links should have a static world pose as well.

osrf-migration commented 10 years ago

Original comment by Andrei Haidu (Bitbucket: ahaidu).


I first noticed it with a model with multiple links, and then tested it as well on a model with one link one collision. Both had the same issue.

osrf-migration commented 10 years ago

Original comment by Steve Peters (Bitbucket: Steven Peters, GitHub: scpeters).


I can confirm that Collision::GetWorldPose() is not returning an updated value.

Maybe Entity::UpdatePhysicsPose is where it should happen? There would be a performance impact, though, to cache the pose of all collisions and visuals in a model.

@nkoenig what do you recommend?

osrf-migration commented 10 years ago

Original comment by Nate Koenig (Bitbucket: Nathan Koenig).


I think the Entity::UpdatePhysicsPose is broken. I'll try writing a test, and then a solution.

osrf-migration commented 10 years ago

Original comment by Nate Koenig (Bitbucket: Nathan Koenig).


See pull request #1049

osrf-migration commented 10 years ago

Original comment by Jonathan Bohren (Bitbucket: jbohren).


I just ran into this, too.

osrf-migration commented 10 years ago

Original comment by Nate Koenig (Bitbucket: Nathan Koenig).


Resolved in pull request #1049

osrf-migration commented 10 years ago

Original comment by Andrei Haidu (Bitbucket: ahaidu).


The issue still appears for models with multiple links. I have installed gazebo from default (currently version 4.0.0).

I am using for testing a model with 2 links. First link has 2 collision, second link 1 collision:

The second collision doesn't get updated. Only when manually moving it with the mouse, and then only for one iteration.

Testing code:

#!c++
    // DEBUG collision issue
    physics::ModelPtr box = this->world->GetModel("box");

    std::cout << "model name: '" << box2->GetName()
            << "' --> world pos: " << box2->GetWorldPose().pos << std::endl;

    // get all links from the model
    physics::Link_V _links = box2->GetLinks();

    // iterate through all the links
    for (physics::Link_V::iterator l_iter = _links.begin();
            l_iter != _links.end(); ++l_iter)
    {
        // get all collisions of the link
        physics::Collision_V _collisions = l_iter->get()->GetCollisions();

        std::cout << "\t link name: '" << l_iter->get()->GetName()
                << "' --> world pos: " << l_iter->get()->GetWorldPose().pos << std::endl;

        // iterate through all the collisions
        for (physics::Collision_V::iterator c_iter = _collisions.begin();
                c_iter != _collisions.end(); ++c_iter)
        {
            std::cout << "\t\t collision name: '" << c_iter->get()->GetName()
                    << "' --> world pos: " << c_iter->get()->GetWorldPose().pos << std::endl;
        }
    }

Screenshot with the terminal output: collision_issue.png

osrf-migration commented 10 years ago

Original comment by Andrei Haidu (Bitbucket: ahaidu).


osrf-migration commented 10 years ago

Original comment by Steve Peters (Bitbucket: Steven Peters, GitHub: scpeters).


Can you suggest a patch for our regression test? That will make it easier to reproduce. Thanks for the report.

osrf-migration commented 10 years ago

Original comment by John Hsu (Bitbucket: hsu, GitHub: hsu).


and reuse issue_1124 branch if possible

Your test world will go into this world folder

osrf-migration commented 9 years ago

Original comment by Roxana Leontie (Bitbucket: rleontie).


Issue #1415 was marked as a duplicate of this issue.

osrf-migration commented 8 years ago

Original comment by Nate Koenig (Bitbucket: Nathan Koenig).


osrf-migration commented 8 years ago

Original comment by Nate Koenig (Bitbucket: Nathan Koenig).