28 GZ_REGISTER_MODEL_PLUGIN(
Motor)
36 printf(
"Destructing Motor Plugin!\n");
45 this->model_ = _parent;
48 this->name_ = model_->GetName();
49 printf(
"Loading Motor Plugin of model %s\n", name_.c_str());
53 this->update_connection_ = event::Events::ConnectWorldUpdateBegin(boost::bind(&
Motor::OnUpdate,
this, _1));
56 this->node_ = transport::NodePtr(
new transport::Node());
58 this->node_->Init(model_->GetWorld()->GetName()+
"/"+name_);
67 this->motor_move_sub_ = this->node_->Subscribe(std::string(
"~/RobotinoSim/MotorMove/"), &Motor::on_motor_move_msg,
this);
76 float yaw = this->model_->GetWorldPose().rot.GetAsEuler().z;
81 x += cos(yaw + 3.1415926f / 2) * vy_;
82 y += sin(yaw + 3.1415926f / 2) * vy_;
84 this->model_->SetLinearVel(math::Vector3(x, y, 0));
85 this->model_->SetAngularVel(math::Vector3(0, 0, vomega_));
97 void Motor::on_motor_move_msg(ConstVector3dPtr &msg)
virtual void Reset()
on Gazebo reset
virtual void Load(physics::ModelPtr _parent, sdf::ElementPtr)
on loading of the plugin
virtual void OnUpdate(const common::UpdateInfo &)
Called by the world update start event.