ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
3

Creating Custom Message using ROS Message (or Custom Message)

asked 2013-11-21 20:04:23 -0500

orion gravatar image

updated 2019-05-26 18:18:01 -0500

jayess gravatar image

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!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
16

answered 2013-11-22 05:47:05 -0500

Dirk Thomas gravatar image

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.

edit flag offensive delete link more

Comments

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.

orion gravatar image orion  ( 2013-11-22 16:53:42 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2013-11-21 20:04:23 -0500

Seen: 17,811 times

Last updated: May 26 '19