小鱼 ROS 2 新书上线!点击链接查看, 新书配套视频点击链接查看。
提问前必看的发帖注意事项—— 提问前必看!不符合要求的问题拒绝回答!!
社区使用指南—如何添加标签修改密码
3.7.3.1 自定义接口实践 编译报错
-
报错信息
Failed <<< example_ros2_interfaces [0.50s, exited with code 1]
Summary: 0 packages finished [0.63s]
1 package failed: example_ros2_interfaces
1 package had stderr output: example_ros2_interfaces
ljy@ljy-LXiaoXinPro-16:~/roscode/chap3$ colcon build --packages-select example_ros2_interfaces
Starting >>> example_ros2_interfaces
--- stderr: example_ros2_interfaces
CMake Error at /opt/ros/humble/share/rosidl_cmake/cmake/rosidl_generate_interfaces.cmake:93 (message):
rosidl_generate_interfaces() the passed file 'srv/MoveRobot.srv' doesn't
exist relative to the CMAKE_CURRENT_SOURCE_DIR
'/home/ljy/roscode/chap3/example_ros2_interfaces'
Call Stack (most recent call first):
CMakeLists.txt:13 (rosidl_generate_interfaces)
这是文件结构
─ example_ros2_interfaces
│ ├── CMakeLists.txt
│ ├── include
│ │ └── example_ros2_interfaces
│ ├── msg
│ │ ├── RobotPose.msg
│ │ └── RobotStatus.msg
│ ├── package.xml
│ └── srv
│ └── Moveobot.srv这是cmakelists
cmake_minimum_required(VERSION 3.8)
project(example_ros2_interfaces)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)rosidl_generate_interfaces(${PROJECT_NAME}
"msg/RobotPose.msg"
"msg/RobotStatus.msg"
"srv/MoveRobot.srv"
DEPENDENCIES geometry_msgs
)if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)the following line skips the linter which checks for copyrights
comment the line when a copyright and license is added to all source files
set(ament_cmake_copyright_FOUND TRUE)
the following line skips cpplint (only works in a git repo)
comment the line when this package is in a git repo and when
a copyright and license is added to all source files
set(ament_cmake_cpplint_FOUND TRUE)
ament_lint_auto_find_test_dependencies()
endif()ament_package()
这是package.xml
<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>example_ros2_interfaces</name>
<version>0.0.0</version>
<description>TODO: Package description</description>
<maintainer email="ljy@todo.todo">ljy</maintainer>
<license>TODO: License declaration</license><buildtool_depend>ament_cmake</buildtool_depend>
<depend>rosidl_default_generators</depend>
<depend>geometry_msgs</depend><member_of_group>rosidl_interface_packages</member_of_group>
<test_depend>ament_lint_auto</test_depend>
<test_depend>ament_lint_common</test_depend><export>
<build_type>ament_cmake</build_type>
</export>
</package>试过删除build没用,anaconda卸载后编译成功,再开机文件就乱了,然后建了一模一样的工作空间,编译又不通过。实在不知道怎么改了
-
-
@小鱼 目录没有中文,文件位置,编译的文件夹也没错。之前的代码编译都没有问题。
-
@1194100657 在 3.7.3.1 自定义接口实践 编译报错 中说:
exist relative to the CMAKE_CURRENT_SOURCE_DIR
'/home/ljy/roscode/chap3/example_ros2_interfaces'看这个错误,你试试把目录带 install
build 都删掉,一层层的看看, -
@小鱼 报错全文是这样的
CMake Error at /opt/ros/humble/share/rosidl_cmake/cmake/rosidl_generate_interfaces.cmake:93 (message): rosidl_generate_interfaces() the passed file 'srv/MoveRobot.srv' doesn't exist relative to the CMAKE_CURRENT_SOURCE_DIR '/home/ljy/d2lros2/chap3/example_ros2_interfaces' Call Stack (most recent call first): CMakeLists.txt:13 (rosidl_generate_interfaces)
-
@小鱼 全删过不好使
-
/opt/ros/humble/share/rosidl_cmake/cmake/rosidl_generate_interfaces.cmake:93 是这样的
-
@1194100657 有修改过bashrc吗,重新打开一个中断试试
-
目录结构错了,Moveobot.srv应该在srv下,你的这里是同级目录了,自然找不到报错。