ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A answers.ros.org

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

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)
project(floorbot)
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_directories(
include ${catkin_INCLUDE_DIRS} install/include/floorbot${mraa_INCLUDE_DIRS})

generate_messages(DEPENDENCIES std_msgs)

catkin_package(
${catkin_CURRENT_SOURCE_DIR} INCLUDE_DIRS include LIBRARIES floorbot mraa util CATKIN_DEPENDS roscpp std_msgs message_runtime DEPENDS system_lib mraa) add_library(util src/robot.cpp src/flags.cpp) add_dependencies(util${catkin_EXPORTED_TARGETS})
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) project(robot_ctlr) find_package(catkin REQUIRED COMPONENTS roscpp rospy std_msgs message_generation #gazebo_ros ) find_package(gazebo REQUIRED) add_message_files( FILES commands.msg ) generate_messages( DEPENDENCIES std_msgs ) catkin_package( #INCLUDE_DIRS include LIBRARIES robot_ctlr CATKIN_DEPENDS roscpp rospy std_msgs message_runtime DEPENDS system_lib #gazebo_ros ) include_directories(include${catkin_INCLUDE_DIRS} install/include/robot_ctlr)

find_package(X11 REQUIRED)
link_libraries(${X11_LIBRARIES}) include_directories(${X11_INCLUDE_DIR})



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 close merge delete

Sort by » oldest newest most voted

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
catkin_init_workspace
cd ..
catkin_make
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!

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?

( 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.

( 2016-11-18 13:58:47 -0500 )edit