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

ERROR: Cannot load message class for [*]. Are your messages built? (Indigo)

asked 2016-11-17 15:49:17 -0500

titan vista gravatar image

I've read several other questions on this topic and the common solutions seem to be 'catkin_make clean', 'catkin_make' to rebuild and source 'devel/setup.bash' or including the msg file in the CMakeLists.txt 'add_message_files()'. I'm not completely sure what "Are your messages built?" means. I've found a .h file of the messages under 'catkin_ws/install/include/floorbot/' so that appears to have been made.

A little more about where I am in this project; I have ROS master running on a desktop (running Ubuntu 14 & ROS Indigo) that is successfully creating messages. Running 'rostopic list' I see '/chat' - my messages. With 'rostopic echo /chat' I can see the actual messages. So that end seems to be setup fine.

If I ssh into my robot (Up Board SBC, running Ubuntu 14 & ROS Indigo), or work directly on the robot I get the same result: If I run 'rostopic list' I can see '/chat'. When I run 'rostopic echo /chat' I get "ERROR: Cannot load message class for [robot_ctlr/commands]. Are your messages built?".

So my current thought is that I have a conflict ion my message scheme. I wrote these project separately and as different projects. The robot is called 'floorbot', so that means that the package is called floorbot and the #include at the top of my main executable is #include ' "floorbot/commands.h" '. My desktop project name is 'robot_ctlr' in a package called 'robot_ctlr' and at the top of my main executable is ' #include "robot_ctlr/commands.h" '.

If that's what causing it, what should I change to make them happy? I tried reworking the naming, but that's given me a lot more problems. If that's not the cause, where else should I look?

Just in case this is helpful, here's the CMakeLists.txt from the robot:

cmake_minimum_required(VERSION 2.8.3)
find_package(catkin REQUIRED COMPONENTS roscpp std_msgs message_generation)
find_package(Boost REQUIRED COMPONENTS system)
find_package(PkgConfig REQUIRED)
pkg_check_modules(mraa REQUIRED mraa)

  include ${catkin_INCLUDE_DIRS}

add_message_files(FILES commands.msg)
generate_messages(DEPENDENCIES std_msgs)

  INCLUDE_DIRS include
  LIBRARIES floorbot mraa util
  CATKIN_DEPENDS roscpp std_msgs
  DEPENDS system_lib mraa)

add_library(util src/robot.cpp src/flags.cpp)
add_dependencies(util ${catkin_EXPORTED_TARGETS})
add_executable(floorbot src/sojourner.cpp)
target_link_libraries(floorbot util ${catkin_LIBRARIES} ${mraa_LIBRARIES})
add_dependencies(floorbot floorbot_generate_message_cpp ${catkin_EXPORTED_TARGETS})

This is the CMakeLists.txt for the robot_ctlr:

cmake_minimum_required(VERSION 2.8.3)

find_package(catkin REQUIRED COMPONENTS

find_package(gazebo REQUIRED)



  #INCLUDE_DIRS include
  LIBRARIES robot_ctlr
  CATKIN_DEPENDS roscpp rospy std_msgs message_runtime
  DEPENDS system_lib

include_directories(include ${catkin_INCLUDE_DIRS} install/include/robot_ctlr)

find_package(X11 REQUIRED)

add_executable(ucomm ucomm.cpp)
target_link_libraries(ucomm ${catkin_LIBRARIES})

For now, I'm going to try and fix what I just broke.

I can include more code, but I'm not sure what would be helpful.

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2016-11-18 11:31:26 -0500

titan vista gravatar image

updated 2016-11-18 11:42:59 -0500

Okay, it works now so I'll answer my own question and maybe it will help someone else down the road.

[floorbot/commands] vs [robot_ctlr/commands] was the issue. I was hoping that the 'commands' part was all it needed. Not the case. So I tried changing ever instance of robot_ctlr to floorbot (file names, folder names and the string in the text of any file). It took me a while but I did it. It was still very broke. So below I will explain how I rebuilt my work space with a new name, since I've never seen specific directions on how to do this.

Rebuilding a catkin workspace from the source code:

I did this as a copy.

First make a new folder in you home directory. I called it 'testkin_ws'.
You get this: ~/testkin_ws/ (/home/<computer_name" testkin_ws)<="" p="">

Next make an 'src' folder in there so you get this: ~/testkin_ws/src/

Copy just the code folder (my was named 'robot_ctlr' I had to rename it 'floorbot' - it also contained the msg folder with my 'commands.msg file') into 'src' and change all the instances of 'robot_ctlr' to 'floobot'. Of course, those names would be the ones that you want to change. I used the find and replace function in Atom. With all the names changed, now all we need to do is rebuild the workspace and let catkin rebuild the project.

Still in 'src' type 'catkin_init_workspace'.

Go back to 'testkin_ws' (cd ..) and type 'catkin_make' to build the solution.

Source the setup from that same location too - 'source devel/setup.bash'.

I also ran 'catkin_make install' to make the 'build' folder too.

So that's it! I'll reiterate it here with command line input (this is the same as above):

From the GUI, make a new folder in the home directory 'testkin_ws' and inside that make a folder 'src'. You get ~/testkin_ws/src/. Copy the source files and folders into 'src', open in an editor and change all instances of the old name to the new. Also change the main folder inside 'src' to match the name of the project. Now open a terminal. Type the following:

cd testkin_ws/src
cd ..
source devel/setup.bash

Then I did

catkin_make install

Rebuilt and renamed!

This was good enough to test. I ultimately took my old project, added an '_old' suffix to it and rebuilt it in a new 'catkin_ws' folder to maintain some scripts and sourcing the '.bashrc ' file.

Corrections are welcome!

edit flag offensive delete link more


Usually I get this error when I try to do a rostopic or something like that in a new terminal. Basically, because I forgot to source devel/setup.bash and therefore ROS does not know where my messages are, I didn't go through your full explanation, but might that be your issue as well?

Javier V. Gómez gravatar image Javier V. Gómez  ( 2016-11-18 12:39:57 -0500 )edit

I have that in my .bashrc, but I did try that. Ultimately it was a naming issue.

titan vista gravatar image titan vista  ( 2016-11-18 13:58:47 -0500 )edit

Question Tools

1 follower


Asked: 2016-11-17 15:49:17 -0500

Seen: 4,641 times

Last updated: Nov 18 '16