### Install ROS Package Files (CMake) Source: https://github.com/tu-darmstadt-ros-pkg/hector_slam/blob/noetic-devel/hector_imu_attitude_to_tf/CMakeLists.txt Specifies installation rules for a ROS package's build artifacts. It installs the executable to the appropriate binary directory and the launch files to the share directory, following standard catkin installation conventions. ```cmake install(TARGETS imu_attitude_to_tf_node ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} ) install(DIRECTORY launch DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION} ) ``` -------------------------------- ### Installation Rules Source: https://github.com/tu-darmstadt-ros-pkg/hector_slam/blob/noetic-devel/hector_mapping/CMakeLists.txt Defines how the built targets and files are installed. This includes the 'hector_mapping' executable, header files from 'hector_slam_lib', and launch files, ensuring the package is correctly deployed. ```cmake install(TARGETS hector_mapping ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} ) ## Don't ask why it's hector_slam_lib, this was Stefan Kohlbrecher's first ROS package and a wrapper of a pre ROS header only library install(DIRECTORY include/hector_slam_lib/ DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION} FILES_MATCHING PATTERN "*.h" PATTERN ".svn" EXCLUDE ) install(DIRECTORY launch/ DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/launch/ ) ``` -------------------------------- ### Install Package Headers and Resources Source: https://github.com/tu-darmstadt-ros-pkg/hector_slam/blob/noetic-devel/hector_map_tools/CMakeLists.txt Defines the installation rules for the hector_map_tools package. It installs header files from the 'include' directory to the appropriate catkin include destination, excluding version control directories. ```cmake install( DIRECTORY include/${PROJECT_NAME}/ DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION} FILES_MATCHING PATTERN "*.h" PATTERN ".svn" EXCLUDE ) ``` -------------------------------- ### Configure hector_map_server Build and Install (CMake) Source: https://github.com/tu-darmstadt-ros-pkg/hector_slam/blob/noetic-devel/hector_map_server/CMakeLists.txt This snippet defines the build configuration for the 'hector_map_server' executable. It finds necessary catkin packages, declares build dependencies, links libraries, and specifies installation directories for the executable. ```cmake cmake_minimum_required(VERSION 3.0.2) project(hector_map_server) find_package(catkin REQUIRED COMPONENTS roscpp hector_map_tools hector_marker_drawing hector_nav_msgs nav_msgs tf) catkin_package( CATKIN_DEPENDS roscpp hector_map_tools hector_marker_drawing hector_nav_msgs nav_msgs tf ) include_directories( ${catkin_INCLUDE_DIRS} ) add_executable(hector_map_server src/hector_map_server.cpp) add_dependencies(hector_map_server ${catkin_EXPORTED_TARGETS}) target_link_libraries(hector_map_server ${catkin_LIBRARIES} ) install(TARGETS hector_map_server ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} ) ``` -------------------------------- ### Install Targets for hector_geotiff Source: https://github.com/tu-darmstadt-ros-pkg/hector_slam/blob/noetic-devel/hector_geotiff/CMakeLists.txt Specifies the installation rules for the built targets. It defines where the libraries, executables, headers, and other resources will be placed in the ROS package structure. ```cmake install(TARGETS geotiff_writer geotiff_saver geotiff_node ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} ) install(DIRECTORY include/${PROJECT_NAME}/ DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION} FILES_MATCHING PATTERN "*.h" PATTERN ".svn" EXCLUDE ) install(DIRECTORY fonts DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION} ) ``` -------------------------------- ### Install map_to_image_node Executable (CMake) Source: https://github.com/tu-darmstadt-ros-pkg/hector_slam/blob/noetic-devel/hector_compressed_map_transport/CMakeLists.txt This snippet defines the installation rules for the map_to_image_node executable built by the hector_compressed_map_transport package. It specifies the destination directories for the executable and its associated libraries within the ROS package structure. ```cmake install(TARGETS map_to_image_node ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} ) ``` -------------------------------- ### Install Launch Files with CMake Source: https://github.com/tu-darmstadt-ros-pkg/hector_slam/blob/noetic-devel/hector_geotiff_launch/CMakeLists.txt Installs the 'launch' directory to the appropriate location within the ROS package's share directory. This ensures that launch files are accessible when the package is sourced. ```cmake install(DIRECTORY launch DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}) ``` -------------------------------- ### CMake Installation Rules for hector_geotiff_plugins Source: https://github.com/tu-darmstadt-ros-pkg/hector_slam/blob/noetic-devel/hector_geotiff_plugins/CMakeLists.txt Defines the installation rules for the hector_geotiff_plugins library and its associated XML file. It specifies the destination directories for archives, libraries, runtime executables, and shared data using catkin variables. ```cmake install(TARGETS hector_geotiff_plugins ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} ) install(FILES hector_geotiff_plugins.xml DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION} ) ``` -------------------------------- ### CMakeLists.txt Configuration for hector_slam Source: https://github.com/tu-darmstadt-ros-pkg/hector_slam/blob/noetic-devel/hector_slam_launch/CMakeLists.txt This CMakeLists.txt file configures the hector_slam ROS package. It specifies the minimum CMake version, project name, and finds the catkin package. It also defines installation rules for launch and rviz configuration files. ```cmake cmake_minimum_required(VERSION 3.0.2) project(hector_slam_launch) find_package(catkin REQUIRED) catkin_package() ############# ## Install ## ############# # all install targets should use catkin DESTINATION variables # See http://ros.org/doc/api/catkin/html/adv_user_guide/variables.html install(DIRECTORY launch rviz_cfg DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION} ) ``` -------------------------------- ### CMake Build Configuration for hector_marker_drawing Source: https://github.com/tu-darmstadt-ros-pkg/hector_slam/blob/noetic-devel/hector_marker_drawing/CMakeLists.txt Configures the build process for the hector_marker_drawing ROS package. It finds necessary packages like catkin, roscpp, visualization_msgs, and Eigen3. It also defines package information and installation rules for header files. ```cmake cmake_minimum_required(VERSION 3.0.2) project(hector_marker_drawing) find_package(catkin REQUIRED COMPONENTS roscpp visualization_msgs) find_package(Eigen3 REQUIRED) catkin_package( INCLUDE_DIRS include CATKIN_DEPENDS roscpp visualization_msgs DEPENDS EIGEN3 ) # all install targets should use catkin DESTINATION variables # See http://ros.org/doc/api/catkin/html/adv_user_guide/variables.html install(DIRECTORY include/${PROJECT_NAME}/ DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION} FILES_MATCHING PATTERN "*.h" PATTERN ".svn" EXCLUDE ) ``` -------------------------------- ### Restart Hector SLAM with New Pose (Bash) Source: https://context7.com/tu-darmstadt-ros-pkg/hector_slam/llms.txt This command uses the `/restart_mapping_with_new_pose` ROS service to reset the SLAM map and initialize the robot's pose to a specified starting location. This service is part of the `hector_mapping` package and requires a `geometry_msgs/Pose` as input. ```bash # Service definition: hector_mapping/ResetMapping # Request: # geometry_msgs/Pose initial_pose # Response: (empty) # Reset map with new starting pose rosservice call /restart_mapping_with_new_pose "initial_pose: position: {x: 5.0, y: 3.0, z: 0.0} orientation: {x: 0.0, y: 0.0, z: 0.707, w: 0.707}" ``` -------------------------------- ### Get Search Position ROS Service Source: https://context7.com/tu-darmstadt-ros-pkg/hector_slam/llms.txt Calls the '/hector_map_server/get_search_position' ROS service to determine a suggested observation position. This service requires the pose of an object of interest and a desired distance, returning a recommended search pose. ```bash # Service definition: hector_nav_msgs/GetSearchPosition # Request: # geometry_msgs/PoseStamped ooi_pose # float32 distance # Response: # geometry_msgs/PoseStamped search_pose # Get search position 2 meters from object rosservice call /hector_map_server/get_search_position "ooi_pose: header: {frame_id: 'map'} pose: position: {x: 5.0, y: 3.0, z: 0.0} orientation: {x: 0.0, y: 0.0, z: 0.0, w: 1.0} distance: 2.0" ``` -------------------------------- ### ROS Service - reset_map Source: https://context7.com/tu-darmstadt-ros-pkg/hector_slam/llms.txt Resets the SLAM map to its initial empty state. This service is of type `std_srvs/Trigger` and is useful for starting fresh mapping sessions. ```APIDOC ## POST /rosapi/reset_map ### Description Calls the `/reset_map` ROS service to reset the SLAM map to an empty state. This is useful for starting a new mapping session without restarting the entire node. ### Method POST ### Endpoint /rosapi/reset_map ### Parameters None ### Request Example ```bash rosservice call /reset_map ``` ### Response #### Success Response (200) - **success** (boolean) - True if the map was reset successfully, False otherwise. - **message** (string) - A message indicating the result of the operation. #### Response Example ```json { "success": true, "message": "" } ``` ``` -------------------------------- ### Get Trajectory Recovery Info ROS Service Source: https://context7.com/tu-darmstadt-ros-pkg/hector_slam/llms.txt Calls the '/trajectory_recovery_info' ROS service to obtain trajectory data for recovery scenarios. This service requires a request time and radius, and returns trajectory information, including entry poses and the requested pose. ```bash # Service definition: hector_nav_msgs/GetRecoveryInfo # Request: # time request_time # float64 request_radius # Response: # nav_msgs/Path trajectory_radius_entry_pose_to_req_pose # geometry_msgs/PoseStamped radius_entry_pose # geometry_msgs/PoseStamped req_pose # Get recovery trajectory from 2 meters radius rosservice call /trajectory_recovery_info "request_time: {secs: 0, nsecs: 0} request_radius: 2.0" ``` -------------------------------- ### Get Distance to Obstacle ROS Service Source: https://context7.com/tu-darmstadt-ros-pkg/hector_slam/llms.txt Calls the '/hector_map_server/get_distance_to_obstacle' ROS service to calculate the distance to the nearest obstacle from a given point and direction. The service takes a pointStamped message and returns the distance and the end point of the ray cast. ```bash # Service definition: hector_nav_msgs/GetDistanceToObstacle # Request: # geometry_msgs/PointStamped point # Response: # float32 distance # geometry_msgs/PointStamped end_point # Query distance to obstacle from robot's current frame rosservice call /hector_map_server/get_distance_to_obstacle "point: header: frame_id: 'base_link' stamp: {secs: 0, nsecs: 0} point: {x: 1.0, y: 0.0, z: 0.0}" # Response: # distance: 3.45 # end_point: {header: {...}, point: {x: 4.45, y: 0.0, z: 0.0}} ``` -------------------------------- ### Get Robot Trajectory ROS Service Source: https://context7.com/tu-darmstadt-ros-pkg/hector_slam/llms.txt Calls the '/trajectory' ROS service provided by hector_trajectory_server to retrieve the robot's complete path. The service returns a nav_msgs/Path message containing timestamped poses. The request is empty, and the response includes a header and a list of poses. ```bash # Service definition: hector_nav_msgs/GetRobotTrajectory # Request: (empty) # Response: # nav_msgs/Path trajectory # Get the robot's trajectory rosservice call /trajectory # Response: # trajectory: # header: {frame_id: "map"} # poses: # - header: {stamp: ...} # pose: {position: {x: 0.0, y: 0.0, z: 0.0}, ...} # - header: {stamp: ...} # pose: {position: {x: 0.5, y: 0.1, z: 0.0}, ...} ``` -------------------------------- ### Reset Hector SLAM Map using ROS Service (Bash) Source: https://context7.com/tu-darmstadt-ros-pkg/hector_slam/llms.txt This command invokes the `/reset_map` ROS service to clear the current occupancy grid map and reset the SLAM system to its initial state. This is useful for starting a new mapping session without needing to restart the entire ROS node. ```bash # Reset the map to empty state rosservice call /reset_map # Response: # success: True # message: "" ``` -------------------------------- ### Complete SLAM Tutorial Launch Source: https://context7.com/tu-darmstadt-ros-pkg/hector_slam/llms.txt Launches a full SLAM system demonstration, including RViz visualization, core SLAM mapping, and GeoTiff export capabilities. It utilizes parameters for map file paths and simulation time. ```xml ``` -------------------------------- ### Build Configuration and Executable Compilation Source: https://github.com/tu-darmstadt-ros-pkg/hector_slam/blob/noetic-devel/hector_mapping/CMakeLists.txt Sets up include directories and compiles the main executable 'hector_mapping'. It links against catkin and Boost libraries, making the necessary functionalities available for the SLAM node. ```cmake include_directories(include/hector_slam_lib) include_directories( ${Boost_INCLUDE_DIRS} ${catkin_INCLUDE_DIRS} ${EIGEN3_INCLUDE_DIRS} ) add_executable(hector_mapping src/HectorDebugInfoProvider.h src/HectorDrawings.h src/HectorMappingRos.h src/HectorMappingRos.cpp src/main.cpp src/PoseInfoContainer.cpp src/PoseInfoContainer.h ) add_dependencies(hector_mapping hector_mapping_generate_messages_cpp) target_link_libraries(hector_mapping ${catkin_LIBRARIES} ${Boost_LIBRARIES} ) ``` -------------------------------- ### Configure ROS Package Build with CMake Source: https://github.com/tu-darmstadt-ros-pkg/hector_slam/blob/noetic-devel/hector_nav_msgs/CMakeLists.txt This snippet sets up the CMake build system for a ROS package. It finds necessary catkin components, declares ROS messages and services to be generated, and specifies package dependencies for compilation. ```cmake cmake_minimum_required(VERSION 3.0.2) project(hector_nav_msgs) find_package(catkin REQUIRED COMPONENTS nav_msgs geometry_msgs message_generation std_msgs) ####################################### ## Declare ROS messages and services ## ####################################### ## Generate services in the 'srv' folder add_service_files( FILES GetDistanceToObstacle.srv GetRecoveryInfo.srv GetRobotTrajectory.srv GetSearchPosition.srv GetNormal.srv ) generate_messages( DEPENDENCIES geometry_msgs nav_msgs std_msgs ) catkin_package( CATKIN_DEPENDS nav_msgs geometry_msgs message_runtime std_msgs ) ``` -------------------------------- ### Setting Initial Pose via Topic Source: https://context7.com/tu-darmstadt-ros-pkg/hector_slam/llms.txt Sets the robot's initial pose estimate by publishing a 'PoseWithCovarianceStamped' message to the '/initialpose' topic. This message includes header information, pose, and covariance data. ```bash # Set initial pose estimate rostopic pub /initialpose geometry_msgs/PoseWithCovarianceStamped "header: frame_id: 'map' pose: pose: position: {x: 1.0, y: 2.0, z: 0.0} orientation: {x: 0.0, y: 0.0, z: 0.0, w: 1.0} covariance: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]" ``` -------------------------------- ### Build Library and Executables Source: https://github.com/tu-darmstadt-ros-pkg/hector_slam/blob/noetic-devel/hector_geotiff/CMakeLists.txt Defines the build targets for the geotiff_writer library and the geotiff_saver and geotiff_node executables. It includes necessary directories and links against required libraries. ```cmake include_directories( include ${catkin_INCLUDE_DIRS} ${EIGEN3_INCLUDE_DIRS} ${Qt5Widgets_INCLUDE_DIRS} ) add_library(geotiff_writer src/geotiff_writer/geotiff_writer.cpp) target_link_libraries(geotiff_writer ${catkin_LIBRARIES} Qt5::Widgets stdc++fs) add_dependencies(geotiff_writer ${catkin_EXPORTED_TARGETS}) add_executable(geotiff_saver src/geotiff_saver.cpp) target_link_libraries(geotiff_saver geotiff_writer) add_dependencies(geotiff_saver ${catkin_EXPORTED_TARGETS}) add_executable(geotiff_node src/geotiff_node.cpp) target_link_libraries(geotiff_node geotiff_writer) add_dependencies(geotiff_node ${catkin_EXPORTED_TARGETS}) ``` -------------------------------- ### Catkin Package Configuration Source: https://github.com/tu-darmstadt-ros-pkg/hector_slam/blob/noetic-devel/hector_mapping/CMakeLists.txt Configures the catkin package, specifying include directories and runtime dependencies. This ensures that the package can be correctly built and linked within the ROS build system. ```cmake catkin_package( INCLUDE_DIRS include # LIBRARIES hector_mapping CATKIN_DEPENDS roscpp nav_msgs visualization_msgs tf message_filters laser_geometry message_runtime DEPENDS EIGEN3 ) ``` -------------------------------- ### ROS Package Configuration and Dependencies Source: https://github.com/tu-darmstadt-ros-pkg/hector_slam/blob/noetic-devel/hector_mapping/CMakeLists.txt Configures the ROS package 'hector_mapping' and declares its dependencies. It finds required ROS packages and external libraries like Boost and Eigen3, essential for the SLAM algorithm's functionality. ```cmake cmake_minimum_required(VERSION 3.0.2) project(hector_mapping) find_package(catkin REQUIRED COMPONENTS roscpp nav_msgs visualization_msgs tf message_filters laser_geometry message_generation std_srvs) find_package(Boost REQUIRED COMPONENTS thread) find_package(Eigen3 REQUIRED) ``` -------------------------------- ### Configure Hector SLAM Node (XML) Source: https://context7.com/tu-darmstadt-ros-pkg/hector_slam/llms.txt This snippet shows the basic ROS launch configuration for the hector_mapping node. It defines parameters for frame names, TF transformations, map properties, update thresholds, and laser filtering. This configuration is essential for initializing and running the SLAM system. ```xml ``` -------------------------------- ### CMake Configuration for hector_geotiff Source: https://github.com/tu-darmstadt-ros-pkg/hector_slam/blob/noetic-devel/hector_geotiff/CMakeLists.txt Configures the CMake build system for the hector_geotiff project. It finds necessary packages like catkin, Qt5, and Eigen3, and defines the package information. ```cmake cmake_minimum_required(VERSION 3.0.2) project(hector_geotiff) find_package(catkin REQUIRED COMPONENTS hector_map_tools hector_nav_msgs nav_msgs pluginlib roscpp std_msgs) find_package(Qt5 COMPONENTS Widgets REQUIRED) find_package(Eigen3 REQUIRED) catkin_package( INCLUDE_DIRS include LIBRARIES geotiff_writer CATKIN_DEPENDS hector_map_tools hector_nav_msgs nav_msgs pluginlib roscpp std_msgs DEPENDS EIGEN3 Qt5Widgets ) ``` -------------------------------- ### Define ROS Package Build (CMake) Source: https://github.com/tu-darmstadt-ros-pkg/hector_slam/blob/noetic-devel/hector_imu_attitude_to_tf/CMakeLists.txt Configures the build for a ROS package using CMake. It sets the minimum CMake version, project name, finds necessary catkin packages, declares package dependencies, includes directories, and defines an executable with its linked libraries. ```cmake cmake_minimum_required(VERSION 3.0.2) project(hector_imu_attitude_to_tf) find_package(catkin REQUIRED COMPONENTS roscpp sensor_msgs tf) catkin_package( CATKIN_DEPENDS roscpp sensor_msgs tf ) include_directories( ${catkin_INCLUDE_DIRS} ) add_executable(imu_attitude_to_tf_node src/imu_attitude_to_tf_node.cpp) target_link_libraries(imu_attitude_to_tf_node ${catkin_LIBRARIES}) ``` -------------------------------- ### Launch Hector Map Server Source: https://context7.com/tu-darmstadt-ros-pkg/hector_slam/llms.txt Launches the hector_map_server node, which provides map-related services such as distance-to-obstacle queries and search position calculations. This node is typically included in a full SLAM launch configuration. ```bash # Launch map server (typically included in full SLAM launch) rosrun hector_map_server hector_map_server ``` -------------------------------- ### CMake Build Configuration for hector_geotiff_plugins Source: https://github.com/tu-darmstadt-ros-pkg/hector_slam/blob/noetic-devel/hector_geotiff_plugins/CMakeLists.txt Configures the build process for the hector_geotiff_plugins library using CMake. It specifies the minimum required CMake version, project name, and finds necessary catkin packages. It also defines library targets, include directories, and linking libraries. ```cmake cmake_minimum_required(VERSION 3.0.2) project(hector_geotiff_plugins) find_package(catkin REQUIRED COMPONENTS hector_geotiff hector_nav_msgs) catkin_package( CATKIN_DEPENDS hector_geotiff hector_nav_msgs ) include_directories( ${catkin_INCLUDE_DIRS} ) add_library(hector_geotiff_plugins src/trajectory_geotiff_plugin.cpp) add_dependencies(hector_geotiff_plugins ${catkin_EXPORTED_TARGETS}) target_link_libraries(hector_geotiff_plugins ${catkin_LIBRARIES} ) ``` -------------------------------- ### Configure hector_compressed_map_transport Package Build (CMake) Source: https://github.com/tu-darmstadt-ros-pkg/hector_slam/blob/noetic-devel/hector_compressed_map_transport/CMakeLists.txt This snippet configures the build environment for the hector_compressed_map_transport ROS package. It finds required catkin packages, Eigen3, and OpenCV, sets include directories, and defines the map_to_image_node executable with its linking libraries. ```cmake cmake_minimum_required(VERSION 3.0.2) project(hector_compressed_map_transport) find_package(catkin REQUIRED COMPONENTS cv_bridge geometry_msgs hector_map_tools image_transport nav_msgs sensor_msgs) find_package(Eigen3 REQUIRED) find_package(OpenCV REQUIRED) catkin_package( CATKIN_DEPENDS geometry_msgs nav_msgs sensor_msgs ) include_directories( ${catkin_INCLUDE_DIRS} ${EIGEN3_INCLUDE_DIRS} ${OpenCV_INCLUDE_DIRS} ) add_executable(map_to_image_node src/map_to_image_node.cpp) target_link_libraries(map_to_image_node ${catkin_LIBRARIES} ${OpenCV_LIBRARIES} ) ``` -------------------------------- ### Subscribe to Robot Pose and Odometry Topics Source: https://context7.com/tu-darmstadt-ros-pkg/hector_slam/llms.txt These commands subscribe to the robot's pose updates and scanmatch odometry data. The pose update is published as geometry_msgs/PoseWithCovarianceStamped, while scanmatch odometry requires the 'pub_odometry' parameter to be set to true and is published as nav_msgs/Odometry. ```bash # Subscribe to pose with covariance (geometry_msgs/PoseWithCovarianceStamped) rostopic echo /poseupdate # Subscribe to scanmatch odometry (nav_msgs/Odometry) # Requires: pub_odometry param set to true rostopic echo /scanmatch_odom ``` -------------------------------- ### Subscribe to SLAM Pose Output (Bash) Source: https://context7.com/tu-darmstadt-ros-pkg/hector_slam/llms.txt This command subscribes to the `/slam_out_pose` topic, which publishes the estimated robot pose from the Hector SLAM node. The pose is published as a `geometry_msgs/PoseStamped` message, providing header information and the pose itself. ```bash # Subscribe to SLAM pose output (geometry_msgs/PoseStamped) rostopic echo /slam_out_pose # Example output: # header: # stamp: {secs: 1234567890, nsecs: 123456789} # frame_id: "map" # pose: # position: {x: 2.5, y: 1.3, z: 0.0} ``` -------------------------------- ### Configure Project with CMake Source: https://github.com/tu-darmstadt-ros-pkg/hector_slam/blob/noetic-devel/hector_geotiff_launch/CMakeLists.txt Configures the ROS package using CMake, specifying the minimum required version and project name. It finds the catkin package, which is essential for building ROS packages. ```cmake cmake_minimum_required(VERSION 3.0.2) project(hector_geotiff_launch) find_package(catkin REQUIRED) catkin_package() ``` -------------------------------- ### Launch Hector Trajectory Server Source: https://context7.com/tu-darmstadt-ros-pkg/hector_slam/llms.txt Launches the hector_trajectory_server node, which tracks and stores the robot's trajectory. It provides services to retrieve the complete path and recovery information. Configuration parameters include target and source frame names, and update/publish rates. ```xml ``` -------------------------------- ### Launch GeoTiff Map Export with Trajectory Source: https://context7.com/tu-darmstadt-ros-pkg/hector_slam/llms.txt Launches the hector_geotiff node to export the current map as a georeferenced TIFF image, including the robot's trajectory. This launch file configures both the trajectory server and the geotiff node, allowing for map saving with trajectory overlay. ```xml ``` -------------------------------- ### ROS Message and Service Generation Source: https://github.com/tu-darmstadt-ros-pkg/hector_slam/blob/noetic-devel/hector_mapping/CMakeLists.txt Defines and generates custom ROS messages and services for the hector_slam package. This includes 'HectorDebugInfo.msg', 'HectorIterData.msg', and the 'ResetMapping.srv', which are crucial for inter-node communication and debugging. ```cmake add_message_files( FILES HectorDebugInfo.msg HectorIterData.msg ) add_service_files( FILES ResetMapping.srv ) generate_messages( DEPENDENCIES geometry_msgs ) ``` -------------------------------- ### Configure CMake Build for Hector SLAM Package Source: https://github.com/tu-darmstadt-ros-pkg/hector_slam/blob/noetic-devel/hector_map_tools/CMakeLists.txt Sets up the CMake build system for the hector_map_tools ROS package. It specifies the minimum CMake version, project name, and finds necessary catkin and Eigen3 packages. It also configures the package for catkin, defining include directories and dependencies. ```cmake cmake_minimum_required(VERSION 3.0.2) project(hector_map_tools) find_package(catkin REQUIRED COMPONENTS nav_msgs) find_package(Eigen3 REQUIRED) catkin_package( INCLUDE_DIRS include CATKIN_DEPENDS nav_msgs DEPENDS EIGEN3 ) ``` -------------------------------- ### ROS Service - restart_mapping_with_new_pose Source: https://context7.com/tu-darmstadt-ros-pkg/hector_slam/llms.txt Resets the map and initializes the robot pose to a specified location. This service also unpauses mapping if it was paused. It uses the `hector_mapping/ResetMapping` service type. ```APIDOC ## POST /rosapi/restart_mapping_with_new_pose ### Description Calls the `/restart_mapping_with_new_pose` ROS service to reset the SLAM map and initialize the robot's pose to a specified `initial_pose`. This service also ensures mapping is unpaused. ### Method POST ### Endpoint /rosapi/restart_mapping_with_new_pose ### Parameters #### Request Body - **initial_pose** (geometry_msgs/Pose) - Required - The desired initial pose for the robot. - **position** (geometry_msgs/Point) - **x** (float) - X coordinate. - **y** (float) - Y coordinate. - **z** (float) - Z coordinate. - **orientation** (geometry_msgs/Quaternion) - **x** (float) - X component of the quaternion. - **y** (float) - Y component of the quaternion. - **z** (float) - Z component of the quaternion. - **w** (float) - W component of the quaternion. ### Request Example ```bash rosservice call /restart_mapping_with_new_pose "initial_pose: {position: {x: 5.0, y: 3.0, z: 0.0}, orientation: {x: 0.0, y: 0.0, z: 0.707, w: 0.707}}" ``` ### Response #### Success Response (200) (This service does not return any specific data upon success, only indicating success via the ROS service call mechanism.) #### Response Example ```json { "": "" } ``` ``` -------------------------------- ### Trigger GeoTiff Save via System Command Source: https://context7.com/tu-darmstadt-ros-pkg/hector_slam/llms.txt Saves the current map as a GeoTiff image by publishing a command to the '/syscommand' topic. The output file includes a UTC timestamp and is saved to the configured 'map_file_path'. ```bash # Trigger geotiff save rostopic pub /syscommand std_msgs/String "data: 'savegeotiff'" # Output file will be saved to configured map_file_path with UTC timestamp # Example: /path/to/maps/hector_slam_map_2024-01-15_14-30-45.tif ``` -------------------------------- ### Retrieve Current Map using ROS Service (Bash) Source: https://context7.com/tu-darmstadt-ros-pkg/hector_slam/llms.txt This command calls the `/dynamic_map` ROS service to retrieve the current occupancy grid map generated by Hector SLAM. The service returns a `nav_msgs/GetMap` response containing map metadata and cell occupancy data. ```bash # Call the dynamic_map service to retrieve current map rosservice call /dynamic_map # Response structure: # map: # info: # resolution: 0.05 # width: 2048 # height: 2048 # origin: # position: {x: -51.2, y: -51.2, z: 0.0} # orientation: {x: 0.0, y: 0.0, z: 0.0, w: 1.0} # data: [array of int8 values: -1=unknown, 0=free, 100=occupied] ``` -------------------------------- ### Define ROS Metapackage Build - CMake Source: https://github.com/tu-darmstadt-ros-pkg/hector_slam/blob/noetic-devel/hector_slam/CMakeLists.txt This CMakeLists.txt file defines the hector_slam metapackage for ROS. It specifies the minimum required CMake version, the project name, and uses catkin to manage package dependencies and build processes. As a metapackage, it does not contain source code but rather aggregates other packages. ```cmake cmake_minimum_required(VERSION 3.0.2) project(hector_slam) find_package(catkin REQUIRED) catkin_metapackage() ``` -------------------------------- ### System Reset via Topic Source: https://context7.com/tu-darmstadt-ros-pkg/hector_slam/llms.txt Resets the SLAM system, including clearing the map and trajectory history, by publishing a 'reset' command to the '/syscommand' topic. This affects 'hector_mapping' and 'hector_trajectory_server'. ```bash # Reset SLAM system (clears map and trajectory) rostopic pub /syscommand std_msgs/String "data: 'reset'" # The following components respond to reset: # - hector_mapping: Resets map to empty state # - hector_trajectory_server: Clears trajectory history ``` -------------------------------- ### Core SLAM Node - hector_mapping Source: https://context7.com/tu-darmstadt-ros-pkg/hector_slam/llms.txt Configuration for the main hector_mapping node, responsible for SLAM processing, subscribing to laser scans, and publishing occupancy grid maps and pose estimates. ```APIDOC ## POST /launch/hector_mapping ### Description Launches the hector_mapping node with specified parameters for SLAM processing. This node subscribes to laser scan data and publishes occupancy grid maps, pose estimates, and TF transforms. ### Method POST ### Endpoint /launch/hector_mapping ### Parameters #### Query Parameters - **base_frame** (string) - Optional - The frame ID for the robot's base. - **odom_frame** (string) - Optional - The frame ID for odometry. - **scan_topic** (string) - Optional - The topic name for laser scan data. - **map_size** (integer) - Optional - The size of the map in pixels. ### Request Body ```xml ``` -------------------------------- ### IMU Attitude to TF Broadcaster - hector_imu_attitude_to_tf Source: https://context7.com/tu-darmstadt-ros-pkg/hector_slam/llms.txt Launches a node that broadcasts TF transforms based on IMU orientation data. It specifically extracts roll and pitch to stabilize the base frame. Requires the 'hector_imu_attitude_to_tf' package. ```xml ``` -------------------------------- ### Published Topics - Pose Estimation Source: https://context7.com/tu-darmstadt-ros-pkg/hector_slam/llms.txt The `hector_mapping` node publishes pose estimates in `geometry_msgs/PoseStamped` format on the `/slam_out_pose` topic for integration with other ROS nodes. ```APIDOC ## SUBSCRIBE /slam_out_pose ### Description Subscribes to the `/slam_out_pose` topic to receive real-time robot pose estimates from the Hector SLAM system. The pose is published as a `geometry_msgs/PoseStamped` message. ### Method SUBSCRIBE ### Endpoint /slam_out_pose ### Parameters None ### Request Example ```bash rostopic echo /slam_out_pose ``` ### Response #### Success Response (200) - **header** (std_msgs/Header) - **stamp** (time) - Timestamp of the pose estimate. - **frame_id** (string) - The frame ID, typically "map". - **pose** (geometry_msgs/Pose) - **position** (geometry_msgs/Point) - **x** (float) - X coordinate of the robot's position. - **y** (float) - Y coordinate of the robot's position. - **z** (float) - Z coordinate of the robot's position. - **orientation** (geometry_msgs/Quaternion) - **x** (float) - X component of the orientation quaternion. - **y** (float) - Y component of the orientation quaternion. - **z** (float) - Z component of the orientation quaternion. - **w** (float) - W component of the orientation quaternion. #### Response Example ```json { "header": { "stamp": {"secs": 1234567890, "nsecs": 123456789}, "frame_id": "map" }, "pose": { "position": {"x": 2.5, "y": 1.3, "z": 0.0}, "orientation": {"x": 0.0, "y": 0.0, "z": 0.0, "w": 1.0} } } ``` ``` -------------------------------- ### ROS Service - dynamic_map Source: https://context7.com/tu-darmstadt-ros-pkg/hector_slam/llms.txt Retrieves the current occupancy grid map from the SLAM system. Returns an OccupancyGrid message containing map metadata and cell occupancy data. ```APIDOC ## GET /rosapi/get_map ### Description Calls the `/dynamic_map` ROS service to retrieve the current occupancy grid map. This service returns a `nav_msgs/GetMap` response containing the map information. ### Method GET ### Endpoint /rosapi/get_map ### Parameters None ### Request Example ```bash rosservice call /dynamic_map ``` ### Response #### Success Response (200) - **map** (nav_msgs/OccupancyGrid) - The current occupancy grid map. - **info** (map_msgs/MapMetaData) - **resolution** (float) - The resolution of the map in meters per pixel. - **width** (integer) - The width of the map in pixels. - **height** (integer) - The height of the map in pixels. - **origin** (geometry_msgs/Pose) - The origin of the map in the map frame. - **data** (array of int8) - Occupancy data for each cell (-1: unknown, 0: free, 100: occupied). #### Response Example ```json { "map": { "info": { "resolution": 0.05, "width": 2048, "height": 2048, "origin": { "position": {"x": -51.2, "y": -51.2, "z": 0.0}, "orientation": {"x": 0.0, "y": 0.0, "z": 0.0, "w": 1.0} } }, "data": [-1, 0, 0, 100, ...] } } ``` ``` -------------------------------- ### Pause/Resume Hector SLAM Mapping (Bash) Source: https://context7.com/tu-darmstadt-ros-pkg/hector_slam/llms.txt This command utilizes the `/pause_mapping` ROS service to control the mapping process. Setting the `data` parameter to `true` pauses scan processing and map updates, while `false` resumes them. This service is of type `std_srvs/SetBool`. ```bash # Pause mapping rosservice call /pause_mapping "data: true" # Resume mapping rosservice call /pause_mapping "data: false" # Response: # success: True # message: "" ``` -------------------------------- ### ROS Service - pause_mapping Source: https://context7.com/tu-darmstadt-ros-pkg/hector_slam/llms.txt Pauses or resumes scan processing. When paused, incoming laser scans are ignored and the map is not updated. Uses the `std_srvs/SetBool` service type. ```APIDOC ## POST /rosapi/pause_mapping ### Description Calls the `/pause_mapping` ROS service to pause or resume the SLAM mapping process. When `data` is set to `true`, mapping is paused; when `false`, it is resumed. ### Method POST ### Endpoint /rosapi/pause_mapping ### Parameters #### Request Body - **data** (boolean) - Required - `true` to pause mapping, `false` to resume. ### Request Example ```bash # Pause mapping rosservice call /pause_mapping "data: true" # Resume mapping rosservice call /pause_mapping "data: false" ``` ### Response #### Success Response (200) - **success** (boolean) - True if the pause/resume operation was successful, False otherwise. - **message** (string) - A message indicating the result of the operation. #### Response Example ```json { "success": true, "message": "" } ``` ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.