Did you forget to specify generate_messages(DEPENDENCIES ...)?

Hi,
I am doing Rosject for “ROS Basics in 5 Days”. In the third part, we should create a customed action message. But I keep receiving this error:

-- Generating .msg files for action section_action/OdomRecord /home/user/catkin_ws/src/section_action/action/OdomRecord.action
Generating for action OdomRecord
CMake Error at /home/user/catkin_ws/build/section_action/cmake/section_action-genmsg.cmake:3 (message):
  Could not find messages which
  '/home/user/catkin_ws/devel/share/section_action/msg/OdomRecordAction.msg'
  depends on.  Did you forget to specify generate_messages(DEPENDENCIES ...)?

  Cannot locate message [Point] in package [section_action] with paths
  [['/home/user/catkin_ws/devel/share/section_action/msg']]
Call Stack (most recent call first):
  /opt/ros/noetic/share/genmsg/cmake/genmsg-extras.cmake:307 (include)
  section_action/CMakeLists.txt:68 (generate_messages)


-- Configuring incomplete, errors occurred!
See also "/home/user/catkin_ws/build/CMakeFiles/CMakeOutput.log".
See also "/home/user/catkin_ws/build/CMakeFiles/CMakeError.log".
Invoking "cmake" failed

The notebook in rosject just offer the action content. So I follow the guidence in the course book of “ROS Basics in 5 Days”. To be honest, there are many typo errors in this part in course book, the contents are even sometimes contradictary to each other. Compared with the error I get, I have some doubts:
1.
the error info says:

Could not find messages which
  '/home/user/catkin_ws/devel/share/section_action/msg/OdomRecordAction.msg'
  depends on.  Did you forget to specify generate_messages(DEPENDENCIES ...)?

and my corresponding code in Cmake.txt is:

## Generate added messages and services with any dependencies listed here
generate_messages(
  DEPENDENCIES
  actionlib_msgs
)

which is exactly following the guidance in course book.
But the error shows we need ‘messages’ for another ‘.msg’ file to depend on, but we are doing ‘action’ here right? Why should we need to consider ‘.msg’? I have correctly named my .action file as:

OdomRecord.action

the second error says:

Cannot locate message [Point] in package [section_action] with paths
  [['/home/user/catkin_ws/devel/share/section_action/msg']]

I have searched for some answers, one of them says that ‘Point’ is not a built-in defaultly type in ROS. Is it true? and we cannot just use it here? Although I followed the construction of that answer and change ‘Point’ to ‘geometric_msgs/point’, it doesn’t work as well.

Please help, I have seen many forums talking about this exactly same error, but none of them fix it.

HI @MeineLiebeAxt ,

You must add as “dependencies” all the message types used in the custom message.
I believe action message uses geometry_msgs/Point32 and float32, therefore you must include geometry_msgs and std_msgs in your CMakeLists.txt and package.xml.

Yes you must replace Point[] list_of_odoms to geometry_msgs/Point32[] list_of_odoms.

You also forgot to incude actionlib in your dependencies.

Let me know if you still need help.

Regards,
Girish

Hi @girishkumar.kannan
Thank you very much! It is finally solved! Finally there is an answer directly to the point…
By the way I still need some small clarifications:
1.
what is the difference if I set the type of ‘list_of_odoms’ as:

geometry_msgs/Point32

instead of:

geometry_msgs/Point32[]

I have tried that and the catkin_make also works. But they do have differences right? I guess without ‘[ ]’ makes ‘list_of_odoms’ cannot restore many points as a list. So may I say that if I want any other variables which are similar with this case, to have ability to stare multipul values as a list, just define it with an ‘[ ]’ afterwards?
2.
would you please, if not bother, explain what do these 3 functions do:

find_package(catkin REQUIRED COMPONENTS
  actionlib_msgs
  geometry_msgs
)

and:

generate_messages(
  DEPENDENCIES
  actionlib_msgs
  geometry_msgs
)

and:

catkin_package(
#  INCLUDE_DIRS include
#  LIBRARIES section_action
 CATKIN_DEPENDS rospy 
#  DEPENDS system_lib
)

and what is their relation?
which one(s) determine the conten of package.xml?

Hi @MeineLiebeAxt ,

This, geometry_msgs/Point32, is a single Point32 message with x, y, z. —> [x, y, z]
Whereas, geometry_msgs/Point32[] is an array of Point32 messages with x, y, z. —> [[x, y, z], [x, y, z]…]
It signifies an array just like you do in C++ as

float my_array[] = {1.2, 2.3, 3.4, 4.5, 5.6}
              ^^

find_package() finds/collects all the required built-in packages for ROS program package (your ROS package).
generate_messages() collects all the built-in ROS packages for your custom messages.
In catkin_package() under CATKIN_DEPENDS, you add all the ROS built-in packages and other dependent packages for your ROS package to run.

packages.xml file should contain all the ROS built-in package dependencies along with message_generation and message_runtime for custom messages. package.xml must also include any other ROS packages that you plan to use for your current ROS package.

Hope I clarified your doubts.

Regards,
Girish

Thanks.
So we should also add message_generation and message_runtime in package.xml, because we define new action type here?

Hi @MeineLiebeAxt ,

I think it is not required for action messages, but if the package contains service messages and/or any other regular messages then yes.

– Girish

thank you very much! @girishkumar.kannan