Quantcast
Channel: Gazebo: Q&A Forum - RSS feed
Viewing all articles
Browse latest Browse all 7017

cmd_vel not working with custom plugin

$
0
0
Hi, i wrote a plugin(attached down) to move a robot in the space , i compile the plugin and is compiling ok. I add this line to my SDF at the end of model i am running the command rostopic pub /src/wilmer_gazebo/cmd_vel geometry_msgs/Twist "linear: x: 0.1 y: 0.0 z: 0.0 angular: x: 0.0 y: 0.0 z: 0.3" publishing and latching message. Press ctrl-C to terminate when i run echo i dont get any return WARNING: no messages received and simulated time is active i run nodegraph and i get this ![image description](/upfiles/14835999557653242.jpg) there is no connection between nodes...how can i solve this? **EDIT** I change my cmd_vel to rostopic pub cmd_vel geometry_msgs/Twist "linear: x: 0.1 y: 0.0 z: 0.0 angular: x: 0.0 y: 0.0 z: 0.3" the run rostopic list and get: /clock /gazebo/link_states /gazebo/model_states /gazebo/parameter_descriptions /gazebo/parameter_updates /gazebo/set_link_state /gazebo/set_model_state /rosout /rosout_agg /wcmd_vel after doing echo i get this graph ![image description](/upfiles/14836504907210737.jpg) **I see my error is that my plugin is not working over the same rostopic but how can i correct this?** my plugin is: #include #include #include "geometry_msgs/Twist.h" #include #include #include static float velx=0.0,vely=0.0,velz=0.0,Vangx=0.0,Vangy=0.0, Vangz=0.0; // set as global namespace gazebo { class plugins : public ModelPlugin { public: void Load(physics::ModelPtr _parent, sdf::ElementPtr /*_sdf*/) { // Store the pointer to the model this->model = _parent; // Listen to the update event. This event is broadcast every // simulation iteration. this->updateConnection = event::Events::ConnectWorldUpdateBegin( boost::bind(&plugins::OnUpdate, this, _1)); } // callback functions run every time data is published to the topic void ROSCallback_Vel(const geometry_msgs::Twist::ConstPtr& msg) { velx=msg->linear.x; vely=msg->linear.y; velz=msg->linear.z; Vangx=msg->angular.x; Vangy=msg->angular.y; Vangz=msg->angular.z; } // Called by the world update start event public: void OnUpdate(const common::UpdateInfo & /*_info*/) { // Apply a small linear velocity to the model. this->model->SetLinearVel(math::Vector3(velx, vely, velz)); this->model->SetAngularVel(math::Vector3(Vangx, Vangy, Vangz)); } // Pointer to the model private: physics::ModelPtr model; // Pointer to the update event connection private: event::ConnectionPtr updateConnection; }; // Register this plugin with the simulator GZ_REGISTER_MODEL_PLUGIN(plugins) }

Viewing all articles
Browse latest Browse all 7017

Trending Articles