ros2+rviz2示例代码--cmakelists.txt与package.xml备份

html 复制代码
cmake_minimum_required(VERSION 3.8)
project(gazebo_pkg)
set(CMAKE_PREFIX_PATH /usr;/opt/ros/humble)
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(robot_state_publisher REQUIRED)
find_package(urdf_tutorial REQUIRED)
find_package(xacro REQUIRED)
find_package(rviz2 REQUIRED)
install(
  DIRECTORY  urdf launch etc
  DESTINATION share/${PROJECT_NAME}
)
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()
html 复制代码
<?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>gazebo_pkg</name>
  <version>0.0.0</version>
  <description>TODO: Package description</description>
  <maintainer email="actorsun@todo.todo">actorsun</maintainer>
  <license>TODO: License declaration</license>

  <buildtool_depend>ament_cmake</buildtool_depend>

  <depend>robot_state_publisher</depend>
  <depend>urdf_tutorial</depend>
  <depend>xacro</depend>
  <depend>rviz2</depend>

  <test_depend>ament_lint_auto</test_depend>
  <test_depend>ament_lint_common</test_depend>

  <export>
    <build_type>ament_cmake</build_type>
  </export>
</package>

其中修改为如下也可以

html 复制代码
<?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>gazebo_pkg</name>
  <version>0.0.0</version>
  <description>TODO: Package description</description>
  <maintainer email="actorsun@todo.todo">actorsun</maintainer>
  <license>TODO: License declaration</license>

  <buildtool_depend>ament_cmake</buildtool_depend>

  <depend>robot_state_publisher</depend>
  <exec_depend>joint_state_publisher</exec_depend>
  <depend>xacro</depend>
  <depend>rviz2</depend>

  <test_depend>ament_lint_auto</test_depend>
  <test_depend>ament_lint_common</test_depend>

  <export>
    <build_type>ament_cmake</build_type>
  </export>
</package>

find_package 命令用法举例

  • find_package(OpenCV)

    • 查找名为 OpenCV 的包,找不到不报错,事后可以通过 ${OpenCV_FOUND} 查询是否找到。
  • find_package(OpenCV QUIET)

    • 查找名为 OpenCV 的包,找不到不报错,也不打印任何信息。
  • find_package(OpenCV REQUIRED) # 最常见用法

    • 查找名为 OpenCV 的包,找不到就报错(并终止 cmake 进程,不再继续往下执行)。
  • find_package(OpenCV REQUIRED COMPONENTS core videoio)

    • 查找名为 OpenCV 的包,找不到就报错,且必须具有 OpenCV::coreOpenCV::videoio 这两个组件,如果没有这两个组件也会报错。
  • find_package(OpenCV REQUIRED OPTIONAL_COMPONENTS core videoio)

    • 查找名为 OpenCV 的包,找不到就报错,可具有 OpenCV::coreOpenCV::videoio 这两个组件,没有这两组件不会报错,通过 ${OpenCV_core_FOUND} 查询是否找到 core 组件。

find_package 说是找"包(package)",到底是在找什么?

相关推荐
云中飞鸿1 天前
MFC中CString的Format、与XML中的XML_SETTEXT格式化注意
xml·c++·mfc
初见_Dream2 天前
Retrofit+OkHttp+ViewModel
xml·okhttp·retrofit
wolf犭良2 天前
14、《SpringBoot+MyBatis集成(2)——进阶配置XML与注解的灵活运用》
xml·spring boot·mybatis
Lojarro2 天前
JavaEE基础之- xml
xml·数据库·java-ee
m0_748233883 天前
使用 Logback 的最佳实践:`logback.xml` 与 `logback-spring.xml` 的区别与用法
xml·spring·logback
zhencon-com3 天前
如何使用qt开发一个xml发票浏览器,实现按发票样式显示
xml·c++·经验分享·python·qt·学习·金融
火烧屁屁啦3 天前
【JavaEE进阶】MyBatis通过XML实现增删改查
xml·java-ee·mybatis
m0_748252236 天前
【mybatis】基本操作:详解Spring通过注解和XML的方式来操作mybatis
xml·spring·mybatis
veminhe8 天前
maven使用默认settings.xml配置时,Idea基于pom.xml更新依赖时报错,有些组件下载时连接超时
xml·maven·intellij-idea
让代码飞~11 天前
java.lang.NoClassDefFoundError: javax/xml/bind/ValidationException
xml·java·开发语言