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

Could not find your msg 'messageType' after following ros wiki tutorial step by step.

asked 2020-08-18 13:44:27 -0500

MaxM gravatar image

updated 2020-08-19 02:24:38 -0500

Delb gravatar image

So I had some trouble with using a custom message type, that's why I decided to follow the tutorials on RosWiki (http://wiki.ros.org/ROS/Tutorials). Unfortunately, this didn't work either. After rosmsg show messageType.msg it outputted: Could not find msg 'messageType'

I hope that I didn't put too much code :)

I am using Ros Melodic on Ubuntu 18.04 (bionic).

The file 'messageType.msg':

string name
uint32 age

The package.xml file:

 <?xml version="1.0"?>

    <package format="2">
      <name>pack</name>
      <version>0.0.0</version>
      <description>The description sentence</description>

      <maintainer email="max@todo.todo">max</maintainer>

  <license>TODO</license>

  <build_depend>message_generation</build_depend>
  <exec_depend>message_runtime</exec_depend>
  <buildtool_depend>catkin</buildtool_depend>
  <build_depend>roscpp</build_depend>
  <build_depend>rospy</build_depend>
  <build_depend>std_msgs</build_depend>
  <build_export_depend>roscpp</build_export_depend>
  <build_export_depend>rospy</build_export_depend>
  <build_export_depend>std_msgs</build_export_depend>
  <exec_depend>roscpp</exec_depend>
  <exec_depend>rospy</exec_depend>
  <exec_depend>std_msgs</exec_depend>


  <!-- The export tag contains other, unspecified, tags -->
  <export>
    <!-- Other tools can request additional information be placed here -->

  </export>
</package>

The CMakeLists.txt file:

cmake_minimum_required(VERSION 3.0.2)
project(pack)

find_package(catkin REQUIRED COMPONENTS
  roscpp
  rospy
  std_msgs
  message_generation
)

add_message_files(
  FILES
  messageType.msg
)

generate_messages(
  DEPENDENCIES
  std_msgs
)

catkin_package(
  CATKIN_DEPENDS message_runtime
)

include_directories(
# include
  ${catkin_INCLUDE_DIRS}
)
edit retag flag offensive close merge delete

Comments

Don't put all the comments in your code, it makes it harder to read the code, I've removed it for you.

Where is your file messageType.msg ? Is it in a folder msg (or another name that you chose ?), you might need to add DIRECTORY msg (msg or the name you chose) in add_message_files.

Moreover have you compiled and sourced before trying to find the message ?

Delb gravatar image Delb  ( 2020-08-19 02:37:35 -0500 )edit

messageType.msg is indeed in a folder msg and I've added DIRECTORY msg to add_message_files as you said, but after rosmsg show messageType.msg, it still outputs Could not find msg 'messageType'. Oh, and yes, I compiled and sourced before trying.

MaxM gravatar image MaxM  ( 2020-08-19 04:24:53 -0500 )edit
1

You might need to add more context to your issue because I couldn't reproduce it. I managed to have rosmsg working using your CmakeLists.txt and package.xml. I only have your issue when I don't source the catkin workspace, what is your output of rosmsg show pack/messageType ? When you type rosmsg show and then tabulate, is your package pack in the list ?

Delb gravatar image Delb  ( 2020-08-19 07:30:03 -0500 )edit

When I type rosmsg show and then tabulate it, my package pack is not in the list.

what is your output of rosmsg show pack/messageType ? I get an error, it is too long for a comment so I'll post it in the next comment

MaxM gravatar image MaxM  ( 2020-08-19 07:46:21 -0500 )edit

If you don't have your package in the list then you don't have sourced your workspace, have you really done source devel/setup.bash ? What is the value of the environment variable ROS_PACKAGE_PATH ?

Delb gravatar image Delb  ( 2020-08-19 07:48:32 -0500 )edit

I'll just post the beginning, because when I try to post the full error, I get a message saying "This content is forbidden".

Unable to load msg [pack/messageType]: Cannot locate message [messageType]: unknown package [pack] on search path [{'rosconsole': ['/opt/ros/melodic/share/rosconsole/msg'], 'catkin': ['/opt/ros/melodic/share/catkin/msg'], 'qt_dotgraph': ['/opt/ros/melodic/share/qt_dotgraph/msg'], 'image_view': ['/opt/ros/melodic/share/image_view/msg'], 'urdf': ['/opt/ros/melodic/share/urdf/msg'], 'rosgraph': ['/opt/ros/melodic/share/rosgraph/msg'], 'resource_retriever': ['/opt/ros/melodic/share/resource_retriever/msg'], 'nodelet_topic_tools': ['/opt/ros/melodic/share/nodelet_topic_tools/msg'], 'rqt_graph': ['/opt/ros/melodic/share/rqt_graph/msg'], 'nodelet_tutorial_math': ['/opt/ros/melodic/share/nodelet_tutorial_math/msg'], 'qt_gui': ['/opt/ros/melodic/share/qt_gui/msg'], 'filters': ['/opt/ros/melodic/share/filters/msg'], 'smclib': ['/opt/ros/melodic/share/smclib/msg'],
MaxM gravatar image MaxM  ( 2020-08-19 07:50:15 -0500 )edit

About the sourcing of the workspace. I did source /opt/ros/melodic/setup.bash. When I try to do source devel/setup.bash, I get this output: bash: devel/setup.bash: No such file or directory, but i do have a devel space so I don't know what's causing this problem.

MaxM gravatar image MaxM  ( 2020-08-19 07:54:11 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2020-08-19 08:00:33 -0500

Delb gravatar image

You need to source your workspace. The command source devel/setup.bash only works if you are at the top level of your catkin workspace.

The source command can be used to load any functions file into the current shell script or a command prompt (source) and you use it doing source PATH_TO_THE_FILE_TO_SOURCE. If the current directory in your terminal is at the same level of your devel folder then the first command will work, if not you need to specify the path from your current directory or from the root.

edit flag offensive delete link more

Comments

I sourced my workspace like you said, but it still outputs Could not find msg 'messageType'. When i type rosmsg show and then tabulate it, my package pack doesn't appear on the list. I'm sorry for all this trouble.

MaxM gravatar image MaxM  ( 2020-08-19 08:07:11 -0500 )edit

Are you doing all the commands in the same terminal ? In one terminal what you need to do is :

  1. Source ros (i.e. source /opt/ros/melodic/setup.bash, you can add this at the end of your the .bashrc file)
  2. Go to your catkin workspace where your package pack is. (i.e. cd PATH_TO_YOUR_CATKIN_WORKSPACE)
  3. Compile it (and maybe clean the workspace too : rm -r build/ devel/ and then catkin_make)
  4. Source your workspace (i.e. source devel/setup.bash since you are at the top level of the catkin ws)

After this it should work, to ensure that you can check if the ouput of echo $ROS_PACKAGE_PATH contains the path to your catkin workspace.

Delb gravatar image Delb  ( 2020-08-19 08:37:23 -0500 )edit

After doing all you said, it is still the same output as before. When I type rosmsg show and then tabulate it, my package pack doesn't appear on the list. Could it be because my package pack is inside a metapackage called meta? Could it be that I have to do something different if the msg folder is inside a package that's inside a metapackage?

MaxM gravatar image MaxM  ( 2020-08-20 03:50:45 -0500 )edit

You mean your package is inside a meta package ? From the metapackages wiki:

They do not install files (other than their package.xml manifest) and they do not contain any tests, code, files, or other items usually found in packages.

You don't put anything inside, you just put your metapackage in your catkin workspace at the same level of your packages (i.e. in the src folder of the workspace). Can you show your directory tree of your workspace please ?

Delb gravatar image Delb  ( 2020-08-20 04:42:39 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2020-08-18 13:44:27 -0500

Seen: 711 times

Last updated: Aug 19 '20