Unit 4 Exercise 4.3

Tried to run exercise 4.3 copied directly from the given solution. It seems to start OK but then I get the message:

Traceback (most recent call last):
File “/home/user/catkin_ws/src/exercise_33/publish_age.py”, line 4, in
from exercise_33.msg import Age #Import Age message from the exercise_33 package
ModuleNotFoundError: No module named ‘exercise_33’
[publish_age_node-1] process has died [pid 12762, exit code 1, cmd /home/user/catkin_ws/src/exercise_33/publish_age.py __name:=publish_age_node __log:=/home/user/.ros/log/578f292c-20eb-11ed-8d0b-0242ac1a0008/publish_age_node-1.log].
log file: /home/user/.ros/log/578f292c-20eb-11ed-8d0b-0242ac1a0008/publish_age_node-1*.log
all processes on machine have died, roslaunch will exit
shutting down processing monitor…
… shutting down processing monitor complete
done

The key problem is that it can’t find a node called exercise_33. I don’t understand this. There is a package called exercise_33, not a node. Line for in the publish_age.py script:
from exercise_33.msg import Age
I don’t know what the file(?) named exercise_33.msg is. I am very confused. Please help.
thanks, Tom

Hi there @consi ,

I am almost going to finish ROS Basics in 5 Days with Python, so I believe that qualifies me to answer you.

The initial error line in the trace back says that there is no module named “exercise_33”. I believe you have copy-pasted the solution into your package that is not named as “exercise_33”.
Solution: Create a catkin package named “exercise_33” and then copy the solution on to it.

My advise: change the launch file node parameters to suit your program/package. Don’t copy from solution. If at all you want to take a look at the solution, understand the logic and re-implement yourself !

Copied from solution:

<launch>
    <node pkg="exercise_33" type="publish_age.py" name="publish_age_node" output="screen" />
</launch>

Breaking down the <node … /> line, we have:
catkin package name: “exercise_33” without quotes
python file name: “publish_age.py”
node name in the above python file : “publish_age_node” (this is the line in code rospy.init_node(“publish_age_node”))
output is usually “screen” to view the messages in stdout, which is terminal screen.

I have not executed or copy-pasted from the solutions but I am sure the solution will work fine.

Final advise: [Re]check your catkin package and/or code. Hope I helped!

Regards,
Girish

1 Like

Hi,

I am having a similar problem. ROS doesn’t recognize the name of the package where the message is defined:
File “/home/user/catkin_ws/src/example_age/scripts/publish_age.py”, line 4, in
from example_age.msg import Age # Import Age message from the example_age package
ModuleNotFoundError: No module named ‘example_age’

The message is defined in the folder /msg inside the folder of the package example_age. ¿Could you help me with this issue?

Thanks!

Julio

Hi @juliogodoy ,

It is a very basic problem. Please go through your tutorial and redo your package.
You either did not make the package using catkin_create_pkg or missing out on Custom message CMake dependencies.
Follow the tutorial again to get it rectified.

Regards,
Girish

1 Like

This topic was automatically closed after 46 hours. New replies are no longer allowed.