Ask Your Question
0

Absolute and Relative paths

asked 2020-01-13 11:42:58 -0600

mikepark93 gravatar image

I get the following error when trying to generate ros2 interfaces.

[build] CMake Error at /opt/ros/dashing/share/rosidl_cmake/cmake/rosidl_generate_interfaces.cmake:80 (message):
[build]   rosidl_generate_interfaces() the passed absolute file
[build]   '/ros2_msgs/srv/Connect' must be represented as an absolute base path
[build]   separated by a colon from the relative path to the interface file
[build] Call Stack (most recent call first):
[build]   CMakeLists.txt:67 (rosidl_generate_interfaces)
edit retag flag offensive close merge delete

Comments

You need to share your CMake code for people to be able to help you.

Dirk Thomas gravatar imageDirk Thomas ( 2020-01-13 12:17:37 -0600 )edit

Apologies. Here is the CMake file.

cmake_minimum_required(VERSION 3.14)
project(ros2_msgs)

SET(ENV{PYTHONPATH} "/opt/ros/dashing/lib/python3.6/site-packages/")
SET(CMAKE_PREFIX_PATH "/opt/ros/dashing")

find_package(rosidl_default_generators REQUIRED)

rosidl_generate_interfaces(${PROJECT_NAME}
  "${CMAKE_CURRENT_SOURCE_DIR}/srv/Connect"
)

Reason for setting the prefix path and the python path is because I am trying to build without using colcon,

mikepark93 gravatar imagemikepark93 ( 2020-01-13 12:23:15 -0600 )edit

The prefix path (CMAKE_PREFIX_PATH) has nothing to do with the error message. But you shouldn't put that into your CMakeLists.txt but instead set it in the environment before building your package - otherwise you can't build your package with other ROS distros - or in combination with a from-source build on other platforms.

Dirk Thomas gravatar imageDirk Thomas ( 2020-01-13 12:29:09 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2020-01-13 12:27:37 -0600

Dirk Thomas gravatar image

You don't need to pass an absolute path to rosidl_generator_interfaces(). A relative path will be just fine, so removing ${CMAKE_CURRENT_SOURCE_DIR}/ should be all it takes.

It also seems that your service file lacks the extension .srv.

The alternative would be to pass an absolute base path (${CMAKE_CURRENT_SOURCE_DIR}) and the relative path (srv/Connect.srv) - separated by a colon.

edit flag offensive delete link more

Your Answer

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

Add Answer

Question Tools

2 followers

Stats

Asked: 2020-01-13 11:42:58 -0600

Seen: 15 times

Last updated: Jan 13