Weird catkin_make error

I’m trying to compile my ‘actions_quiz’ package that I created for the Unit 9 quiz of the ROS basics Python course. However, it keeps giving me an error indicating that it cannot find an “action” folder within the ‘src’ folder of ‘catkin_ws’. Following is the output from the terminal when I used ‘catkin_make’:

user:~/catkin_ws$ catkin_make
Base path: /home/user/catkin_ws
Source space: /home/user/catkin_ws/src
Build space: /home/user/catkin_ws/build
Devel space: /home/user/catkin_ws/devel
Install space: /home/user/catkin_ws/install

Running command: “make cmake_check_build_system” in “/home/user/catkin_ws/build”

– Using CATKIN_DEVEL_PREFIX: /home/user/catkin_ws/devel
– Using CMAKE_PREFIX_PATH: /home/user/catkin_ws/devel;/home/simulations/public_sim_ws/devel;/opt/ros/noetic
– This workspace overlays: /home/user/catkin_ws/devel;/home/simulations/public_sim_ws/devel;/opt/ros/noetic
– Found PythonInterp: /usr/bin/python3 (found suitable version “3.8.5”, minimum required is “3”)
– Using PYTHON_EXECUTABLE: /usr/bin/python3
– Using Debian Python package layout
– Using empy: /usr/lib/python3/dist-packages/em.py
– Using CATKIN_ENABLE_TESTING: ON
– Call enable_testing()
– Using CATKIN_TEST_RESULTS_DIR: /home/user/catkin_ws/build/test_results
– Forcing gtest/gmock from source, though one was otherwise available.
– Found gtest sources under ‘/usr/src/googletest’: gtests will be built
– Found gmock sources under ‘/usr/src/googletest’: gmock will be built
– Found PythonInterp: /usr/bin/python3 (found version “3.8.5”)
– Using Python nosetests: /usr/bin/nosetests3
– catkin 0.8.9
– BUILD_SHARED_LIBS is on
– Using these message generators: gencpp;geneus;genlisp;gennodejs;genpy
CMake Error at /opt/ros/noetic/share/actionlib_msgs/cmake/actionlib_msgs-extras.cmake:20 (message):
add_action_files() directory not found: /home/user/catkin_ws/src/action
Call Stack (most recent call first):
CMakeLists.txt:69 (add_action_files)

– Configuring incomplete, errors occurred!
See also “/home/user/catkin_ws/build/CMakeFiles/CMakeOutput.log”.
See also “/home/user/catkin_ws/build/CMakeFiles/CMakeError.log”.
make: *** [Makefile:320: cmake_check_build_system] Error 1
Invoking “make cmake_check_build_system” failed

I guess there is supposed to be an “/home/user/catkin_ws/src/action” folder. But my workspace doesn’t seem to have one. The only “action” folder I have is the one I created within my package to define the custom action message that I need to use.

However, I suspect there might be something wrong in the way I modified my ‘CMakeLists.txt’ and ‘package.xml’ files. For reference, these are as follows:

CMakeLists.txt:

cmake_minimum_required(VERSION 3.0.2)
project(actions_quiz)

find_package(catkin REQUIRED COMPONENTS
  std_msgs
  actionlib_msgs
)


add_action_files(
	FILES
	CustomActionMsg.action
)


generate_messages(
	DEPENDENCIES
	std_msgs
	actionlib_msgs
)


catkin_package(
	CATKIN_DEPENDS
	rospy
)

include_directories(
  ${catkin_INCLUDE_DIRS}
)

package.xml:

<?xml version="1.0"?>
<package format="2">
<name>actions_quiz</name>
<version>0.0.0</version>
<description>The actions_quiz package</description>

<maintainer email="user@todo.todo">user</maintainer>

<license>TODO</license>

<buildtool_depend>catkin</buildtool_depend>
<build_depend>rospy</build_depend>
<build_depend>std_msgs</build_depend>
<build_depend>actionlib_msgs</build_depend>
<build_depend>actionlib</build_depend>

<build_export_depend>rospy</build_export_depend>
<build_export_depend>std_msgs</build_export_depend>
<build_export_depend>actionlib_msgs</build_export_depend>
<build_export_depend>actionlib</build_export_depend>

<exec_depend>rospy</exec_depend>
<exec_depend>std_msgs</exec_depend>
<exec_depend>actionlib_msgs</exec_depend>
<exec_depend>actionlib</exec_depend>

<export>
    <!-- Other tools can request additional information be placed here -->

</export>
</package>

Is there anything that stands out here that could be wrong?

HI @torino ,

Your package.xml file is correct.
Your add_action_files in CmakeLists.txt file is correct.

Try adding all the four packages to find_package and catkin_package, like this:

find_package(catkin REQUIRED COMPONENTS
  rospy
  std_msgs
  actionlib_msgs
  actionlib
)

catkin_package(
  CATKIN_DEPENDS rospy std_msgs actionlib_msgs actionlib
)

Try this and let me know if this works.

Regards,
Girish

Thanks for the suggestion, Girish. Unfortunately, it did not work. I still get the same error (for reference, see below for output).

One of the lines in the error notes says:

Call Stack (most recent call first):
  CMakeLists.txt:69 (add_action_files)

Line 69 in my ‘CMakeLists.txt’ file is just before the “add_action_files” function:

69 # )
70 add_action_files(
71 	FILES
72 	CustomActionMsg.action
73 )

So it appears that’s where the problem starts? Is there anything else associated with establishing/compiling my custom ‘.action’ file that I should look into?

For reference, here is the complete output after running ‘catkin_make’:

user:~/catkin_ws$ catkin_make
Base path: /home/user/catkin_ws
Source space: /home/user/catkin_ws/src
Build space: /home/user/catkin_ws/build
Devel space: /home/user/catkin_ws/devel
Install space: /home/user/catkin_ws/install
####
#### Running command: "make cmake_check_build_system" in "/home/user/catkin_ws/build"
####
-- Using CATKIN_DEVEL_PREFIX: /home/user/catkin_ws/devel
-- Using CMAKE_PREFIX_PATH: /home/user/catkin_ws/devel;/home/simulations/public_sim_ws/devel;/opt/ros/noetic
-- This workspace overlays: /home/user/catkin_ws/devel;/home/simulations/public_sim_ws/devel;/opt/ros/noetic
-- Found PythonInterp: /usr/bin/python3 (found suitable version "3.8.5", minimum required is "3")
-- Using PYTHON_EXECUTABLE: /usr/bin/python3
-- Using Debian Python package layout
-- Using empy: /usr/lib/python3/dist-packages/em.py
-- Using CATKIN_ENABLE_TESTING: ON
-- Call enable_testing()
-- Using CATKIN_TEST_RESULTS_DIR: /home/user/catkin_ws/build/test_results
-- Forcing gtest/gmock from source, though one was otherwise available.
-- Found gtest sources under '/usr/src/googletest': gtests will be built
-- Found gmock sources under '/usr/src/googletest': gmock will be built
-- Found PythonInterp: /usr/bin/python3 (found version "3.8.5")
-- Using Python nosetests: /usr/bin/nosetests3
-- catkin 0.8.9
-- BUILD_SHARED_LIBS is on
-- Using these message generators: gencpp;geneus;genlisp;gennodejs;genpy
CMake Error at /opt/ros/noetic/share/actionlib_msgs/cmake/actionlib_msgs-extras.cmake:20 (message):
  add_action_files() directory not found: /home/user/catkin_ws/src/action
Call Stack (most recent call first):
  CMakeLists.txt:69 (add_action_files)


-- Configuring incomplete, errors occurred!
See also "/home/user/catkin_ws/build/CMakeFiles/CMakeOutput.log".
See also "/home/user/catkin_ws/build/CMakeFiles/CMakeError.log".
make: *** [Makefile:320: cmake_check_build_system] Error 1
Invoking "make cmake_check_build_system" failed
user:~/catkin_ws$

Hi @torino ,

Your problem seems to be very weird. I have a couple of suggestions that might help you solve this problem.

  1. Try deleting the build, devel and install directories within ~/catkin_ws path. And then do catkin_make ....

    cd ~/catkin_ws
    rm -rf ./build ./devel ./install
    catkin_make --only-pkg-with-deps actions_quiz
    source devel/setup.bash
    
  2. Take a backup of your actions_quiz programs (the python files). Delete the actions_quiz package and create it again from scratch.

  3. CAUTION / WARNING / ATTENTION: This will delete catkin_ws and all packages inside the folder.
    i. Take a backup of the entire catkin_ws by downloading the folder to your computer. Simply right click on catkin_ws and on the right-click menu, click on download. You can download this as a compressed file to your computer.
    ii. Delete the catkin_ws directory and create a new one and copy all the backup files inside.

    cd ~                              # go to home directory
    rm -rf ./catkin_ws                # remove the catkin_ws directory
    mkdir -p ./catkin_ws/src          # create the catkin_ws again
    cd ./catkin_ws                    # get inside catkin_ws
    catkin_make                       # to add this path to catkin_make
    source devel/setup.bash           # source the workspace
    

    iii. To copy files back into catkin_ws/src from your physical computer, just extract the compressed file which you downloaded earlier and drag and drop each package you created inside the newly created catkin_ws/src folder on the course IDE.
    There is a post about doing this (option 3) created by @bayodesegun. I could not find that post when I searched the forums.

I believe either option 1 or option 2 should solve your problem. I hope you do not have to choose option 3.

Regards,
Girish

PS: Let us know if your problem is resolved.

Thanks, Girish. Option 2 worked!

However, this leaves me with another question. Although the package compiled successfully (using “catkin_make --only-pkg-with-deps actions_quiz rospy std_msgs”), from where do I import the action messages (i.e., CustomActionMsgAction, CustomActionMsgFeedback, etc.)?

In the tutorials, the “actionlib_tutorials” package had an “msg” folder that contained the required messages, so that the messages could be imported simply with:

from actionlib_tutorials.msg import FibonacciFeedback, FibonacciResult, FibonacciAction”.

However, I do not see an “msg” folder in my compiled “actions_quiz” package (I just assumed it would be created and populated automatically).

Hi @torino ,

Glad that you got it working!

I am sure you cannot use the command this way to compile a package.
You must not include rospy and std_msgs in catkin_make command. It is used only when creating a package, that is, with the catkin_create_pkg command.

You must first create a custom action message (within action sub folder) and then compile your package again to get the action message recognized and then use the action message.

At this point, I believe that you have forgotten what you have learned in the course. Please go through your course again and see how to make a custom action message for your ros package. Then implement the same steps for your rosject.

Regards,
Girish

Yeah, you can ignore that. That was just a copy/paste error. It’s just “catkin_make --only-pkg-with-deps actions_quiz”.

However, I think you may have misunderstood the second question. I have been following along the tutorial and already know the steps for creating a custom action message. My question was more about, I guess, syntax for how to import the new message.

In the tutorial examples, we used the “actionlib_tutorials” package for the action messages, and then imported the action messages in the python script as follows:

For the Fibonnaci example, it was:

from actionlib_tutorials.msg import FibonacciFeedback, FibonacciResult, FibonacciAction

The “actionlib_tutorials” directory clearly has a “msg” folder within it, so the line “from actionlib_tutorials.msg import …” makes sense:

user:/opt/ros/noetic/share/actionlib_tutorials/msg$ ls -lah
total 64K
drwxr-xr-x 2 root root 4.0K Feb 8 2021 .
drwxr-xr-x 5 root root 4.0K Feb 8 2021 …
-rw-r–r-- 1 root root 180 Jan 12 2021 AveragingAction.msg
-rw-r–r-- 1 root root 146 Jan 12 2021 AveragingActionFeedback.msg
-rw-r–r-- 1 root root 135 Jan 12 2021 AveragingActionGoal.msg
-rw-r–r-- 1 root root 142 Jan 12 2021 AveragingActionResult.msg
-rw-r–r-- 1 root root 137 Jan 12 2021 AveragingFeedback.msg
-rw-r–r-- 1 root root 102 Jan 12 2021 AveragingGoal.msg
-rw-r–r-- 1 root root 119 Jan 12 2021 AveragingResult.msg
-rw-r–r-- 1 root root 180 Jan 12 2021 FibonacciAction.msg
-rw-r–r-- 1 root root 146 Jan 12 2021 FibonacciActionFeedback.msg
-rw-r–r-- 1 root root 135 Jan 12 2021 FibonacciActionGoal.msg
-rw-r–r-- 1 root root 142 Jan 12 2021 FibonacciActionResult.msg
-rw-r–r-- 1 root root 99 Jan 12 2021 FibonacciFeedback.msg
-rw-r–r-- 1 root root 100 Jan 12 2021 FibonacciGoal.msg
-rw-r–r-- 1 root root 107 Jan 12 2021 FibonacciResult.msg

However, after successful compilation, the “actions_quiz” package does not.

Still, from simple analogy, I wrote:

from actions_quiz.msg import CustomActionMsgAction, CustomActionMsgFeedback

And it worked! I completed the quiz successfully. But I’m not sure why. Is there a hidden “msg” folder within the “actions_quiz” folder that I can’t see? Does writing “from actions_quiz.msg import …” point to some other location?

Small details like this, understandably, can get left out in the tutorials. Or perhaps it was mentioned briefly and I missed/misunderstood it. In any case, I just wanted some clarification on that.

Hi @torino ,

Yes, this is correct.

You make custom action messages as a CustomActionMessageName.action file and put it inside the action directory inside your package. Once you have made the custom message (and modified your CMakeLists.txt and package.xml file), you MUST compile your package.

Once compiled with the custom message, you will import the custom message as:

from package_name.msg import (CustomActionMessageNameAction,
                              CustomActionMessageNameActionFeedback,
                              CustomActionMessageNameActionResult) 

This is when you can make use of the custom action message inside your program.

Technically there is something similar that happens in the compiled version of the program. But you will not see a msg directory inside your package. It does not make any hidden folders. This is the syntax to call and make use of the action messages in ROS1, but it is different in ROS2.

Do you remember that in ROS1, to list the actions you do rostopic list and not rosaction list ?
That is because of the fact that action messages are created as topics unlike services. This is also one of the reason in ROS1, you do from package_name.msg import CustomAction and not something like from package_name.action import CustomAction.

Hope I clarified your doubts.

Regards,
Girish