@867975819 解决好久一直没找到解决方法
重要提示
提问前必看的发帖注意事项—— 提问前必看!不符合要求的问题拒绝回答!!
社区使用指南—如何添加标签修改密码
3279725327 发布的最新帖子
-
服务接口报错
CMake Error at /opt/ros/humble/share/ament_cmake_target_dependencies/cmake/ament_target_dependencies.cmake:77 (message):
ament_target_dependencies() the passed package name 'test_serivce_rclcpp'
was not found before
Call Stack (most recent call first):
CMakeLists.txt:22 (ament_target_dependencies)
CMakeLists.txt文件如下配置:
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(rosidl_default_generators REQUIRED)
find_package(test_serivce_rclcpp REQUIRED)
rosidl_generate_interfaces(${PROJECT_NAME}
"srv/CheckFloat.srv"
)add_executable(check_float_client src/check_float_client.cpp)
target_include_directories(check_float_client PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)
target_compile_features(check_float_client PUBLIC c_std_99 cxx_std_17) # Require C99 and C++17
ament_target_dependencies(
check_float_client
"rclcpp"
"test_serivce_rclcpp"
)install(TARGETS check_float_client
DESTINATION lib/${PROJECT_NAME})add_executable(check_float_server src/check_float_server.cpp)
target_include_directories(check_float_server PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)
target_compile_features(check_float_server PUBLIC c_std_99 cxx_std_17) # Require C99 and C++17ament_target_dependencies(
check_float_server
"rclcpp"
"test_serivce_rclcpp"
)install(TARGETS check_float_server
DESTINATION lib/${PROJECT_NAME})
package.xml如下:<buildtool_depend>ament_cmake</buildtool_depend>
<depend>rclcpp</depend>
<depend>example_ros2_interfaces</depend><test_depend>ament_lint_auto</test_depend>
<test_depend>ament_lint_common</test_depend><export>
<build_type>ament_cmake</build_type>
</export>
报错
-
自定义接口编译报错
CMake Error at CMakeLists.txt:11 (find_package):
By not providing "Findexample_ros2_interfaces.cmake" in CMAKE_MODULE_PATH
this project has asked CMake to find a package configuration file provided
by "example_ros2_interfaces", but CMake did not find one.Could not find a package configuration file provided by
"example_ros2_interfaces" with any of the following names:example_ros2_interfacesConfig.cmake example_ros2_interfaces-config.cmake
Add the installation prefix of "example_ros2_interfaces" to
CMAKE_PREFIX_PATH or set "example_ros2_interfaces_DIR" to a directory
containing one of the above files. If "example_ros2_interfaces" provides a
separate development package or SDK, be sure it has been installed.
Failed <<< example_interfaces_rclcpp [0.98s, exited with code 1]
Aborted <<< example_topic_rclpy [0.97s]Summary: 2 packages finished [1.22s]
1 package failed: example_interfaces_rclcpp
1 package aborted: example_topic_rclpy
1 package had stderr output: example_interfaces_rclcpp
yangruilin@yangruilin-virtual-machine:~/d21ros2/chapt3/chapt3_ws$ ^C
yangruilin@yangruilin-virtual-machine:~/d21ros2/chapt3/chapt3_ws$ colcon build
Starting >>> example_interfaces_rclcpp
Starting >>> example_service_rclcpp
Starting >>> example_topic_rclcpp
Starting >>> example_topic_rclpy
Finished <<< example_topic_rclcpp [0.80s]
Finished <<< example_service_rclcpp [0.83s]
--- stderr: example_interfaces_rclcpp
CMake Error at CMakeLists.txt:11 (find_package):
By not providing "Findexample_ros2_interfaces.cmake" in CMAKE_MODULE_PATH
this project has asked CMake to find a package configuration file provided
by "example_ros2_interfaces", but CMake did not find one.