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

Fix catkin workspace, can't launch newly compiled nodes

asked 2015-06-17 08:51:59 -0500

Cesare gravatar image

updated 2015-06-18 05:06:26 -0500

Hello I'm having issues running new modules, the compilation goes right but rosrun can't find the new nodes, i guess it's en environment issue, but as I'm a noob, it's just a guess :)

I have the catkin ws under ~/ros_ws/, in this folder i have my package pcltest, that have a single source file src/pcltest_node.cpp When i run catkin_make i can see the compilation having success:

...
[100%] Building CXX object pcltest/CMakeFiles/pcltest_node.dir/src/pcltest_node.cpp.o
Linking CXX executable pcltest_node
[100%] Built target pcltest_node
...

And I can find my binary compiled in ~/ros_ws/build/pcltest/pcltest_node

This is the output of catkin_make install

-- Install configuration: ""
-- Up-to-date: /home/cesare/ros_ws/install/_setup_util.py
-- Up-to-date: /home/cesare/ros_ws/install/env.sh
-- Up-to-date: /home/cesare/ros_ws/install/setup.bash
-- Up-to-date: /home/cesare/ros_ws/install/setup.sh
-- Up-to-date: /home/cesare/ros_ws/install/setup.zsh
-- Up-to-date: /home/cesare/ros_ws/install/.rosinstall
-- Up-to-date: /home/cesare/ros_ws/install/lib/pkgconfig/pcltest.pc
-- Up-to-date: /home/cesare/ros_ws/install/share/pcltest/cmake/pcltestConfig.cmake
-- Up-to-date: /home/cesare/ros_ws/install/share/pcltest/cmake/pcltestConfig-version.cmake
-- Up-to-date: /home/cesare/ros_ws/install/share/pcltest/package.xml

then usually I source /home/cesare/ros_ws/install/setup.bash but when i try to run the node with rosrun pcltest xxx i have an error, it looks like it's not copying the binary from the build to the install folder... what am I doing wrong ?

----- ----- ----- EDIT ----- ----- -----
I've tried to source /home/cesare/ros_ws/devel/setup.bash but it doesn't change much. In both the cases rosrun is able to find (and autocoplete) the package but it can't find che binary :(

This is how it looks my 'devel/share' dir

.
└── pcltest
    └── cmake
        ├── pcltestConfig.cmake
        └── pcltestConfig-version.cmake

This is the install/share dir

.
└── pcltest
    ├── cmake
    │   ├── pcltestConfig.cmake
    │   └── pcltestConfig-version.cmake
    └── package.xml

This is the package in the build dir

drwxrwxr-x  4 cesare cesare   4096 giu 18 10:46 .
drwxrwxr-x  8 cesare cesare   4096 giu 18 10:47 ..
drwxrwxr-x  4 cesare cesare   4096 giu 18 10:46 catkin_generated
drwxrwxr-x 47 cesare cesare   4096 giu 18 10:46 CMakeFiles
-rw-rw-r--  1 cesare cesare   2280 giu 18 10:46 cmake_install.cmake
-rw-rw-r--  1 cesare cesare    277 giu 18 10:46 CTestTestfile.cmake
-rw-rw-r--  1 cesare cesare  41872 giu 18 10:46 Makefile
-rwxrwxr-x  1 cesare cesare 466725 giu 18 10:46 pcltest_node

CMakeList.txt

cmake_minimum_required(VERSION 2.8.3)
project(pcltest)

find_package(catkin REQUIRED COMPONENTS
  pcl_ros
  roscpp
  rospy
  std_msgs
)
#add_executable(pcltest src/pcltest.cpp) #in this position doesn't work :(
catkin_package(
)

include_directories(
  ${catkin_INCLUDE_DIRS}
)


add_executable(pcltest src/pcltest.cpp)

target_link_libraries(pcltest
   ${catkin_LIBRARIES}
)

Thank you :)

edit retag flag offensive close merge delete

Comments

Does it work if you source devel/ ? What is your cmake file?

dornhege gravatar image dornhege  ( 2015-06-17 09:28:10 -0500 )edit

You still haven't shown us your CMakeLists.txt, as @dornhege asked. Binary targets need to be install(..)-ed, they will not automagically appear in your install space.

gvdhoorn gravatar image gvdhoorn  ( 2015-06-18 04:45:11 -0500 )edit

Sorry, I didn't understood you wanted the CMakeList.txt, posted :)
Now works, I found the problem (but I don't understand), apparently it was caused by add_executable being called to early in the CMakeList (see comment in file)... however I like to know more about the install(..) ^_^

Cesare gravatar image Cesare  ( 2015-06-18 05:10:03 -0500 )edit
Cesare gravatar image Cesare  ( 2015-06-18 05:13:13 -0500 )edit

Binaries end up in devel/lib/<pkg>. They should have been built there.

dornhege gravatar image dornhege  ( 2015-06-18 05:48:14 -0500 )edit

1 Answer

Sort by » oldest newest most voted
1

answered 2015-06-18 06:07:11 -0500

gvdhoorn gravatar image

updated 2015-06-18 06:11:35 -0500

then usually I source /home/cesare/ros_ws/install/setup.bash but when i try to run the node with rosrun pcltest xxx i have an error, it looks like it's not copying the binary from the build to the install folder... what am I doing wrong ?

If you really must use the install space, you'll need to add the required install(..) statements to your CMakeLists.txt. See catkin 0.6.14 documentation » How to do common tasks » Package format 2 (recommended) » Building and installing C++ executables for more info on that.

As @dornhege mentioned, all binaries will always also end up in /path/to/catkin_ws/devel/lib/<pkg>, so if you source /path/to/catkin_ws/devel/setup.bash, you should be able to start your node, even without having an install(..) statement in your build script.


Edit:

Now works, I found the problem (but I don't understand), apparently it was caused by add_executable being called to early in the CMakeList (see comment in file).. [..]

Ordering of statements in CMakeLists.txt files is very important. This is not ROS and / or catkin specific, normal CMake can also do strange unexpected things if you don't setup your scripts correctly.

See wiki/catkin/CMakeLists.txt - Overall Structure and Ordering for an overview of the order of statements for catkin.

edit flag offensive delete link more

Comments

Thank you for all the help, i found my way out :) actually i don't think i need install() :)

Cesare gravatar image Cesare  ( 2015-06-18 06:12:13 -0500 )edit
1

For your test pkg you probably don't need it, the devel space should be enough. If you ever want to release your pkg though, you'll need to install all nodes, libraries and other files (launch files, meshes, etc). Otherwise they won't be packaged into the .deb or .rpm.

gvdhoorn gravatar image gvdhoorn  ( 2015-06-18 06:15:51 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2015-06-17 08:51:59 -0500

Seen: 1,953 times

Last updated: Jun 18 '15