cmd_vel not working with custom plugin

asked 2017-01-05 01:07:40 -0600

wilmer gravatar image

updated 2017-01-05 15:09:25 -0600

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

  <plugin name="plugins" filename=""/>

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
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

there is no connection between 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:


after doing echo i get this graph image description

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 <boost/bind.hpp>
#include <gazebo/gazebo.hh>
#include "geometry_msgs/Twist.h"
#include <gazebo/physics/physics.hh>
#include <gazebo/common/common.hh>
#include <stdio.h>
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)

    // 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
edit retag flag offensive close merge delete