Gazebo | Ignition | Community
Ask Your Question
0

Move model by pressing the button

asked 2016-08-06 15:18:30 -0600

Shkryaba gravatar image

Hi.

I began to study plugins, and faced with the problem. There is a lesson model_pish - http://gazebosim.org/tutorials?tut=pl.... I wanted to change it up a bit, but do not understand how to do it. I wanted to make sure that the model is moved only to a certain place with the push of a button.

In the next lesson, there is something similar http://gazebosim.org/tutorials?tut=el..., but there is no description of how it works. Please, if you do something lift excess, tell me how to implement this?

namespace gazebo
{ double x,z,y;

  class ModelPush : public ModelPlugin
  {
    public: void Load(physics::ModelPtr _parent, sdf::ElementPtr /*_sdf*/)
    {

  this->model = _parent;

  this->updateConnection = event::Events::ConnectWorldUpdateBegin(
      boost::bind(&ModelPush::OnUpdate, this, _1));
}

public: void OnUpdate(const common::UpdateInfo & /*_info*/)
{
      while(model.getWorldPose().pose.x != x1)
          model.setVelocity(math::Vector3(1,0,0));
      while(model.getWorldPose().pos.y != y1)
          model.setVelocity(math::Vector3(0,1,0));
      while(model.getWorldPose().pose.z != z1)
          model.setVelocity(math::Vector3(0,0,1));
}

private: physics::ModelPtr model;

private: event::ConnectionPtr updateConnection;

}; GZ_REGISTER_MODEL_PLUGIN(ModelPush) }

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2016-08-18 20:30:41 -0600

winston gravatar image

If you want a GUI(a button), you could use Qt to design that. And when the button is pressed, the program should start sending gazebo messages to indicate the start of model moving.

You may also want to use Gazebo's GUI API. But I have not used it yet, so I am not sure how it would be. Good luck!

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2016-08-06 15:18:30 -0600

Seen: 934 times

Last updated: Aug 18 '16