Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

catkin_make not detecting .msg files in msg directory

I'm fairly new to ROS, so I don't fully comprehend what's going on. This wasn't an issue until I installed some new python libraries to my computer earlier today. Essentially, when I run catkin_make it doesn't make the msg files available as header files in the include directory in the devel directory. So when it tries to compile the .cpp files in the source directory it says "mobility/Resource.h" no such file or directory.

Now, when I move the .msg files up one directory to the same directory as mobility/ where CMakeLists.txt and package.xml are, then it does detect them. This is the current directory structure with the .msg files where they are supposed to be.

This wasn't an issue at all until today. It compiled perfectly before today.

Doesn't compile with this:

mobility/
├── CMakeLists.txt
├── msg
│   ├── Pose2D.msg
│   ├── Resource.msg
│   └── Status.msg
├── package.xml
└── src
    └── mobility.cpp

Compiles with this:

src/mobility/
├── CMakeLists.txt
├── msg
│   ├── Pose2D.msg
│   ├── Resource.msg
│   └── Status.msg
├── package.xml
├── Pose2D.msg
├── Resource.msg
├── src
│   └── mobility.cpp
└── Status.msg

Current CMake file:

cmake_minimum_required(VERSION 2.8.3)
project(mobility)

find_package(catkin REQUIRED COMPONENTS
  geometry_msgs
  roscpp
  sensor_msgs
  std_msgs
  random_numbers
  message_generation
)

add_message_files(
    FILES
    Resource.msg
    Pose2D.msg
    Status.msg
    )

generate_messages(
    DEPENDENCIES
    std_msgs
    )

catkin_package(
  CATKIN_DEPENDS 
  geometry_msgs 
  roscpp 
  sensor_msgs 
  std_msgs 
  random_numbers
  message_runtime
)


add_executable(
  mobility src/mobility.cpp
)

target_link_libraries(
  mobility
  ${catkin_LIBRARIES}
)

package.xml:

<?xml version="1.0"?>
<package>
  <name>mobility</name>
  <version>0.2.0</version>
  <description>Algorithmic implementation of random search as a finite state machine</description>

  <maintainer email="swarmathon@cs.unm.edu">NASA Swarmathon</maintainer>

  <license>GPLv2</license>

  <buildtool_depend>catkin</buildtool_depend>
  <build_depend>geometry_msgs</build_depend>
  <build_depend>roscpp</build_depend>
  <build_depend>sensor_msgs</build_depend>
  <build_depend>std_msgs</build_depend>
  <build_depend>random_numbers</build_depend>
  <build_depend>message_generation</build_depend>

  <run_depend>geometry_msgs</run_depend>
  <run_depend>roscpp</run_depend>
  <run_depend>sensor_msgs</run_depend>
  <run_depend>std_msgs</run_depend>
  <run_depend>random_numbers</run_depend>
  <run_depend>message_runtime</run_depend>

</package>

first few lines of mobility.cpp:

#include <ros/ros.h>

//ROS libraries
#include <angles/angles.h>
#include <random_numbers/random_numbers.h>
#include <tf/transform_datatypes.h>

//ROS messages
#include <std_msgs/Int16.h>
#include <std_msgs/UInt8.h>
#include <std_msgs/String.h>
#include <sensor_msgs/Joy.h>
#include <sensor_msgs/Range.h>
#include <geometry_msgs/Pose2D.h>
#include <geometry_msgs/Twist.h>
#include <nav_msgs/Odometry.h>
#include "mobility/Resource.h"
#include "mobility/Pose2D.h"
#include "mobility/Status.h"
#include <map>
// To handle shutdown signals so the node quits properly in response to "rosnode kill"
#include <ros/ros.h>
#include <signal.h>

catkin_make not detecting .msg files in msg directory

I'm fairly new to ROS, so I don't fully comprehend what's going on. This wasn't an issue until I installed some new python libraries to my computer earlier today. Essentially, when I run catkin_make it doesn't make the msg files available as header files in the include directory in the devel directory. So when it tries to compile the .cpp files in the source directory it says "mobility/Resource.h" no such file or directory.

Now, when I move the .msg files up one directory to the same directory as mobility/ where CMakeLists.txt and package.xml are, then it does detect them. This is the current directory structure with the .msg files where they are supposed to be.

This wasn't an issue at all until today. It compiled perfectly before today.

Oh yes. So if I do rosmsg list | grep mobility all 3 msg files show up.

Doesn't compile with this:

mobility/
├── CMakeLists.txt
├── msg
│   ├── Pose2D.msg
│   ├── Resource.msg
│   └── Status.msg
├── package.xml
└── src
    └── mobility.cpp

Compiles with this:

src/mobility/
├── CMakeLists.txt
├── msg
│   ├── Pose2D.msg
│   ├── Resource.msg
│   └── Status.msg
├── package.xml
├── Pose2D.msg
├── Resource.msg
├── src
│   └── mobility.cpp
└── Status.msg

Current CMake file:

cmake_minimum_required(VERSION 2.8.3)
project(mobility)

find_package(catkin REQUIRED COMPONENTS
  geometry_msgs
  roscpp
  sensor_msgs
  std_msgs
  random_numbers
  message_generation
)

add_message_files(
    FILES
    Resource.msg
    Pose2D.msg
    Status.msg
    )

generate_messages(
    DEPENDENCIES
    std_msgs
    )

catkin_package(
  CATKIN_DEPENDS 
  geometry_msgs 
  roscpp 
  sensor_msgs 
  std_msgs 
  random_numbers
  message_runtime
)


add_executable(
  mobility src/mobility.cpp
)

target_link_libraries(
  mobility
  ${catkin_LIBRARIES}
)

package.xml:

<?xml version="1.0"?>
<package>
  <name>mobility</name>
  <version>0.2.0</version>
  <description>Algorithmic implementation of random search as a finite state machine</description>

  <maintainer email="swarmathon@cs.unm.edu">NASA Swarmathon</maintainer>

  <license>GPLv2</license>

  <buildtool_depend>catkin</buildtool_depend>
  <build_depend>geometry_msgs</build_depend>
  <build_depend>roscpp</build_depend>
  <build_depend>sensor_msgs</build_depend>
  <build_depend>std_msgs</build_depend>
  <build_depend>random_numbers</build_depend>
  <build_depend>message_generation</build_depend>

  <run_depend>geometry_msgs</run_depend>
  <run_depend>roscpp</run_depend>
  <run_depend>sensor_msgs</run_depend>
  <run_depend>std_msgs</run_depend>
  <run_depend>random_numbers</run_depend>
  <run_depend>message_runtime</run_depend>

</package>

first few lines of mobility.cpp:

#include <ros/ros.h>

//ROS libraries
#include <angles/angles.h>
#include <random_numbers/random_numbers.h>
#include <tf/transform_datatypes.h>

//ROS messages
#include <std_msgs/Int16.h>
#include <std_msgs/UInt8.h>
#include <std_msgs/String.h>
#include <sensor_msgs/Joy.h>
#include <sensor_msgs/Range.h>
#include <geometry_msgs/Pose2D.h>
#include <geometry_msgs/Twist.h>
#include <nav_msgs/Odometry.h>
#include "mobility/Resource.h"
#include "mobility/Pose2D.h"
#include "mobility/Status.h"
#include <map>
// To handle shutdown signals so the node quits properly in response to "rosnode kill"
#include <ros/ros.h>
#include <signal.h>