Unknown CMake command "add_action_files"

Trying to complete the Action Server quiz, and I can’t get the catkin_make to run. It gives this error:

– +++ processing catkin package: ‘actions_quiz’
– ==> add_subdirectory(actions_quiz)
– Using these message generators: gencpp;geneus;genlisp;gennodejs;genpy
CMake Error at actions_quiz/CMakeLists.txt:64 (add_action_files):
Unknown CMake command “add_action_files”.

Hello @hodel_benjamin_j,

From the error message, it looks like you have an error in your CMakeLists.txt file, around line 64. The add_action_files() function should look something like this:

add_action_files(
  FILES
  CustomActionMsg.action
)

Make sure that there’s not any character (could be spaces) around there that could be messing things up.

I think my file shows exactly that. I copied it here:

add_action_files(
  FILES
  CustomActionMsg.action
)

Solved my own problem by reading this article:
https://answers.ros.org/question/240228/unknown-cmake-command-add_action_files/

Apparently I didn’t have the proper “actionlib_msgs” references in the “find_package” call.

1 Like

2nd problem. After calling catkin_make, it completes successfully, but there is no “msg” folder with auto-generated .msg files. I followed the actions_quiz examples for CMakeLists.txt and package.xml verbatim. What else do I need to do?

Hi @hodel_benjamin_j, the messages are generated in the ~/catkin_ws/devel folder.

Your should be able to find them with the command below:

find ~/catkin_ws -name '*msg*'

Now I get this error:

ERROR: Cannot load message class for [actions_quiz/CustomActionMsgActionResult]. Are your messages built?

Edit:
BTW, using find I found them here:

/home/user/catkin_ws/devel/share/actions_quiz/msg/CustomActionMsgActionFeedback.msg
/home/user/catkin_ws/devel/share/actions_quiz/msg/CustomActionMsgActionResult.msg
/home/user/catkin_ws/devel/share/actions_quiz/msg/CustomActionMsgAction.msg
/home/user/catkin_ws/devel/share/actions_quiz/msg/CustomActionMsgGoal.msg
/home/user/catkin_ws/devel/share/actions_quiz/msg/CustomActionMsgFeedback.msg
/home/user/catkin_ws/devel/share/actions_quiz/msg/CustomActionMsgActionGoal.msg
/home/user/catkin_ws/devel/share/actions_quiz/msg/CustomActionMsgResult.msg

1 Like

Great to know that you found them.

@ralves, I found them, but I am still getting an error (see above). I’m stuck, so can you help?

Hi @hodel_benjamin_j,

when you compile your custom messages with cd ~/catkin_ws; catkin_make, you have to source the catkin_ws again, so that ROS can find the messages you just compiled.

If you run the command below after compiling the ~/catkin_ws, you should be able to import the messages without any problems:

source ~/catkin_ws/devel/setup.bash

Remember that you have to source in each in each shell, or if you prefer, you can just reload the page that the source will run automatically in all shells.

Please let us know whether the problem when away after sourcing ;). If the problem persists, can you paste the whole error message here?