Move model by pressing the button
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) }