Gazebo | Ignition | Community
Ask Your Question

new to ROS.. trying to operate a robot in gazebo using the teleop_twist_keyboard

asked 2019-08-10 19:45:16 -0600

cbdru_ros gravatar image

updated 2019-08-15 02:30:21 -0600

kumpakri gravatar image

I have successfully created an instance of pioneer 3dx robot from ( in gazebo. now i am trying to operate it with teleop_twist_keyboard.

I am currently running the following topics


these are the nodes that are running


how do i get the robot in gazebo to move using the teleop_twist???

not sure how to progress. I've read quite a few guides online, but I'm not able to link the cmd_vel to the gazebo model.. what exactly should i be doing?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2019-08-15 02:49:10 -0600

kumpakri gravatar image

I can see from the list of the topics that there is no controller topic for the wheels of your robot.

If you look into the description of your robot, you should find a transmission tags that are given the names of the drive wheels joints. Inside the gazebo tags you will find there is a plugin called libgazebo_ros_control loaded. This plugin looks for the transmission tags to see what controllers it should load.

But you also need to set the controllers yourself (I'm not sure of the causality in this process, but this is what you need to do). So you need this controller configuration file and then you need to actually load it into your simulation.

That is supposed to be done by this file, however in this package the loading of the controller is commented out. I'm not sure what is the state in your local package. I cannot validate all of what is written in this file, but given everything else is correct, the file should look as follows:

  <arg name="name" default="p3dx"/>
  <arg name="x" default="0.0"/>
  <arg name="y" default="0.0"/>
  <arg name="init_yaw" default="0.0"/>
  <arg name="namespace_arg" default=""/>
  <arg name="tfprefix" default=""/>

  <!-- Load joint controller configurations from YAML file to parameter server -->
  <rosparam file="$(find p3dx_control)/config/pioneer3dx.yaml" command="load"/>

  <!--<rosparam param="p3dx_velocity_controller/base_frame_id" subst_value="True">$(arg tfprefix)/base_link</rosparam>-->

  <!-- load the controllers -->
  <node name="controller_spawner" pkg="controller_manager" type="spawner" respawn="false" output="screen" ns="/$(arg namespace_arg)" args="joint1_position_controller joint2_position_controller joint_state_controller"/>

  <!-- transform the robot's coordinates to map-->
  <node pkg="tf" type="static_transform_publisher" name="map_odom_broadcaster" args="0 0 0 0 0 0 /map /$(arg tfprefix)/odom 100" />

  <!-- convert joint states to TF transforms for rviz, etc -->
  <node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher" respawn="false" output="screen">
    <remap from="/joint_states" to="/joint_states" />


The last step is to launch the control (the file above), which is commonly done in the launch file where you spawn the robot. You can see the lines loading the controller launch file are commented out in this file as well (all the way at the bottom). So you would need to uncomment also this command.

<!-- ros_control p3rd launch file -->
<!-- <include file="$(find p3dx_control)/launch/control.launch" /> -->

What you want to see in your topic list are two topics named something like /p3dx/joint1_position_controller/command and /p3dx/joint2_position_controller/command. Those are the topics that any kind of keyboad operation node has to sent the target velocities in order to move your robot.

edit flag offensive delete link more


Hi! Thanks for the answer. I was able to get it to work after I used your solution AND reinstalling ros_control package for Ros melodic. There were some corrupted elements in that package that were causing the issue.

cbdru_ros gravatar imagecbdru_ros ( 2019-08-15 16:41:44 -0600 )edit

answered 2019-08-15 02:53:07 -0600

kosjaat gravatar image

You do not have to link the cmd_vel topic as it is already included in your robot. The robot uses the DiffDrive Controller, so it automatically takes your velocity input and applies it to your wheel joints. Make sure you spawn the robot with gazebo_ros and make sure you do it either with the xacro file or the urdf file.

Once the robot is spawned in the scene you can launch your teleop_twist node and start using it. The diffDrive then should revieve the cmd_vel messages and apply them to your robot.

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2019-08-10 19:38:18 -0600

Seen: 1,700 times

Last updated: Aug 15 '19