Differential drive plugin not working

asked 2018-01-29 11:45:34 -0600

SteBisi gravatar image

updated 2018-01-29 11:57:34 -0600

Hello everyone, I'm trying to replicate the pioneer 2dx example for a uni project using this time my own robot, which has four wheels. Thus I put two different differential drive plugins in my robot.gazebo file:

<gazebo>

<plugin filename="libgazebo_ros_diff_drive.so" name="front_differential_drive_controller">

  <alwaysOn>true</alwaysOn>

  <updateRate>100</updateRate>

  <leftJoint>front_sx_joint</leftJoint>

  <rightJoint>front_dx_joint</rightJoint>

  <torque>5</torque>

  <wheelSeparation>12</wheelSeparation>

  <wheelDiameter>8</wheelDiameter>

  <commandTopic>bot2489/cmd_vel</commandTopic>

  <odometryTopic>odom</odometryTopic>

  <odometryFrame>odom</odometryFrame>

  <robotBaseFrame>base_link</robotBaseFrame>

  <publishWheelTF>true</publishWheelTF>

  <publishWheelJointState>true</publishWheelJointState>

  <wheelAcceleration>0</wheelAcceleration>

  <wheelTorque>5</wheelTorque>

  <rosDebugLevel>na</rosDebugLevel>

</plugin>

</gazebo>

<gazebo>

<plugin filename="libgazebo_ros_diff_drive.so" name="back_differential_drive_controller">

  <alwaysOn>true</alwaysOn>

  <updateRate>100</updateRate>

  <leftJoint>back_sx_joint</leftJoint>

  <rightJoint>back_dx_joint</rightJoint>

  <torque>5</torque>

  <wheelSeparation>12</wheelSeparation>

  <wheelDiameter>8</wheelDiameter>

  <commandTopic>bot2489/cmd_vel</commandTopic>

  <odometryTopic>odom</odometryTopic>

  <odometryFrame>odom</odometryFrame>

  <robotBaseFrame>base_link</robotBaseFrame>

  <publishWheelTF>true</publishWheelTF>

  <publishWheelJointState>true</publishWheelJointState>

  <wheelAcceleration>0</wheelAcceleration>

  <wheelTorque>5</wheelTorque>

  <rosDebugLevel>na</rosDebugLevel>

</plugin>

</gazebo>

the joints I refer to are defined in the wheel.xacro file that is later imported and implemented in the main xacro of the robot

<robot< p="">

xmlns:sensor="http://playerstage.sourceforge.net/gazebo/xmlschema/#sensor"

xmlns:controller="http://playerstage.sourceforge.net/gazebo/xmlschema/#controller"

xmlns:interface="http://playerstage.sourceforge.net/gazebo/xmlschema/#interface"

xmlns:xacro="http://ros.org/wiki/xacro"

>

<property name="M_PI" value="3.14159"/>

<xacro:macro name="wheel" params="prefix *joint_pose">

<link name="${prefix}_wheel">

  <visual>

    <origin xyz="0 0 0" rpy="0 0 0"/>

    <geometry>

      <mesh filename="package://bot2489_description/meshes/bot2489_wheel.dae" scale="0.1 0.1 0.1"/>

    </geometry>

    <material name="grey" />

  </visual>

  <collision>

    <origin xyz="0 0 0" rpy="0 0 0"/>

    <geometry>

      <mesh filename="package://bot2489_description/meshes/bot2489_wheel.dae" scale="0.1 0.1 0.1"/>

    </geometry>

  </collision>

  <inertial>

    <origin xyz="0 0 0" rpy="0 0 0"/>

    <mass value="1.0"/>

    <inertia

      ixx="0.0013" ixy="0" ixz="0"

      iyy="0.0024" iyz="0"

      izz="0.0013"/>

  </inertial>

</link>



<joint name="${prefix}_joint" type="continuous">

  <parent link="body_link"/>

  <child link="${prefix}_wheel" />

  <xacro:insert_block name="joint_pose" />

  <axis xyz="0 1 0" />

</joint>


<transmission name="${prefix}_transmission">

  <type>transmission_interface/SimpleTransmission</type>

  <joint name="${prefix}_joint">

    <hardwareInterface>EffortJointInterface</hardwareInterface>

  </joint>

  <actuator name="${prefix}_motor">

    <hardwareInterface>EffortJointInterface</hardwareInterface>

    <mechanicalReduction>1</mechanicalReduction>

  </actuator>

</transmission>

</xacro:macro>

</robot>

The problem is that apparently the plugin is not working: it doesn't publish on the /odom topic and it doesn't subscribe to the /bot2489/cmd_vel topic. I use three different launch files, one for gazebo, one for the navigation stack (move base, gmapping etc...) and one for rviz, exactly like in the pioneer package (except for the fourth package that is a simple controller and for the moment I don't need it) If may help, I'm using ROS Kinetic and the pioneer example works well. Does anyone have any idea of what is going wrong?

edit: in the robot.gazebo file, there are also a camera and a laser plugin that are correctly published and visualized from RViz

edit retag flag offensive close merge delete

Comments

Try launching Gazebo with the --verbose option. It might tell you if there's anything wrong. The one thing I can spot is that your odometryTopics are the same for both plugins which may not be such a good idea considering they calculate odometry independently.

Raskkii gravatar imageRaskkii ( 2018-01-30 01:41:51 -0600 )edit