0
$\begingroup$

Rosanswers logo

I'm trying to complete the robot state publisher tutorial, but when I run:

roslaunch myrobot_description myrobot_rviz.launch

Rviz shows no model and in the left-hand panel reports the error "Fixed Frame [map] does not exist".

myrobot.urdf.xarco:

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

    <xacro:macro name="default_inertial" params="mass">
        <inertial>
                <mass value="${mass}" />
                <inertia
                    ixx="1.0" ixy="0.0" ixz="0.0"
                    iyy="1.0" iyz="0.0" izz="1.0" />
        </inertial>
    </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" />
    
    <!-- mass of a single upper leg piece in kg -->
    <property name="upper_leg_mass" value="0.010" />
    
    <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:default_inertial mass="${torso_mass}"/>
    </link>
    <xacro:macro name="leg" params="name reflect_x reflect_y">
        <link name="${name}">
            <visual>
                <geometry>
                    <box size="0.003 0.04 0.005" />
                </geometry>
                <origin xyz="0 0.04 0" rpy="0 0 0"/>
                <material name="blue" />
            </visual>
            <collision>
                <geometry>
                    <box size="0.003 0.04 0.005" />
                </geometry>
                <origin xyz="0 0.04 0" rpy="0 0 0"/>
            </collision>
            <xacro:default_inertial mass="${upper_leg_mass}"/>
        </link>
        <joint name="torso_to_${name}" type="fixed">
            <parent link="base_link"/>
            <child link="${name}"/>
            <origin xyz="${torso_x_size/2*reflect_x} ${torso_y_size/2*reflect_y} 0" />
            <axis xyz="0 1 0" rpy="0 0 0" />
        </joint>
    </xacro:macro>
    <xacro:leg name="front_right_leg" reflect_x="1" reflect_y="1" />
</robot>

myrobot_rviz.launch:

<launch>
  <param name="robot_description" command="$(find xacro)/xacro.py '$(find myrobot_description)/urdf/myrobot.urdf.xacro'" />
 
  <!-- source that publishes the joint positions as a sensor_msgs/JointState -->
  <param name="use_gui" value="true"/>
  <node name="joint_state_publisher" pkg="joint_state_publisher" type="joint_state_publisher" />
 
  <!-- robot visualization -->
  <node name="rviz" pkg="rviz" type="rviz" required="true" />
 
  <!-- publish all the frames to TF -->
  <node name="robot_state_publisher" pkg="robot_state_publisher" type="state_publisher">
    <param name="publish_frequency" value="50"/> <!-- Hz -->
  </node>
</launch>

I googled that error, and other pages claim the it means there's no base_link defined in my model, but there clearly is. What am I doing wrong?

Edit: I changed my launch file to:

<launch>
    <arg name="model" />
    <arg name="gui" default="True" />
    <param name="robot_description" command="$(find xacro)/xacro.py $(arg model)" />
    <param name="use_gui" value="$(arg gui)"/>
    <node name="joint_state_publisher" pkg="joint_state_publisher" type="joint_state_publisher" />
    <node name="robot_state_publisher" pkg="robot_state_publisher" type="state_publisher">
        <param name="publish_frequency" value="50"/> <!-- Hz -->
    </node>
    <node name="rviz" pkg="rviz" type="rviz" args="-d $(find myrobot_description)/urdf.rviz" required="true" />
</launch>

and now call it like:

roslaunch myrobot_description myrobot_rviz.launch model:='$(find myrobot_description)/urdf/myrobot.urdf.xacro'

and that makes the model show in Rviz, but it doesn't look any different from a the other xacrodisplay launches the tutorial goes over. Is the tutorial incomplete, or am I overlooking some steps? It says I need to have a "source that publishes the joint positions" but doesn't explain how to do that. Is that a a node I have to implement myself?


Originally posted by Cerin on ROS Answers with karma: 940 on 2015-04-26

Post score: 0


Original comments

Comment by gvdhoorn on 2015-04-27:
Would you please open a new question for the issue you added in your last edit? The title of the question is "RViz reporting no fixed frame", your last edit is about something different. That makes it hard to keep answers on-topic and findable.

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

Have you set the Fixed Frame to base_link after RViz has started?


Edit:

I don't understand your question. I posted all my code. As you can see, I have a base_link defined.

The question is whether you have configured RViz correctly. I can see you have a base_link, but if you don't set the Fixed Frame configuration option to base_link, RViz will not know 'where' your TF tree starts, to put it like that.

It renders fine in Rviz when I run the tutorial's other roslaunch examples like roslaunch urdf_tutorial xacrodisplay.launch model:='$(find myrobot_description)/urdf/myrobot.urdf.xacro'

Yes, and that is because the xacrodisplay.launch file instructs RViz to load the urdf_tutorial/urdf.rviz file, which sets the Fixed Frame configuration option to base_link (from xacrodisplay.launch):

<launch>
    ...
    <arg name="rvizconfig" default="$(find urdf_tutorial)/urdf.rviz" />
    ...
    <node name="rviz" pkg="rviz" type="rviz" args="-d $(arg rvizconfig)" required="true" />
</launch>

And from urdf_tutorial/urdf.rviz:

...
  Global Options:
    Background Color: 48; 48; 48
    Fixed Frame: /base_link
...

That option is shown under Global Options in the tree on the left in the main RViz window.


Edit2:

When I changed my rviz tag to point to urdf.rviz, that fixed that error. [..]

Note that you could've just as easily used the dropdown next to Fixed Frame in the RViz window.

Now I see the model, but I still don't see the "Joint State Publisher" dialog shown here. Why is that?

Note that this is unrelated to your initial issue(s). I'm not sure, but it could be a parameter resolution issue. Try making the use_gui parameter private to the joint_state_publisher node (it is the only node using that parameter anyway).


Originally posted by gvdhoorn with karma: 86574 on 2015-04-27

This answer was ACCEPTED on the original site

Post score: 2


Original comments

Comment by Cerin on 2015-04-27:
I don't understand your question. I posted all my code. As you can see, I have a base_link defined. It renders fine in Rviz when I run the tutorial's other roslaunch examples like roslaunch urdf_tutorial xacrodisplay.launch model:='$(find myrobot_description)/urdf/myrobot.urdf.xacro'

Comment by Cerin on 2015-04-27:
Ah, thanks for the edit. That makes sense. When I changed my rviz tag to point to urdf.rviz, that fixed that error. Now I see the model, but I still don't see the "Joint State Publisher" dialog shown here. Why is that?

Comment by Cerin on 2015-04-27:
To clarify, I see "process[joint_state_publisher-2]: started with pid [7581]" in the console, so I think it's running. What effect should that have in Rviz?

Comment by gvdhoorn on 2015-04-27:\

What effect should that have in Rviz?

None. The joint_state_publisher is a stand-alone node. It has no relation to RViz whatsoever.

Comment by Cerin on 2015-04-27:
What do you mean by "private parameter"? I tried replacing the node with <node name="joint_state_publisher" pkg="joint_state_publisher" type="joint_state_publisher"><param name="use_gui" value="true"/></node> but that had no effect.

Comment by gvdhoorn on 2015-04-27:
That should've worked. Are you sure the window isn't hidden behind the RViz window? The joint_state_publisher window is not part of RViz, nor is it a child window.

Comment by Cerin on 2015-04-29:
You're absolutely right. From the screenshot, I thought it was inside the Rviz screen, but it's a separate window. I was on dual monitors, and it's tiny and showed up on a different monitor, so I didn't notice. Thanks.

$\endgroup$

Your Answer

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