Exercise 3.1 - Write a Publisher & Subscriber Node. Failing to move robot

Hello,

I’m facing an issue that I cannot seem to fix.
I’m on chapter 3 and I tried to take Exercise 3.1 which is Write a Publisher & Subscriber Node.
I’ve done everything in solutions but it still fails.

Attaching below the output I received after I ran this command:
ros2 launch exercise31_pkg exercise31_pkg_launch_file.launch.py

user:~/ros2_ws$ ros2 launch exercise31_pkg exercise31_pkg_launch_file.launch.py
[INFO] [launch]: All log files can be found below /home/user/.ros/log/2021-11-04-20-05-23-363287-3_xterm-27751
[INFO] [launch]: Default logging verbosity is set to INFO
[INFO] [exercise31-1]: process started with pid [27753]
[exercise31-1] Traceback (most recent call last):
[exercise31-1]   File "/home/user/ros2_ws/install/exercise31_pkg/lib/exercise31_pkg/exercise31", line 11, in <module>
[exercise31-1]     load_entry_point('exercise31-pkg==0.0.0', 'console_scripts', 'exercise31')()
[exercise31-1]   File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 490, in load_entry_point
[exercise31-1]     return get_distribution(dist).load_entry_point(group, name)
[exercise31-1]   File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2854, in load_entry_point
[exercise31-1]     return ep.load()
[exercise31-1]   File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2445, in load
[exercise31-1]     return self.resolve()
[exercise31-1]   File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2451, in resolve
[exercise31-1]     module = __import__(self.module_name, fromlist=['__name__'], level=0)
[exercise31-1] ModuleNotFoundError: No module named 'exercise31_pkg.exercise31'
[ERROR] [exercise31-1]: process has died [pid 27753, exit code 1, cmd '/home/user/ros2_ws/install/exercise31_pkg/lib/exercise31_pkg/exercise31 --ros-args'].

Not sure what I’ve done wrong :frowning:
Unfortunately, the robot does not seem to move.

I’d appreciate it if anyone could help me :slight_smile:
Thanks a lot!

EDIT : Found the issue I had! :slight_smile:

1 Like

Can you show the screenshot of the code for exercise31_pkg_launch_file.launch.py

Hello,
This is the code which I pasted from the solutions:

from launch import LaunchDescription
from launch_ros.actions import Node

def generate_launch_description():
    return LaunchDescription([
        Node(
            package='exercise31_pkg',
            executable='exercise31',
            output='screen'),
    ])

Glad you found the issue. Could you share it here (and mark it as solved) in case someone else runs into the same issue?

Hello,

I created the ** exercise31.py** file in the wrong directory and what caused the issues :frowning: