dips
dips

Reputation: 1

ModuleNotFoundError: No module named 'catkin_pkg'

i follow this video https://youtu.be/Vbh3--etiwg?si=xOzCUZrJK5369Sjp to use ros2 for beginner. But i have this problem when i input this in terminal, colcon build --symlink-install. I'm new in ubuntu and ros2, so if you can help me you are a very nice guy :)

This is the URDF Code

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

<xacro:property name="base_width" value = "0.31"/>
<xacro:property name="base_length" value = "0.42"/>
<xacro:property name="base_height" value = "0.18"/>

<xacro:property name="wheel_radius" value="0.10"/>
<xacro:property name="wheel_width" value="0.04"/>
<xacro:property name="wheel_ygap" value="0.025"/>
<xacro:property name="wheel_zoff" value="0.01"/>
<xacro:property name="wheel_xoff" value="0.05"/>

<xacro:property name="caster_xoff" value="0.1"/>

  <!-- Define intertial property macros  -->
  <xacro:macro name="box_inertia" params="m w h d">
    <inertial>
      <origin xyz="0 0 0" rpy="${pi/2} 0 ${pi/2}"/>
      <mass value="${m}"/>
      <inertia ixx="${(m/12) * (h*h + d*d)}" ixy="0.0" ixz="0.0" iyy="${(m/12) * (w*w + d*d)}" iyz="0.0" izz="${(m/12) * (w*w + h*h)}"/>
    </inertial>
  </xacro:macro>

  <xacro:macro name="cylinder_inertia" params="m r h">
    <inertial>
      <origin xyz="0 0 0" rpy="${pi/2} 0 0" />
      <mass value="${m}"/>
      <inertia ixx="${(m/12) * (3*r*r + h*h)}" ixy = "0" ixz = "0" iyy="${(m/12) * (3*r*r + h*h)}" iyz = "0" izz="${(m/2) * (r*r)}"/>
    </inertial>
  </xacro:macro>

  <xacro:macro name="sphere_inertia" params="m r">
    <inertial>
      <mass value="${m}"/>
      <inertia ixx="${(2/5) * m * (r*r)}" ixy="0.0" ixz="0.0" iyy="${(2/5) * m * (r*r)}" iyz="0.0" izz="${(2/5) * m * (r*r)}"/>
    </inertial>
  </xacro:macro>


  <!-- Robot Base -->
  <link name="base_link">
    <visual>
    <origin xyz="0 0 ${base_height/2}" rpy="0 0 0"/>
      <geometry>
        <box size="${base_length} ${base_width} ${base_height}"/>
      </geometry>
      <material name="Cyan">
        <color rgba="0 1.0 1.0 1.0"/>
      </material>
    </visual>
    <collision>
    <origin xyz="0 0 ${base_height/2}" rpy="0 0 0"/>
      <geometry>
        <box size="${base_length} ${base_width} ${base_height}"/>
      </geometry>
    </collision>

    <xacro:box_inertia m="5" w="${base_width}" d="${base_length}" h="${base_height}"/>
  </link>

   <gazebo reference="base_link">
    <material>Gazebo/Orange</material>
  </gazebo>

    <!-- Caster Wheel -->
  <link name="caster">
    <visual>
      <geometry>
        <sphere radius="${wheel_zoff}"/>
      </geometry>
      <material name="white">
        <color rgba="1 1.0 1.0 1.0"/>
      </material>
    </visual>
    <collision>
      <origin xyz="0 0 0" rpy="0 0 0"/>
      <geometry>
        <sphere radius="${wheel_zoff}"/>
      </geometry>
    </collision>

    <xacro:sphere_inertia m="0.5" r="${(wheel_radius+wheel_zoff-(base_height/2))}"/>
  </link>

   <gazebo reference="caster">
    <material>Gazebo/Blue</material>
  </gazebo>

  <joint name="caster_joint" type="fixed">
    <parent link="base_link"/>
    <child link="caster"/>
    <origin xyz="${-caster_xoff} 0.0 0" rpy="0 0 0"/>
  </joint>

    <!-- Wheels -->
  <xacro:macro name="wheel" params="prefix x_reflect y_reflect">
    <link name="${prefix}_link">
      <visual>
        <origin xyz="0 0 0" rpy="${pi/2} 0 0"/>
        <geometry>
            <cylinder radius="${wheel_radius}" length="${wheel_width}"/>
        </geometry>
        <material name="Gray">
          <color rgba="0.5 0.5 0.5 1.0"/>
        </material>
      </visual>
      <collision>
        <origin xyz="0 0 0" rpy="${pi/2} 0 0"/>
        <geometry>
          <cylinder radius="${wheel_radius}" length="${wheel_width}"/>
        </geometry>
      </collision>

      <xacro:cylinder_inertia m="0.5" r="${wheel_radius}" h="${wheel_width}"/>
    </link>

    <joint name="${prefix}_joint" type="continuous">
      <parent link="base_link"/>
      <child link="${prefix}_link"/>
      <origin xyz="${-x_reflect*wheel_xoff} ${y_reflect*(base_width/2+wheel_ygap)} ${wheel_radius-wheel_zoff}" rpy="0 0 0"/>
      <axis xyz="0 1 0"/>
    </joint>
  </xacro:macro>

  <xacro:wheel prefix="drivewhl_l" x_reflect="-1" y_reflect="1" />
  <xacro:wheel prefix="drivewhl_r" x_reflect="-1" y_reflect="-1" />

<gazebo>
  <plugin name='diff_drive' filename='libgazebo_ros_diff_drive.so'>

    <!-- wheels -->
    <left_joint>drivewhl_l_joint</left_joint>
    <right_joint>drivewhl_r_joint</right_joint>

    <!-- kinematics -->
    <wheel_separation>0.4</wheel_separation>
    <wheel_diameter>0.2</wheel_diameter>

    <!-- limits -->
    <max_wheel_torque>80</max_wheel_torque>
    <max_wheel_acceleration>1.0</max_wheel_acceleration>

    <!-- output -->
    <publish_odom>true</publish_odom>
    <publish_odom_tf>false</publish_odom_tf>
    <publish_wheel_tf>true</publish_wheel_tf>

    <odometry_frame>odom</odometry_frame>
    <robot_base_frame>base_link</robot_base_frame>
  </plugin>
</gazebo>

</robot>

When I want to colcon build --symlink-install in terminal, i get this error

Starting >>> my_package
--- stderr: my_package                         
Traceback (most recent call last):
  File "/opt/ros/jazzy/share/ament_cmake_core/cmake/core/package_xml_2_cmake.py", line 22, in <module>
    from catkin_pkg.package import parse_package_string
ModuleNotFoundError: No module named 'catkin_pkg'
CMake Error at /opt/ros/jazzy/share/ament_cmake_core/cmake/core/ament_package_xml.cmake:95 (message):
  execute_process(/usr/local/bin/python3.13
  /opt/ros/jazzy/share/ament_cmake_core/cmake/core/package_xml_2_cmake.py
  /home/arya/learn_ros2_ws/src/my_package/package.xml
  /home/arya/learn_ros2_ws/build/my_package/ament_cmake_core/package.cmake)
  returned error code 1
Call Stack (most recent call first):
  /opt/ros/jazzy/share/ament_cmake_core/cmake/core/ament_package_xml.cmake:49 (_ament_package_xml)
  /opt/ros/jazzy/share/ament_lint_auto/cmake/ament_lint_auto_find_test_dependencies.cmake:31 (ament_package_xml)
  CMakeLists.txt:32 (ament_lint_auto_find_test_dependencies)


---
Failed   <<< my_package [0.23s, exited with code 1]

Summary: 0 packages finished [0.36s]
  1 package failed: my_package
  1 package had stderr output: my_package

i have this problem. I have done pip install catkin_pkg and another download things, but i always get this problem. Can someone help me

Upvotes: 0

Views: 98

Answers (1)

achille
achille

Reputation: 675

Wipe your build and install folders inside the colcon workspace. That fixed it for me.

Upvotes: 0

Related Questions