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

CLion doesn't see header generated by service

asked 2019-09-21 09:42:42 -0500

SEnergy gravatar image

updated 2019-09-21 11:29:52 -0500

I have a fresh install of all - Ubuntu, CLion and ROS Melodic, and I am having troubles with how CLion handles the headers

I have a package called maze_controller, which contains a custom service and a robot controller

compiling works without a problem, but CLion, for some reason, reports that it can't find a message.h header, even tho it is in devel/include and the code compiles fine despite that... as you might already guess, the message used is also reported as unknown, but catkin compiles the code juuust fine...

is there a way to fix this? I don't remember having such issue before I updated everything (coming from Lunar and Ubuntu 16.04)

yes, CLion is opened from a terminal with sourced workspace yes, project was built before yes, I tried deleting .idea

CMake for the package:

cmake_minimum_required(VERSION 2.8.3)
project(maze_controller)

add_compile_options(-std=c++11)

find_package(catkin REQUIRED COMPONENTS
  message_generation
  roscpp
  std_msgs
)

add_service_files(
        FILES
        movement.srv
)

generate_messages(
        DEPENDENCIES
        std_msgs
)

catkin_package(
  INCLUDE_DIRS include
  LIBRARIES maze_controller
  CATKIN_DEPENDS roscpp std_msgs message_runtime
)

include_directories(
  include
  ${catkin_INCLUDE_DIRS}
)

add_library(${PROJECT_NAME} src/virtual_controller.cpp src/real_controller.cpp)
add_dependencies(${PROJECT_NAME} ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
target_link_libraries(${PROJECT_NAME} ${catkin_LIBRARIES})

add_executable(${PROJECT_NAME}_test_sim src/virtual_controller_test.cpp)
target_link_libraries(${PROJECT_NAME}_test_sim ${PROJECT_NAME})

add_executable(${PROJECT_NAME}_test src/real_controller_test.cpp)
target_link_libraries(${PROJECT_NAME}_test ${PROJECT_NAME})

## Mark executables and/or libraries for installation
install(TARGETS ${PROJECT_NAME}
        ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
        LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
        RUNTIME DESTINATION ${CATKIN_PACKAGE_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
        )

image description

edit retag flag offensive close merge delete

Comments

Please attach your screenshot to the question directly. I've given you sufficient karma for that.

gvdhoorn gravatar image gvdhoorn  ( 2019-09-21 11:23:13 -0500 )edit

I don't know whether CLion needs it, but there is no add_dependencies(..) anywhere in your CMakeLists.txt.

Refer to Catkin documentation: Building messages, services or actions for why this needed and how to add it.

gvdhoorn gravatar image gvdhoorn  ( 2019-09-21 11:25:23 -0500 )edit

@gvdhoorn I just went over http://wiki.ros.org/catkin/CMakeLists... and made slightly different CMake file (basically the same, but with the add_dependencies), I will update question asap

SEnergy gravatar image SEnergy  ( 2019-09-21 11:27:38 -0500 )edit

And just to make sure: you have seen wiki/IDEs - CLion?

gvdhoorn gravatar image gvdhoorn  ( 2019-09-21 11:30:00 -0500 )edit

yes... I never had this problem before when I was using Ubuntu 16.04 and Lunar, however I just switched to 18.04 and Melodic... I am also using CLion only as an editor, and still manually compile using catkin_make... I use CLion for it's autocomplettion, but it doesn't work with the custom messages/services anymore for some reason

SEnergy gravatar image SEnergy  ( 2019-09-21 11:35:49 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2019-09-21 11:48:05 -0500

SEnergy gravatar image

I didn't really realize this, as I've been using CLion only for editing, not for compiling & running, but I still had to set the generation path and cmake options for ROS according to this http://wiki.ros.org/IDEs#CLion

I've also been missing the add_dependencies() macro for my lib

after adding those 2, CLion seems to be able to find the custom service header

edit flag offensive delete link more

Question Tools

Stats

Asked: 2019-09-21 09:19:06 -0500

Seen: 829 times

Last updated: Sep 21 '19