Roslaunch issue

Hello,
I’m currently learn the course: ROS basics 5 days.
Right now I have a problem in the lesson: Understand ROS topics -Publisher.
As for exercise 21:
I create a ROS package as:

catkin_create_pkg beginner_tutorials geomery_msgs rospy

After create the package, I also do as:

catkin_make
source ~/catkin_ws/devel/setup.bash

Then I fellows the solution of exercise to create the .launch and .py.
Finally, when I run the command:
roslaunch exercise21 move_robot.launch
I got the error:
ERROR: cannot launch node of type [exercise_21/move_robot.py]: exercise_21
ROS path [0]=/opt/ros/kinetic/share/ros
ROS path [1]=/home/user/catkin_ws/src
ROS path [2]=/home/simulations/public_sim_ws/src
ROS path [3]=/opt/ros/kinetic/share

But when I run the command:
rosrun exercise21 move_robot.py

The robot moves as the expectation.
I didn’t know what’s the reason.
By the way, it seems when I create a ROS package as publisher, do I have to add the msg lib as dependency? This is not introduced in the course.
Would you give me some advice in future study?

Could you post the launch file here, because f the rosrun is working, the package is well build and there has to be something wrong in the launch file probably.

As for adding thedependencies, yeah,its better that you add the necessary dependencies in the package creation if you know them beforehand. Otherwise you can add them afterwards insid ethe package.xml and the CMakelists.txt of the package.


I cat the launch.file information in command window.
This problem bothers me many times. I copy the launch file directly from the solution.
Thanks!

Hello, I have attached the lauch file.

Your move_robot.py file does not seem to be located in the exercise21/src folder. This might be it :slight_smile:

The normal ROS convention is like this:
pkg_name/launch/ --> includes .launch files
pkg_name/scripts/ --> includes .py files
pkg_name/src/ --> includes .cpp files

But you can put the python files also into /src