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

Catkin_make skips new package

asked 2016-05-16 20:52:46 -0500

adiadidas15 gravatar image

updated 2016-05-19 18:20:15 -0500

I am a beginner with ROS, working through chapter 2 of the Learning ROS for Robotics Programming book (2nd ed). When I use catkin_create_pkg it appears to execute normally (my terminal output matches the output shown in the book). I then change directory to my workspace and execute catkin_make. This completes without any errors, but it fails to acknowledge my new package. Using rospack find also fails to find the package. What am I missing? Thanks for your help in advance!

Edit: here's requested data to help diagnose my problem.

#Terminal input/output for catkin_make:

viki@c3po:~$ cd ~/dev/catkin_ws
viki@c3po:~/dev/catkin_ws$ catkin_make
Base path: /home/viki/dev/catkin_ws
Source space:
/home/viki/dev/catkin_ws/src Build
space: /home/viki/dev/catkin_ws/build
Devel space:
/home/viki/dev/catkin_ws/devel Install
space:
/home/viki/dev/catkin_ws/install
####
#### Running command: "make cmake_check_build_system" in
"/home/viki/dev/catkin_ws/build"
####
####
#### Running command: "make -j1 -l1" in "/home/viki/dev/catkin_ws/build"
#### viki@c3po:~/dev/catkin_ws$ rospack find chapter2_tutorials
[rospack] Error: stack/package
chapter2_tutorials not found

#CMakeLists.txt:

cmake_minimum_required(VERSION 2.8.3)
project(chapter2_tutorials)

## Find catkin macros and libraries
## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
## is used, also find other catkin packages
find_package(catkin REQUIRED COMPONENTS
  roscpp
  std_msgs
)

## System dependencies are found with CMake's conventions
# find_package(Boost REQUIRED COMPONENTS system)


## Uncomment this if the package has a setup.py. This macro ensures
## modules and global scripts declared therein get installed
## See http://ros.org/doc/api/catkin/html/user_guide/setup_dot_py.html
# catkin_python_setup()

################################################
## Declare ROS messages, services and actions ##
################################################

## To declare and build messages, services or actions from within this
## package, follow these steps:
## * Let MSG_DEP_SET be the set of packages whose message types you use in
##   your messages/services/actions (e.g. std_msgs, actionlib_msgs, ...).
## * In the file package.xml:
##   * add a build_depend and a run_depend tag for each package in MSG_DEP_SET
##   * If MSG_DEP_SET isn't empty the following dependencies might have been
##     pulled in transitively but can be declared for certainty nonetheless:
##     * add a build_depend tag for "message_generation"
##     * add a run_depend tag for "message_runtime"
## * In this file (CMakeLists.txt):
##   * add "message_generation" and every package in MSG_DEP_SET to
##     find_package(catkin REQUIRED COMPONENTS ...)
##   * add "message_runtime" and every package in MSG_DEP_SET to
##     catkin_package(CATKIN_DEPENDS ...)
##   * uncomment the add_*_files sections below as needed
##     and list every .msg/.srv/.action file to be processed
##   * uncomment the generate_messages entry below
##   * add every package in MSG_DEP_SET to generate_messages(DEPENDENCIES ...)

## Generate messages in the 'msg' folder
# add_message_files(
#   FILES
#   Message1.msg
#   Message2.msg
# )

## Generate services in the 'srv' folder
# add_service_files(
#   FILES
#   Service1.srv
#   Service2.srv
# )

## Generate actions in the 'action' folder
# add_action_files(
#   FILES
#   Action1.action
#   Action2.action
# )

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

###################################
## catkin specific configuration ##
###################################
## The catkin_package macro generates cmake config files for your package
## Declare things to be passed to dependent projects
## INCLUDE_DIRS: uncomment this if you package contains header files
## LIBRARIES: libraries you create in this project that dependent projects also need
## CATKIN_DEPENDS: catkin_packages dependent ...
(more)
edit retag flag offensive close merge delete

Comments

Is this new package in a catkin workspace? (i.e. did you call catkin_init_workspace in the src folder?) In which directory are you calling catkin_make?

mgruhler gravatar image mgruhler  ( 2016-05-17 01:54:57 -0500 )edit

Yes, I can confirm that catkin_init_workspace was executed because when I tried it just now, it echoed: ~"/dev/catkin_ws/src/CMakeLists.txt" already exists. I execute catkin_make in ~/dev/catkin_ws as instructed by the tutorial.

adiadidas15 gravatar image adiadidas15  ( 2016-05-17 18:50:42 -0500 )edit

did you then source ~/dev/catkin_ws/devel/setup.bash? If not, please edit your question with the output of catkin_make (copy-paste, please no screenshot), as well as with the contents of package.xml and CMakelists.txt.

mgruhler gravatar image mgruhler  ( 2016-05-18 00:55:38 -0500 )edit

Following my tutorial, I edited my ~/.bashrc file by echo "source /opt/ros/hydro/setup.bash" >> ~/.bashrc. So this step should be taken care of when I restart the terminal. In case it is helpful for you, I added the data you requested. Sorry about the formatting. It was better when previewed.

adiadidas15 gravatar image adiadidas15  ( 2016-05-18 22:09:25 -0500 )edit

And thanks for your continued support!

adiadidas15 gravatar image adiadidas15  ( 2016-05-18 22:09:46 -0500 )edit

@adiadidas15 please reupload this and format it properly ;-) It is so hard to read like this. I.e. just copy-paste directly from the file, mark it, and then hit the button with the 101010 on it. This is code formatting.

Also, we need the CMakelists.txt of your package, not the top-level one.

mgruhler gravatar image mgruhler  ( 2016-05-19 00:56:26 -0500 )edit

You need to source your workspace, i.e. not only source /opt/ros/hydro/setup.bash (and I would actually go to a more recent version like indigo or soon kinetic), but source ~/dev/catkin_ws/devel/setup.bash. Otherwise, it will not find anything because echo $ROS_PACKAGE_PATH needs to contain

mgruhler gravatar image mgruhler  ( 2016-05-19 01:00:04 -0500 )edit

the path to your workspace. Otherwise, it is clear why it does not find your package. It is just not on your path.

mgruhler gravatar image mgruhler  ( 2016-05-19 01:00:28 -0500 )edit

2 Answers

Sort by » oldest newest most voted
2

answered 2016-05-20 02:41:48 -0500

ROSkinect gravatar image

updated 2016-05-21 05:43:29 -0500

You should first run source ~/dev/catkin_ws/devel/setup.bash and if you use rosbuild(which is not your case) from the terminal echo "export ROS_PACKAGE_PATH"~/dev/yourfoldername:${ROS_PACKAGE_PATH}" >> ~/.bashrc or manually add this export ROS_PACKAGE_PATH"~/dev/yourfoldername:${ROS_PACKAGE_PATH} at the end of the ~/.bashrc file

You did forget to edit your CMakelists.txt as it is in the book in the paragraph Building the node

rosbuild_add_executable(example1_a src/example1_a.cpp) 
rosbuild_add_executable(example1_b src/example1_b.cpp)

And in the book there are using Rosbuild package, but if you want to use catkin, just edit your CMakelists.txt as follow

include_directories(include ${catkin_INCLUDE_DIRS})

add_executable(example1_a src/example1_a.cpp)
target_link_libraries(example1_a ${catkin_LIBRARIES})
add_dependencies(example1_a chapter2_tutorials_generate_messages_cpp)

add_executable(example1_b src/example1_b.cpp)
target_link_libraries(example1_b ${catkin_LIBRARIES})
add_dependencies(example1_b chapter2_tutorials_generate_messages_cpp)
edit flag offensive delete link more

Comments

Thanks ROSkinect for your advice. What I said above is based on pages 43 & 44 of the book, which indicate that the following commands will result in the built package:

cd ~/dev/catkin_ws/src
catkin_create_pkg chapter2_tutorials std_msgs roscpp
cd ~/dev/catkin_ws
catkin_make
adiadidas15 gravatar image adiadidas15  ( 2016-05-20 22:46:35 -0500 )edit

Do you agree, or am I misreading the book? Thinking that the source devel/setup.bash was the reason for catkin_make failing to compile my project, I went forward in the chapter and added the code which you kindly provided from pages 56 through 60.

adiadidas15 gravatar image adiadidas15  ( 2016-05-20 22:55:57 -0500 )edit

Unfortunately, when I execute catkin_make chapter2_tutorials mentioned on page 60, the package still isn't built. So I am still baffled about what I am getting wrong...

adiadidas15 gravatar image adiadidas15  ( 2016-05-20 23:05:14 -0500 )edit

I also just noticed that you mentioned the book using Rosbuild, however, in my book (Second Edition) I cannot find Rosbuild being mentioned anywhere in chapter 2. Where do you see this at?

adiadidas15 gravatar image adiadidas15  ( 2016-05-20 23:19:25 -0500 )edit

I edited my answer, check it out

ROSkinect gravatar image ROSkinect  ( 2016-05-21 07:22:20 -0500 )edit

ROSkinect, thanks for all your help. As I explained to mig, I decided to start the tutorial over in a new workspace and was able to complete it successfully. I still don't know why my original package wouldn't build, but that is okay...

adiadidas15 gravatar image adiadidas15  ( 2016-05-22 00:02:45 -0500 )edit
1

answered 2016-05-20 01:25:14 -0500

mgruhler gravatar image

rosrun does not find anything, because you do not build anything. I.e. there is no executable.

In the CMakelists.txt, you need to tell CMake, which is called by catkin_make, which source files you want to compile into which executable. This is what the add_executable and add_library calls are for. Check the book, this should be explained therein and you probably just need to uncomment the respective lines, together with the target_link_libraries calls for the respective targets. Or check the wiki tutorials.

edit flag offensive delete link more

Comments

Thanks for your continued help mig. My book did not mention adding the add_executable(), add_dependencies() & target_link_libraries() until later in the chapter. Unfortunately, adding this code (mentioned above by ROSkinect) still does not resolve my problem.

adiadidas15 gravatar image adiadidas15  ( 2016-05-20 23:11:35 -0500 )edit

The book does not mention adding add_libraries() as you mentioned. Do you think this could be my problem?

adiadidas15 gravatar image adiadidas15  ( 2016-05-20 23:13:15 -0500 )edit

I took a look at the wiki tutorial for this same node building exercise. My CMakeLists.txt is consistent with what the wiki defined. I also tried catkin_make --force-cmake, which didn't fix the problem. And I tried catkin_make -pkg chapter2_tutorials, which replied with package not found.

adiadidas15 gravatar image adiadidas15  ( 2016-05-21 00:43:54 -0500 )edit

But rospack find chapter2_tutorials is successful in finding the package.

adiadidas15 gravatar image adiadidas15  ( 2016-05-21 00:44:52 -0500 )edit

I just edit my answer

Probably we don't have the same book or the same edition

ROSkinect gravatar image ROSkinect  ( 2016-05-21 05:45:07 -0500 )edit

Thanks for all your help mig. After trying to figure out what was preventing my package from building for several nights, I decided to start over from scratch with a new workspace. Knowing what I know now I was able to complete the tutorial. I still am not sure what kept my package from building.

adiadidas15 gravatar image adiadidas15  ( 2016-05-21 23:57:03 -0500 )edit

Pointing out that I needed to source devel/setup.bash was one crucial element I was missing, so thanks for diagnosing this for me!

adiadidas15 gravatar image adiadidas15  ( 2016-05-22 00:00:27 -0500 )edit

That was my last editing for ;) everything is crucial and has a reason behind it.. Good luck

ROSkinect gravatar image ROSkinect  ( 2016-05-22 04:01:03 -0500 )edit

Question Tools

Stats

Asked: 2016-05-16 20:52:46 -0500

Seen: 3,057 times

Last updated: May 21 '16