custom msg to use in different node

asked 2018-04-09 08:43:02 -0600

Ashi gravatar image

updated 2018-04-09 10:03:48 -0600

mgruhler gravatar image

Hello,

I have created a custom msg in node X_node. It compiled without errors. Now I want to use this custom msg in node Y_node it gives error when compile Here is CMakeLists.txt of Y_node:

cmake_minimum_required(VERSION 2.8.3)

project(track)

find_package(catkin REQUIRED
    COMPONENTS
    pcl_ros
    roscpp
    sensor_msgs
    std_msgs
    X_node
)
add_message_files(
                  FILES
        Float32MultiArrayStamped.msg)

catkin_package(
  CATKIN_DEPENDS 
        pcl_ros
            roscpp
            sensor_msgs
        std_msgs)

include_directories(
 include
 ${catkin_INCLUDE_DIRS})

add_executable(track_obj src/Y_node.cpp)

add_dependencies(track_obj ${${X_node}_EXPORTED_TARGETS})

target_link_libraries( track_obj   ${catkin_LIBRARIES})

Here is package.xml of Y_node:

<?xml version="1.0"?>
<package format="2">
  <name>track</name>
  <version>0.0.0</version>
  <description>The track package</description>

  <buildtool_depend>catkin</buildtool_depend>

  <build_depend>roscpp</build_depend>

  <build_depend>libpcl-all-dev</build_depend>

  <build_depend>X_node</build_depend>

  <build_depend>message_generation</build_depend>

  <build_depend>pcl_ros</build_depend>

  <build_depend>sensor_msgs</build_depend>

  <build_depend>std_msgs</build_depend>

  <build_export_depend>message_runtime</build_export_depend>

  <exec_depend>roscpp</exec_depend>

  <exec_depend>X_node</exec_depend>

  <exec_depend>message_runtime</exec_depend>

  <exec_depend>pcl_ros</exec_depend>

  <exec_depend>sensor_msgs</exec_depend>

  <exec_depend>std_msgs</exec_depend>

</package>

Compilation error :

  Project 'Y_node' tried to find library 'X_node'. The library is neither a
  target nor built/installed properly.  Did you compile project 'X_node'? Did
  you find_package() it before the subdirectory containing its code is
  included?
Call Stack (most recent call first):
  /opt/ros/kinetic/share/catkin/cmake/catkinConfig.cmake:76 (find_package)
  track/CMakeLists.txt:4 (find_package)

Please help,

Regards

edit retag flag offensive close merge delete

Comments

You have to create your custom message into a message folder, and make sure you added it into the CMakeLists. The tutorial explains the correct way to implement custom msgs.

kharkad gravatar imagekharkad ( 2018-04-09 09:19:26 -0600 )edit