小鱼 ROS 2 新书上线!点击链接查看, 新书配套视频点击链接查看。
提问前必看的发帖注意事项—— 提问前必看!不符合要求的问题拒绝回答!!
社区使用指南—如何添加标签修改密码
vm虚拟机+ubuntu20+ros2,添加接口后报错,cmake过不去
-
@练剑的书生 我找了下源码测试下,发现没有问题,同foxy版本。
root@097c0c2d6b66:/home/mouse/code/github/ros2_town# colcon build Starting >>> village_interfaces Finished <<< village_interfaces [6.30s] Starting >>> village_li Starting >>> village_wang Starting >>> village_zhang Finished <<< village_li [0.89s] Finished <<< village_zhang [4.31s] Finished <<< village_wang [7.31s] Summary: 4 packages finished [13.7s] root@097c0c2d6b66:/home/mouse/code/github/ros2_town# echo $ROS_DISTRO foxy
源码地址:https://github.com/fishros/ros2_town
请你下载源码后直接编译看看,排除是代码问题
-
@小鱼 下载下来编译还是这个样子,像是cmake环境有问题了
-
@练剑的书生 你装的是桌面版的ROS2吗,我也怀疑编译工具问题,你在village_interfaces文件夹下试一下下面的语句
source /opt/ros/foxy/setup.bash mkdir build cd build cmake .. make
-
@小鱼 是桌面版
-- The C compiler identification is GNU 9.4.0
-- The CXX compiler identification is GNU 9.4.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found ament_cmake: 0.9.9 (/opt/ros/foxy/share/ament_cmake/cmake)
-- Found PythonInterp: /usr/bin/python3 (found suitable version "3.8.10", minimum required is "3")
-- Using PYTHON_EXECUTABLE: /usr/bin/python3
-- Found sensor_msgs: 2.0.5 (/opt/ros/foxy/share/sensor_msgs/cmake)
-- Using all available rosidl_typesupport_c: rosidl_typesupport_fastrtps_c;rosidl_typesupport_introspection_c
-- Found rosidl_adapter: 1.2.1 (/opt/ros/foxy/share/rosidl_adapter/cmake)
-- Found OpenSSL: /usr/lib/x86_64-linux-gnu/libcrypto.so (found version "1.1.1f")
-- Found FastRTPS: /opt/ros/foxy/include
-- Using all available rosidl_typesupport_cpp: rosidl_typesupport_fastrtps_cpp;rosidl_typesupport_introspection_cpp
-- Found rosidl_default_generators: 1.0.1 (/opt/ros/foxy/share/rosidl_default_generators/cmake)
-- Found PythonInterp: /usr/bin/python3 (found version "3.8.10")
CMake Error at /opt/ros/foxy/share/rosidl_cmake/cmake/rosidl_generate_interfaces.cmake:240 (list):
list index: 1 out of range (-1, 0)
Call Stack (most recent call first):
CMakeLists.txt:26 (rosidl_generate_interfaces)CMake Error at /opt/ros/foxy/share/rosidl_cmake/cmake/rosidl_generate_interfaces.cmake:240 (list):
list index: 1 out of range (-1, 0)
Call Stack (most recent call first):
CMakeLists.txt:26 (rosidl_generate_interfaces)CMake Error at /opt/ros/foxy/share/rosidl_cmake/cmake/rosidl_generate_interfaces.cmake:240 (list):
list index: 1 out of range (-1, 0)
Call Stack (most recent call first):
CMakeLists.txt:26 (rosidl_generate_interfaces)CMake Error at /opt/ros/foxy/share/rosidl_generator_c/cmake/rosidl_generator_c_generate_interfaces.cmake:65 (message):
Target dependency
'/src/examples/src/village_interfaces/build/rosidl_adapter/village_interfaces/msg/Novel.idl'
does not exist
Call Stack (most recent call first):
/opt/ros/foxy/share/ament_cmake_core/cmake/core/ament_execute_extensions.cmake:48 (include)
/opt/ros/foxy/share/rosidl_cmake/cmake/rosidl_generate_interfaces.cmake:286 (ament_execute_extensions)
CMakeLists.txt:26 (rosidl_generate_interfaces)-- Configuring incomplete, errors occurred!
See also "/home/gsl/桌面/src/examples/src/village_interfaces/build/CMakeFiles/CMakeOutput.log". -
@练剑的书生 先去掉sensor_msgs依赖以及Novel.msg中的image字段试试
-
@小鱼 Starting >>> village_interfaces
--- stderr: village_interfaces
CMake Error at /opt/ros/foxy/share/rosidl_cmake/cmake/rosidl_generate_interfaces.cmake:162 (message):
rosidl_generate_interfaces() the passed dependency 'sensor_msgs' has not
been found before using find_package()
Call Stack (most recent call first):
CMakeLists.txt:26 (rosidl_generate_interfaces)
Failed <<< village_interfaces [0.45s, exited with code 1]
Summary: 0 packages finished [0.65s]
1 package failed: village_interfaces
1 package had stderr output: village_interfaces
3 packages not processed -
@练剑的书生 在 vm虚拟机+ubuntu20+ros2,添加接口后报错,cmake过不去 中说:
CMake Error at /opt/ros/foxy/share/rosidl_cmake/cmake/rosidl_generate_interfaces.cmake:162 (message):
rosidl_generate_interfaces() the passed dependency 'sensor_msgs' has not
been found before using find_package()看到这个错误了,你把CMakeLists.txt中的find_package(sensor_msgs)去掉
-
@练剑的书生 屏蔽了之后编译是这样的
-
@练剑的书生 贴一下你的CMakeLists.txt,应该是没删除干净
-
@小鱼 cmake_minimum_required(VERSION 3.5)
project(village_interfaces)Default to C99
if(NOT CMAKE_C_STANDARD)
set(CMAKE_C_STANDARD 99)
endif()Default to C++14
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14)
endif()if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()find dependencies
find_package(ament_cmake REQUIRED)
#find_package(sensor_msgs REQUIRED)
find_package(rosidl_default_generators REQUIRED)uncomment the following section in order to fill in
further dependencies manually.
find_package(<dependency> REQUIRED)
if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)the following line skips the linter which checks for copyrights
uncomment the line when a copyright and license is not present in all source files
#set(ament_cmake_copyright_FOUND TRUE)
the following line skips cpplint (only works in a git repo)
uncomment the line when this package is not in a git repo
#set(ament_cmake_cpplint_FOUND TRUE)
ament_lint_auto_find_test_dependencies()
endif()rosidl_generate_interfaces(${PROJECT_NAME}
"msg/Novel.msg"
DEPENDENCIES sensor_msgs
)ament_package()
-
-
@小鱼
全部屏蔽了才正常