1
$\begingroup$

While trying to transfer my robot to the Gazebo environment, I get an error like this:

[ERROR] [1712090101.761754170, 0.341000000]: This robot has a joint named "screw_right_first_2_to_right_first_joint_1" which is not in the gazebo model.
[FATAL] [1712090101.761854037, 0.341000000]: Could not initialize robot simulation interface

I looked at many resources but couldn't find the solution.

My config file is as follows:

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

# Position Controllers ---------------------------------------
right1_position_controller:
  type: effort_controllers/JointPositionController
  joint: screw_right_first_2_to_right_first_joint_1
  pid: {p: 100.0, i: 0.01, d: 10.0}

The relevant part of my xacro model file is as follows:

<!-- Transmissions for ROS Control -->
<xacro:macro name="transmission_block" params="joint_name">
    <transmission name="tran1">
        <type>transmission_interface/SimpleTransmission</type>
        <joint name="${joint_name}">
            <hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>
        </joint>
        <actuator name="motor1">
            <hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>
            <mechanicalReduction>1</mechanicalReduction>
        </actuator>
    </transmission>
</xacro:macro>


<!-- Revolute joints -->
<xacro:transmission_block joint_name="screw_right_first_2_to_right_first_joint_1"/>

<!-- ros_control plugin -->
<gazebo>
    <plugin name="gazebo_ros_control" filename="libgazebo_ros_control.so">
        <robotNamespace>/</robotNamespace>
    </plugin>
</gazebo>

screw_right_first_2_to_right_first_joint_1 is defined at the top of my xacro file for a joint with this name. I even get an error defining this the second time. This way I maintained control. I am giving this part because my code file is too long.

The content of the joint.launch file I created is as follows:

<launch>

  <include file="$(find test_urdf)/launch/gazebo.launch" />
  <rosparam file="$(find test_urdf)/config/joints.yaml" command="load"/>

  
  <!-- load the controllers -->
  <node name="controller_spawner" pkg="controller_manager" type="spawner" respawn="false"
    output="screen" ns="/test_urdf" args="joint_state_controller right1_position_controller"/>

  <!-- 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="/test_urdf/joint_states" />
  </node>

</launch>

The macro I defined as inertial_matrix is as follows:

<!-- Inertial matrix -->
<xacro:macro name="inertial_matrix" params="mass">
    <inertial>
        <origin xyz="0 0 0" rpy="0 0 0" />
        <mass value="${mass}" />
        <inertia ixx="1.0" ixy="0.0" ixz="0.0" iyy="0.5" iyz="0.0" izz="1.0" />
    </inertial>
</xacro:macro>

I added this matrix and collision values to the links.

At the same time, I can view my robot completely in the RVIZ environment. But when it comes to the gazebo environment, unfortunately I cannot view my robot fully.

I checked these codes many times and researched in many places, but unfortunately I could not get any results.

Can you help me?

[EDIT-1]-----

I just realized this:

rostopic echo /test_urdf/joint_states

after running the command "WARNING: no messages received and simulated time is active. Is /clock being published?" I got the error. To solve this, I set the use_sim_time value to false in the gazebo.launch file, but it still didn't work.

[EDIT-2]-----

My robot's xacro file is as follows. Since it was a bit long, I shortened some parts and put "..."

<?xml version="1.0" ?>

<robot name="test_urdf" xmlns:xacro="http://ros.org/wiki/xacro">

    <!-- Inertial matrix -->
    <xacro:macro name="inertial_matrix" params="mass">
        <inertial>
            <origin xyz="0 0 0" rpy="0 0 0" />
            <mass value="${mass}" />
            <inertia ixx="1.0" ixy="0.0" ixz="0.0" iyy="0.5" iyz="0.0" izz="1.0" />
        </inertial>
    </xacro:macro>
    
    <!-- Transmissions for ROS Control -->
    <xacro:macro name="transmission_block" params="joint_name">
        <transmission name="tran1">
            <type>transmission_interface/SimpleTransmission</type>
            <joint name="${joint_name}">
                <hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>
            </joint>
            <actuator name="motor1">
                <hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>
                <mechanicalReduction>1</mechanicalReduction>
            </actuator>
        </transmission>
    </xacro:macro>

    <!-- Legs -->
    <xacro:macro name="leg" params="direction order">

        <link name="base_cyc_${direction}_${order}">
            <visual>
                ...
            </visual>
            <collision>
                ...
            </collision>
            <xacro:inertial_matrix mass="1"/>
        </link>

        <!-- base_link to base_cyc_${direction}_${order}-->
        <joint name="base_link_to_base_cyc_${direction}_${order}" type="fixed">
            <parent link="base_link" />
            <child link="base_cyc_${direction}_${order}" />
            ...
        </joint>

        <link name="screw_${direction}_${order}_1"></link>
        
        <!-- base_link to base_cyc_${direction}_${order}-->
        <joint name="base_cyc_${direction}_${order}_to_screw_${direction}_${order}_1" type="fixed">
            <parent link="base_cyc_${direction}_${order}" />
            <child link="screw_${direction}_${order}_1" />
            ...
        </joint>

        <link name="${direction}_${order}_joint_piece_1">
            <visual>
                ...
            </visual>
            <collision>
                ...
            </collision>
            <xacro:inertial_matrix mass="0.5"/>
        </link>

        <!-- screw_${direction}_${order}_1 to ${direction}_${order}_joint_piece_1-->
        <joint name="screw_${direction}_${order}_1_to_${direction}_${order}_joint_piece_1" type="fixed">
            <parent link="screw_${direction}_${order}_1" />
            <child link="${direction}_${order}_joint_piece_1" />
            ...
        </joint>

        <link name="screw_${direction}_${order}_2"></link>

        <!-- ${direction}_${order}_joint_piece_1 to screw_${direction}_${order}_2-->
        <joint name="${direction}_${order}_joint_piece_1_to_screw_${direction}_${order}_2" type="fixed">
            <parent link="${direction}_${order}_joint_piece_1" />
            <child link="screw_${direction}_${order}_2" />
            ...
        </joint>

        <link name="${direction}_${order}_joint_1">
            <visual>
                ...
            </visual>
            <collision>
                ...
            </collision>
            <xacro:inertial_matrix mass="0.5"/>
        </link>
        
        <!-- screw_${direction}_${order}_2 to ${direction}_${order}_joint_1 -->
        <joint name="screw_${direction}_${order}_2_to_${direction}_${order}_joint_1" type="revolute">
            <parent link="screw_${direction}_${order}_2" />
            <child link="${direction}_${order}_joint_1" />
            ...
        </joint>

        <link name="screw_${direction}_${order}_3"></link>

        <!-- ${direction}_${order}_joint_1 to screw_${direction}_${order}_3-->
        <joint name="${direction}_${order}_joint_1_to_screw_${direction}_${order}_3" type="fixed">
            <parent link="${direction}_${order}_joint_1" />
            <child link="screw_${direction}_${order}_3" />
            ...     
        </joint>

        <link name="${direction}_${order}_joint_2">
            <visual>
                ...
            </visual>
            <collision>
                ...
            </collision>
            <xacro:inertial_matrix mass="0.5"/>
        </link>

        <!-- screw_${direction}_${order}_3 to ${direction}_${order}_joint_2 -->
        <joint name="screw_${direction}_${order}_3_to_${direction}_${order}_joint_2" type="fixed">
            <parent link="screw_${direction}_${order}_3" />
            <child link="${direction}_${order}_joint_2" />
            ...     
        </joint>

        <link name="screw_${direction}_${order}_4"></link>

        <!-- ${direction}_${order}_joint_2 to screw_${direction}_${order}_4 -->
        <joint name="${direction}_${order}_joint_2_to_screw_${direction}_${order}_4" type="revolute">
            <parent link="${direction}_${order}_joint_2" />
            <child link="screw_${direction}_${order}_4" />
            ...
        </joint>

        <link name="${direction}_${order}_joint_piece_2">
            <visual>
                ...
            </visual>
            <collision>
                ...
            </collision>
            <xacro:inertial_matrix mass="0.5"/>
        </link>

        <!-- screw_${direction}_${order}_3 to ${direction}_${order}_joint_piece_2 -->
        <joint name="screw_${direction}_${order}_4_to_${direction}_${order}_joint_piece_2" type="fixed">
            <parent link="screw_${direction}_${order}_4" />
            <child link="${direction}_${order}_joint_piece_2" />
            ...
        </joint>

        <link name="${direction}_${order}_cyc_1">
            <visual>
                ...
            </visual>
            <collision>
                ...
            </collision>
            <xacro:inertial_matrix mass="1"/>
        </link>

        <!-- ${direction}_${order}_joint_piece_2 to  ${direction}_${order}_cyc_1 -->
        <joint name="${direction}_${order}_joint_piece_2_to_${direction}_${order}_joint2" type="fixed">
            <parent link="${direction}_${order}_joint_piece_2" />
            <child link="${direction}_${order}_cyc_1" />
            ...
        </joint>

        <link name="${direction}_${order}_joint_3">
            <visual>
                ...
            </visual>
            <collision>
                ...
            </collision>
            <xacro:inertial_matrix mass="0.5"/>
        </link>

        <!--  ${direction}_${order}_cyc_1 to ${direction}_${order}_joint_3 -->
        <joint name="${direction}_${order}_cyc_1_to_${direction}_${order}_joint_3" type="fixed">
            <parent link="${direction}_${order}_cyc_1" />
            <child link="${direction}_${order}_joint_3" />
            ... 
        </joint>

        <link name="screw_${direction}_${order}_5"></link>

        <!-- ${direction}_${order}_joint_3 to screw_${direction}_${order}_5 -->
        <joint name="${direction}_${order}_joint_3_to_screw_${direction}_${order}_5" type="revolute">
            <parent link="${direction}_${order}_joint_3" />
            <child link="screw_${direction}_${order}_5" />
            ...
        </joint>

        <link name="${direction}_${order}_joint_piece_3">
            <visual>
                ...
            </visual>
            <collision>
                ...
            </collision>
            <xacro:inertial_matrix mass="0.5"/>
        </link>

        <!-- screw_${direction}_${order}_5 to ${direction}_${order}_joint_piece_3 -->
        <joint name="screw_${direction}_${order}_5_to_${direction}_${order}_joint_piece_3" type="fixed">
            <parent link="screw_${direction}_${order}_5" />
            <child link="${direction}_${order}_joint_piece_3" />
            ...
        </joint>

        <link name="${direction}_${order}_cyc_2">
            <visual>
                ...
            </visual>
            <collision>
                ...
            </collision>
            <xacro:inertial_matrix mass="1"/>
        </link>

        <!-- ${direction}_${order}_joint_piece_3 to ${direction}_${order}_cyc_2 -->
        <joint name="${direction}_${order}_joint_piece_3_to_${direction}_${order}_cyc_2" type="fixed">
            <parent link="${direction}_${order}_joint_piece_3" />
            <child link="${direction}_${order}_cyc_2" />
            ... 
        </joint>

        <!-- GAZEBO REFERENCES -->

        <gazebo reference="base_cyc_${direction}_${order}">
            <material>Gazebo/Black</material>
        </gazebo>

        <gazebo reference="${direction}_${order}_joint_piece_1">
            <material>Gazebo/Red</material>
        </gazebo>

        <gazebo reference="${direction}_${order}_joint_1">
            <material>Gazebo/Red</material>
        </gazebo>

        <gazebo reference="${direction}_${order}_joint_2">
            <material>Gazebo/Red</material>
        </gazebo>

        <gazebo reference="${direction}_${order}_joint_piece_2">
            <material>Gazebo/Red</material>
        </gazebo>

        <gazebo reference="${direction}_${order}_cyc_1">
            <material>Gazebo/Black</material>
        </gazebo>

        <gazebo reference="${direction}_${order}_joint_3">
            <material>Gazebo/Red</material>
        </gazebo>

        <gazebo reference="${direction}_${order}_joint_piece_3">
            <material>Gazebo/Red</material>
        </gazebo>

        <gazebo reference="${direction}_${order}_cyc_2">
            <material>Gazebo/Black</material>
        </gazebo>


        <gazebo reference="screw_${direction}_${order}_1"></gazebo>
        <gazebo reference="screw_${direction}_${order}_2"></gazebo>
        <gazebo reference="screw_${direction}_${order}_3"></gazebo>
        <gazebo reference="screw_${direction}_${order}_4"></gazebo>
        <gazebo reference="screw_${direction}_${order}_5"></gazebo>
        
        <!-- Revolute joints -->
        <xacro:transmission_block joint_name="screw_${direction}_${order}_2_to_${direction}_${order}_joint_1"/>
        <xacro:transmission_block joint_name="${direction}_${order}_joint_2_to_screw_${direction}_${order}_4"/>
        <xacro:transmission_block joint_name="${direction}_${order}_joint_3_to_screw_${direction}_${order}_5"/>

    </xacro:macro>

    <!-- base_link -->
    <link name="base_link">
        <visual>
           ...
        </visual>
        <collision>
           ...
        </collision>
        <xacro:inertial_matrix mass="6"/>
    </link>

    <!-- LEGS -->
    <xacro:leg direction="right" order="first" />

    <gazebo reference="base_link">
        <material>Gazebo/Green</material>
    </gazebo>

    <!-- ros_control plugin -->
    <gazebo>
        <plugin name="gazebo_ros_control" filename="libgazebo_ros_control.so">
            <robotNamespace>/</robotNamespace>
        </plugin>
    </gazebo>
    
</robot>

[EDIT-3]-----

The tf trees I obtained when running robot_description files in the Gazebo and RVIZ environment are as follows. When you run it in Gazebo environment, the tf tree structure is broken.enter image description here

enter image description here

[EDIT-4]-----

I'm still trying to fix the error and I still can't see where I made a mistake. In the xacro file;

<joint name="screw_${direction}_${order}_2_to_${direction}_${order}_joint_1" type="revolute">
    <parent link="screw_${direction}_${order}_2" />
    <child link="${direction}_${order}_joint_1" />
    ...
</joint>

When you change it like this:

<joint name="screw_${direction}_${order}_2_to_${direction}_${order}_joint_1" type="fixed">
    <parent link="screw_${direction}_${order}_2" />
    <child link="${direction}_${order}_joint_1" />
    ...
</joint>

I noticed that my entire robot is in the Gazebo environment, but the same error (This robot has a joint named "screw_right_first_2_to_right_first_joint_1" which is not in the gazebo model) still persists.

I changed the joint type from revolute to fixed.

$\endgroup$
13
  • 1
    $\begingroup$ read the error messsge and then read the xacro file ... the two are not the same $\endgroup$
    – jsotola
    Apr 2 at 23:48
  • $\begingroup$ better still do a search for screw_right_second_2_to_right_second_joint_1 on this webpage $\endgroup$
    – jsotola
    Apr 2 at 23:50
  • $\begingroup$ Even though I read the xacro file many times, I could not catch the error specifically. I have searched this web page many times. Although I found similar errors and examined them, unfortunately I did not correct them. $\endgroup$
    – furkan
    Apr 3 at 5:15
  • $\begingroup$ no, you are not understanding... I did not say this website ... I said this webpage that you are looking at right now as you read this comment $\endgroup$
    – jsotola
    Apr 3 at 5:30
  • $\begingroup$ you will find that there is no screw_right_second_2_to_right_second_joint_1 in the xacto file you presented $\endgroup$
    – jsotola
    Apr 3 at 5:58

1 Answer 1

1
$\begingroup$

Finally I managed to solve the problem. In other projects, I get the correct output without adding inertial matrix to empty links. Even though I couldn't understand it, I solved the problem by adding inertial matrix as follows.

Old

<link name="screw_${direction}_${order}_1">

</link>

New

<link name="screw_${direction}_${order}_1">
    <xacro:inertial_matrix mass="0.5"/>
</link>
$\endgroup$

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.