Had to rebuild Services header files after every session

Custom header files doest seems to be backed up. They would have to be rebuilt every time after reloading the session. I normally had to comment out building the src files to create these header files first and rebuild the source files again.

Its a workable work around but it would be helpful to have the custom header files backed up as well.

/home/user/catkin_ws/src/services_quiz/src/bb8_move_custom_service_client.cpp:2:51: fatal error: services_quiz/BB8CustomServiceMessage.h: No such file or directory

Thanks

Hi @cshreyastech,

Sorry for the trouble!

Please help us to understand better

  • are you talking about having to recreate the files or having to rebuild them?
  • as far as I understand, you shouldn’t have to create header files for your custom messages manually - are you do this manually? If so, why?
  • where are you putting your custom header files? Any file you put in catkin_ws/src should be backed up.

Hi @bayodesegun,
My apologies for being unclear.
catkit workspace had to be rebuild to generate custom header file for every new session. They are not being backup. Rest of the source files are being backup properly. no issues with them.

I dont create header file manually. I just let the compile take care of it.

Steps to reproduce and fix:

  1. attempt to build my workspace this morning (fresh session)

user:~/catkin_ws$ catkin_make -DCATKIN_BLACKLIST_PACKAGES=“my_package;service_server_pkg;service_client_pkg;topic_publisher_pkg;topic_subscriber_pkg;my_custom_srv_msg_pkg;action_client_pkg;”

[ 7%] Building CXX object services_quiz/CMakeFiles/move_bb8_in_square_custom_client.dir/src/bb8_move_custom_service_client.cpp.o
/home/user/catkin_ws/src/services_quiz/src/bb8_move_custom_service_client.cpp:2:51: fatal error: services_quiz/BB8CustomServiceMessage.h: No such file or directory

  1. comment out compile source files from CMakeList.txt in services_quiz to generate BB8CustomServiceMessage.h and rebuild
# add_executable(move_bb8_in_square_custom_server src/bb8_move_custom_service_server.cpp)
# add_dependencies(move_bb8_in_square_custom_server ${move_bb8_in_square_custom_server_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
# target_link_libraries(move_bb8_in_square_custom_server
#    ${catkin_LIBRARIES}
#  )

# add_executable(move_bb8_in_square_custom_client src/bb8_move_custom_service_client.cpp)
# add_dependencies(move_bb8_in_square_custom_client ${move_bb8_in_square_custom_client_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
# target_link_libraries(move_bb8_in_square_custom_client
#    ${catkin_LIBRARIES}
#  )

after rebuild, head file created

user:~/catkin_ws$ find -name BB8CustomServiceMessage.h
./devel/include/services_quiz/BB8CustomServiceMessage.h

step 3) rebuild, uncommenting the CMakelists.txt to compile the source files of services_quiz
all source file compiled successfully as the depended header files are available

[ 0%] Built target _services_quiz_generate_messages_check_deps_BB8CustomServiceMessage
[ 7%] Building CXX object services_quiz/CMakeFiles/move_bb8_in_square_custom_client.dir/src/bb8_move_custom_service_client.cpp.o
[ 15%] Linking CXX executable /home/user/catkin_ws/devel/lib/services_quiz/move_bb8_in_square_custom_client
[ 15%] Built target move_bb8_in_square_custom_client
Scanning dependencies of target move_bb8_in_square_custom_server
[ 23%] Building CXX object services_quiz/CMakeFiles/move_bb8_in_square_custom_server.dir/src/bb8_move_custom_service_server.cpp.o
[ 30%] Linking CXX executable /home/user/catkin_ws/devel/lib/services_quiz/move_bb8_in_square_custom_server
[ 30%] Built target move_bb8_in_square_custom_server
[ 46%] Built target topics_quiz_node
[ 53%] Built target services_quiz_generate_messages_cpp
[ 69%] Built target services_quiz_generate_messages_py
[ 84%] Built target services_quiz_generate_messages_eus
[ 92%] Built target services_quiz_generate_messages_nodejs
[100%] Built target services_quiz_generate_messages_lisp
[100%] Built target services_quiz_generate_messages

This has to be done for every new session. In short, it seems devel directory doest get backed up and they have the header files.

@cshreyastech,

Yes, the build and devel folders are not saved, but that’s not the problem, because while loading your environment we recompile the workspace for you.

The problem is that you have to comment/uncomment some lines in CMakeList.txt in order to get your workspace compiled - you shouldn’t have to do this :cold_sweat:.

The problem that has to be fixed here is that you should not have to comment or uncomment to have things working. Could you please tell us why are you doing that:

  • Do you have some lines that really shouldn’t be there?
  • Do you have some lines with wrong configurations (like wrong file or directory name)?

I dont think I have anything missing in CMakeList.txt as of my knowledge . I think I am missing some dependencies. Here is the file. Can you kindly review it?

cmake_minimum_required(VERSION 2.8.3)

project(services_quiz)

## Compile as C++11, supported in ROS Kinetic and newer

# add_compile_options(-std=c++11)

## 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

message_generation

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 tag for "message_generation"

## * add a build_depend and a exec_depend tag for each package in MSG_DEP_SET

## * If MSG_DEP_SET isn't empty the following dependency has been pulled in

## but can be declared for certainty nonetheless:

## * add a exec_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

BB8CustomServiceMessage.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

)

################################################

## Declare ROS dynamic reconfigure parameters ##

################################################

## To declare and build dynamic reconfigure parameters within this

## package, follow these steps:

## * In the file package.xml:

## * add a build_depend and a exec_depend tag for "dynamic_reconfigure"

## * In this file (CMakeLists.txt):

## * add "dynamic_reconfigure" to

## find_package(catkin REQUIRED COMPONENTS ...)

## * uncomment the "generate_dynamic_reconfigure_options" section below

## and list every .cfg file to be processed

## Generate dynamic reconfigure parameters in the 'cfg' folder

# generate_dynamic_reconfigure_options(

# cfg/DynReconf1.cfg

# cfg/DynReconf2.cfg

# )

###################################

## 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 your package contains header files

## LIBRARIES: libraries you create in this project that dependent projects also need

## CATKIN_DEPENDS: catkin_packages dependent projects also need

## DEPENDS: system dependencies of this project that dependent projects also need

catkin_package(

# INCLUDE_DIRS include

# LIBRARIES services_quiz

# CATKIN_DEPENDS message_generation roscpp std_msgs

# DEPENDS system_lib

)

add_executable(move_bb8_in_square_custom_server src/bb8_move_custom_service_server.cpp)

add_dependencies(move_bb8_in_square_custom_server ${move_bb8_in_square_custom_server_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})

target_link_libraries(move_bb8_in_square_custom_server

${catkin_LIBRARIES}

)

add_executable(move_bb8_in_square_custom_client src/bb8_move_custom_service_client.cpp)

add_dependencies(move_bb8_in_square_custom_client ${move_bb8_in_square_custom_client_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})

target_link_libraries(move_bb8_in_square_custom_client

${catkin_LIBRARIES}

)

###########

## Build ##

###########

## Specify additional locations of header files

## Your package locations should be listed before other locations

include_directories(

# include

${catkin_INCLUDE_DIRS}

)

## Declare a C++ library

# add_library(${PROJECT_NAME}

# src/${PROJECT_NAME}/services_quiz.cpp

# )

## Add cmake target dependencies of the library

## as an example, code may need to be generated before libraries

## either from message generation or dynamic reconfigure

# add_dependencies(${PROJECT_NAME} ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})

## Declare a C++ executable

## With catkin_make all packages are built within a single CMake context

## The recommended prefix ensures that target names across packages don't collide

# add_executable(${PROJECT_NAME}_node src/services_quiz_node.cpp)

## Rename C++ executable without prefix

## The above recommended prefix causes long target names, the following renames the

## target back to the shorter version for ease of user use

## e.g. "rosrun someones_pkg node" instead of "rosrun someones_pkg someones_pkg_node"

# set_target_properties(${PROJECT_NAME}_node PROPERTIES OUTPUT_NAME node PREFIX "")

## Add cmake target dependencies of the executable

## same as for the library above

# add_dependencies(${PROJECT_NAME}_node ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})

## Specify libraries to link a library or executable target against

# target_link_libraries(${PROJECT_NAME}_node

# ${catkin_LIBRARIES}

# )

#############

## Install ##

#############

# all install targets should use catkin DESTINATION variables

# See http://ros.org/doc/api/catkin/html/adv_user_guide/variables.html

## Mark executable scripts (Python etc.) for installation

## in contrast to setup.py, you can choose the destination

# install(PROGRAMS

# scripts/my_python_script

# DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}

# )

## Mark executables for installation

## See http://docs.ros.org/melodic/api/catkin/html/howto/format1/building_executables.html

# install(TARGETS ${PROJECT_NAME}_node

# RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}

# )

## Mark libraries for installation

## See http://docs.ros.org/melodic/api/catkin/html/howto/format1/building_libraries.html

# install(TARGETS ${PROJECT_NAME}

# ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}

# LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}

# RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}

# )

## Mark cpp header files for installation

# install(DIRECTORY include/${PROJECT_NAME}/

# DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}

# FILES_MATCHING PATTERN "*.h"

# PATTERN ".svn" EXCLUDE

# )

## Mark other files for installation (e.g. launch and bag files, etc.)

# install(FILES

# # myfile1

# # myfile2

# DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}

# )

#############

## Testing ##

#############

## Add gtest based cpp test target and link libraries

# catkin_add_gtest(${PROJECT_NAME}-test test/test_services_quiz.cpp)

# if(TARGET ${PROJECT_NAME}-test)

# target_link_libraries(${PROJECT_NAME}-test ${PROJECT_NAME})

# endif()

## Add folders to be run by python nosetests

# catkin_add_nosetests(test)

Thanks

I will play around with it this week. I will see if can figure it out myself first.

Thanks,

Shreyas

1 Like

Are you able to figure this out yet @cshreyastech?

@bayodesegun
I tried altering dependencies both in Cmakelist and in the xml file. I still run into same issue. I am sure I am missing some dependencies. I am not sure about that yet.

@cshreyastech You need to examine your CMakeList.txt according to the instructions and examples given, and then make the necessary corrections.

@bayodesegun @cshreyastech
I am getting this same issue exactly. And it looks like we were on similar portions of the tutorial.

I encountered this issue for the first time after making no edits to what I was working on. I had a working, compiled workspace, I logged out and when I logged back in I encountered this issue when I went to run ‘catkin_make’.

@rmmilner @cshreyastech

Problems like this usually have to do with not editing CMakeLists.txt and package.xml correctly. Any small type or wrong name could ruin things. Here are some hints:

  • Add the necessary dependencies at during package creation. E,g catkin_create_pkg my_pack rospy adds roscpp as a dependency. The examples and the exercises will tell you what dependency to add. The right entries will be created for your in CMakeLists.txt and package.xml.
  • Avoid copy/pasting CMakeLists.txt and package.xml. Rather, edit the ones automatically created accordingly.
  • Remember that you need to setup the C++ source file in CMakeLists.txt.
  • Setup CMakeLists.txt and package.xml to recognize custom messages, following the examples and instructions given carefully.

@cshreyastech
Are you able to get past this error?

I made no edits to any file to fix this issue. I left the project, went to another module and then returned and that fixed it.

yes, I could fix it long time ago. I dont quite remember the fix. I think its about adding correct dependency.

make_minimum_required(VERSION 2.8.3)
project(services_quiz)

## Compile as C++11, supported in ROS Kinetic and newer
# add_compile_options(-std=c++11)

## 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
  message_generation
  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 tag for "message_generation"
##   * add a build_depend and a exec_depend tag for each package in MSG_DEP_SET
##   * If MSG_DEP_SET isn't empty the following dependency has been pulled in
##     but can be declared for certainty nonetheless:
##     * add a exec_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
    BB8CustomServiceMessage.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
 )

################################################
## Declare ROS dynamic reconfigure parameters ##
################################################

## To declare and build dynamic reconfigure parameters within this
## package, follow these steps:
## * In the file package.xml:
##   * add a build_depend and a exec_depend tag for "dynamic_reconfigure"
## * In this file (CMakeLists.txt):
##   * add "dynamic_reconfigure" to
##     find_package(catkin REQUIRED COMPONENTS ...)
##   * uncomment the "generate_dynamic_reconfigure_options" section below
##     and list every .cfg file to be processed

## Generate dynamic reconfigure parameters in the 'cfg' folder
# generate_dynamic_reconfigure_options(
#   cfg/DynReconf1.cfg
#   cfg/DynReconf2.cfg
# )

###################################
## 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 your package contains header files
## LIBRARIES: libraries you create in this project that dependent projects also need
## CATKIN_DEPENDS: catkin_packages dependent projects also need
## DEPENDS: system dependencies of this project that dependent projects also need
catkin_package(
#  INCLUDE_DIRS include
#  LIBRARIES services_quiz
#  CATKIN_DEPENDS message_generation roscpp std_msgs
#  DEPENDS system_lib
)

add_executable(move_bb8_in_square_custom_server src/bb8_move_custom_service_server.cpp)
add_dependencies(move_bb8_in_square_custom_server ${move_bb8_in_square_custom_server_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
target_link_libraries(move_bb8_in_square_custom_server
   ${catkin_LIBRARIES}
 )

add_executable(move_bb8_in_square_custom_client src/bb8_move_custom_service_client.cpp)
add_dependencies(move_bb8_in_square_custom_client ${move_bb8_in_square_custom_client_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
target_link_libraries(move_bb8_in_square_custom_client
   ${catkin_LIBRARIES}
 )

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

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

## Declare a C++ library
# add_library(${PROJECT_NAME}
#   src/${PROJECT_NAME}/services_quiz.cpp
# )

## Add cmake target dependencies of the library
## as an example, code may need to be generated before libraries
## either from message generation or dynamic reconfigure
# add_dependencies(${PROJECT_NAME} ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})

## Declare a C++ executable
## With catkin_make all packages are built within a single CMake context
## The recommended prefix ensures that target names across packages don't collide
# add_executable(${PROJECT_NAME}_node src/services_quiz_node.cpp)

## Rename C++ executable without prefix
## The above recommended prefix causes long target names, the following renames the
## target back to the shorter version for ease of user use
## e.g. "rosrun someones_pkg node" instead of "rosrun someones_pkg someones_pkg_node"
# set_target_properties(${PROJECT_NAME}_node PROPERTIES OUTPUT_NAME node PREFIX "")

## Add cmake target dependencies of the executable
## same as for the library above
# add_dependencies(${PROJECT_NAME}_node ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})

## Specify libraries to link a library or executable target against
# target_link_libraries(${PROJECT_NAME}_node
#   ${catkin_LIBRARIES}
# )

#############
## Install ##
#############

# all install targets should use catkin DESTINATION variables
# See http://ros.org/doc/api/catkin/html/adv_user_guide/variables.html

## Mark executable scripts (Python etc.) for installation
## in contrast to setup.py, you can choose the destination
# install(PROGRAMS
#   scripts/my_python_script
#   DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
# )

## Mark executables for installation
## See http://docs.ros.org/melodic/api/catkin/html/howto/format1/building_executables.html
# install(TARGETS ${PROJECT_NAME}_node
#   RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
# )

## Mark libraries for installation
## See http://docs.ros.org/melodic/api/catkin/html/howto/format1/building_libraries.html
# install(TARGETS ${PROJECT_NAME}
#   ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
#   LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
#   RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION}
# )

## Mark cpp header files for installation
# install(DIRECTORY include/${PROJECT_NAME}/
#   DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
#   FILES_MATCHING PATTERN "*.h"
#   PATTERN ".svn" EXCLUDE
# )

## Mark other files for installation (e.g. launch and bag files, etc.)
# install(FILES
#   # myfile1
#   # myfile2
#   DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
# )

#############
## Testing ##
#############

## Add gtest based cpp test target and link libraries
# catkin_add_gtest(${PROJECT_NAME}-test test/test_services_quiz.cpp)
# if(TARGET ${PROJECT_NAME}-test)
#   target_link_libraries(${PROJECT_NAME}-test ${PROJECT_NAME})
# endif()

## Add folders to be run by python nosetests
# catkin_add_nosetests(test)

@bayodesegun, this is the working version.

1 Like

@bayodesegun I looked at this post, changed my makefile to mirror this and I am still getting the same error.

@rmmilner,

I suppose you got it working before now?

What I would advise:

  • Go over the steps given in the notebook again to be sure there’s nothing missed.
  • Run rm -rf build/ devel/ from catkin_ws.
  • Run catkin_make and then source devel/setup.bash.

If you are still getting any errors, please give more details about it.