|
| 1 | +.. mapping: |
| 2 | +
|
| 3 | +
|
| 4 | +Mapping with the Costmap Stack |
| 5 | +------------------------------ |
| 6 | + |
| 7 | +The mapping workflow with the ``easynav_costmap_stack`` mirrors the one used in the Simple Stack. |
| 8 | +For background and step-by-step context, see :doc:`the Simple Stack Mapping tutorial <../easynav_simple_stack/mapping>`. |
| 9 | +The main difference is that here the environment is represented internally as a graded **Costmap2D** instead of a |
| 10 | +binary occupancy grid. |
| 11 | + |
| 12 | +Overview |
| 13 | +^^^^^^^^ |
| 14 | + |
| 15 | +1. **Generate a map** (e.g., using a SLAM solution). The output should be a **YAML + image** pair |
| 16 | + (``.yaml`` + ``.pgm/.png``) describing resolution, origin and free/occupied thresholds. |
| 17 | +2. **Place the map files** inside a package in your workspace. The Costmap Maps Manager will later load it |
| 18 | + using the pair of parameters ``package`` and ``map_path_file`` (you can also provide an absolute path). |
| 19 | +3. **Prepare an EasyNav parameters file**. In this tutorial we will use *dummy* plugins for controller, |
| 20 | + planner and localizer, and the **Costmap Maps Manager** to load and publish the map. This is enough to |
| 21 | + validate that the costmap is properly loaded and visualized. |
| 22 | + |
| 23 | +Example parameters |
| 24 | +^^^^^^^^^^^^^^^^^^ |
| 25 | + |
| 26 | +Below is a minimal working configuration you can use to verify mapping. It mirrors the structure of the Simple Stack |
| 27 | +example but uses the Costmap-based maps manager. You may replace ``my_maps_pkg`` and the YAML path with your own. |
| 28 | + |
| 29 | +.. code-block:: yaml |
| 30 | +
|
| 31 | + controller_node: |
| 32 | + ros__parameters: |
| 33 | + use_sim_time: true |
| 34 | + controller_types: [dummy] |
| 35 | + dummy: |
| 36 | + rt_freq: 30.0 |
| 37 | + plugin: easynav_controller/DummyController |
| 38 | + cycle_time_nort: 0.01 |
| 39 | + cycle_time_rt: 0.001 |
| 40 | +
|
| 41 | + localizer_node: |
| 42 | + ros__parameters: |
| 43 | + use_sim_time: true |
| 44 | + localizer_types: [dummy] |
| 45 | + dummy: |
| 46 | + rt_freq: 50.0 |
| 47 | + freq: 5.0 |
| 48 | + reseed_freq: 0.1 |
| 49 | + plugin: easynav_localizer/DummyLocalizer |
| 50 | + cycle_time_nort: 0.01 |
| 51 | + cycle_time_rt: 0.001 |
| 52 | +
|
| 53 | + maps_manager_node: |
| 54 | + ros__parameters: |
| 55 | + use_sim_time: true |
| 56 | + map_types: [costmap] |
| 57 | + costmap: |
| 58 | + freq: 10.0 |
| 59 | + plugin: easynav_costmap_maps_manager/CostmapMapsManager |
| 60 | + package: my_maps_pkg |
| 61 | + map_path_file: maps/office.yaml |
| 62 | +
|
| 63 | + planner_node: |
| 64 | + ros__parameters: |
| 65 | + use_sim_time: true |
| 66 | + planner_types: [dummy] |
| 67 | + dummy: |
| 68 | + freq: 1.0 |
| 69 | + plugin: easynav_planner/DummyPlanner |
| 70 | + cycle_time_nort: 0.2 |
| 71 | + cycle_time_rt: 0.001 |
| 72 | +
|
| 73 | + sensors_node: |
| 74 | + ros__parameters: |
| 75 | + use_sim_time: true |
| 76 | + forget_time: 0.5 |
| 77 | +
|
| 78 | + system_node: |
| 79 | + ros__parameters: |
| 80 | + use_sim_time: true |
| 81 | + position_tolerance: 0.1 |
| 82 | + angle_tolerance: 0.05 |
| 83 | +
|
| 84 | +Running and visualizing |
| 85 | +^^^^^^^^^^^^^^^^^^^^^^^ |
| 86 | + |
| 87 | +1. Launch your simulator (or a static map server) and start EasyNav with the parameter file above. |
| 88 | +2. Open ``rviz2`` and add an *OccupancyGrid* display for the topic |
| 89 | + ``maps_manager_node/<plugin_name>/map`` (static) or ``maps_manager_node/<plugin_name>/dynamic_map`` (dynamic). |
| 90 | + You should see the costmap as a grayscale image where darker values denote higher traversal cost. |
| 91 | + |
| 92 | +Saving maps (SLAM Toolbox vs. Maps Manager) |
| 93 | +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 94 | + |
| 95 | +The Costmap Maps Manager reads and writes maps using the **same YAML + image format** as MoveBase/Nav2. |
| 96 | +That means you do *not* need to rely on the manager's internal save path if you are producing the map with SLAM Toolbox. |
| 97 | + |
| 98 | +- **Option A (Maps Manager service):** The manager exposes a ``savemap`` service at |
| 99 | + ``maps_manager_node/<plugin_name>/savemap`` which saves its current static map to the configured path. |
| 100 | +- **Option B (Recommended with SLAM Toolbox):** Call the SLAM Toolbox service |
| 101 | + ``/slam_toolbox/save_map`` (service type ``slam_toolbox/srv/SaveMap``) directly. This will write the |
| 102 | + YAML + image pair in the standard format that the Costmap Maps Manager can later load with |
| 103 | + ``package`` + ``map_path_file``. |
| 104 | + |
| 105 | +.. note:: |
| 106 | + |
| 107 | + This tutorial is analogous to :doc:`../easynav_simple_stack/mapping`. The only conceptual change is the |
| 108 | + internal map representation (``Costmap2D`` with values 0–255 and obstacle inflation support) which allows |
| 109 | + subsequent components (planner/controller) to leverage graded costs instead of a hard free/occupied dichotomy. |
0 commit comments