Ask Your Question
1

catkin doesn't create test executable

asked 2015-01-18 11:31:32 -0600

Matthew.J gravatar image

updated 2015-01-18 14:40:57 -0600

I'm trying to create subscriber for PR2 kinect, but I'm stuck with the most basic thing. I expected to compile this test package and begin with functionality implementation. But catkin_make doesn't build any executable for this package. my package structure:

./package.xml
./CMakeLists.txt
./src
./src/test.cpp
./include
./include/test
./include/test/test.hpp

CMakeLists:

cmake_minimum_required(VERSION 2.8.3)
project(test)

find_package(catkin REQUIRED COMPONENTS
  pcl_ros
  roscpp
  sensor_msgs
  std_msgs
)

catkin_package(
  INCLUDE_DIRS include
)
include_directories(
  ${catkin_INCLUDE_DIRS}
)
add_executable(test src/test.cpp)

test.cpp:

#include <test/test.hpp>

void processPoint::processCloud( const sensor_msgs::PointCloud2ConstPtr& cloud )
{

}

int main(int argc, char **argv) 
{
  init(argc, argv, "test");

  //ros::NodeHandle n;

  processPoint processPoint;

  ros::spin();

  return 0;
}

test.hpp:

#include <ros/ros.h>
#include <pcl_ros/point_cloud.h>
#include <sensor_msgs/PointCloud2.h>

using namespace ros;
using namespace sensor_msgs;

class processPoint {
    NodeHandle nh;
    Subscriber sub;

public:
    processPoint() {
        sub = nh.subscribe<sensor_msgs::PointCloud2>("/head_mount_kinect/depth/points", 1, &processPoint::processCloud, this);
    }

    ~processPoint() {   
     }

    void processCloud( const sensor_msgs::PointCloud2ConstPtr& cloud );
};

And finally catkin_make result:

Base path: /home/ros-user/catkin_ws
Source space: /home/ros-user/catkin_ws/src
Build space: /home/ros-user/catkin_ws/build
Devel space: /home/ros-user/catkin_ws/devel
Install space: /home/ros-user/catkin_ws/install
####
#### Running command: "cmake /home/ros-user/catkin_ws/src -DCATKIN_DEVEL_PREFIX=/home/ros-user/catkin_ws/devel -DCMAKE_INSTALL_PREFIX=/home/ros-user/catkin_ws/install" in "/home/ros-user/catkin_ws/build"
####
-- Using CATKIN_DEVEL_PREFIX: /home/ros-user/catkin_ws/devel
-- Using CMAKE_PREFIX_PATH: /home/ros-user/catkin_ws/devel;/opt/ros/hydro
-- This workspace overlays: /home/ros-user/catkin_ws/devel;/opt/ros/hydro
-- Using PYTHON_EXECUTABLE: /usr/bin/python
-- Python version: 2.7
-- Using Debian Python package layout
-- Using CATKIN_ENABLE_TESTING: ON
-- Call enable_testing()
-- Using CATKIN_TEST_RESULTS_DIR: /home/ros-user/catkin_ws/build/test_results
-- Found gtest sources under '/usr/src/gtest': gtests will be built
-- catkin 0.5.89
-- BUILD_SHARED_LIBS is on
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- ~~  traversing 1 packages in topological order:
-- ~~  - test
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- +++ processing catkin package: 'test'
-- ==> add_subdirectory(test)
-- Using these message generators: gencpp;genlisp;genpy
-- Configuring done
-- Generating done
-- Build files have been written to: /home/ros-user/catkin_ws/build
####
#### Running command: "make -j4 -l4" in "/home/ros-user/catkin_ws/build"
####

I think that after Running command: "make -j4 -l4" should follow compilation of executable test defined by add_executable(test src/test.cpp) but nothing happens. I had no problems with compiling tutorials so I have no idea why this package doesn't work.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
4

answered 2015-01-18 13:46:23 -0600

gvdhoorn gravatar image

I can only think of two things:

  1. You named your target test: this could cause a name clash with actual testing targets
  2. You don't have a target_link_libraries(..) invocation in your CMakeLists.txt

I'd be surprised if it is the second, but the first does make sense, sort of.

edit flag offensive delete link more

Comments

I created package under new name and it helped. I was already going nutz from this. THX

Matthew.J gravatar imageMatthew.J ( 2015-01-18 14:45:10 -0600 )edit

Can you confirm whether it was the name clash?

gvdhoorn gravatar imagegvdhoorn ( 2015-01-18 15:41:25 -0600 )edit

Yes it was. After renaming it I got compiler error because CMakefile wasn't correctly set up for header files.

Matthew.J gravatar imageMatthew.J ( 2015-01-18 16:11:39 -0600 )edit
1

This is no longer allowed in CMake >= 3.0: https://cmake.org/cmake/help/v3.0/pol...

William gravatar imageWilliam ( 2016-06-01 16:57:30 -0600 )edit

Your Answer

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

Add Answer

Question Tools

1 follower

Stats

Asked: 2015-01-18 11:31:32 -0600

Seen: 1,799 times

Last updated: Jan 18 '15