ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

[ERROR] [launch]: Caught exception in launch (see debug for traceback): Caught exception when trying to load file of format [py]: not well-formed (invalid token): line 5, column 30

asked 2023-02-15 19:12:53 -0500

Sumukha gravatar image

Hi, There is some error in launch file, could someone help me with this.

rsp.launch.py:

import os

from ament_index_python.packages import get_package_share_directory

from launch import LaunchDescription

from launch.substitutions import LaunchConfiguration

from launch.actions import DeclareLaunchArgument

from launch_ros.actions import Node
import xacro

def generate_launch_description():

    # Check if we're told to use sim time
    use_sim_time = LaunchConfiguration('use_sim_time')

    # Process the URDF file
    pkg_path = os.path.join(get_package_share_directory('my_bot'))
    xacro_file = os.path.join(pkg_path,'description','robot.urdf.xacro')
    robot_description_config = xacro.process_file(xacro_file)

    # Create a robot_state_publisher node
    params = {'robot_description': robot_description_config.toxml(), 'use_sim_time': use_sim_time}
    node_robot_state_publisher = Node(
        package='robot_state_publisher',
        executable='robot_state_publisher',
        output='screen',
        parameters=[params]
    )


    # Launch!
    return LaunchDescription([
        DeclareLaunchArgument(
            'use_sim_time',
            default_value='false',
            description='Use sim time if true'),

        node_robot_state_publisher
    ])

robot_core.xecro:

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

    <material name="white">
        <color rgba="1 1 1 1"/ >
    </material>

    <material name="orange">
        <color rgba="1 0.3 0.1 1"/ >
    </material>

    <material name="blue">
        <color rgba="0.2 0.2 1 1"/ >
    </material>

    <material name="black">
        <color rgba="0 0 0 1"/ >
    </material>

    <link name="base_link">

    </link>

    <joint name="chassis_joint" type="fixed">
        <parent link="base_link"/>
        <child link="chassis"/>
        <origin xyz="-0.1 0 0"/>
    </joint>

    <link name="chassis">
        <visual>
           <origin xyz="0.15 0 0.75"/>
           <geometry>
             <box size="0.3 0.3 0.15"/>
           <geometry>
           <material name="white"/>
        </visual>
    </link>

</robot>

robot.urdf.xecro file:

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

    <xacro:include filename="robot_core.xacro" />
</robot>
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2023-02-16 06:50:43 -0500

Ranjit Kathiriya gravatar image

updated 2023-02-16 06:54:29 -0500

Hello there,

I think you need to correct your robot_core.xacro file:

<color rgba="1 1 1 1"/ >

Ensure you are not keeping a space while closing the tag between / and >. You need to change this to your full file.

In your Link : chassis

It would help if you closed <geometry> tag you can do so by </geometry>.

I think this should fix the error.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2023-02-15 19:12:53 -0500

Seen: 8,553 times

Last updated: Feb 16 '23