-
我在复制粘贴提供的自定义接口,build后出现以下错误:
CMake Error at /opt/ros/dashing/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:35 (rosidl_generate_interfaces) CMake Error at /opt/ros/dashing/share/rosidl_typesupport_c/cmake/rosidl_typesupport_c_generate_interfaces.cmake:50 (message): Target dependency '/topic_test/build/ros2_interfaces/rosidl_adapter/ros2_interfaces/msg/RobotPose.idl' does not exist Call Stack (most recent call first): /opt/ros/dashing/share/ament_cmake_core/cmake/core/ament_execute_extensions.cmake:48 (include) /opt/ros/dashing/share/rosidl_cmake/cmake/rosidl_generate_interfaces.cmake:286 (ament_execute_extensions) CMakeLists.txt:35 (rosidl_generate_interfaces) --- Failed <<< ros2_interfaces [4.88s, exited with code 1]
然后我在社区搜索相关解决方案,将CMake.list中的代码修改为以下:
cmake_minimum_required(VERSION 3.5) project(ros2_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(rosidl_default_generators REQUIRED) # find_package(geometry_msgs REQUIRED) find_package(rosidl_default_generators 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/RobotPose.msg" # "msg/RobotStatus.msg" # "srv/MoveRobot.srv" # # DEPENDENCIES geometry_msgs # ) ament_package()
可以build成功,但是我在调用时,提示我以下报错
Traceback (most recent call last): File "/home/xh/桌面/topic_test/install/example_topic/lib/example_topic/example_interfaces_robot_02", line 11, in <module> load_entry_point('example-topic==0.0.0', 'console_scripts', 'example_interfaces_robot_02')() File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 480, in load_entry_point return get_distribution(dist).load_entry_point(group, name) File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2693, in load_entry_point return ep.load() File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2324, in load return self.resolve() File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2330, in resolve module = __import__(self.module_name, fromlist=['__name__'], level=0) File "/home/xh/桌面/topic_test/install/example_topic/lib/python3.6/site-packages/example_topic/example_robot.py", line 7, in <module> from ros2_interfaces.msg import RobotStatus ModuleNotFoundError: No module named 'ros2_interfaces'
而且在install文件夹内并没有出现文中所述的C++和Python环境,想问小鱼这是什么原因。
我安装的Ros2版本是dashing桌面版本,Ubuntu系统是18.04 -
@守护最好的佩奇 估计和你的ROS版本有关系,18实在太老了,建议换新版本使用,差距还是挺大的
-
@守护最好的佩奇 我也遇到了报错,你解决了么? 我是ubuntu20.04+foxy
-
@s212633 贴一下具体的错误和文件看看
-