0
$\begingroup$

Gazebo Answers logo

I have successfully created an instance of pioneer 3dx robot from (https://github.com/mario-serna/pioneer_p3dx_model) in gazebo. now i am trying to operate it with teleop_twist_keyboard.

I am currently running the following topics

/clock. 
/cmd_vel. 
/gazebo/link_states. 
/gazebo/model_states. 
/gazebo/parameter_descriptions. 
/gazebo/parameter_updates, 
/gazebo/set_link_state, 
/gazebo/set_model_state, 
/p3dx/joint_states, 
/rosout, 
/rosout_agg, 
/tf, 
/tf_static,

these are the nodes that are running

/gazebo, 
/gazebo_gui, 
/p3dx/map_odom_broadcaster, 
/p3dx/robot_state_publisher, 
/rosout, 
/teleop_twist_keyboard,

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?


Originally posted by cbdru_ros on Gazebo Answers with karma: 3 on 2019-08-10

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Gazebo Answers logo

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:

<launch>
  <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 -->
  <!-- THIS NEEDS TO BE UNCOMMENTED -->
  <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" />
  </node>

</launch>

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.


Originally posted by kumpakri with karma: 755 on 2019-08-15

This answer was ACCEPTED on the original site

Post score: 0


Original comments

Comment by cbdru_ros on 2019-08-15:
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.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.