0
$\begingroup$

Rosanswers logo

My problem is similar to this link, however, I do understand how to use messages within the same package. My problem focuses on how to include a message from a separate package. I have created a package with some "CustomMessage" that pulls from other packages and their messages. These messages may be from a common package within my system, or a simple message type within geometry_msgs.

I have tried including the required dependencies in the CMakeLists.txt and Package.xml files, but for the code to work I have to include the package name in the variable type call. For example:

common_package/Variable variable_text

If the package name is not included, I get something like:

Could not find messages which
  '../CustomMessage.msg'
  depends on.  Did you forget to specify generate_messages(DEPENDENCIES ...)?

Cannot locate message [PoseArray] in package [mission_control]

Is this the only way to include a custom message from another package, or is there a better way? During my search, I found one other solution that followed this train of though at this link. However, I was under the assumption that by correctly setting the CMakeLists.txt and Package.xml file correctly, it would understand the pathing.

For those who will ask, below is the CMakeLists.txt file:

cmake_minimum_required(VERSION 2.8.3)
project(mission_control)

find_package(catkin REQUIRED COMPONENTS 
    project_common
    roscpp
    rospy
    geometry_msgs
    std_msgs
    message_generation
)

add_message_files(
   FILES
   CustomMessage1.msg
   CustomMessage2.msg
)

generate_messages(
    DEPENDENCIES
    geometry_msgs
    std_msgs
    project_common
)

catkin_package(
   #  INCLUDE_DIRS include
   #  LIBRARIES mission_control
   CATKIN_DEPENDS message_runtime project_common geometry_msgs std_msgs
   #  DEPENDS system_lib
)

include_directories(
    ${catkin_INCLUDE_DIRS}
)

Thanks for the help!


Originally posted by orion on ROS Answers with karma: 213 on 2013-11-21

Post score: 3

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

The error message indicates that you use PoseArray without prefixing it with geometry_msgs. Can you please post your message file in the question?

Just to clarify the syntax in a message file - it is:

PackageName/VariableType variable_name

The PackageName/ is left out when referring to message from the same package.


Originally posted by Dirk Thomas with karma: 16276 on 2013-11-22

This answer was ACCEPTED on the original site

Post score: 16


Original comments

Comment by orion on 2013-11-22:
Actually, that is exactly what I was asking. I added that to my message file and the error went away as I mentioned in the question. I was mainly wondering if that was the correct way or if there was another way. My assumption was that it was correct, but thanks for confirming.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.