ROS Basics In 5 Days - subscriber and messge exercise 23 issues

Hello,
I follow the solution for exercise 23. I have successfull create a new message Age in my package exercise23.
After I do the following steps to create lauch file and py file, I run this in command:
roslaunch exercise_23 publish_age.launch
I got the error:
[publish_age.launch] is neither a launch file in package [exercise_23] nor is [exercise_23] a launch file name
The traceback for the exception was written to the log file

I also try the command:
rosrun exercise23 publish_age.py
I got the error:
Traceback (most recent call last):
File “/home/user/catkin_ws/src/exercise23/publish_age.py”, line 4, in
** from exercise_23.msg import Age #Import Age message from the exercise_23 package**
ImportError: No module named msg
I have verfied: rosmsg list | grep Age rosmsg show Age. And I got:
erate_messages
user:~/catkin_ws$ source devel/setup.bash
user:~/catkin_ws$ roscd exercise23
user:~/catkin_ws/src/exercise23$ roslaunch exercise_23 publish_age.launch
[publish_age.launch] is neither a launch file in package [exercise_23] nor is [exercise_23] a launch file name
The traceback for the exception was written to the log file
user:~/catkin_ws/src/exercise23$ rosrun exercise23 publish_age.py
Traceback (most recent call last):
File “/home/user/catkin_ws/src/exercise23/publish_age.py”, line 4, in
from exercise_23.msg import Age #Import Age message from the exercise_23 package
ImportError: No module named msg
user:~/catkin_ws/src/exercise23$ rosmsg show Age
[exercise23/Age]:
float32 years
float32 months
float32 days

After I complete the programming, I also do:
roscd
cd …
catkin_make
source devel/setup.bash.

I do not know what’s wrong with my process. Need help.

Thanks

Hi,
So there are things that don’t quite fit.

Could you post the launch file publish_age.launch? Because it doesn’t seem to be well written for some reason.
Also the fact that you arent able to find the Age message means that you didn’t source or you didn’t compile correctly. Try cleaning the compilation files and compiling agagin and sourcing:

cd ~/catkin_ws;rm -rf build devel;catkin_make, source devel/setup.bash, rospack profile

Hello,
Thanks for your reply. Actually, I’m able to find the Age message. But after I add .launch file and .py file I got the error:
File “/home/user/catkin_ws/src/exercise23/publish_age.py”, line 4, in
** from exercise_23.msg import Age #Import Age message from the exercise_23 package**
ImportError: No module named msg
I have verfied: rosmsg list | grep Age rosmsg show Age
Here is the snapshot.

Hello, I have attached the lauch file.
I copy from the solution.

Hi @mingyucai0915,
Have you correctly edited the CMakeLists.txt and package.xml for building custom messages?