0
$\begingroup$

I am trying to develop a simple bot using ROS 2. I created a package called my_rover. when I give

colcon build --packages-select my_rover

it gives this error which i cannot understand..

Starting >>> my_rover
Traceback (most recent call last):1.7s]
  File "<string>", line 1, in <module>
  File "/usr/lib/python3.8/distutils/core.py", line 215, in run_setup
    exec(f.read(), g)
  File "<string>", line 15, in <module>
AttributeError: module 'posixpath' has no attribute 'joint'
--- stderr: my_rover                   
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/colcon_core/executor/__init__.py", line 91, in __call__
    rc = await self.task(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/colcon_core/task/__init__.py", line 93, in __call__
    return await task_method(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/colcon_ros/task/ament_python/build.py", line 51, in build
    setup_py_data = get_setup_data(self.context.pkg, env)
  File "/usr/lib/python3/dist-packages/colcon_core/task/python/__init__.py", line 20, in get_setup_data
    return dict(pkg.metadata[key](env))
  File "/usr/lib/python3/dist-packages/colcon_ros/package_augmentation/ros_ament_python.py", line 57, in getter
    return get_setup_information(
  File "/usr/lib/python3/dist-packages/colcon_python_setup_py/package_identification/python_setup_py.py", line 241, in get_setup_information
    _setup_information_cache[hashable_env] = _get_setup_information(
  File "/usr/lib/python3/dist-packages/colcon_python_setup_py/package_identification/python_setup_py.py", line 288, in _get_setup_information
    result = subprocess.run(
  File "/usr/lib/python3.8/subprocess.py", line 516, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['/usr/bin/python3', '-c', 'import sys;from contextlib import suppress;exec("with suppress(ImportError):    from setuptools.extern.packaging.specifiers    import SpecifierSet");exec("with suppress(ImportError):    from packaging.specifiers import SpecifierSet");from distutils.core import run_setup;dist = run_setup(    \'setup.py\', script_args=(\'--dry-run\',), stop_after=\'config\');skip_keys = (\'cmdclass\', \'distclass\', \'ext_modules\', \'metadata\');data = {    key: value for key, value in dist.__dict__.items()     if (        not key.startswith(\'_\') and         not callable(value) and         key not in skip_keys and         key not in dist.display_option_names    )};data[\'metadata\'] = {    k: v for k, v in dist.metadata.__dict__.items()     if k not in (\'license_files\', \'provides_extras\')};sys.stdout.buffer.write(repr(data).encode(\'utf-8\'))']' returned non-zero exit status 1.
---
Failed   <<< my_rover [1.91s, exited with code 1]
                                
Summary: 0 packages finished [3.25s]
  1 package failed: my_rover
  1 package had stderr output: my_rover
Command '['/usr/bin/python3', '-c', 'import sys;from contextlib import suppress;exec("with suppress(ImportError):    from setuptools.extern.packaging.specifiers    import SpecifierSet");exec("with suppress(ImportError):    from packaging.specifiers import SpecifierSet");from distutils.core import run_setup;dist = run_setup(    \'setup.py\', script_args=(\'--dry-run\',), stop_after=\'config\');skip_keys = (\'cmdclass\', \'distclass\', \'ext_modules\', \'metadata\');data = {    key: value for key, value in dist.__dict__.items()     if (        not key.startswith(\'_\') and         not callable(value) and         key not in skip_keys and         key not in dist.display_option_names    )};data[\'metadata\'] = {    k: v for k, v in dist.metadata.__dict__.items()     if k not in (\'license_files\', \'provides_extras\')};sys.stdout.buffer.write(repr(data).encode(\'utf-8\'))']' returned non-zero exit status 1.

I have python version - 3.8.10 in my machine. How can I resolve this one?

In my_rover package I have these below files

rover.urdf

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

    <link name="chassis">
        <visual>
            <geometry>
                <box size="0.75 0.4 0.15" />
            </geometry>
            <material name="Orange">
                <color rgba="1.0 0.3 0.1 1.0"/>
            </material>
        </visual>
        <collision>
            <geometry>
                <box size="0.75 0.4 0.15" />
            </geometry>
        </collision>
        <inertial>
            <mass value="2"/>
            <inertia ixx="0.04" ixy="0.0" ixz="0.0" iyy="0.17" iyz="0.0" izz="0.25"/>
        </inertial>
    </link>

    <link name="front_right_wheel">
        <visual>
            <geometry>
                <mesh filename="package://my_rover/meshes/right_tire.stl" scale = "0.005 0.005 0.005"/>
            </geometry>
            <material name="Red">
                <color rgba="1.0 0.0 0.0 1.0"/>
            </material>
        </visual>
        <collision>
            <geometry>
                <cylinder radius="0.15" length="0.18"/>
            </geometry>
            <contact_coefficients mu = "1" kp = "1e+13" kd = "1.0"/>
        </collision>
        <inertial>
            <mass value="2"/>
            <inertia ixx="1e-3" ixy="0.0" ixz="0.0" iyy="1e-3" iyz="0.0" izz="1e-3"/>
        </inertial>
    </link>

    <joint name="front_right_wheel_joint" type="continuous">
        <origin xyz="0.2 0.24 0.0" rpy="0.0 0.0 0.0"/>
        <parent link="chassis"/>
        <child link="front_right_wheel"/>
        <axis xyz="0.0 1.0 0.0"/>
  </joint>

    <link name="front_left_wheel">
        <visual>
            <geometry>
                <mesh filename="package://my_rover/meshes/left_tire.stl" scale = "0.005 0.005 0.005"/>
            </geometry>
            <material name="Red">
                <color rgba="1.0 0.0 0.0 1.0"/>
            </material>
        </visual>
        <collision>
            <geometry>
                <cylinder radius="0.15" length="0.18"/>
            </geometry>
            <contact_coefficients mu = "1" kp = "1e+13" kd = "1.0"/>
        </collision>
        <inertial>
            <mass value="2"/>
            <inertia ixx="1e-3" ixy="0.0" ixz="0.0" iyy="1e-3" iyz="0.0" izz="1e-3"/>
        </inertial>
    </link>

    <joint name="front_left_wheel_joint" type="continuous">
        <origin xyz="0.2 -0.24 0.0" rpy="0.0 0.0 0.0"/>
        <parent link="chassis"/>
        <child link="front_left_wheel"/>
        <axis xyz="0.0 1.0 0.0"/>
  </joint>

    <link name="back_right_wheel">
        <visual>
            <geometry>
                <mesh filename="package://my_rover/meshes/right_tire.stl" scale = "0.005 0.005 0.005"/>
            </geometry>
            <material name="Red">
                <color rgba="1.0 0.0 0.0 1.0"/>
            </material>
        </visual>
        <collision>
            <geometry>
                <cylinder radius="0.15" length="0.18"/>
            </geometry>
            <contact_coefficients mu = "1" kp = "1e+13" kd = "1.0"/>
        </collision>
        <inertial>
            <mass value="2"/>
            <inertia ixx="1e-3" ixy="0.0" ixz="0.0" iyy="1e-3" iyz="0.0" izz="1e-3"/>
        </inertial>
    </link>

    <joint name="back_right_wheel_joint" type="continuous">
        <origin xyz="-0.2 0.24 0.0" rpy="0.0 0.0 0.0"/>
        <parent link="chassis"/>
        <child link="back_right_wheel"/>
        <axis xyz="0.0 1.0 0.0"/>
  </joint>

      <link name="back_left_wheel">
        <visual>
            <geometry>
                <mesh filename="package://my_rover/meshes/left_tire.stl" scale = "0.005 0.005 0.005"/>
            </geometry>
            <material name="Red">
                <color rgba="1.0 0.0 0.0 1.0"/>
            </material>
        </visual>
        <collision>
            <geometry>
                <cylinder radius="0.15" length="0.18"/>
            </geometry>
            <contact_coefficients mu = "1" kp = "1e+13" kd = "1.0"/>
        </collision>
        <inertial>
            <mass value="2"/>
            <inertia ixx="1e-3" ixy="0.0" ixz="0.0" iyy="1e-3" iyz="0.0" izz="1e-3"/>
        </inertial>
    </link>

    <joint name="back_left_wheel_joint" type="continuous">
        <origin xyz="-0.2 -0.24 0.0" rpy="0.0 0.0 0.0"/>
        <parent link="chassis"/>
        <child link="back_left_wheel"/>
        <axis xyz="0.0 1.0 0.0"/>
  </joint>

    <link name="camera">
        <visual>
            <geometry>
                <box size="0.010 0.05 0.05"/>
            </geometry>
            <material name="blue">
                <color rgba="0.0 0.0 1.0 1.0"/>
            </material>
        </visual>
        <collision>
            <geometry>
                <box size="0.010 0.05 0.05"/>
            </geometry>
        </collision>
        <inertial>
            <mass value="0.5" />
            <inertia ixx="0.01" ixy="0.0" ixz="0" 
            iyy="0.01" iyz="0" izz="0.01" />        
        </inertial>
    </link>

    <joint name="camera_joint" type="fixed">
        <parent link="chassis"/>
        <child link="camera"/>
        <origin xyz="0.375 0.0 0.15" rpy="0.0 0.0 3.14"/>
    </joint>

    <link name="lidar">
        <visual>
            <geometry>
                <mesh filename="package://my_rover/meshes/lds.stl" scale="0.002 0.002 0.002"/>            </geometry>
            <material name="LightGrey">
                <color rgba="0.7 0.7 0.7 1.0"/>
            </material>
        </visual>
        <collision>
            <geometry>
                <cylinder radius="0.08" length="0.1"/>
            </geometry>
        </collision>
        <inertial>
            <mass value="0.5"/>
            <inertia ixx="0.01" ixy="0.0" ixz="0.0" iyy="0.01" iyz="0.0" izz="0.01"/>
        </inertial>
    </link>

    <joint name="lodar_joint" type="fixed">
        <parent link="chassis"/>
        <child link="lidar"/>
        <origin xyz="0.2 0 0.25" rpy="0 0 0"/>
    </joint>
</robot>

This my 1_rviz.lauunch.py file

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

def generate_launch_description():
    package_dir = get_package_share_directory('mr_rover')
    urdf = os.path.join(package_dir,'rover.urdf')

    return LaunchDescription([
        Node(
            package='robot_state_publisher',
            executable='robot_state_publisher',
            name='robot_state_publisher',
            output='screen',
            arguments=[urdf]),
        Node(
            package='joint_state_publisher_gui',
            executable='joint_state_publisher_gui',
            name='joint_state_publisher_gui',
            arguments=[urdf]),

        Node(
        package='rviz2',
        executable='rviz2',
        name='rviz2',
        output='screen'),
        

    ])

These are the two files I added after the package created.

And this is setup.py file

from setuptools import setup
import os
from glob import glob
package_name = 'my_rover'

setup(
    name=package_name,
    version='0.0.0',
    packages=[package_name],
    data_files=[
        ('share/ament_index/resource_index/packages',
            ['resource/' + package_name]),
        ('share/' + package_name, ['package.xml']),
        
        (os.path.joint('share', package_name), glob('launch/*.py')),
        (os.path.joint('share', package_name), glob('urdf/*')),
    ],
    install_requires=['setuptools'],
    zip_safe=True,
    maintainer='vasanth',
    maintainer_email='[email protected]',
    description='TODO: Package description',
    license='TODO: License declaration',
    tests_require=['pytest'],
    entry_points={
        'console_scripts': [
        ],
    },
)
$\endgroup$
2
  • $\begingroup$ Welcome to Robotics Stack Exchange! I tried correcting the format of the error but couldn't. Please edit your question and use the "Code Sample" icon shown using {} markers. Thank you for your kind cooperation. $\endgroup$
    – ravi
    Commented Aug 25, 2023 at 13:30
  • $\begingroup$ done. I modified the question using {} markers. $\endgroup$
    – Vasanth
    Commented Aug 25, 2023 at 15:47

1 Answer 1

0
$\begingroup$

The error states that:

AttributeError: module 'posixpath' has no attribute 'joint'

posixpath is a part of the pathlib library. This error comes up when you attempt to access an attribute of a class or import that does not exist: in this case, you've done something like this:

p = Path('./path/to/something')
p.joint

joint is not a valid attribute to ask from Path, and so the error is presented.

You are likely aiming to load the contents of a file at a path, but your code is actually only accessing the path. It's impossible to say exactly without seeing any code or your configuration, but you should take a closer look at how you are returning files: you likely want to return their parsed contents, but you're instead passing simply their path.

EDIT now that the setup.py has been provided:

The problem is in your setup.py, here:

os.path.joint('share', package_name)

and right below it:

os.path.joint('share', package_name)

Notice that you are calling the path module from os, and then you're expecting it to have the attribute joint. path, which in this case is posixpath because you're on a POSIX-compliant system, does not have that attribute.

In short, the module 'posixpath' has no attribute called 'joint'.

Perhaps you meant to call os.path.join() (no t) to join the paths?

$\endgroup$
4
  • $\begingroup$ i updated the question with the files i created in my_rover package. Honestly, i don't know which file you are mentioning. So, can you enlighten me more? $\endgroup$
    – Vasanth
    Commented Aug 26, 2023 at 5:24
  • $\begingroup$ To help you guys understand what my package contains i added setup.py file in the question. $\endgroup$
    – Vasanth
    Commented Aug 28, 2023 at 7:13
  • $\begingroup$ @Vasanth I've updated my answer. $\endgroup$
    – cst0
    Commented Aug 28, 2023 at 13:34
  • $\begingroup$ Thank you @cst0 for your insight. I should have checked the code at first, rather than focusing on only the error part. It works finally. $\endgroup$
    – Vasanth
    Commented Aug 29, 2023 at 4:43

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.