### Example: Installing Header Files - CMake Source: https://github.com/jianzhuozhuthu/putn/blob/main/src/putn/putn_map/CMakeLists.txt Demonstrates how to install header files from a specified directory into the package's include destination, optionally filtering by pattern. This command is currently commented out. ```CMake # install(DIRECTORY include/${PROJECT_NAME}/ # DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION} # FILES_MATCHING PATTERN "*.h" # PATTERN ".svn" EXCLUDE # ) ``` -------------------------------- ### Install ROS Controllers Package Source: https://github.com/jianzhuozhuthu/putn/blob/main/src/scout_simulator/README.md Installs the `ros-controllers` package, which provides pre-built and common kinematics plugins and controllers used within the `ros-control` framework. Necessary for standard robot control setups. ```bash sudo apt-get install ros-melodic-ros-controllers ``` -------------------------------- ### Example: Installing Library Targets - CMake Source: https://github.com/jianzhuozhuthu/putn/blob/main/src/putn/putn_map/CMakeLists.txt Shows how to install library targets built by the project into the appropriate Catkin destination directories for libraries and runtime components. This command is currently commented out. ```CMake # install(TARGETS ${PROJECT_NAME} # ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} # LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} # RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION} # ) ``` -------------------------------- ### Example: Installing Executable Targets - CMake Source: https://github.com/jianzhuozhuthu/putn/blob/main/src/putn/putn_map/CMakeLists.txt Illustrates how to install executable targets built by the project into the appropriate Catkin destination for binaries. This command is currently commented out. ```CMake # install(TARGETS ${PROJECT_NAME}_node # RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} # ) ``` -------------------------------- ### Example: Setting up Python Module - CMake Source: https://github.com/jianzhuozhuthu/putn/blob/main/src/putn/putn_map/CMakeLists.txt Illustrates how to integrate a Python setup.py file into the Catkin build process for installing Python modules and scripts. This command is currently commented out. ```CMake # catkin_python_setup() ``` -------------------------------- ### Example: Installing Other Files - CMake Source: https://github.com/jianzhuozhuthu/putn/blob/main/src/putn/putn_map/CMakeLists.txt Illustrates how to install arbitrary files (like launch files, bag files, config files) into the package's share directory for other ROS components to find. This command is currently commented out. ```CMake # install(FILES # # myfile1 # # myfile2 # DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION} # ) ``` -------------------------------- ### Install Package Dependencies Source: https://github.com/jianzhuozhuthu/putn/blob/main/src/scout_simulator/README.md Checks and installs any system dependencies required by the packages found in the workspace's source space using `rosdep`. The flags ensure it checks packages from the source space, ignores already built sources, retries failed installations, and runs non-interactively. ```bash rosdep install --from-paths src --ignore-src -r -y ``` -------------------------------- ### Example: Installing Python Scripts - CMake Source: https://github.com/jianzhuozhuthu/putn/blob/main/src/putn/putn_map/CMakeLists.txt Shows how to mark Python executable scripts for installation into the package's binary destination directory. This command uses a Catkin-specific macro and is currently commented out. ```CMake # catkin_install_python(PROGRAMS # scripts/my_python_script # DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} # ) ``` -------------------------------- ### Installing Package Directories - CMake Source: https://github.com/jianzhuozhuthu/putn/blob/main/src/scout_simulator/scout_description/CMakeLists.txt Specifies which directories should be installed as part of the catkin package. The `launch`, `meshes`, and `urdf` directories are installed to the standard package share destination. ```CMake install( DIRECTORY launch meshes urdf DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION} ) ``` -------------------------------- ### Install Joint State Publisher GUI Package Source: https://github.com/jianzhuozhuthu/putn/blob/main/src/scout_simulator/README.md Installs the `joint-state-publisher-gui` package. This tool allows visualization and manipulation of robot joints in Rviz, useful for debugging and understanding robot kinematics. ```bash sudo apt-get install ros-melodic-joint-state-publisher-gui ``` -------------------------------- ### Installing Other Files in ROS CMake Source: https://github.com/jianzhuozhuthu/putn/blob/main/src/putn/putn_launch/CMakeLists.txt Installs arbitrary files (like launch files, configuration files, etc.) to the standard Catkin share destination, where they can be accessed by other ROS tools. ```CMake # install(FILES # # myfile1 # # myfile2 # DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION} # ) ``` -------------------------------- ### Installing Libraries (Commented) Source: https://github.com/jianzhuozhuthu/putn/blob/main/src/scout_simulator/scout_control/CMakeLists.txt Marks library targets for installation to standard ROS library destinations (archive, library, and runtime). ```CMake ## Mark libraries for installation ## See http://docs.ros.org/melodic/api/catkin/html/howto/format1/building_libraries.html # install(TARGETS ${PROJECT_NAME} # ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} # LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} # RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION} # ) ``` -------------------------------- ### Install Gazebo ROS Interface Package Source: https://github.com/jianzhuozhuthu/putn/blob/main/src/scout_simulator/README.md Installs the `gazebo-ros` package, which is the main communication interface between the Gazebo simulator and ROS. It allows ROS nodes to interact with the Gazebo simulation environment. ```bash sudo apt-get install ros-melodic-gazebo-ros ``` -------------------------------- ### Installing Other Files (Commented) Source: https://github.com/jianzhuozhuthu/putn/blob/main/src/scout_simulator/scout_control/CMakeLists.txt Installs miscellaneous files (like launch files, configuration files, etc.) to the package's share directory within the ROS install space. ```CMake ## Mark other files for installation (e.g. launch and bag files, etc.) # install(FILES # # myfile1 # # myfile2 # DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION} # ) ``` -------------------------------- ### Installing Python Scripts (Commented) Source: https://github.com/jianzhuozhuthu/putn/blob/main/src/scout_simulator/scout_control/CMakeLists.txt Marks executable Python scripts for installation to a standard location (`bin` directory) within the ROS install space. An alternative to using `setup.py` for installing scripts. ```CMake ## Mark executable scripts (Python etc.) for installation ## in contrast to setup.py, you can choose the destination # catkin_install_python(PROGRAMS # scripts/my_python_script # DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} # ) ``` -------------------------------- ### Finding System Dependencies (Commented) Source: https://github.com/jianzhuozhuthu/putn/blob/main/src/scout_simulator/scout_control/CMakeLists.txt An example of how to find external system libraries or packages using CMake's `find_package`. This commented example shows finding the Boost libraries with specific components. Uncomment and adjust as needed for package dependencies. ```CMake ## System dependencies are found with CMake's conventions # find_package(Boost REQUIRED COMPONENTS system) ``` -------------------------------- ### Launch Scout Mini Gazebo Simulation Source: https://github.com/jianzhuozhuthu/putn/blob/main/src/scout_simulator/README.md Launches the Gazebo simulator environment along with the Scout Mini robot model loaded into a playpen world. This starts the physics simulation for the robot. ```bash roslaunch scout_gazebo_sim scout_mini_playpen.launch ``` -------------------------------- ### Install ROS Control Package Source: https://github.com/jianzhuozhuthu/putn/blob/main/src/scout_simulator/README.md Installs the `ros-control` package, which is a core ROS middleware for robot control interfaces and controllers. This package is a prerequisite for simulating robot control in ROS. ```bash sudo apt-get install ros-melodic-ros-control ``` -------------------------------- ### Install Gazebo ROS Control Package Source: https://github.com/jianzhuozhuthu/putn/blob/main/src/scout_simulator/README.md Installs the `gazebo-ros-control` package, which provides the standard controller interfaces for connecting ROS `ros-control` controllers to the Gazebo simulation physics engine. Essential for controlling simulated robots in Gazebo via ROS. ```bash sudo apt-get install ros-melodic-gazebo-ros-control ``` -------------------------------- ### Installing Header Files in ROS CMake Source: https://github.com/jianzhuozhuthu/putn/blob/main/src/putn/putn_launch/CMakeLists.txt Installs header files from a specified directory to the standard Catkin include destination, making them available to other packages that include this one. ```CMake # install(DIRECTORY include/${PROJECT_NAME}/ # DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION} # FILES_MATCHING PATTERN "*.h" # PATTERN ".svn" EXCLUDE # ) ``` -------------------------------- ### Example: Defining ROS Interface Files (Msg/Srv/Action) - CMake Source: https://github.com/jianzhuozhuthu/putn/blob/main/src/putn/putn_map/CMakeLists.txt Shows how to declare ROS message (.msg), service (.srv), and action (.action) files that need to be processed by the build system to generate source code. These commands are commented out examples. ```CMake # add_message_files( # FILES # Message1.msg # Message2.msg # ) ``` ```CMake # add_service_files( # FILES # Service1.srv # Service2.srv # ) ``` ```CMake # add_action_files( # FILES # Action1.action # Action2.action # ) ``` -------------------------------- ### Installing Executables (Commented) Source: https://github.com/jianzhuozhuthu/putn/blob/main/src/scout_simulator/scout_control/CMakeLists.txt Marks executable targets for installation to the standard ROS executable destination. Useful for making nodes available via `rosrun`. ```CMake ## Mark executables for installation ## See http://docs.ros.org/melodic/api/catkin/html/howto/format1/building_executables.html # install(TARGETS ${PROJECT_NAME}_node # RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} # ) ``` -------------------------------- ### Enabling Python Setup.py (Commented) Source: https://github.com/jianzhuozhuthu/putn/blob/main/src/scout_simulator/scout_control/CMakeLists.txt Macro to process a `setup.py` file if the ROS package includes Python modules or scripts that need to be installed using standard Python mechanisms. Uncomment if a `setup.py` is present and needed. ```CMake ## Uncomment this if the package has a setup.py. This macro ensures ## modules and global scripts declared therein get installed ## See http://ros.org/doc/api/catkin/html/user_guide/setup_dot_py.html # catkin_python_setup() ``` -------------------------------- ### Example: Generating ROS Dynamic Reconfigure Options - CMake Source: https://github.com/jianzhuozhuthu/putn/blob/main/src/putn/putn_map/CMakeLists.txt Shows how to process dynamic reconfigure (.cfg) files to generate necessary source code for dynamic parameter adjustment in ROS nodes. This command is a commented out example. ```CMake # generate_dynamic_reconfigure_options( # cfg/DynReconf1.cfg # cfg/DynReconf2.cfg # ) ``` -------------------------------- ### Source ROS Workspace Environment Source: https://github.com/jianzhuozhuthu/putn/blob/main/src/scout_simulator/README.md Sources the workspace setup script (`devel/setup.bash`) to add the workspace's compiled executables and sourced packages to the current terminal session's environment variables (like `ROS_PACKAGE_PATH`). This command must be run in every new terminal before using workspace packages. ```bash source devel/setup.bash ``` -------------------------------- ### Launch Scout V2 Gazebo Simulation Source: https://github.com/jianzhuozhuthu/putn/blob/main/src/scout_simulator/README.md Launches the Gazebo simulator environment along with the Scout V2 robot model loaded into an empty world. This starts the physics simulation for the robot. ```bash roslaunch scout_gazebo_sim scout_empty_world.launch ``` -------------------------------- ### Example: Finding System Dependency (Boost) - CMake Source: https://github.com/jianzhuozhuthu/putn/blob/main/src/putn/putn_map/CMakeLists.txt Demonstrates how to find a system-level library dependency, like Boost, using CMake's `find_package`. This command is currently commented out. ```CMake # find_package(Boost REQUIRED COMPONENTS system) ``` -------------------------------- ### Install Teleop Twist Keyboard Package Source: https://github.com/jianzhuozhuthu/putn/blob/main/src/scout_simulator/README.md Installs the `teleop-twist-keyboard` package, which provides a simple ROS node to send `geometry_msgs/Twist` messages based on keyboard input. This is used here to control the robot's movement in the Gazebo simulation. ```bash sudo apt-get install ros-melodic-teleop-twist-keyboard ``` -------------------------------- ### Installing Header Files (Commented) Source: https://github.com/jianzhuozhuthu/putn/blob/main/src/scout_simulator/scout_control/CMakeLists.txt Installs header files from a specified directory (commonly `include/${PROJECT_NAME}`) to the standard ROS include destination. This makes headers available for other packages that depend on this one. ```CMake ## Mark cpp header files for installation # install(DIRECTORY include/${PROJECT_NAME}/ # DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION} # FILES_MATCHING PATTERN "*.h" # PATTERN ".svn" EXCLUDE # ) ``` -------------------------------- ### Installing C++ Executable in ROS CMake Source: https://github.com/jianzhuozhuthu/putn/blob/main/src/putn/putn_launch/CMakeLists.txt Marks a compiled executable target for installation to the standard Catkin binary destination. This allows the executable to be found and run using `rosrun`. ```CMake # install(TARGETS ${PROJECT_NAME}_node # RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} # ) ``` -------------------------------- ### Example: Generating ROS Interfaces (Msg/Srv/Action) - CMake Source: https://github.com/jianzhuozhuthu/putn/blob/main/src/putn/putn_map/CMakeLists.txt Illustrates how to trigger the generation of source code from declared ROS message, service, and action files, specifying any dependent message packages. This command is a commented out example. ```CMake # generate_messages( # DEPENDENCIES # std_msgs # Or other packages containing msgs # ) ``` -------------------------------- ### Example: Defining a C++ Library Target - CMake Source: https://github.com/jianzhuozhuthu/putn/blob/main/src/putn/putn_map/CMakeLists.txt Illustrates how to create a CMake target for a C++ library using source files within the package. This command is currently commented out. ```CMake # add_library(${PROJECT_NAME} # src/${PROJECT_NAME}/complex_terrain_gazebo.cpp # ) ``` -------------------------------- ### Example: Adding Dependencies to Library Target - CMake Source: https://github.com/jianzhuozhuthu/putn/blob/main/src/putn/putn_map/CMakeLists.txt Shows how to declare build dependencies for a library target, ensuring that prerequisite steps (like message generation) are completed before building the library. This command is currently commented out. ```CMake # add_dependencies(${PROJECT_NAME} ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS}) ``` -------------------------------- ### Installing C++ Library in ROS CMake Source: https://github.com/jianzhuozhuthu/putn/blob/main/src/putn/putn_launch/CMakeLists.txt Marks a compiled library target for installation to the standard Catkin library destinations. This makes the library available to other packages that depend on this one. ```CMake # install(TARGETS ${PROJECT_NAME} # ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} # LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} # RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION} # ) ``` -------------------------------- ### Example: Linking Libraries to Executable Target - CMake Source: https://github.com/jianzhuozhuthu/putn/blob/main/src/putn/putn_map/CMakeLists.txt Demonstrates how to link libraries to an executable target, making the library's symbols available to the executable. This typically includes Catkin's libraries. This command is currently commented out. ```CMake # target_link_libraries(${PROJECT_NAME}_node # ${catkin_LIBRARIES} # ) ``` -------------------------------- ### Example: Adding Dependencies to Executable Target - CMake Source: https://github.com/jianzhuozhuthu/putn/blob/main/src/putn/putn_map/CMakeLists.txt Illustrates how to declare build dependencies for an executable target, similar to library targets, to ensure necessary code generation or other steps are finished first. This command is currently commented out. ```CMake # add_dependencies(${PROJECT_NAME}_node ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS}) ``` -------------------------------- ### Example: Adding Python Nosetests - CMake Source: https://github.com/jianzhuozhuthu/putn/blob/main/src/putn/putn_map/CMakeLists.txt Demonstrates how to include Python tests located in a specific directory for running with Nosetests. This uses a Catkin macro and is currently commented out. ```CMake # catkin_add_nosetests(test) ``` -------------------------------- ### Declaring ROS Services (Commented) Source: https://github.com/jianzhuozhuthu/putn/blob/main/src/scout_simulator/scout_control/CMakeLists.txt Example of how to declare custom ROS service (.srv) files to be processed. List service files in the `FILES` section. Requires `message_generation` build dependency. ```CMake ## Generate services in the 'srv' folder # add_service_files( # FILES # Service1.srv # Service2.srv # ) ``` -------------------------------- ### Example: Adding C++ GTest Targets - CMake Source: https://github.com/jianzhuozhuthu/putn/blob/main/src/putn/putn_map/CMakeLists.txt Shows how to define a C++ test target using the GTest framework and link it against the project's library. This uses a Catkin macro and is currently commented out. ```CMake # catkin_add_gtest(${PROJECT_NAME}-test test/test_complex_terrain_gazebo.cpp) ``` ```CMake # if(TARGET ${PROJECT_NAME}-test) # target_link_libraries(${PROJECT_NAME}-test ${PROJECT_NAME}) # endif() ``` -------------------------------- ### Change Directory to Workspace Root Source: https://github.com/jianzhuozhuthu/putn/blob/main/src/scout_simulator/README.md Changes the current directory to the root of the ROS workspace (`scout_ws`). This is necessary before running commands like `rosdep install` or `catkin_make` which operate on the entire workspace. ```bash cd scout_ws ``` -------------------------------- ### Run Keyboard Teleoperation Node Source: https://github.com/jianzhuozhuthu/putn/blob/main/src/scout_simulator/README.md Starts the `teleop_twist_keyboard.py` script as a ROS node using `rosrun`. This node listens for keyboard commands ('i', 'j', 'l', ',') in its terminal and publishes corresponding `geometry_msgs/Twist` messages to control the robot's velocity in the Gazebo simulation. ```bash rosrun teleop_twist_keyboard teleop_twist_keyboard.py ``` -------------------------------- ### Example: Renaming Executable Target - CMake Source: https://github.com/jianzhuozhuthu/putn/blob/main/src/putn/putn_map/CMakeLists.txt Shows how to set properties for an executable target, specifically renaming it to remove the project prefix for easier command-line use (e.g., `rosrun `). This command is currently commented out. ```CMake # set_target_properties(${PROJECT_NAME}_node PROPERTIES OUTPUT_NAME node PREFIX "") ``` -------------------------------- ### Declaring ROS Actions (Commented) Source: https://github.com/jianzhuozhuthu/putn/blob/main/src/scout_simulator/scout_control/CMakeLists.txt Example of how to declare custom ROS action (.action) files to be processed. List action files in the `FILES` section. Requires `message_generation` build dependency and typically `actionlib_msgs` runtime dependency. ```CMake ## Generate actions in the 'action' folder # add_action_files( # FILES # Action1.action # Action2.action # ) ``` -------------------------------- ### Example: Defining a C++ Executable Target - CMake Source: https://github.com/jianzhuozhuthu/putn/blob/main/src/putn/putn_map/CMakeLists.txt Demonstrates how to create a CMake target for a C++ executable (ROS node) from source files. The target name is prefixed with the project name by default in Catkin. This command is currently commented out. ```CMake # add_executable(${PROJECT_NAME}_node src/complex_terrain_gazebo_node.cpp) ``` -------------------------------- ### Declaring ROS Messages (Commented) Source: https://github.com/jianzhuozhuthu/putn/blob/main/src/scout_simulator/scout_control/CMakeLists.txt Example of how to declare custom ROS message (.msg) files to be processed by the build system. Add message files to the `FILES` list and ensure `message_generation` is a build dependency. ```CMake ## Generate messages in the 'msg' folder # add_message_files( # FILES # Message1.msg # Message2.msg # ) ``` -------------------------------- ### Adding C++ GTest Target in ROS CMake Source: https://github.com/jianzhuozhuthu/putn/blob/main/src/putn/putn_launch/CMakeLists.txt Configures a C++ test target using the GTest framework. This macro handles necessary setup for compiling and running tests within the Catkin build system. ```CMake # catkin_add_gtest(${PROJECT_NAME}-test test/test_putn_launch.cpp) # if(TARGET ${PROJECT_NAME}-test) # target_link_libraries(${PROJECT_NAME}-test ${PROJECT_NAME}) # endif() ``` -------------------------------- ### Adding Roslaunch File Checks - CMake Source: https://github.com/jianzhuozhuthu/putn/blob/main/src/scout_simulator/scout_description/CMakeLists.txt Utilizes a catkin macro to add checks for roslaunch files within a specified directory (`launch`). This helps verify the existence and validity of launch files during the build or installation process. ```CMake roslaunch_add_file_check(launch) ``` -------------------------------- ### Create and Initialize ROS Workspace Source: https://github.com/jianzhuozhuthu/putn/blob/main/src/scout_simulator/README.md Creates a new ROS workspace directory (`scout_ws`), navigates into it, creates a source space (`src`), navigates into the source space, and initializes it for catkin, the ROS build system. ```bash mkdir scout_ws cd scout_ws mkdir src cd src catkin_init_workspace ``` -------------------------------- ### Download Simulation Model Package Source: https://github.com/jianzhuozhuthu/putn/blob/main/src/scout_simulator/README.md Downloads the Scout robot simulation package source code from a Git repository into the source space (`src`) of the ROS workspace. This package contains the necessary model files and launch configurations. ```bash git clone https://github.com/agilexrobotics/ugv_sim/scout.git ``` -------------------------------- ### Compile ROS Workspace Source: https://github.com/jianzhuozhuthu/putn/blob/main/src/scout_simulator/README.md Compiles all packages within the ROS workspace using the catkin build system. This builds executables, libraries, and scripts from the source code, making them available for use. ```bash catkin_make ``` -------------------------------- ### Generating Dynamic Reconfigure Options (Commented) Source: https://github.com/jianzhuozhuthu/putn/blob/main/src/scout_simulator/scout_control/CMakeLists.txt Macro to process dynamic reconfigure (.cfg) files and generate the necessary source code. List all .cfg files in the arguments. Requires `dynamic_reconfigure` build and execution dependencies. ```CMake ## Generate dynamic reconfigure parameters in the 'cfg' folder # generate_dynamic_reconfigure_options( # cfg/DynReconf1.cfg # cfg/DynReconf2.cfg # ) ``` -------------------------------- ### Generating ROS Dynamic Reconfigure Options in CMake Source: https://github.com/jianzhuozhuthu/putn/blob/main/src/putn/putn_launch/CMakeLists.txt Specifies `.cfg` files in the 'cfg' folder for processing by the dynamic reconfigure code generator. This creates C++, Python, and rqt_reconfigure interfaces for runtime parameter modification. Requires `dynamic_reconfigure` dependency. ```CMake # generate_dynamic_reconfigure_options( # cfg/DynReconf1.cfg # cfg/DynReconf2.cfg # ) ``` -------------------------------- ### Configuring ROS Package Build with CMake Source: https://github.com/jianzhuozhuthu/putn/blob/main/src/putn/putn_waypoint_generator/CMakeLists.txt This CMake script defines the build process for the 'waypoint_generator' ROS package. It specifies compiler requirements, checks for C++11/C++0x support, sets additional compiler flags, finds ROS dependencies, adds source directories, creates an executable from a source file, and links it against ROS libraries. ```CMake cmake_minimum_required(VERSION 2.8.3) project(waypoint_generator) set(CMAKE_VERBOSE_MAKEFILE "true") include(CheckCXXCompilerFlag) CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11) CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X) if(COMPILER_SUPPORTS_CXX11) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") elseif(COMPILER_SUPPORTS_CXX0X) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") else() message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.") endif() set(ADDITIONAL_CXX_FLAG "-Wall -O3 -march=native") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ADDITIONAL_CXX_FLAG}") find_package(catkin REQUIRED COMPONENTS roscpp tf nav_msgs ) catkin_package() include_directories(include) include_directories( ${catkin_INCLUDE_DIRS} ) add_executable(waypoint_generator src/waypoint_generator.cpp) target_link_libraries(waypoint_generator ${catkin_LIBRARIES} ) ``` -------------------------------- ### Declaring Catkin Package - CMake Source: https://github.com/jianzhuozhuthu/putn/blob/main/src/scout_simulator/scout_description/CMakeLists.txt Declares this project as a catkin package. This macro configures the project for the ROS catkin build system, setting up include paths, library paths, and dependencies based on the `find_package` calls. ```CMake catkin_package() ``` -------------------------------- ### Configuring ROS Catkin Package with CMake Source: https://github.com/jianzhuozhuthu/putn/blob/main/src/putn/putn_launch/CMakeLists.txt Declares the ROS package using the `catkin_package` macro. This exports include directories, libraries, and dependencies (both Catkin and system) to projects that depend on this package. ```CMake catkin_package( # INCLUDE_DIRS include # LIBRARIES putn_launch # CATKIN_DEPENDS other_catkin_pkg # DEPENDS system_lib ) ``` -------------------------------- ### Finding Catkin Build System - CMake Source: https://github.com/jianzhuozhuthu/putn/blob/main/src/putn/putn_map/CMakeLists.txt Locates the Catkin build system, which is required for building ROS packages using CMake. The REQUIRED keyword makes this a mandatory dependency. ```CMake find_package(catkin REQUIRED) ``` -------------------------------- ### Declaring ROS Action Files in CMake Source: https://github.com/jianzhuozhuthu/putn/blob/main/src/putn/putn_launch/CMakeLists.txt Specifies `.action` files in the 'action' folder that should be processed to generate corresponding source code for action client and server implementations. ```CMake # add_action_files( # FILES # Action1.action # Action2.action # ) ``` -------------------------------- ### Adding Include Directories - CMake Source: https://github.com/jianzhuozhuthu/putn/blob/main/src/putn/putn_map/CMakeLists.txt Specifies additional directories where the compiler should look for header files. This typically includes the package's own include directory and Catkin's generated include paths. ```CMake include_directories( # include # ${catkin_INCLUDE_DIRS} ) ``` -------------------------------- ### Generating ROS Messages and Services in CMake Source: https://github.com/jianzhuozhuthu/putn/blob/main/src/putn/putn_launch/CMakeLists.txt Triggers the message and service code generation process for the files declared previously. Dependencies on other message packages must be listed to ensure correct order. ```CMake # generate_messages( # DEPENDENCIES # std_msgs # Or other packages containing msgs # ) ``` -------------------------------- ### Launch Scout Mini Rviz Display Source: https://github.com/jianzhuozhuthu/putn/blob/main/src/scout_simulator/README.md Launches a ROS node (`roslaunch`) that displays the URDF model of the Scout Mini robot in the Rviz visualization tool. This allows visualizing the robot's structure and joint states. ```bash roslaunch scout_description display_scout_mini.launch ``` -------------------------------- ### Setting Minimum CMake Version Source: https://github.com/jianzhuozhuthu/putn/blob/main/src/scout_simulator/scout_control/CMakeLists.txt Specifies the minimum version of CMake required to configure the project. This is the first command in any CMakeLists.txt file. ```CMake cmake_minimum_required(VERSION 3.0.2) ``` -------------------------------- ### Configuring Catkin Package Properties - CMake Source: https://github.com/jianzhuozhuthu/putn/blob/main/src/putn/putn_map/CMakeLists.txt Sets properties for the Catkin package, including include directories, libraries, and package dependencies (both Catkin and system) that are exported for use by other packages. ```CMake catkin_package( # INCLUDE_DIRS include # LIBRARIES complex_terrain_gazebo # CATKIN_DEPENDS other_catkin_pkg # DEPENDS system_lib ) ``` -------------------------------- ### Declaring ROS Service Files in CMake Source: https://github.com/jianzhuozhuthu/putn/blob/main/src/putn/putn_launch/CMakeLists.txt Specifies `.srv` files in the 'srv' folder that should be processed to generate corresponding source code for service communication. ```CMake # add_service_files( # FILES # Service1.srv # Service2.srv # ) ``` -------------------------------- ### Including Header Directories in ROS CMake Source: https://github.com/jianzhuozhuthu/putn/blob/main/src/putn/putn_launch/CMakeLists.txt Specifies directories where CMake should search for header files. It's common to include the package's 'include' directory and the include directories from dependent Catkin packages. ```CMake include_directories( # include # ${catkin_INCLUDE_DIRS} ) ``` -------------------------------- ### Setting Minimum CMake Version - CMake Source: https://github.com/jianzhuozhuthu/putn/blob/main/src/putn/putn_map/CMakeLists.txt Specifies the minimum required version of CMake to build this project. This ensures compatibility with the commands and features used in the file. ```CMake cmake_minimum_required(VERSION 3.0.2) ``` -------------------------------- ### Declaring ROS Message Files in CMake Source: https://github.com/jianzhuozhuthu/putn/blob/main/src/putn/putn_launch/CMakeLists.txt Specifies `.msg` files in the 'msg' folder that should be processed to generate corresponding source code in various languages (C++, Python, Lisp, etc.). Requires `message_generation` dependency. ```CMake # add_message_files( # FILES # Message1.msg # Message2.msg # ) ``` -------------------------------- ### Adding Target Dependencies (Commented) Source: https://github.com/jianzhuozhuthu/putn/blob/main/src/scout_simulator/scout_control/CMakeLists.txt Ensures that specific targets (like generated messages or dynamic reconfigure code) are built before the main library or executable that depends on them. Useful when code generation is involved. ```CMake ## Add cmake target dependencies of the library ## as an example, code may need to be generated before libraries ## either from message generation or dynamic reconfigure # add_dependencies(${PROJECT_NAME} ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS}) ``` -------------------------------- ### Finding Required ROS Packages - CMake Source: https://github.com/jianzhuozhuthu/putn/blob/main/src/scout_simulator/scout_description/CMakeLists.txt Locates required ROS packages and their components using catkin's `find_package` macro. This ensures that necessary dependencies, like `roslaunch`, are available for the build. ```CMake find_package(catkin REQUIRED COMPONENTS roslaunch) ``` -------------------------------- ### Finding Catkin Build System in ROS CMake Source: https://github.com/jianzhuozhuthu/putn/blob/main/src/putn/putn_launch/CMakeLists.txt Finds the Catkin build system package. The `REQUIRED` keyword ensures that CMake will fail if Catkin is not found, as it is essential for building ROS packages. ```CMake find_package(catkin REQUIRED) ``` -------------------------------- ### Linking Libraries to Target in ROS CMake Source: https://github.com/jianzhuozhuthu/putn/blob/main/src/putn/putn_launch/CMakeLists.txt Links required libraries to a specified executable or library target. This typically includes libraries from Catkin dependencies (`${catkin_LIBRARIES}`) and any libraries built within the current project. ```CMake # target_link_libraries(${PROJECT_NAME}_node # ${catkin_LIBRARIES} # ) ``` -------------------------------- ### Launch Scout V2 Rviz Display Source: https://github.com/jianzhuozhuthu/putn/blob/main/src/scout_simulator/README.md Launches a ROS node (`roslaunch`) that displays the URDF model of the Scout V2 robot in the Rviz visualization tool. This allows visualizing the robot's structure and joint states. ```bash roslaunch scout_description display_scout_v2.launch ``` -------------------------------- ### Specifying Include Directories (Commented) Source: https://github.com/jianzhuozhuthu/putn/blob/main/src/scout_simulator/scout_control/CMakeLists.txt Adds directories to the include path for the current project's source files. It's common to include a package's own `include` directory and the directories provided by Catkin and its dependencies. ```CMake ## Specify additional locations of header files ## Your package locations should be listed before other locations include_directories( # include # ${catkin_INCLUDE_DIRS} ) ``` -------------------------------- ### Linking Libraries to Target (Commented) Source: https://github.com/jianzhuozhuthu/putn/blob/main/src/scout_simulator/scout_control/CMakeLists.txt Specifies which libraries (like those provided by Catkin and its dependencies) should be linked to an executable or library target. This ensures that the target can use functions and symbols from those libraries. ```CMake ## Specify libraries to link a library or executable target against # target_link_libraries(${PROJECT_NAME}_node # ${catkin_LIBRARIES} # ) ``` -------------------------------- ### Setting Minimum CMake Version - CMake Source: https://github.com/jianzhuozhuthu/putn/blob/main/src/scout_simulator/scout_description/CMakeLists.txt Specifies the minimum version of CMake required to build the project. This ensures compatibility with the CMake features used in the file. ```CMake cmake_minimum_required(VERSION 2.8.3) ``` -------------------------------- ### Adding Python Nosetests Target in ROS CMake Source: https://github.com/jianzhuozhuthu/putn/blob/main/src/putn/putn_launch/CMakeLists.txt Configures a test target using the Python Nosetests framework. This macro allows running Python tests located in specified directories as part of the Catkin build process. ```CMake # catkin_add_nosetests(test) ``` -------------------------------- ### Adding Python Nosetests (Commented) Source: https://github.com/jianzhuozhuthu/putn/blob/main/src/scout_simulator/scout_control/CMakeLists.txt Macro to define Python test targets run by the Nosetests framework. Specify the directory containing the test files. ```CMake ## Add folders to be run by python nosetests # catkin_add_nosetests(test) ``` -------------------------------- ### Setting Minimum CMake Version in ROS CMake Source: https://github.com/jianzhuozhuthu/putn/blob/main/src/putn/putn_launch/CMakeLists.txt Specifies the minimum required version of CMake to build this project. This is crucial for compatibility with the build system and specific CMake features used. ```CMake cmake_minimum_required(VERSION 3.0.2) ``` -------------------------------- ### Finding ROS Catkin Package Source: https://github.com/jianzhuozhuthu/putn/blob/main/src/scout_simulator/scout_control/CMakeLists.txt Locates and loads configuration for the ROS Catkin build system. This is essential for building any ROS package using Catkin. The `REQUIRED` keyword ensures the build fails if Catkin is not found. ```CMake ## Find catkin macros and libraries ## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz) ## is used, also find other catkin packages find_package(catkin REQUIRED) ``` -------------------------------- ### Compiling with C++11 (Commented) Source: https://github.com/jianzhuozhuthu/putn/blob/main/src/scout_simulator/scout_control/CMakeLists.txt An optional setting to enforce compilation using the C++11 standard. This is often required for modern ROS development (Kinetic and newer). It is currently commented out. ```CMake ## Compile as C++11, supported in ROS Kinetic and newer # add_compile_options(-std=c++11) ``` -------------------------------- ### Declaring a C++ Library (Commented) Source: https://github.com/jianzhuozhuthu/putn/blob/main/src/scout_simulator/scout_control/CMakeLists.txt Defines a C++ library target to be built from source files. The library name is typically the project name. ```CMake ## Declare a C++ library # add_library(${PROJECT_NAME} # src/${PROJECT_NAME}/scout_control.cpp # ) ``` -------------------------------- ### Generating ROS Messages/Services (Commented) Source: https://github.com/jianzhuozhuthu/putn/blob/main/src/scout_simulator/scout_control/CMakeLists.txt Macro used to trigger the generation of source code (C++, Python, Lisp) from .msg, .srv, or .action files. Dependencies (like `std_msgs`) must be listed so their message types are available during generation. ```CMake ## Generate added messages and services with any dependencies listed here # generate_messages( # DEPENDENCIES # std_msgs # Or other packages containing msgs # ) ``` -------------------------------- ### Declaring a C++ Executable (Commented) Source: https://github.com/jianzhuozhuthu/putn/blob/main/src/scout_simulator/scout_control/CMakeLists.txt Defines a C++ executable target to be built from source files. Catkin recommends prefixing executable names with the package name to avoid naming collisions across packages. ```CMake ## Declare a C++ executable ## With catkin_make all packages are built within a single CMake context ## The recommended prefix ensures that target names across packages don't collide # add_executable(${PROJECT_NAME}_node src/scout_control_node.cpp) ``` -------------------------------- ### Declaring ROS Project Name - CMake Source: https://github.com/jianzhuozhuthu/putn/blob/main/src/putn/putn_map/CMakeLists.txt Defines the name of the CMake project, which typically corresponds to the ROS package name. This name is used by other CMake commands. ```CMake project(putn_map) ``` -------------------------------- ### Defining CMake Project Name - CMake Source: https://github.com/jianzhuozhuthu/putn/blob/main/src/scout_simulator/scout_description/CMakeLists.txt Sets the name of the CMake project. This name is often used in subsequent CMake commands and identifies the project being built. ```CMake project(scout_description) ``` -------------------------------- ### Adding C++ GTest Target (Commented) Source: https://github.com/jianzhuozhuthu/putn/blob/main/src/scout_simulator/scout_control/CMakeLists.txt Macro to define a C++ test target using Google Test. Specify the test source file. The target is typically linked against the library or executable it is testing. ```CMake ## Add gtest based cpp test target and link libraries # catkin_add_gtest(${PROJECT_NAME}-test test/test_scout_control.cpp) # if(TARGET ${PROJECT_NAME}-test) # target_link_libraries(${PROJECT_NAME}-test ${PROJECT_NAME}) # endif() ``` -------------------------------- ### Adding C++ Executable Target in ROS CMake Source: https://github.com/jianzhuozhuthu/putn/blob/main/src/putn/putn_launch/CMakeLists.txt Declares a C++ executable target (a ROS node) from the specified source file. The recommended Catkin prefix prevents naming collisions with executables in other packages. ```CMake # add_executable(${PROJECT_NAME}_node src/putn_launch_node.cpp) ``` -------------------------------- ### Renaming C++ Executable (Commented) Source: https://github.com/jianzhuozhuthu/putn/blob/main/src/scout_simulator/scout_control/CMakeLists.txt Removes the package name prefix from an executable target name, allowing it to be run using the shorter name (e.g., `rosrun package_name node` instead of `rosrun package_name package_name_node`). ```CMake ## Rename C++ executable without prefix ## The above recommended prefix causes long target names, the following renames the ## target back to the shorter version for ease of user use ## e.g. "rosrun someones_pkg node" instead of "rosrun someones_pkg someones_pkg_node" # set_target_properties(${PROJECT_NAME}_node PROPERTIES OUTPUT_NAME node PREFIX "") ``` -------------------------------- ### Defining ROS Project Name Source: https://github.com/jianzhuozhuthu/putn/blob/main/src/scout_simulator/scout_control/CMakeLists.txt Declares the name of the ROS package project. This name is used by subsequent CMake and Catkin commands to refer to the current package. ```CMake project(scout_control) ``` -------------------------------- ### Declaring ROS Project Name in CMake Source: https://github.com/jianzhuozhuthu/putn/blob/main/src/putn/putn_launch/CMakeLists.txt Defines the name of the CMake project, which is typically the name of the ROS package. This name is used by CMake for various internal purposes and target naming. ```CMake project(putn_launch) ``` -------------------------------- ### Adding C++ Library Target in ROS CMake Source: https://github.com/jianzhuozhuthu/putn/blob/main/src/putn/putn_launch/CMakeLists.txt Declares a C++ library target using the specified source file(s). The library name is typically the project name. This is a common pattern for reusable code within or between ROS packages. ```CMake # add_library(${PROJECT_NAME} # src/${PROJECT_NAME}/putn_launch.cpp # ) ``` -------------------------------- ### Defining Catkin Package Properties Source: https://github.com/jianzhuozhuthu/putn/blob/main/src/scout_simulator/scout_control/CMakeLists.txt The core Catkin macro that defines properties of the package for use by dependent packages. It allows declaring include directories, libraries to export, and package dependencies (both Catkin and system). ```CMake ## The catkin_package macro generates cmake config files for your package ## Declare things to be passed to dependent projects ## INCLUDE_DIRS: uncomment this if your package contains header files ## LIBRARIES: libraries you create in this project that dependent projects also need ## CATKIN_DEPENDS: catkin_packages dependent projects also need ## DEPENDS: system dependencies of this project that dependent projects also need catkin_package( # INCLUDE_DIRS include # LIBRARIES scout_control # CATKIN_DEPENDS other_catkin_pkg # DEPENDS system_lib ) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.