0
$\begingroup$

Rosanswers logo

I'm trying to follow the Gazebo ROS Control tutorial but when I run the line:

roslaunch myrobot_gazebo myrobot_world.launch

I get the error output:

[ INFO] [1430582458.651473605]: Finished loading Gazebo ROS API Plugin.
[ INFO] [1430582458.655485962]: waitForService: Service [/gazebo/set_physics_properties] has not been advertised, waiting...
spawn_model script started
[INFO] [WallTime: 1430582458.938102] [0.000000] Loading model xml from ros parameter
[INFO] [WallTime: 1430582458.941118] [0.000000] Waiting for service /gazebo/spawn_urdf_model
[ INFO] [1430582459.741922815, 0.023000000]: waitForService: Service [/gazebo/set_physics_properties] is now available.
[ INFO] [1430582459.819138448, 0.096000000]: Physics dynamic reconfigure ready.
[INFO] [WallTime: 1430582459.855947] [0.132000] Calling service /gazebo/spawn_urdf_model
[INFO] [WallTime: 1430582460.083841] [0.295000] Spawn status: SpawnModel: Successfully spawned model
[ INFO] [1430582460.118077443, 0.295000000]: Loading gazebo_ros_control plugin
[ INFO] [1430582460.118570188, 0.295000000]: Starting gazebo_ros_control plugin in namespace: /myrobot
[ INFO] [1430582460.120080182, 0.295000000]: gazebo_ros_control plugin is waiting for model URDF in parameter [/robot_description] on the ROS param server.
[ERROR] [1430582460.223045545, 0.295000000]: No valid hardware interface element found in joint 'torso_to_front_right_leg_joint'.
[ERROR] [1430582460.223576289, 0.295000000]: Failed to load joints for transmission 'torso_to_front_right_leg_joint_trans'.
[ INFO] [1430582460.363040693, 0.295000000]: Loaded gazebo_ros_control.
[urdf_spawner-3] process has finished cleanly
log file: /home/chris/.ros/log/6b610a90-f0e4-11e4-bb58-001c1091e5ab/urdf_spawner-3*.log
[ERROR] [1430582476.852961975, 16.562000000]: Exception thrown while initializing controller torso_to_front_right_leg_joint_position_controller.
Could not find resource 'torso_to_front_right_leg_joint' in 'hardware_interface::EffortJointInterface'.
[ERROR] [1430582476.853310724, 16.563000000]: Initializing controller 'torso_to_front_right_leg_joint_position_controller' failed

My robot's urdf is just a single box "torso" with a single box "leg", and all the joints and interfaces and transmissions are defined:

<?xml version="1.0"?>
<robot name="myrobot"
    xmlns:xacro="http://www.ros.org/wiki/xacro">

    <xacro:macro name="box_inertia" params="mass x y z">
        <inertia
            ixx="${mass*(y*y+z*z)/12}" ixy="0" ixz="0"
            iyy="${mass*(x*x+z*z)/12}" iyz="0" izz="${mass*(x*x+z*z)/12}" /> 
    </xacro:macro>
    
    <xacro:include filename="$(find myrobot_description)/urdf/materials.urdf.xacro" />
    
    <!-- width in meters -->
    <property name="torso_x_size" value="0.1" />
    
    <!-- length in meters -->
    <property name="torso_y_size" value="0.205" />
    
    <!-- height in meters -->
    <property name="torso_z_size" value="0.03" />
    
    <!-- torso mass (not including legs) in kg -->
    <property name="torso_mass" value="0.920" />

    <!-- distance from ground to shoulders when standing at full height -->
    <property name="total_leg_height" value="0.158" />
        
    <!-- mass of a single upper leg piece in kg -->
    <property name="upper_leg_mass" value="0.010" />
    
    <property name="upper_leg_depth" value="0.003" />
    <property name="upper_leg_length" value="0.04" />
    <property name="upper_leg_thickness" value="0.005" />
    
    <link name="base_footprint">
        <visual>
            <origin xyz="0 0 0" rpy="0 0 0" />
            <geometry>
                <box size="0.001 0.001 0.001" />
            </geometry>
        </visual>
        <inertial>
            <mass value="0.0001" />
            <origin xyz="0 0 0" />
            <inertia
                ixx="0.0001" ixy="0.0" ixz="0.0"
                iyy="0.0001" iyz="0.0" izz="0.0001" />
        </inertial>
    </link>
    <gazebo reference="base_footprint">
        <turnGravityOff>false</turnGravityOff>
    </gazebo>
    
    <joint name="base_footprint_joint" type="fixed">
        <origin xyz="0 0 ${total_leg_height}" rpy="0 0 0" />
        <parent link="base_footprint"/>
        <child link="base_link" />
    </joint>
  
    <link name="base_link">
        <visual>
            <geometry>
                <box size="${torso_x_size} ${torso_y_size} ${torso_z_size}" />
            </geometry>
            <material name="red"/>
        </visual>
        <collision>
            <geometry>
                <box size="${torso_x_size} ${torso_y_size} ${torso_z_size}" />
            </geometry>
        </collision>
        <xacro:box_inertia
            mass="${torso_mass}"
            x="${torso_x_size}" y="${torso_y_size}" z="${torso_z_size}" />
    </link>
    <gazebo reference="base_link">
        <material>Gazebo/Red</material>
        <turnGravityOff>false</turnGravityOff>
    </gazebo>
    
    <xacro:macro name="leg" params="name reflect_x reflect_y">
        <link name="${name}">
            <visual>
                <geometry>
                    <box size="${upper_leg_depth} ${upper_leg_length} ${upper_leg_thickness}" />
                </geometry>
                <origin xyz="${upper_leg_depth/2*reflect_x} ${upper_leg_length/2} 0" rpy="0 0 0"/>
                <material name="blue" />
            </visual>
            <collision>
                <geometry>
                    <box size="${upper_leg_depth} ${upper_leg_length} ${upper_leg_thickness}" />
                </geometry>
                <origin xyz="${upper_leg_depth/2*reflect_x} ${upper_leg_length/2} 0" rpy="0 0 0"/>
            </collision>
            <xacro:box_inertia
                mass="${upper_leg_mass}"
                x="${upper_leg_depth}" y="${upper_leg_length}" z="${upper_leg_thickness}" />
        </link>
        <gazebo reference="${name}">
            <mu1 value="1.0"/>
            <mu2 value="1.0"/>
            <kp  value="10000000.0" />
            <kd  value="1.0" />
            <fdir1 value="1 0 0"/>
            <material>Gazebo/Blue</material>
            <turnGravityOff>false</turnGravityOff>
        </gazebo>
        <joint name="torso_to_${name}_joint" type="continuous">
            <parent link="base_link"/>
            <child link="${name}"/>
            <origin xyz="${(torso_x_size/2)*reflect_x} ${torso_y_size/2*reflect_y} ${-torso_z_size*0.25}" />
            <axis xyz="1 0 0" rpy="0 0 0" />
            <limit effort="100" velocity="100"/>
            <joint_properties damping="0.0" friction="0.0"/>
        </joint>
        <transmission name="torso_to_${name}_joint_trans">
            <type>transmission_interface/SimpleTransmission</type>
            <joint name="torso_to_${name}_joint" />
            <actuator name="torso_to_${name}_joint_motor">
                <hardwareInterface>EffortJointInterface</hardwareInterface>
                <mechanicalReduction>1</mechanicalReduction>
            </actuator>
        </transmission>
    </xacro:macro>
    
    <xacro:leg name="front_right_leg" reflect_x="1" reflect_y="1" />
    
    <gazebo>
        <plugin name="gazebo_ros_control" filename="libgazebo_ros_control.so">
            <robotNamespace>/myrobot</robotNamespace>
        </plugin>
    </gazebo>
    
</robot>

myrobot_world.launch:

<launch>
    <!-- these are the arguments you can pass this launch file, for example paused:=true -->
    <arg name="paused" default="false"/>
    <arg name="use_sim_time" default="true"/>
    <arg name="gui" default="true"/>
    <arg name="headless" default="false"/>
    <arg name="debug" default="false"/>
    <!-- We resume the logic in empty_world.launch, changing only the name of the world to be launched -->
    <include file="$(find gazebo_ros)/launch/empty_world.launch">
        <arg name="world_name" value="$(find myrobot_gazebo)/worlds/empty.world"/>
        <arg name="debug" value="$(arg debug)" />
        <arg name="gui" value="$(arg gui)" />
        <arg name="paused" value="$(arg paused)"/>
        <arg name="use_sim_time" value="$(arg use_sim_time)"/>
        <arg name="headless" value="$(arg headless)"/>
    </include>
    <!-- Load the URDF into the ROS Parameter Server -->
    <param name="robot_description"
        command="$(find xacro)/xacro.py '$(find myrobot_description)/urdf/myrobot.urdf.xacro'" />
    <!-- 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="screen"
    args="-urdf -model myrobot -param robot_description"/>
    <!-- ros_control myrobot launch file -->
    <!--include file="$(find myrobot_control)/launch/myrobot_control.launch" /-->
</launch>

However, Gazebo only renders the torso and not the leg, and complains about "torso_to_front_right_leg_joint" not existing, even though it's clearly defined in my URDF. Why is this?

Edit: Based on this question, I found that this is actually a bug/typo in the tutorial, which tells you to specify transmissions like:

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

which is incorrect, as they actually need to be defined like:

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

That fixes the first error, but now I get a different error:

This robot has a joint named "torso_to_front_right_leg_joint" which is not in the gazebo model.

What does it mean by "not in the gazebo model"? Is this why the leg is still not showing up in Gazebo?

I realize I don't have a tag for my joints, but the Gazebo ROS tutorial claims that these are optional for joints. Is this incorrect? Even if I add:

<gazebo reference="torso_to_${name}_joint">
</gazebo>

I still get the same error.


Originally posted by Cerin on ROS Answers with karma: 940 on 2015-05-02

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

Turns out the problem was the location of my tags. The Gazebo tutorial lead me to believe that:

An element within each

element must be properly specified and configured.

This is, at best, ambiguously worded. The tag must not be directly inside your link. I only got it to work after I added an <inertial><inertia ...></inertial> tag inside all my links.


Originally posted by Cerin with karma: 940 on 2015-05-02

This answer was ACCEPTED on the original site

Post score: 0


Original comments

Comment by gvdhoorn on 2015-05-03:
It's probably a good idea to update the tutorial, or at the very least report this to the Gazebo people.

$\endgroup$

Your Answer

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