I’m trying to run my quiz for the Actions Server unit. I’m facing the following import error:
ImportError: cannot import name CustomActionMsgFeedback
I had tried also to change this:
" from actions_quiz import CustomActionMsgFeedback, CustomActionMsgResult, CustomActionMsgAction "
" from actions_quiz.msg import CustomActionMsgFeedback, CustomActionMsgResult, CustomActionMsgAction "
but then, I get
ImportError: No module named msg
I had followed all steps for creating custom actions, and I don’t know what is wrong. You can check all my code in this gist:
This file has been truncated.
## Compile as C++11, supported in ROS Kinetic and newer
## Find catkin macros and libraries
## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
## is used, also find other catkin packages
find_package(catkin REQUIRED COMPONENTS
<node pkg="actions_quiz" type="actions_quiz.py" name="action_custom_msg_as" output="screen">
There are more than three files.
Thank you very much in advanced.
Thank you for contacting us and welcome to the Community!
Please make the following corrections (if necessary and try again):
Your action message name is named
CustomActionMsg.launch. It should be
CustomActionMsg.action. Also ensure that this file is inside a subdirectory named
action, in your actions_quiz package directory.
The import line should read
from actions_quiz.msg .... You cannot import directly from
Follow this guide to ensure the message is properly compiled:
ERROR: Cannot load message class for [package/Message]. Are your messages built?
i have the same problem with the import
i think the structure of my directories is corrrect
( made the msg directory myself. it is empty and was not created or filled during the catkin_make command)
i build my messages using
i also get a response searching for the message like this:
user:~/catkin_ws$ rosmsg show actions_quiz/CustomActionMsgAction
i think this means that the message is build correctly! is this true?
What could then be the source of the error?
Please remove the folder if there’s nothing inside it. It’s not needed and might cause some confusion.
ensure you have run
on the terminal on which you’re trying to run the code. Running on one terminal does not work for other terminals; it has to be run on each terminal. check that you are importing the right message (not typo or error in the name).
I got it solved!
The error is caused by the naming of the package and the python file.
If the name is exactly the same except for the .py ending you will have trouble with the imports.
Sometimes the tutorials suggest problematic naming.