### CMake Configuration for Navigation2 Costmap Filters Demo Source: https://github.com/ros-navigation/navigation2_tutorials/blob/rolling/nav2_costmap_filters_demo/CMakeLists.txt This CMakeLists.txt file configures the 'nav2_costmap_filters_demo' ROS 2 package. It sets the minimum CMake version, defines the project name, specifies C++14 standard, finds required ament packages, and installs the 'launch', 'maps', and 'params' directories to the package's share destination, making them available for the ROS 2 environment. ```CMake cmake_minimum_required(VERSION 3.5) project(nav2_costmap_filters_demo) set(CMAKE_CXX_STANDARD 14) find_package(ament_cmake REQUIRED) install(DIRECTORY launch DESTINATION share/${PROJECT_NAME} ) install(DIRECTORY maps DESTINATION share/${PROJECT_NAME} ) install(DIRECTORY params DESTINATION share/${PROJECT_NAME} ) ament_package() ``` -------------------------------- ### Install ROS2 Plugin and Export Ament Package Source: https://github.com/ros-navigation/navigation2_tutorials/blob/rolling/nav2_straightline_planner/CMakeLists.txt This section handles the installation of the compiled shared library, header files, and the `pluginlib` description XML file to their respective ROS2 installation directories. It also uses `ament_export_*` commands to make the package's include directories, libraries, and dependencies available to other ROS2 packages, completing the package's build and export process. ```CMake pluginlib_export_plugin_description_file(nav2_core global_planner_plugin.xml) install(TARGETS ${library_name} ARCHIVE DESTINATION lib LIBRARY DESTINATION lib RUNTIME DESTINATION lib/${PROJECT_NAME} ) install(DIRECTORY include/ DESTINATION include/ ) install(FILES global_planner_plugin.xml DESTINATION share/${PROJECT_NAME} ) 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() ament_export_include_directories(include) ament_export_libraries(${library_name}) ament_export_dependencies(${dependencies}) ament_package() ``` -------------------------------- ### Build Configuration for ROS2 Navigation2 Pure Pursuit Controller Source: https://github.com/ros-navigation/navigation2_tutorials/blob/rolling/nav2_pure_pursuit_controller/CMakeLists.txt This CMakeLists.txt file defines the build rules for the `nav2_pure_pursuit_controller` ROS2 package. It specifies minimum CMake version, project name, finds required Ament and Navigation2 packages, defines include directories and dependencies, compiles the `pure_pursuit_controller.cpp` source into a shared library, and handles installation paths and pluginlib export for `nav2_core`. ```CMake cmake_minimum_required(VERSION 3.5) project(nav2_pure_pursuit_controller) find_package(ament_cmake REQUIRED) find_package(nav2_common REQUIRED) find_package(nav2_core REQUIRED) find_package(nav2_costmap_2d REQUIRED) find_package(nav2_util REQUIRED) find_package(rclcpp REQUIRED) find_package(geometry_msgs REQUIRED) find_package(nav_msgs REQUIRED) find_package(pluginlib REQUIRED) find_package(tf2 REQUIRED) nav2_package() include_directories( include ) set(dependencies rclcpp geometry_msgs nav2_costmap_2d pluginlib nav_msgs nav2_util nav2_core tf2 ) add_library(nav2_pure_pursuit_controller SHARED src/pure_pursuit_controller.cpp) # prevent pluginlib from using boost target_compile_definitions(nav2_pure_pursuit_controller PUBLIC "PLUGINLIB__DISABLE_BOOST_FUNCTIONS") ament_target_dependencies(nav2_pure_pursuit_controller ${dependencies} ) install(TARGETS nav2_pure_pursuit_controller ARCHIVE DESTINATION lib LIBRARY DESTINATION lib RUNTIME DESTINATION bin ) install(DIRECTORY include/ DESTINATION include/ ) if(BUILD_TESTING) find_package(ament_lint_auto REQUIRED) # the following line skips the linter which checks for copyrights set(ament_cmake_copyright_FOUND TRUE) ament_lint_auto_find_test_dependencies() endif() ament_export_include_directories(include) ament_export_libraries(nav2_pure_pursuit_controller) ament_export_dependencies(${dependencies}) pluginlib_export_plugin_description_file(nav2_core nav2_pure_pursuit_controller.xml) ament_package() ``` -------------------------------- ### CMake Build Configuration for ROS2 Navigation Costmap Plugin Source: https://github.com/ros-navigation/navigation2_tutorials/blob/rolling/nav2_gradient_costmap_plugin/CMakeLists.txt This CMakeLists.txt file configures the build process for a ROS2 navigation costmap plugin. It sets minimum CMake and C++/C standards, applies strict compiler warnings, finds necessary ROS2 and pluginlib dependencies, compiles the `gradient_layer.cpp` source into a shared library, and handles its installation and ament package integration for plugin discovery. ```CMake cmake_minimum_required(VERSION 3.5) project(nav2_gradient_costmap_plugin) set(lib_name ${PROJECT_NAME}_core) # === Environment === # 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() # === Dependencies === find_package(ament_cmake REQUIRED) find_package(rclcpp REQUIRED) find_package(nav2_costmap_2d REQUIRED) find_package(pluginlib REQUIRED) set(dep_pkgs rclcpp nav2_costmap_2d pluginlib) # === Build === add_library(${lib_name} SHARED src/gradient_layer.cpp) include_directories(include) # === Installation === install(TARGETS ${lib_name} DESTINATION lib) # === Ament work === # pluginlib_export_plugin_description_file() installs gradient_layer.xml # file into "share" directory and sets ament indexes for it. # This allows the plugin to be discovered as a plugin of required type. pluginlib_export_plugin_description_file(nav2_costmap_2d gradient_layer.xml) ament_target_dependencies(${lib_name} ${dep_pkgs}) ament_package() ``` -------------------------------- ### Complete CMake Configuration for ROS 2 Navigation2 Behavior Package Source: https://github.com/ros-navigation/navigation2_tutorials/blob/rolling/nav2_sms_behavior/CMakeLists.txt This snippet provides the full CMakeLists.txt content for setting up a ROS 2 package. It includes directives for minimum CMake version, project naming, C++ standard, finding packages, defining include directories, specifying library dependencies, generating custom ROS 2 interfaces (actions), compiling a shared library, exporting plugin descriptions, and installing package artifacts. ```CMake cmake_minimum_required(VERSION 3.5) project(nav2_sms_behavior) # Default to C++14 set(CMAKE_CXX_STANDARD 14) # find dependencies find_package(ament_cmake REQUIRED) find_package(rclcpp REQUIRED) find_package(rclcpp_action REQUIRED) find_package(rclcpp_lifecycle REQUIRED) find_package(std_msgs REQUIRED) find_package(visualization_msgs REQUIRED) find_package(nav2_util REQUIRED) find_package(nav2_msgs REQUIRED) find_package(nav_msgs REQUIRED) find_package(geometry_msgs REQUIRED) find_package(builtin_interfaces REQUIRED) find_package(tf2_ros REQUIRED) find_package(nav2_costmap_2d REQUIRED) find_package(nav2_core REQUIRED) find_package(nav2_behaviors REQUIRED) find_package(pluginlib REQUIRED) find_package(rosidl_default_generators REQUIRED) find_package(action_msgs REQUIRED) find_package(CURL REQUIRED) include_directories( include ) set(library_name ${PROJECT_NAME}_plugin) set(dependencies rclcpp rclcpp_action rclcpp_lifecycle std_msgs visualization_msgs nav2_util nav2_msgs nav_msgs geometry_msgs builtin_interfaces tf2_ros nav2_costmap_2d nav2_core pluginlib nav2_behaviors CURL ) rosidl_generate_interfaces(${PROJECT_NAME} "action/SendSms.action" DEPENDENCIES builtin_interfaces std_msgs ) add_library(${library_name} SHARED src/send_sms.cpp src/twilio.cpp ) target_compile_definitions(${library_name} PUBLIC "PLUGINLIB__DISABLE_BOOST_FUNCTIONS") ament_target_dependencies(${library_name} ${dependencies} ) rosidl_get_typesupport_target(cpp_typesupport_target ${PROJECT_NAME} "rosidl_typesupport_cpp") target_link_libraries(${library_name} "${cpp_typesupport_target}") pluginlib_export_plugin_description_file(nav2_core behavior_plugin.xml) install(TARGETS ${library_name} ARCHIVE DESTINATION lib LIBRARY DESTINATION lib RUNTIME DESTINATION lib/${PROJECT_NAME} ) install(DIRECTORY include/ DESTINATION include/ ) install(FILES behavior_plugin.xml DESTINATION share/${PROJECT_NAME} ) 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() ament_export_dependencies(rosidl_default_runtime) ament_export_include_directories(include) ament_export_libraries(${library_name}) ament_export_dependencies(${dependencies}) ament_package() ``` -------------------------------- ### Configure ROS 2 Package with CMake Source: https://github.com/ros-navigation/navigation2_tutorials/blob/rolling/sam_bot_description/CMakeLists.txt This CMakeLists.txt file configures a ROS 2 package named 'sam_bot_description'. It sets the minimum required CMake version, defines C and C++ standards (C99 and C++14 respectively), enables common compiler warnings for GCC/Clang, finds necessary ROS 2 dependencies like 'ament_cmake' and 'xacro', and specifies installation directories for package resources. It also includes conditional logic for setting up build testing and linting with 'ament_lint_auto'. ```CMake cmake_minimum_required(VERSION 3.5) project(sam_bot_description) # 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(xacro REQUIRED) # uncomment the following section in order to fill in # further dependencies manually. # find_package( REQUIRED) install( DIRECTORY src launch rviz config world DESTINATION share/${PROJECT_NAME} ) 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() ament_package() ``` -------------------------------- ### Define and Build ROS2 Shared Library in CMake Source: https://github.com/ros-navigation/navigation2_tutorials/blob/rolling/nav2_straightline_planner/CMakeLists.txt This snippet defines the shared library for the straight-line planner plugin, specifying its source file and linking it against the previously found dependencies. It also adds a public compile definition to disable Boost functions for `pluginlib`, which is a common practice in ROS2 to avoid Boost dependencies. ```CMake include_directories( include ) set(library_name ${PROJECT_NAME}_plugin) set(dependencies rclcpp rclcpp_action rclcpp_lifecycle std_msgs visualization_msgs nav2_util nav2_msgs nav_msgs geometry_msgs builtin_interfaces tf2_ros nav2_costmap_2d nav2_core pluginlib ) add_library(${library_name} SHARED src/straight_line_planner.cpp ) ament_target_dependencies(${library_name} ${dependencies} ) target_compile_definitions(${library_name} PUBLIC "PLUGINLIB__DISABLE_BOOST_FUNCTIONS") ``` -------------------------------- ### Find ROS2 Package Dependencies in CMake Source: https://github.com/ros-navigation/navigation2_tutorials/blob/rolling/nav2_straightline_planner/CMakeLists.txt This section uses `find_package` to locate all required ROS2 and third-party dependencies for the `nav2_straightline_planner` package. These dependencies are crucial for building the planner, providing access to core ROS2 functionalities, navigation messages, and utility libraries like `rclcpp`, `nav2_util`, and `pluginlib`. ```CMake find_package(ament_cmake REQUIRED) find_package(rclcpp REQUIRED) find_package(rclcpp_action REQUIRED) find_package(rclcpp_lifecycle REQUIRED) find_package(std_msgs REQUIRED) find_package(visualization_msgs REQUIRED) find_package(nav2_util REQUIRED) find_package(nav2_msgs REQUIRED) find_package(nav_msgs REQUIRED) find_package(geometry_msgs REQUIRED) find_package(builtin_interfaces REQUIRED) find_package(tf2_ros REQUIRED) find_package(nav2_costmap_2d REQUIRED) find_package(nav2_core REQUIRED) find_package(pluginlib REQUIRED) ``` -------------------------------- ### Configure ROS2 Package CMake Standards Source: https://github.com/ros-navigation/navigation2_tutorials/blob/rolling/nav2_straightline_planner/CMakeLists.txt This snippet sets the minimum CMake version required, defines the project name, and specifies the C and C++ language standards for the ROS2 package. It ensures compatibility and modern language features are used during compilation, adhering to common ROS2 development practices. ```CMake cmake_minimum_required(VERSION 3.5) project(nav2_straightline_planner) # Default to C99 set(CMAKE_C_STANDARD 99) # Default to C++14 set(CMAKE_CXX_STANDARD 14) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.