0
$\begingroup$

I've created a URDF file using a few Xacro files, and for some reason as soon as I added in the caster wheel it started having problems. The chassis and caster both show up, but the caster just spawns in at the world origin, rather than linked to the chassis. Below has my launch file, and both xacro files (yes I have the state publisher node)

visualize_robot.py

import os
from ament_index_python.packages import get_package_share_directory
from launch import LaunchDescription
from launch_ros.actions import Node
import xacro


def generate_launch_description():

    # Specify the name of the package and path to xacro file within the package
    pkg_name = 'roomba_891'
    file_subpath = 'description/robot_base.urdf.xacro'


    # Use xacro to process the file
    xacro_file = os.path.join(get_package_share_directory(pkg_name),file_subpath)
    robot_description_raw = xacro.process_file(xacro_file).toxml()


    # Configure the node
    node_robot_state_publisher = Node(
        package='robot_state_publisher',
        executable='robot_state_publisher',
        output='screen',
        parameters=[{'robot_description': robot_description_raw}] # add other parameters here if required
    )


    # Run the node
    return LaunchDescription([
        node_robot_state_publisher
    ])

robot_base.urdf.xacro

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


    <link name="world"></link>

    <xacro:include filename="drivebase.xacro"/>


    <joint name="base_joint" type="fixed">
        <origin xyz="0.0 0.0 0.016" rpy="0.0 0.0 0.0"/>
        <parent link="world"/>
        <child link="chassis_link"/>
    </joint>
</robot>

drivebase.xacro

<?xml version="1.0"?>
<robot xmlns:xacro="http://www.ros.org/wiki/xacro">
    <link name="chassis_link">
        <visual>
            <origin xyz="0.0 0.0 0.0375"/>
            <geometry>
                <cylinder radius="0.170" length="0.075"/>
            </geometry>
            <material name="gray">
                <color rgba="0.5 0.5 0.5 1"/>
            </material>
        </visual>
    </link>

    <!-- <link name="left_wheel">
        <visual>
            <origin xyz="0.0 0.0 0.0"/>
            <geometry>
                <cylinder radius="0.0375" length="0.016"/>
                <material>
                    <color rgba="1 0.0 0.0 1"/>
                </material>
            </geometry>
        </visual>
    </link>

    <link name="right_wheel">
        <visual>
            <origin xyz="0.0 0.0 0.0"/>
            <geometry>
                <cylinder radius="0.0375" length="0.016"/>
                <material>
                    <color rgba="1 0.0 0.0 1"/>
                </material>
            </geometry>
        </visual>
    </link> -->

    <link name="caster_wheel">
        <visual>
            <origin xyz="0.0 0.0 0.0"/>
            <geometry>
                <sphere radius="0.047"/>
            </geometry>
            <material name="white">
                <color rgba="1.0 1.0 1.0 1.0"/>
            </material>
        </visual>
    </link>

    <joint name="caster_joint" type="continuous">
        <parent link="chassis_link"/>
        <child link="caster_wheel"/>
    
        <origin xyz="0.129 0.0 0.0" rpy="0.0 0.0 0.0"/>
        <axis xyz="0.0 1.0 0.0"/>
    </joint>
</robot>
```
$\endgroup$

1 Answer 1

1
$\begingroup$

I was unaware that you're required to be publishing the joint states, they wont just default to zero.

$\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.