Gazebo | Ignition | Community
Ask Your Question
0

Gravity doesnt pull my Model

asked 2018-12-07 11:41:14 -0600

Delay Lama gravatar image

updated 2018-12-07 22:58:20 -0600

Hello Everyone,

I am running Gazebo version 9.5.0 in an Ubuntu 18.04 LTS.

I build my own Model and tried to control it with an self written plugin. The Plugin applies a small force on the x-Vector. And the Model is moving in this direction. But it seems like it is not affected by gravity, also it is not static? I made a model and used the follower plugin from the tutorials witch behaves normal. Other objects are effected by gravity as well. It seems like the problem is in my Plugin.

I put the Model, Plugin and a short video in the attachments for you to check out. Maybe you are able to tell me what i am missing out.

I am new to gazebo and i hope you can help me.

Thank you Delay Lama

EDIT: It seems to be, that there is an error while running gazebo, which might be in relation to the Problem [ Node::Advertise(): Error advertising a topic. Did you forget to start the discovery service? ]

Plugin: C:\fakepath\model_push.cc

Model: C:\fakepath\model.sdf

Das Video: https://youtu.be/AcG3D7kpQo8

edit retag flag offensive close merge delete

Comments

It looks like the attachments didn't come through

chapulina gravatar imagechapulina ( 2018-12-07 12:07:56 -0600 )edit

People look at this, but they leaf no answer or questions that could lead to answers.... Is there something unclear about my Problem? Or is something else wrong?

Delay Lama gravatar imageDelay Lama ( 2018-12-14 01:00:12 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2018-12-18 10:07:13 -0600

azeey gravatar image

Gravity does not apply on an object if it's being moved by a SetLinearVel call because setting the velocity of an object overrides any forces being applied on the object. Instead, you need to use AddForce on the links of the model. You can choose to apply the force on all the links or one designated link (or multiple links). In your case, the easiest thing might be to apply it on the very first link:

class ModelPush : public ModelPlugin
{
  public: void Load(physics::ModelPtr _parent, sdf::ElementPtr /*_sdf*/)
  {
    // Store the pointer to the model
    this->model = _parent;
    this->baseLink = _parent->GetLinks()[0];

    // Listen to the update event. This event is broadcast every
    // simulation iteration.
    this->updateConnection = event::Events::ConnectWorldUpdateBegin(
        std::bind(&ModelPush::OnUpdate, this));
  }

  // Called by the world update start event
  public: void OnUpdate()
  {
    // Apply a small linear velocity to all the base link the model.
    this->baseLink->AddForce(ignition::math::Vector3d(.3, 0, 0));
  }

  // Pointer to the model
  private: physics::ModelPtr model;
  private: physics::LinkPtr baseLink;

  // Pointer to the update event connection
  private: event::ConnectionPtr updateConnection;
};
edit flag offensive delete link more

Comments

Thank you very much for your help, azeey.

Delay Lama gravatar imageDelay Lama ( 2018-12-18 11:47:14 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2018-12-07 11:41:14 -0600

Seen: 698 times

Last updated: Dec 18 '18