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

Disable gravity for links #504

Open
chapulina opened this issue Dec 18, 2020 · 5 comments
Open

Disable gravity for links #504

chapulina opened this issue Dec 18, 2020 · 5 comments
Labels
enhancement New feature or request help wanted We accept pull requests! physics Involves Ignition Physics

Comments

@chapulina
Copy link
Contributor

Gazebo Classic supports the <link><gravity> SDF element, which makes links float.

That hasn't been ported to Ignition yet, we aren't even parsing the flag into sdf::Link.

@chapulina chapulina added enhancement New feature or request help wanted We accept pull requests! physics Involves Ignition Physics labels Dec 18, 2020
mjcarroll pushed a commit that referenced this issue Jan 7, 2021
Improved visualization debugging docs

Approved-by: Louise Poubel <[email protected]>
@rachase
Copy link

rachase commented Jul 13, 2022

Ive been working on a plugin to disable grav, but not sure the right way to do it (ignition documentation is really rough...). I have the plugin loading, and the gravity is being printed out as 0 0 0 , but not sure if its being applied to the model at all. Any suggestions?

void AntiGrav::Configure(const ignition::gazebo::Entity &_entity,
    const std::shared_ptr<const sdf::Element> &_sdf,
    ignition::gazebo::EntityComponentManager &_ecm,
    ignition::gazebo::EventManager &/*_eventMgr*/)
{
    std::string link_name_;
    //ignition::gazebo::Model model{ ignition::gazebo::kNullEntity};
    ignition::gazebo::Model model{_entity};

    // Get sdf parameters
    if (_sdf->HasElement("linkName"))
    {
      link_name_ = _sdf->Get<std::string>("linkName");
    }
    else
    {
      ignerr << "The AntiGrav plugin for " << "[MODEL  NAME] " << "requires a `linkName` parameter tag" <<std::endl;
      return;
    }

    if(!model.Valid(_ecm))
    {
      ignerr << "AntiGrav plugin should be attached to a model entity. " << std::endl;
    return;
    }
    
    ignition::gazebo::Entity E = model.LinkByName(_ecm,link_name_);
    
    _ecm.CreateComponent<ignition::gazebo::components::Gravity>(_entity,ignition::gazebo::components::Gravity());

    //const components::Gravity *gravity = _ecm.Component<components::Gravity>(this->dataPtr->world);
    const ignition::gazebo::components::Gravity *gravity = _ecm.Component<ignition::gazebo::components::Gravity>(_entity);

    if(nullptr == gravity)
    {
      ignmsg << "gravity is a null pointer" << std::endl;
    }
    else
    {
      ignmsg << gravity->Data().X() << gravity->Data().Y() << gravity->Data().Z() << std::endl;
    }
}

@slim71
Copy link

slim71 commented Jun 5, 2024

Any update on this? Specifically, in my case, into Garden...

@iche033
Copy link
Contributor

iche033 commented Jun 6, 2024

the sdformat PRs were merged and forward ported to garden and newer versions. We'll need to make sdformat releases so that the gz-physics and gz-sim PRs can be merged.

@slim71
Copy link

slim71 commented Jun 6, 2024

not to rush or anything, but does this have an ETA? is it scheduled?

@iche033
Copy link
Contributor

iche033 commented Jun 6, 2024

I'll kick off the sdformat releases, starting with fortress gazebosim/sdformat#1430

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted We accept pull requests! physics Involves Ignition Physics
Projects
None yet
Development

No branches or pull requests

4 participants