urdfのテスト

testbot.urdf

<?xml version="1.0" ?>
<robot name="testbot">
    <material name="black">
        <color rgba="0.0 0.0 0.0 1.0"/>
    </material>
    <material name="orange">
        <color rgba="1.0 0.4 0.0 1.0"/> 
    </material>

    <link name="base"/>
    <joint name="fixed" type="fixed">
        <parent link="base"/>
        <child link="link1"/> 
    </joint>

    <link name="link1"> 
        <collision>
            <origin xyz="0 0 0.25" rpy="0 0 0"/>
            <geometry>
                <box size="0.1 0.1 0.5"/> 
            </geometry>
        </collision> 
        <visual>
            <origin xyz="0 0 0.25" rpy="0 0 0"/> 
            <geometry>
                <box size="0.1 0.1 0.5"/> 
            </geometry>
            <material name="black"/>
        </visual> 
        <inertial>
            <origin xyz="0 0 0.25" rpy="0 0 0"/> 
            <mass value="1" />
            <inertia ixx="1.0" ixy="0.0" ixz="0.0" iyy="1.0" iyz="0.0" izz="1.0" />
        </inertial> 
    </link>

    <joint name="joint1" type="revolute"> 
        <parent link="link1"/>
        <child link="link2"/>
        <origin xyz="0 0 0.5" rpy="0 0 0"/> 
        <axis xyz="0 0 1"/>
        <limit effort="30" lower="-2.617" upper="2.617" velocity="1.571"/> 
    </joint>

    <link name="link2"> 
        <collision>
            <origin xyz="0 0 0.25" rpy="0 0 0"/> 
            <geometry>
                <box size="0.1 0.1 0.5"/> 
            </geometry>
        </collision>
        <visual>
            <origin xyz="0 0 0.25" rpy="0 0 0" />
            <geometry>
                <box size="0.1 0.1 0.5" />
            </geometry>
            <material name="orange" />
        </visual>
        <inertial>
            <origin xyz="0 0 0.25" rpy="0 0 0"/>
            <mass value="1" />
            <inertia ixx="1.0" ixy="0.0" ixz="0.0" iyy="1.0" iyz="0.0" izz="1.0" />
        </inertial>
    </link>

    <joint name="joint2" type="revolute">
        <parent link="link2"/>
        <child link="link3" />
        <origin xyz="0 0 0.5" rpy="0 0 0"/>
        <axis xyz="0 1 0"/>
        <limit effort="30" lower="-2.617" upper="2.617" velocity="1.571" />
    </joint>

    <link name="link3">
        <collision>
            <origin xyz="0 0 0.5" rpy="0 0 0" />
            <geometry>
                <box size="0.1 0.1 1" />
            </geometry>
        </collision>
        <visual>
            <origin xyz="0 0 0.5" rpy="0 0 0" />
            <geometry>
                <box size="0.1 0.1 1" />
            </geometry>
            <material name="black" />
        </visual>
        <inertial>
            <origin xyz="0 0 0.5" rpy="0 0 0" />
            <mass value="1" />
            <inertia ixx="1.0" ixy="0.0" ixz="0.0" iyy="0.0" iyz="0.0" izz="1.0" />
        </inertial>
    </link>
    
    <joint name="joint3" type="revolute">
        <parent link="link3"/>
        <child link="link4"/>
        <origin xyz="0 0 1.0" rpy="0 0 0"/>
        <axis xyz="0 1 0"/>
        <limit effort="30" lower="-2.617" upper="2.617" velocity="1.571" />
    </joint>

    <link name="link4">
        <collision>
            <origin xyz="0 0 0.25" rpy="0 0 0" />
            <geometry>
                <box size="0.1 0.1 0.5" />
            </geometry>
        </collision>
        <visual>
            <origin xyz="0 0 0.25" rpy="0 0 0" />
            <geometry>
                <box size="0.1 0.1 0.5" />
            </geometry>
            <material name="orange" />
        </visual>
        <inertial>
            <origin xyz="0 0 0.25" rpy="0 0 0" />
            <mass value="1" />
            <inertia ixx="1.0" ixy="0.0" ixz="0.0" iyy="1.0" iyz="0.0" izz="1.0" />
        </inertial>
    </link>

</robot>
$ urdf_to_graphiz testbot.urdf

f:id:seinzumtode:20201123220541p:plain

launch/testbot.launch

<launch>
<arg name="model" default="$(find testbot_description)/urdf/testbot.urdf" />
<arg name="gui" default="True" />
<param name="robot_description" textfile="$(arg model)" /> 
<param name="use_gui" value="$(arg gui)"/>
<node pkg="joint_state_publisher" type="joint_state_publisher"
  name="joint_state_publisher" />
<node pkg="robot_state_publisher" type="robot_state_publisher"
  name="robot_state_publisher" />
</launch>

起動
$ roslaunch testbot_description testbot.launch
$ rviz

f:id:seinzumtode:20201123222137p:plain


GitHubレポジトリに上がっていた
github.com

上のGitHubをそのまま実行すると以下のエラーがでるので、testbot.launch内のstate_publisherをrobot_state_publisherに変更する
ERROR: cannot launch node of type [robot_state_publisher/state_publisher]: Cannot locate node of type [state_publisher] in package [robot_state_publisher]. Make sure file exists in package path and permission is set to executable (chmod +x)