Robotics StackExchange | Archived questions

Can't parse transmissions. Invalid robot description.

I want to simulate my robotic arm in gazebo. This error is coming whenever I am spawning my robot in gazebo and I can't able to load any of my joint_position controllers. I am attaching my urdf , control.yaml, and the launch files. error when spawning the robot

[ERROR] [1594782495.582555693, 0.326000000]: Can't parse transmissions. Invalid robot description.
[ERROR] [1594782495.669790261, 0.326000000]: Error document empty.

error when loading the controllers:

[ERROR] [1594783081.365081451, 539.791000000]: Exception thrown while initializing controller joint_1_position_controller.
Could not find resource 'joint_1' in 'hardware_interface::EffortJointInterface'.
[ERROR] [1594783081.365288101, 539.791000000]: Initializing controller 'joint_1_position_controller' failed

error while loading controller in another terminal

 Loading controller: joint_1_position_controller
    [ERROR] [1594783082.375160, 540.688000]: Failed to load joint_1_position_controller
    [INFO] [1594783082.375588, 540.688000]: Loading controller: joint_2_position_controller
    [ERROR] [1594783083.453085, 541.622000]: Failed to load joint_2_position_controller

This is my controller file

test_1_urdf:
#publish all joint states ------
  joint_state_controller:
    type: joint_state_controller/JointStateController
    publish_rate: 50

#position Controllers
  joint_1_position_controller:
    type: effort_controllers/JointPositionController
    joint: joint_1
    pid: {p: 100.0 , i: 0.01 , d: 10 }
  joint_2_position_controller:
    type: effort_controllers/JointPositionController
    joint: joint_2
    pid: {p: 100.0 , i: 0.01 , d: 10 }
  joint_3_position_controller:
    type: effort_controllers/JointPositionController
    joint: joint_3
    pid: {p: 100.0 , i: 0.01 , d: 10 }
  joint_4_position_controller:
    type: effort_controllers/JointPositionController
    joint: joint_4
    pid: {p: 100.0 , i: 0.01 , d: 10 }
  joint_5_position_controller:
    type: effort_controllers/JointPositionController
    joint: joint_5
    pid: {p: 100.0 , i: 0.01 , d: 10 }

This my urdf file

<?xml version="1.0"?>
<!-- This URDF was automatically created by SolidWorks to URDF Exporter! Originally created by Stephen Brawner (brawner@gmail.com) 
     Commit Version: 1.5.1-0-g916b5db  Build Version: 1.5.7152.31018
     For more information, please see http://wiki.ros.org/sw_urdf_exporter -->
<robot
  name="test_1_urdf">

 <!-- <link name="world"/>
  <joint name="fixed" type="fixed">
    <parent name="world"/>
    <chile name="base_link"/>
  </joint>-->

  <link
    name="base_link">
    <inertial>
      <origin
        xyz="0.026901 0.024709 -0.0098697"
        rpy="0 0 0" />
      <mass
        value="0.34742" />
      <inertia
        ixx="0.00046368"
        ixy="-2.9001E-06"
        ixz="-3.7543E-19"
        iyy="0.0010571"
        iyz="-5.1522E-19"
        izz="0.00076443" />
    </inertial>
    <visual>
      <origin
        xyz="0 0 0"
        rpy="0 0 0" />
      <geometry>
        <mesh
          filename="package://test_1_urdf/meshes/base_link.STL" />
      </geometry>
      <material
        name="">
        <color
          rgba="0.79216 0.81961 0.93333 1" />
      </material>
    </visual>
    <collision>
      <origin
        xyz="0 0 0"
        rpy="0 0 0" />
      <geometry>
        <mesh
          filename="package://test_1_urdf/meshes/base_link.STL" />
      </geometry>
    </collision>
  </link>
  <link
    name="link_1">
    <inertial>
      <origin
        xyz="-0.033996 0.053779 0.0013632"
        rpy="0 0 0" />
      <mass
        value="0.62403" />
      <inertia
        ixx="0.00055304"
        ixy="3.8373E-06"
        ixz="1.4793E-07"
        iyy="0.00073956"
        iyz="-2.5812E-09"
        izz="0.00076923" />
    </inertial>
    <visual>
      <origin
        xyz="0 0 0"
        rpy="0 0 0" />
      <geometry>
        <mesh
          filename="package://test_1_urdf/meshes/link_1.STL" />
      </geometry>
      <material
        name="">
        <color
          rgba="0.79216 0.81961 0.93333 1" />
      </material>
    </visual>
    <collision>
      <origin
        xyz="0 0 0"
        rpy="0 0 0" />
      <geometry>
        <mesh
          filename="package://test_1_urdf/meshes/link_1.STL" />
      </geometry>
    </collision>
  </link>
  <joint
    name="joint_1"
    type="revolute">
    <origin
      xyz="0 0.01 0"
      rpy="1.5708 0 0" />
    <parent
      link="base_link" />
    <child
      link="link_1" />
    <axis
      xyz="0 1 0" />
    <limit
      lower="-1.57"
      upper="1.57"
      effort="10"
      velocity="1" />
  </joint>
  <link
    name="link_2">
    <inertial>
      <origin
        xyz="0.093132 -0.0072567 0.0031795"
        rpy="0 0 0" />
      <mass
        value="0.66404" />
      <inertia
        ixx="0.0005867"
        ixy="3.2043E-20"
        ixz="-0.00010232"
        iyy="0.0033357"
        iyz="-9.491E-19"
        izz="0.003555" />
    </inertial>
    <visual>
      <origin
        xyz="0 0 0"
        rpy="0 0 0" />
      <geometry>
        <mesh
          filename="package://test_1_urdf/meshes/link_2.STL" />
      </geometry>
      <material
        name="">
        <color
          rgba="0.79216 0.81961 0.93333 1" />
      </material>
    </visual>
    <collision>
      <origin
        xyz="0 0 0"
        rpy="0 0 0" />
      <geometry>
        <mesh
          filename="package://test_1_urdf/meshes/link_2.STL" />
      </geometry>
    </collision>
  </link>
  <joint
    name="joint_2"
    type="revolute">
    <origin
      xyz="-0.085 0.15 0"
      rpy="-1.5708 0 1.5365" />
    <parent
      link="link_1" />
    <child
      link="link_2" />
    <axis
      xyz="0 1 0" />
    <limit
      lower="-1.57"
      upper="1.57"
      effort="10"
      velocity="1" />
  </joint>
  <link
    name="link_3">
    <inertial>
      <origin
        xyz="6.1402E-05 1.9818E-05 -0.076313"
        rpy="0 0 0" />
      <mass
        value="0.12484" />
      <inertia
        ixx="9.6476E-05"
        ixy="1.9635E-10"
        ixz="2.755E-07"
        iyy="7.9833E-05"
        iyz="8.8918E-08"
        izz="4.1182E-05" />
    </inertial>
    <visual>
      <origin
        xyz="0 0 0"
        rpy="0 0 0" />
      <geometry>
        <mesh
          filename="package://test_1_urdf/meshes/link_3.STL" />
      </geometry>
      <material
        name="">
        <color
          rgba="0.79216 0.81961 0.93333 1" />
      </material>
    </visual>
    <collision>
      <origin
        xyz="0 0 0"
        rpy="0 0 0" />
      <geometry>
        <mesh
          filename="package://test_1_urdf/meshes/link_3.STL" />
      </geometry>
    </collision>
  </link>
  <joint
    name="joint_3"
    type="revolute">
    <origin
      xyz="0.35479 -0.04038 0.012185"
      rpy="1.5708 0.034331 3.1416" />
    <parent
      link="link_2" />
    <child
      link="link_3" />
    <axis
      xyz="0 0 1" />
    <limit
      lower="-1.57"
      upper="1.57"
      effort="10"
      velocity="1" />
  </joint>
  <link
    name="link_4">
    <inertial>
      <origin
        xyz="0.0052809 -0.016241 0.12532"
        rpy="0 0 0" />
      <mass
        value="0.35413" />
      <inertia
        ixx="0.0016351"
        ixy="1.9393E-05"
        ixz="-0.0002487"
        iyy="0.001665"
        iyz="0.00010111"
        izz="0.00029855" />
    </inertial>
    <visual>
      <origin
        xyz="0 0 0"
        rpy="0 0 0" />
      <geometry>
        <mesh
          filename="package://test_1_urdf/meshes/link_4.STL" />
      </geometry>
      <material
        name="">
        <color
          rgba="0.79216 0.81961 0.93333 1" />
      </material>
    </visual>
    <collision>
      <origin
        xyz="0 0 0"
        rpy="0 0 0" />
      <geometry>
        <mesh
          filename="package://test_1_urdf/meshes/link_4.STL" />
      </geometry>
    </collision>
  </link>
  <joint
    name="joint_4"
    type="revolute">
    <origin
      xyz="0 0 -0.1225"
      rpy="1.5708 0.73625 -1.5708" />
    <parent
      link="link_3" />
    <child
      link="link_4" />
    <axis
      xyz="0 0 1" />
    <limit
      lower="-1.57"
      upper="1.57"
      effort="10"
      velocity="1" />
  </joint>
  <link
    name="link_5">
    <inertial>
      <origin
        xyz="0.000764 -1.3878E-17 -0.00069468"
        rpy="0 0 0" />
      <mass
        value="0.049859" />
      <inertia
        ixx="1.0433E-05"
        ixy="1.5128E-19"
        ixz="1.8054E-07"
        iyy="2.2582E-05"
        iyz="7.9112E-21"
        izz="2.5114E-05" />
    </inertial>
    <visual>
      <origin
        xyz="0 0 0"
        rpy="0 0 0" />
      <geometry>
        <mesh
          filename="package://test_1_urdf/meshes/link_5.STL" />
      </geometry>
      <material
        name="">
        <color
          rgba="0.79216 0.81961 0.93333 1" />
      </material>
    </visual>
    <collision>
      <origin
        xyz="0 0 0"
        rpy="0 0 0" />
      <geometry>
        <mesh
          filename="package://test_1_urdf/meshes/link_5.STL" />
      </geometry>
    </collision>
  </link>
  <joint
    name="joint_5"
    type="revolute">
    <origin
      xyz="0.00014009 0.00012696 0.2605"
      rpy="3.1416 0 2.307" />
    <parent
      link="link_4" />
    <child
      link="link_5" />
    <axis
      xyz="1 0 0" />
    <limit
      lower="-1.57"
      upper="1.57"
      effort="10"
      velocity="1" />
  </joint>

<!--adding transmission tag -->
<tranmission name="tran1">
    <type>transmission_interface/SimpleTransmission</type>
    <joint name= "joint_1">
        <hardwareInterface>EffortJointInterface</hardwareInterface>
    </joint>
    <actuator name="motor1">
    <hardwareInterface>EffortJointInterface</hardwareInterface>
        <mechanicalReduction>1</mechanicalReduction>
    </actuator>
</tranmission>

<tranmission name="tran2">
    <type>transmission_interface/SimpleTransmission</type>
    <joint name= "joint_2">
        <hardwareInterface>EffortJointInterface</hardwareInterface>
    </joint>
    <actuator name="motor2">
    <hardwareInterface>EffortJointInterface</hardwareInterface>
        <mechanicalReduction>1</mechanicalReduction>
    </actuator>
</tranmission>

<transmission name="tran3">
    <type>transmission_interface/SimpleTransmission</type>
    <joint name= "joint_3">
        <hardwareInterface>EffortJointInterface</hardwareInterface>
    </joint>
    <actuator name="motor3">
    <hardwareInterface>EffortJointInterface</hardwareInterface>
        <mechanicalReduction>1</mechanicalReduction>
    </actuator>
</transmission>

<transmission name="tran4">
    <type>transmission_interface/SimpleTransmission</type>
    <joint name= "joint_4">
        <hardwareInterface>EffortJointInterface</hardwareInterface>
    </joint>
    <actuator name="motor4">
    <hardwareInterface>EffortJointInterface</hardwareInterface>
        <mechanicalReduction>1</mechanicalReduction>
    </actuator>
</transmission>

<transmission name="tran5">
    <type>transmission_interface/SimpleTransmission</type>
    <joint name= "joint_5">
        <hardwareInterface>EffortJointInterface</hardwareInterface>
    </joint>
    <actuator name="motor5">
    <hardwareInterface>EffortJointInterface</hardwareInterface>
        <mechanicalReduction>1</mechanicalReduction>
    </actuator>
</transmission>


<gazebo>
    <static>false</static>
    <plugin name="gazebo_ros_control" filename="libgazebo_ros_control.so">
    <robotNamespace>/test_1_urdf</robotNamespace>
    <legacyModeNS>true</legacyModeNS>
 </plugin>
</gazebo>

</robot>

This is my urdf spawning file.

<?xml version="1.0"?>
<launch>

    <include file="$(find gazebo_ros)/launch/empty_world.launch">
    </include>

<!-- load the urdf file-->
    <param name="robot_description" value="cat '$(find gazebo_test1)/urdf/test_1_urdf.urdf'"/>

<!--run a python script to run gazzebo_ros to spawn a urdf robot-->
    <node name="spawn_model" pkg="gazebo_ros" type="spawn_model" respawn="false" args="-file $(find gazebo_test1)/urdf/test_1_urdf.urdf -urdf -model test_1_urdf"
    output="screen" />

</launch>

Asked by Khule on 2020-07-14 22:31:29 UTC

Comments

Hi, @Khule

Maybe the problem is how you specify your transmission and the ROS control plugin params. From my own projects I use transmission like this:

<transmission name="trans_1">
  <type>transmission_interface/SimpleTransmission</type>
  <joint name="joint_1">
    <hardwareInterface>hardware_interface/VelocityJointInterface</hardwareInterface>
  </joint>
  <actuator name="motor_1">
    <mechanicalReduction>1</mechanicalReduction>
  </actuator>
 </transmission>

An the plugin like this:

<gazebo>
  <plugin filename="libgazebo_ros_control.so" name="ros_control"
   <robotNamespace>/test_1_urdf</robotNamespace>
   <robotParam>robot_description</robotParam>
   <controlPeriod>0.001</controlPeriod>
   <robotSimType>gazebo_ros_control/DefaultRobotHWSim</robotSimType
   <legacyModeNS>true</legacyModeNS>
  </plugin>    
</gazebo>

Maybe the most important part is the robotSimType param since you are using Gazebo.

Asked by Weasfas on 2020-07-15 06:21:16 UTC

Hi Weasfas, I try your code also but same error is coming. That is transmission in not loaded in the gazebo.

Asked by Khule on 2020-07-15 13:52:54 UTC

Answers

Hi @Khule,

I will post this as an answer since to not have a cap in the max characters.

I took the liberty of using/modifying your files in order to solve the problem and I came up with this solution. In my last comment I said that the problem maybe the transmissions:

<transmission name="trans_1">
  <type>transmission_interface/SimpleTransmission</type>
  <joint name="joint_1">
    <hardwareInterface>hardware_interface/VelocityJointInterface</hardwareInterface>
  </joint>
  <actuator name="motor_1">
    <mechanicalReduction>1</mechanicalReduction>
  </actuator>
 </transmission>

And that is technicaally not true since the proper definition seems to be:

<transmission name="tran1">
  <type>transmission_interface/SimpleTransmission</type>
  <joint name="joint_1">
    <hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>
  </joint>
  <actuator name="motor1">
    <hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>
    <mechanicalReduction>1</mechanicalReduction>
  </actuator>
</transmission>

At least with the effort controllers, I used in the past the velocity ones and I did not need the hardwareInterface on the actuator part. In fact the official documentation says that the tag should be placed only in the joint but from my experience with your description if you do that the joint_state_controller is unable to produce a proper tf tree and ROS_control will not work since that tree is broken.

For this reason what I have done is properly instantiated new transmission, tidy up your description and provide full proper configuration and launchers. So I will post here all this files and hope this can help you.

The description should look like this:

<?xml version="1.0"?>
<!-- This URDF was automatically created by SolidWorks to URDF Exporter! Originally created by Stephen Brawner (brawner@gmail.com) 
     Commit Version: 1.5.1-0-g916b5db  Build Version: 1.5.7152.31018
     For more information, please see http://wiki.ros.org/sw_urdf_exporter -->
<robot name="test_1_urdf">
  <link name="world"/>

  <joint name="fixed" type="fixed">
    <parent link="world"/>
    <child link="base_link"/>
  </joint>

  <link name="base_link">
    <inertial>
      <origin xyz="0.026901 0.024709 -0.0098697" rpy="0 0 0" />
      <mass value="0.34742" />
      <inertia
        ixx="0.00046368" ixy="-2.9001E-06" ixz="-3.7543E-19"
        iyy="0.0010571"  iyz="-5.1522E-19" izz="0.00076443" />
    </inertial>
    <visual>
      <origin xyz="0 0 0" rpy="0 0 0" />
      <geometry>
        <mesh filename="package://test_1_urdf/meshes/base_link.STL" />
      </geometry>
      <material name="base_link_material">
        <color rgba="0.79216 0.81961 0.93333 1" />
      </material>
    </visual>
    <collision>
      <origin xyz="0 0 0" rpy="0 0 0" />
      <geometry>
        <mesh filename="package://test_1_urdf/meshes/base_link.STL" />
      </geometry>
    </collision>
  </link>

  <joint name="joint_1" type="revolute">
    <origin xyz="0 0.01 0" rpy="1.5708 0 0" />
    <parent link="base_link" />
    <child link="link_1" />
    <axis xyz="0 1 0" />
    <limit lower="-1.57" upper="1.57" effort="10" velocity="1" />
  </joint>

  <link name="link_1">
    <inertial>
      <origin xyz="-0.033996 0.053779 0.0013632" rpy="0 0 0" />
      <mass value="0.62403" />
      <inertia
        ixx="0.00055304" ixy="3.8373E-06"  ixz="1.4793E-07"
        iyy="0.00073956" iyz="-2.5812E-09" izz="0.00076923" />
    </inertial>
    <visual>
      <origin xyz="0 0 0" rpy="0 0 0" />
      <geometry>
        <mesh filename="package://test_1_urdf/meshes/link_1.STL" />
      </geometry>
      <material name="link_1_material">
        <color rgba="0.79216 0.81961 0.93333 1" />
      </material>
    </visual>
    <collision>
      <origin xyz="0 0 0" rpy="0 0 0" />
      <geometry>
        <mesh filename="package://test_1_urdf/meshes/link_1.STL" />
      </geometry>
    </collision>
  </link>

  <joint name="joint_2" type="revolute">
    <origin xyz="-0.085 0.15 0" rpy="-1.5708 0 1.5365" />
    <parent link="link_1" />
    <child link="link_2" />
    <axis xyz="0 1 0" />
    <limit lower="-1.57" upper="1.57" effort="10" velocity="1" />
  </joint>

  <link name="link_2">
    <inertial>
      <origin xyz="0.093132 -0.0072567 0.0031795" rpy="0 0 0" />
      <mass value="0.66404" />
      <inertia
        ixx="0.0005867" ixy="3.2043E-20" ixz="-0.00010232"
        iyy="0.0033357" iyz="-9.491E-19" izz="0.003555" />
    </inertial>
    <visual>
      <origin xyz="0 0 0" rpy="0 0 0" />
      <geometry>
        <mesh filename="package://test_1_urdf/meshes/link_2.STL" />
      </geometry>
      <material name="link_2_material">
        <color rgba="0.79216 0.81961 0.93333 1" />
      </material>
    </visual>
    <collision>
      <origin xyz="0 0 0" rpy="0 0 0" />
      <geometry>
        <mesh filename="package://test_1_urdf/meshes/link_2.STL" />
      </geometry>
    </collision>
  </link>

  <joint name="joint_3" type="revolute">
    <origin xyz="0.35479 -0.04038 0.012185" rpy="1.5708 0.034331 3.1416" />
    <parent link="link_2" />
    <child link="link_3" />
    <axis xyz="0 0 1" />
    <limit lower="-1.57" upper="1.57" effort="10" velocity="1" />
  </joint>

  <link name="link_3">
    <inertial>
      <origin xyz="6.1402E-05 1.9818E-05 -0.076313" rpy="0 0 0" />
      <mass value="0.12484" />
      <inertia 
        ixx="9.6476E-05" ixy="1.9635E-10" ixz="2.755E-07"
        iyy="7.9833E-05" iyz="8.8918E-08" izz="4.1182E-05" />
    </inertial>
    <visual>
      <origin xyz="0 0 0" rpy="0 0 0" />
      <geometry>
        <mesh filename="package://test_1_urdf/meshes/link_3.STL" />
      </geometry>
      <material name="link_3_material">
        <color rgba="0.79216 0.81961 0.93333 1" />
      </material>
    </visual>
    <collision>
      <origin xyz="0 0 0" rpy="0 0 0" />
      <geometry>
        <mesh filename="package://test_1_urdf/meshes/link_3.STL" />
      </geometry>
    </collision>
  </link>

  <joint name="joint_4" type="revolute">
    <origin xyz="0 0 -0.1225" rpy="1.5708 0.73625 -1.5708" />
    <parent link="link_3" />
    <child link="link_4" />
    <axis xyz="0 0 1" />
    <limit lower="-1.57" upper="1.57" effort="10" velocity="1" />
  </joint>

  <link name="link_4">
    <inertial>
      <origin xyz="0.0052809 -0.016241 0.12532" rpy="0 0 0" />
      <mass value="0.35413" />
      <inertia
        ixx="0.0016351" ixy="1.9393E-05" ixz="-0.0002487"
        iyy="0.001665"  iyz="0.00010111" izz="0.00029855" />
    </inertial>
    <visual>
      <origin xyz="0 0 0" rpy="0 0 0" />
      <geometry>
        <mesh filename="package://test_1_urdf/meshes/link_4.STL" />
      </geometry>
      <material name="link_4_material">
        <color rgba="0.79216 0.81961 0.93333 1" />
      </material>
    </visual>
    <collision>
      <origin xyz="0 0 0" rpy="0 0 0" />
      <geometry>
        <mesh filename="package://test_1_urdf/meshes/link_4.STL" />
      </geometry>
    </collision>
  </link>

  <joint name="joint_5" type="revolute">
    <origin mxyz="0.00014009 0.00012696 0.2605" mrpy="3.1416 0 2.307" />
    <parent link="link_4" />
    <child link="link_5" />
    <axis xyz="1 0 0" />
    <limit lower="-1.57" upper="1.57" effort="10" velocity="1" />
  </joint>

  <link name="link_5">
    <inertial>
      <origin xyz="0.000764 -1.3878E-17 -0.00069468" rpy="0 0 0" />
      <mass value="0.049859" />
      <inertia
        ixx="1.0433E-05" ixy="1.5128E-19" ixz="1.8054E-07"
        iyy="2.2582E-05" iyz="7.9112E-21" izz="2.5114E-05" />
    </inertial>
    <visual>
      <origin xyz="0 0 0" rpy="0 0 0" />
      <geometry>
        <mesh filename="package://test_1_urdf/meshes/link_5.STL" />
      </geometry>
      <material name="link_5_material">
        <color rgba="0.79216 0.81961 0.93333 1" />
      </material>
    </visual>
    <collision>
      <origin xyz="0 0 0" rpy="0 0 0" />
      <geometry>
        <mesh filename="package://test_1_urdf/meshes/link_5.STL" />
      </geometry>
    </collision>
  </link>

  <!--adding transmission tag -->
  <transmission name="tran1">
    <type>transmission_interface/SimpleTransmission</type>
    <joint name="joint_1">
      <hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>
    </joint>
    <actuator name="motor1">
      <hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>
      <mechanicalReduction>1</mechanicalReduction>
    </actuator>
  </transmission>

  <transmission name="tran2">
    <type>transmission_interface/SimpleTransmission</type>
    <joint name="joint_2">
      <hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>
    </joint>
    <actuator name="motor2">
      <hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>
      <mechanicalReduction>1</mechanicalReduction>
    </actuator>
  </transmission>

  <transmission name="tran3">
    <type>transmission_interface/SimpleTransmission</type>
    <joint name="joint_3">
      <hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>
    </joint>
    <actuator name="motor3">
      <hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>
      <mechanicalReduction>1</mechanicalReduction>
    </actuator>
  </transmission>

  <transmission name="tran4">
    <type>transmission_interface/SimpleTransmission</type>
    <joint name="joint_4">
      <hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>
    </joint>
    <actuator name="motor4">
      <hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>
      <mechanicalReduction>1</mechanicalReduction>
    </actuator>
  </transmission>

  <transmission name="tran5">
    <type>transmission_interface/SimpleTransmission</type>
    <joint name="joint_5">
      <hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>
    </joint>
    <actuator name="motor5">
      <hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>
      <mechanicalReduction>1</mechanicalReduction>
    </actuator>
  </transmission>

  <gazebo>
      <plugin name="gazebo_ros_control" filename="libgazebo_ros_control.so">
        <robotNamespace>/test_1_urdf</robotNamespace>
        <robotParam>robot_description</robotParam>
        <controlPeriod>0.001</controlPeriod>
        <robotSimType>gazebo_ros_control/DefaultRobotHWSim</robotSimType>
        <legacyModeNS>true</legacyModeNS>
      </plugin>
  </gazebo>

</robot>

I have only changed the position of several tag and params as well as the transmissions. Finally please note the properrobot_namespace for your robot name in the gazebo_ros_control plugin.

Then you should need proper launchers:

  • For the robot description

<?xml version="1.0"?>

<launch>
  <arg name="vehicle" default="test_1_urdf"/>
  <arg name="sim" default="false"/>
  <arg name="output" default="log"/>

  <!-- Load the URDF into the ROS Parameter Server -->
  <param name="robot_description" textfile="$(find gazebo_test1)/urdf/test_1_urdf.urdf"/>

  <!-- State joints publisher for debug -->
  <node unless="$(arg sim)" name="joint_state_publisher" pkg="joint_state_publisher" type="joint_state_publisher" output="$(arg output)" />

  <!-- Combine joint values -->
  <node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher" output="$(arg output)" />
</launch>
  • For the robot control

<?xml version="1.0"?>

<launch>
  <!-- Coordinates to spawn model -->
  <arg name="x" default="0.0"/>
  <arg name="y" default="0.0"/>
  <arg name="z" default="0.01"/>
  <arg name="roll" default="0.0"/>
  <arg name="pitch" default="0.0"/>
  <arg name="yaw" default="0.0"/>

  <!-- Prefix for links: Multiple vehicles -->
  <arg name="vehicle" default="test_1_urdf"/>
  <arg name="output" default="log"/>

  <!-- Load controllers config file into the ROS Parameter Server -->
  <rosparam file="$(find gazebo_test1)/config/test1_control.yaml" command="load"/>

  <!-- Start controllers -->
  <node name="controller_spawner" pkg="controller_manager" type="spawner" respawn="false"
    output="$(arg output)" args="
    joint_1_position_controller
    joint_2_position_controller
    joint_3_position_controller
    joint_4_position_controller
    joint_5_position_controller
    joint_state_controller"
  />

  <!-- Run a python script to the send a service call to gazebo_ros to spawn a URDF robot -->
  <node name="urdf_spawner" pkg="gazebo_ros" type="spawn_model" respawn="false" output="$(arg output)"
    args="-urdf -model $(arg vehicle) -param robot_description -x $(arg x) -y $(arg y) -z $(arg z) -R $(arg roll) -P $(arg pitch) -Y $(arg yaw)"/>
</launch>
  • An finally to bring up all in Gazebo:

<?xml version="1.0"?>

<launch>
  <arg name="sim" value="true"/>
  <arg name="vehicle" default="test_1_urdf"/>

  <!-- Coordinates to spawn model -->
  <arg name="x" default="0.0"/>
  <arg name="y" default="0.0"/>
  <arg name="z" default="0.05"/>
  <arg name="roll" default="0.0"/>
  <arg name="pitch" default="0.0"/>
  <arg name="yaw" default="0.0"/>

  <!-- Robot description for TF -->
  <group ns="$(arg vehicle)">
    <include file="$(find gazebo_test1)/launch/robot_description.launch">
      <arg name="sim" value="$(arg sim)"/>
      <arg name="vehicle" value="$(arg vehicle)"/>
    </include>
  </group>

  <include file="$(find gazebo_ros)/launch/empty_world.launch"/>

  <!-- Ares Spawner and controllers -->
  <group ns="$(arg vehicle)">
    <include file="$(find gazebo_test1)/launch/robot_control.launch">
      <arg name="x" value="$(arg x)"/>
      <arg name="y" value="$(arg y)"/>
      <arg name="z" value="$(arg z)"/>
      <arg name="roll" value="$(arg roll)"/>
      <arg name="pitch" value="$(arg pitch)"/>
      <arg name="yaw" value="$(arg yaw)"/>
      <arg name="vehicle" value="$(arg vehicle)"/>
    </include>
  </group>

  <!-- Show in Rviz   -->
  <node name="rviz" pkg="rviz" type="rviz" />

</launch>

Please note that if you already use the joint_state_controller you do not need to launch the joint_state_publisher node and that you will need to generate the config and launch folders for your project to store properly these files.

And since we are using the <group> tag to set a namespace for the robot you config file should look like this:

#publish all joint states ------
joint_state_controller:
  type: joint_state_controller/JointStateController
  publish_rate: 50

#position Controllers
joint_1_position_controller:
  type: effort_controllers/JointPositionController
  joint: joint_1
  pid: {p: 100.0 , i: 0.01 , d: 10 }
joint_2_position_controller:
  type: effort_controllers/JointPositionController
  joint: joint_2
  pid: {p: 100.0 , i: 0.01 , d: 10 }
joint_3_position_controller:
  type: effort_controllers/JointPositionController
  joint: joint_3
  pid: {p: 100.0 , i: 0.01 , d: 10 }
joint_4_position_controller:
  type: effort_controllers/JointPositionController
  joint: joint_4
  pid: {p: 100.0 , i: 0.01 , d: 10 }
joint_5_position_controller:
  type: effort_controllers/JointPositionController
  joint: joint_5
  pid: {p: 100.0 , i: 0.01 , d: 10 }

Hope this helps you with the problem.

Regards.

Asked by Weasfas on 2020-07-16 08:10:11 UTC

Comments

Thank you Weasfas. It worked for me finally. I am stuck on that problem for 3 weeks Thank you sooo much Weasfas. I can not able express my gratitude in words. Atlast thank you again.

Asked by Khule on 2020-07-16 13:19:56 UTC

Hi @Khule,

Glad to heard that!

If you do not mind can you check the answer as valid? to let others know that the solution is viable.

Thanks! =)

Asked by Weasfas on 2020-07-16 14:33:13 UTC