Unit1_exercise.cpp

rosrun c_scripts unit1_exercise
[rosrun] Couldn’t find executable named unit1_exercise below /home/user/catkin_ws/src/cpp_course_repo/utilities/cpp_course_repo/c_scripts

I have done the instructors. Why did it run?

Hello fkaraal,
I suggest:

  1. try add .py to unit1_exercise : rosrun c_scripts unit1_exercise.py
  2. check if this package exist by " roscd <package_name>".
  3. then check the package content, is the unit1_exercise.py exist?
    Kindly, let me know if this reply help you.
1 Like

Hello fkaraal,
how its going with ROS learning?
I have faced same issue just now, that issue happened when I rename the python file, so just check the python file name.
if the name right, change its directory to : c_scripts/src

also you should check you launch file, is your python file name and the parameter inside type are same?

1 Like

Hi @fkaraal,

Welcome to our community.

In addition to what @aameralshamy3 suggested (checking file names), another possible reason why it fails is that your script does not have execution permission.

You can give execution permissions with:

cd /home/user/catkin_ws/src/cpp_course_repo/utilities/cpp_course_repo/c_scripts

chmod +x unit1_exercise.py

If after checking the files and giving execute permissions the rosrun command still fails, could you tell us the output of the command below?

tree ~/catkin_ws/src/cpp_course_repo

Thank you for your response;
I did it but didn’t work.
Could you clarify steps 2 and 3? What should I have written as a package_name and how can I check the package content?

| |-- CMakeLists.txt
| |-- package.xml
| -- src | |-- unit1_exercise.cpp | |-- unit2_exercise.cpp | |-- unit3_exercise.cpp | |-- unit4_exercise.cpp | |-- unit5_exercise.cpp | – unit6_exercise.cpp
|-- rosbot_control
| |-- CMakeLists.txt
| |-- include
| | -- rosbot_control | | – rosbot_class.h
| |-- package.xml
| -- src | – rosbot_class.cpp
-- utilities |-- README.md |-- cpp_course_repo | |-- c_scripts | | |-- CMakeLists.txt | | |-- package.xml | | – src
| | |-- unit1_exercise.cpp
| | |-- unit2_exercise.cpp
| | |-- unit3_exercise.cpp
| | |-- unit4_exercise.cpp
| | |-- unit5_exercise.cpp
| | -- unit6_exercise.cpp | |-- rosbot_control | | |-- CMakeLists.txt | | |-- include | | | – rosbot_control
| | | -- rosbot_class.h | | |-- package.xml | | – src
| | -- rosbot_class.cpp | – utilities
|-- name.cpp
`-- name_compiled

15 directories, 27 files

Also, it seems confusing. Because the code is based on c++. Why should we write with .py extension?

Hi @fkaraal,

yes, I mistakenly assumed you were talking about Python because you posted in the " Python Basics For Robotics" category.

Could you then tell us which is the course and which specific Unit that you are following? This would help us reproduce the issue.

If you are following a C++ course, then you have to make sure your package is compiled with:

cd ~/catkin_ws

catkin_make

source ~/devel/setup.bash

Only then run your node:

rosrun c_scripts unit1_exercise

If compiling and sourcing as instructed here does not work, please remember to answer the questions I asked here

It was my bad. Yes, I mistakenly posted the wrong category. Sorry about that.

However, It didn’t work again when I did what you said and what the instructor said. The result is below.

user:~/catkin_ws$ source ~/devel/setup.bash
bash: /home/user/devel/setup.bash: No such file or directory

user:~/catkin_ws$ rosrun c_scripts unit1_exercise
[rosrun] Couldn’t find executable named unit1_exercise below /home/user/catkin_ws/src/cpp_course_repo/utilities/cpp_course_repo/c_scripts

the course is C++ for Robotics, unit _1_exercise_1

Hi, @fkaraal,

I was checking the code you used and saw that you had somehow cloned the cpp_course_repo repository twice.

You have to remove the second folder in order to make catkin_make work, otherwise, it complains that there are two packages with the same name.

The procedure you have to follow is the following:

# Go to the home page
cd

# This command is to show you that you have two folders with the same name
find ~/catkin_ws/src -name cpp_course_repo

# Let's remove the second folder
sudo rm -rf ./catkin_ws/src/cpp_course_repo/utilities/cpp_course_repo

# Now, remove build and devel folders and recompile your workspace
 cd catkin_ws/

rm devel/ build/ -r

catkin_make

# Now that the workspace is compiled, source the `devel/setup.sh` so that ROS can find your package, then you can run your node:

 source devel/setup.bash
rosrun c_scripts unit1_exercise

Please let me know if you still have any problems.

Hi @ralves ;
That worked,
Thank you so much for your support.

1 Like

The code works, but when I log out and log in to the application, I have to apply the same procedure again. Is there a way to permanently fix it?

Hi @fkaraal ,

is the problem exactly the same?

The folder that your remove should not be automatically put there. Are you cloning the repository again?

Could you tell us the exact procedures you are following and put here the logs to help you diagnose the problem further?

This topic was automatically closed after 2 days. New replies are no longer allowed.