ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Not able to subscribe to /cmd_vel topic

asked 2021-06-06 02:43:21 -0600

sudiv gravatar image

updated 2021-06-06 07:55:43 -0600

Hi, I'm new to ros,I followed a tutorial in internet to build a two-wheeled robot.Here is the problem,when i run rosrun teleop_twist_keyboard the output is

Waiting for subscriber to connect to /cmd_vel

here is launch file:

<?xml version="1.0" encoding="UTF-8"?>
<param name="robot_description" command="$(find xacro)/xacro --inorder '$(find m2wr_description)/urdf/m2wr.xacro'" />

<arg name="x" default="0"/>
<arg name="y" default="0"/>
<arg name="z" default="0.5"/>

<node name="mybot_spawn" pkg="gazebo_ros" type="spawn_model" output="screen"
      args="-urdf -param robot_description -model m2wr -x $(arg x) -y $(arg y) -z $(arg z)" />

<node pkg="teleop_twist_keyboard" type="" name="teleop">


Here is my gazebo plugin code:

<plugin filename="" name="differential_drive_controller">

I don't know what is the problem. Please help!

edit retag flag offensive close merge delete



First, check that the /cmd_vel topic exists and have a look which nodes subscribe/publish to it. (Please edit your question with the respective output. Use rostopic list | grep cmd_vel and rostopic info /cmd_vel for that.

I've also experienced "issues" (rather non-issues, no warnings, no errors, simply didn't work) when the respective plugins aren't installed. Please check that you have ros-noetic-gazebo-plugins installed. It does not come with the default ros-noetic-gazebo-ros package.

mgruhler gravatar image mgruhler  ( 2021-06-07 01:01:49 -0600 )edit

Thanks! I installed plugins and it worked.

sudiv gravatar image sudiv  ( 2021-06-07 09:02:09 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2021-06-07 01:05:28 -0600

apprentice_user gravatar image

The file publishes cmd_vel topic. With this topic, linear velocity (x) and angular velocity (z) are published. The cmd_vel topic expects a topic to subscribe to these published speeds. The error message states this. All you have to do is add lines to subscribe to your driving code. just like this one. This is a driving code that I use. After that, you can send the x and z values you receive to your robot as an order. I hope it was understandable

  def cmd_cb(msg):
      global x, theta
      x = msg.linear.x
      theta = msg.angular.z 


goal = rospy.Subscriber("cmd_vel", Twist, cmd_cb)
edit flag offensive delete link more

Question Tools

1 follower


Asked: 2021-06-06 02:39:04 -0600

Seen: 1,755 times

Last updated: Jun 07 '21