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

Error when trying to use my own .msg

asked 2013-10-29 02:54:59 -0500

Mr Hillgren gravatar image

I've tried to use my own .msg to send between nodes but I'm having some trouble. I got an answer on It before http://answers.ros.org/question/95406/how-can-i-use-my-own-msg/ but I don not get It to work properly.

The package .xml looks like this:

    <?xml version="1.0"?>
<package>
  <name>distanceCalc</name>
  <version>0.0.0</version>
  <description>The distanceCalc package</description>
  <maintainer <a href="mailto:email="patrik@todo.todo">patrik</maintainer">email="patrik@todo.todo">patrik</maintainer</a>>

  <license>TODO</license>
  <build_depend>message_generation</build_depend>
  <run_depend>message_runtime</run_depend>
  <buildtool_depend>catkin</buildtool_depend>
  <build_depend>cv_bridge</build_depend>
  <build_depend>pcl</build_depend>
  <build_depend>pcl_ros</build_depend>
  <build_depend>roscpp</build_depend>
  <build_depend>sensor_msgs</build_depend>
  <build_depend>std_msgs</build_depend>
  <build_depend>std_msgs</build_depend>
  <build_depend>stereo_msgs</build_depend>
  <build_depend>message_generation</build_depend>
  <run_depend>message_generation</run_depend>
  <build_depend>msg/distanceMessage</build_depend>
  <run_depend>msg/distanceMessage</run_depend>
  <run_depend>cv_bridge</run_depend>
  <run_depend>pcl</run_depend>
  <run_depend>pcl_ros</run_depend>
  <run_depend>roscpp</run_depend>
  <run_depend>sensor_msgs</run_depend>
  <run_depend>std_msgs</run_depend>
  <run_depend>std_msgs</run_depend>
  <run_depend>stereo_msgs</run_depend>
  <export>
  </export>
</package>

The CmakeList.txt looks like this:

cmake_minimum_required(VERSION 2.8.3)
project(distanceCalc)

find_package(catkin REQUIRED COMPONENTS
  cv_bridge
  pcl
  pcl_ros
  roscpp
  sensor_msgs
  std_msgs
  stereo_msgs
  message_generation
)
 add_message_files(FILES distanceMessage.msg)

generate_messages(DEPENDENCIES std_msgs)
include_directories(
  ${catkin_INCLUDE_DIRS}
  ${OpenCV_INCLUDE_DIRS}
  ${PCL_INCLUDE_DIRS}
)
add_executable(distanceCalc src/distanceCalculation.cpp)
target_link_libraries(distanceCalc ${catkin_LIBRARIES} ${OpenCV_LIBRARIES} ${PCL_INCLUDE_DIRS})
add_dependencies(distanceCalc distanceCalc_gen_msg_cpp)

In my case I have projects within my src folder in the catkin_ws, one of them is named distanceCalc and have a folder named msg where the message distanceMessage.msg is placed.

Is there some mistake that I'm making, because when I try to inclide the message with the line

#include <msg/distanceMessage>

in my cpp file which exists in the src folder in the project distanceCalc I get an error (when trying to perform the catkin_make command) saying

"fatal error: msg/distanceMessage: No such file or directory"?

If this is not enough information to answer the questions please inform me and I will update.

Regards, Patrik

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2013-10-29 03:37:53 -0500

davinci gravatar image

You have to include the header file of the message. You should include a build command for this in you CMakelist: http://wiki.ros.org/catkin/CMakeLists.txt#Messages.2C_Services.2C_and_Action_Targets. Then a header file is generated which you should include.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2013-10-29 02:54:59 -0500

Seen: 211 times

Last updated: Oct 29 '13