Ask Your Question
0

Message type can't be found with catkin_make

asked 2014-08-05 03:18:19 -0500

trc123 gravatar image

updated 2014-08-05 04:45:53 -0500

So I'm trying to make a publisher to publish some data from a speed controller and I know how I can get the data. I decided to use a custom message almost the same to the Pose.msg in turtlesim (with fewer fields). However whenever I run catkin make I get this error.

/home/ros/catkin_ws/src/bot/src/wheeldata.cpp: In function ‘int main(int, char**)’:
/home/ros/catkin_ws/src/bot/src/wheeldata.cpp:19:36: error: ‘Pose’ was not declared in this scope
/home/ros/catkin_ws/src/bot/src/wheeldata.cpp:19:36: note: suggested alternative:
/home/ros/catkin_ws/devel/include/bot/Pose.h:85:45: note:   ‘bot::Pose’
/home/ros/catkin_ws/src/bot/src/wheeldata.cpp:19:59: error: no matching function for call to ‘ros::NodeHandle::advertise(const char [10], int)’
/home/ros/catkin_ws/src/bot/src/wheeldata.cpp:19:59: note: candidates are:
/opt/ros/hydro/include/ros/node_handle.h:236:15: note: template<class M> ros::Publisher ros::NodeHandle::advertise(const string&, uint32_t, bool)
/opt/ros/hydro/include/ros/node_handle.h:300:13: note: template<class M> ros::Publisher ros::NodeHandle::advertise(const string&, uint32_t, const SubscriberStatusCallback&, const SubscriberStatusCallback&, const VoidConstPtr&, bool)
/home/ros/catkin_ws/src/bot/src/wheeldata.cpp:29:8: error: expected ‘;’ before ‘p’
/home/ros/catkin_ws/src/bot/src/wheeldata.cpp:30:3: error: ‘p’ was not declared in this scope
make[2]: *** [bot/CMakeFiles/wheeldata.dir/src/wheeldata.cpp.o] Error 1
make[1]: *** [bot/CMakeFiles/wheeldata.dir/all] Error 2
make: *** [all] Error 2
Invoking "make" failed

Here is the CMakeList.txt:

cmake_minimum_required(VERSION 2.8.3)
project(bot)


find_package(catkin REQUIRED COMPONENTS
  roscpp
  std_msgs
  message_generation
  bot
)

################################################
## Declare ROS messages, services and actions ##
################################################
## Generate messages in the 'msg' folder
add_message_files( DIRECTORY msg
   FILES
   Pose.msg
)

## Generate added messages and services with any dependencies listed here
#generate_messages(
#  DEPENDENCIES
#  std_msgs

#)


catkin_package(CATKIN_DEPENDS
roscpp 
std_msgs
message_runtime 
)

catkin_package()

###########
## Build ##
###########

## Specify additional locations of header files
## Your package locations should be listed before other locations
# include_directories(include)
include_directories(
  ${catkin_INCLUDE_DIRS}
)

## Add cmake target dependencies of the executable/library
## as an example, message headers may need to be generated before nodes
# add_dependencies(bot_node bot_generate_messages_cpp)



# include_directories(include ${catkin_INCLUDE_DIRS})

 add_executable(wheeldata src/wheeldata.cpp)
 target_link_libraries(wheeldata ${catkin_LIBRARIES})
 add_dependencies(wheeldata bot_generate_messages_cpp)

Here is the package.xml:

<?xml version="1.0"?>
<package>
  <name>bot</name>
  <version>0.0.0</version>
  <description>The bot package</description>


  <!-- The *_depend tags are used to specify dependencies -->
  <!-- Dependencies can be catkin packages or system dependencies -->
  <!-- Examples: -->
  <!-- Use build_depend for packages you need at compile time: -->
  <build_depend>message_generation</build_depend>
  <!-- Use buildtool_depend for build tool packages: -->
  <!--   <buildtool_depend>catkin</buildtool_depend> -->
  <!-- Use run_depend for packages you need at runtime: -->
  <run_depend>message_runtime</run_depend>
  <!-- Use test_depend for packages you need only for testing: -->
  <!--   <test_depend>gtest</test_depend> -->
  <buildtool_depend>catkin</buildtool_depend>
  <build_depend>roscpp</build_depend>
  <build_depend>rospy</build_depend>
  <build_depend>std_msgs</build_depend>
  <run_depend>roscpp</run_depend>
  <run_depend>rospy</run_depend>
  <run_depend>std_msgs</run_depend>


  <!-- The export tag contains other, unspecified, tags -->
  <export>
    <!-- You can specify that this package is a metapackage here: -->
    <!-- <metapackage/> -->

    <!-- Other tools can ...
(more)
edit retag flag offensive close merge delete

4 Answers

Sort by » oldest newest most voted
2

answered 2014-08-06 11:18:15 -0500

Chrissi gravatar image

updated 2014-08-06 11:24:19 -0500

It looks like you're using the bot/Pose message in another package as well and added it to the dependencies. See this answer especially the last part about custom messages being used in different custom packages. I think you are using the bot/Pose message somewhere else (a subscriber?!) and added it to the add_dependencies statement but not to the package.xml.

Regarding the code, it has to be bot::Pose otherwise it won't find it.

Also you should remove bot from

find_package(catkin REQUIRED COMPONENTS
roscpp
std_msgs
message_generation
bot
)

Because you are trying to build the bot package so looking for it with find_package at the same time might have unwanted effects.

edit flag offensive delete link more
1

answered 2014-08-05 04:19:55 -0500

Mehdi. gravatar image

updated 2014-08-05 04:21:18 -0500

I would say you should uncomment this part in your CMakeLists.txt in order to generate the messages.

## Generate added messages and services with any dependencies listed here
#generate_messages(
#  DEPENDENCIES
#  std_msgs  
#)
edit flag offensive delete link more

Comments

Please can you see the edit.

trc123 gravatar imagetrc123 ( 2014-08-05 04:41:25 -0500 )edit

maybe Pose is already a defined message name in ROS, in general it is a good practice to avoid using keywords like Pose for example. I am not sure about that but try using a different name for your message like MyRobotPose.msg or something unlikely to already exist.

Mehdi. gravatar imageMehdi. ( 2014-08-05 04:57:17 -0500 )edit

I've done that and changed bot to bot1 and I still get: add_custom_target cannot create target "bot1_generate_messages_lisp" because another target with the same name already exists.

trc123 gravatar imagetrc123 ( 2014-08-05 05:36:39 -0500 )edit
0

answered 2014-08-05 04:21:29 -0500

updated 2014-08-05 04:25:31 -0500

I think you are missing some include files. Try to include this in your source code:

#include <bot/Pose.h>

This should be the header file auto-generated for your message definition.

Also, I don't know if the code that you posted is complete, but there is also missing:

#include <ros/ros.h>

I hope this helps

edit flag offensive delete link more

Comments

sorry, I do have these includes, for some reason I didn't paste them in: #include "ros/ros.h" #include "std_msgs/String.h" #include "bot/Pose.h"

trc123 gravatar imagetrc123 ( 2014-08-05 04:30:08 -0500 )edit
0

answered 2014-08-05 05:23:10 -0500

RobotnikRoman gravatar image

Hi,

When you declare the variable Pose, do you declare it as "Pose" or "bot::Pose". In that case, try declaring as bot::Pose

/home/ros/catkin_ws/src/bot/src/wheeldata.cpp:19:36: error: ‘Pose’ was not declared in this scope

Regards

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2014-08-05 03:18:19 -0500

Seen: 2,832 times

Last updated: Aug 06 '14