|
| 1 | +.. _bonxai_navmap_from_rosbag: |
| 2 | + |
| 3 | +====================================================== |
| 4 | +Building Bonxai and NavMap Maps from a Recorded ROSBag |
| 5 | +====================================================== |
| 6 | + |
| 7 | +This HowTo shows how to generate both **Bonxai** and **NavMap** representations |
| 8 | +from a **recorded ROSBag** containing a ``PointCloud2`` map, typically produced |
| 9 | +by a SLAM algorithm. The input point cloud must be referenced to the ``world`` |
| 10 | +or ``map`` frame. |
| 11 | + |
| 12 | +.. contents:: On this page |
| 13 | + :local: |
| 14 | + :depth: 2 |
| 15 | + |
| 16 | +--- |
| 17 | + |
| 18 | +Overview |
| 19 | +-------- |
| 20 | + |
| 21 | +You will: |
| 22 | + |
| 23 | +1. Align coordinate frames (``world`` → ``map`` if needed). |
| 24 | +2. Play a pre-recorded ROS bag containing the ``/map`` point cloud. |
| 25 | +3. Launch EasyNav with both **BonxaiMapsManager** and **NavMapMapsManager** |
| 26 | + to build the two maps simultaneously. |
| 27 | +4. Visualize both in **RViz2**. |
| 28 | +5. Save the resulting maps to disk. |
| 29 | + |
| 30 | +--- |
| 31 | + |
| 32 | +1. Align the Frames (world → map) |
| 33 | +--------------------------------- |
| 34 | + |
| 35 | +If your ROS bag publishes a ``PointCloud2`` in the frame ``world``, |
| 36 | +you need to publish a static transform so that the **map managers** |
| 37 | +receive data in ``map``. |
| 38 | + |
| 39 | +In a new terminal, run: |
| 40 | + |
| 41 | +.. code-block:: bash |
| 42 | +
|
| 43 | + ros2 run tf2_ros static_transform_publisher --frame-id world --child-frame-id map |
| 44 | +
|
| 45 | +Keep this terminal **running for the entire session**. |
| 46 | +If your point cloud is already in the ``map`` frame, skip this step. |
| 47 | + |
| 48 | +--- |
| 49 | + |
| 50 | +2. Play the ROSBag |
| 51 | +------------------ |
| 52 | + |
| 53 | +Next, replay the recorded ROS bag containing the point cloud map. |
| 54 | + |
| 55 | +The example bag is about 1600 seconds long. |
| 56 | +To jump close to the end (around 1500 seconds, when the map is already dense) |
| 57 | +but still leave a few seconds to build the maps, run: |
| 58 | + |
| 59 | +.. code-block:: bash |
| 60 | +
|
| 61 | + ros2 bag play rosbag_excavation_urjc_map_tf_only --clock --start-offset 1500 |
| 62 | +
|
| 63 | +This will replay the point cloud topic ``/map`` and the TF tree |
| 64 | +needed by the map managers. |
| 65 | + |
| 66 | +--- |
| 67 | + |
| 68 | +3. Launch EasyNav with Bonxai and NavMap Maps Managers |
| 69 | +------------------------------------------------------ |
| 70 | + |
| 71 | +In a new terminal, launch **EasyNav System** with both map managers active. |
| 72 | + |
| 73 | +.. code-block:: bash |
| 74 | +
|
| 75 | + ros2 run easynav_system system_main \ |
| 76 | + --ros-args \ |
| 77 | + --params-file /absolute/path/to/bonxai-navmap.dummy.params.yaml \ |
| 78 | + -r /maps_manager_node/navmap/incoming_pc2_map:=/map \ |
| 79 | + -r /maps_manager_node/bonxai/incoming_pc2_map:=/map |
| 80 | +
|
| 81 | +This setup assumes: |
| 82 | + |
| 83 | +- The input cloud topic is ``/map``. |
| 84 | +- The QoS settings are standard (reliable, transient local). |
| 85 | +- Both managers will build their respective maps automatically. |
| 86 | + |
| 87 | +The file ``bonxai-navmap.dummy.params.yaml`` defines **dummy plugins** |
| 88 | +for all nodes except ``maps_manager_node``. |
| 89 | + |
| 90 | +Example configuration: |
| 91 | + |
| 92 | +.. code-block:: yaml |
| 93 | +
|
| 94 | + controller_node: |
| 95 | + ros__parameters: |
| 96 | + use_sim_time: true |
| 97 | + controller_types: [dummy] |
| 98 | + dummy: |
| 99 | + rt_freq: 30.0 |
| 100 | + plugin: easynav_controller/DummyController |
| 101 | + cycle_time_nort: 0.01 |
| 102 | + cycle_time_rt: 0.001 |
| 103 | +
|
| 104 | + localizer_node: |
| 105 | + ros__parameters: |
| 106 | + use_sim_time: true |
| 107 | + localizer_types: [dummy] |
| 108 | + dummy: |
| 109 | + rt_freq: 50.0 |
| 110 | + freq: 5.0 |
| 111 | + reseed_freq: 0.1 |
| 112 | + plugin: easynav_localizer/DummyLocalizer |
| 113 | + cycle_time_nort: 0.01 |
| 114 | + cycle_time_rt: 0.001 |
| 115 | +
|
| 116 | + maps_manager_node: |
| 117 | + ros__parameters: |
| 118 | + use_sim_time: true |
| 119 | + map_types: [bonxai, navmap] |
| 120 | + bonxai: |
| 121 | + freq: 10.0 |
| 122 | + plugin: easynav_bonxai_maps_manager/BonxaiMapsManager |
| 123 | + package: easynav_indoor_testcase |
| 124 | + bonxai_path_file: maps/excavation_urjc.pcd |
| 125 | + navmap: |
| 126 | + freq: 10.0 |
| 127 | + plugin: easynav_navmap_maps_manager/NavMapMapsManager |
| 128 | + package: easynav_indoor_testcase |
| 129 | + navmap_path_file: maps/excavation_urjc.navmap |
| 130 | +
|
| 131 | + planner_node: |
| 132 | + ros__parameters: |
| 133 | + use_sim_time: true |
| 134 | + planner_types: [dummy] |
| 135 | + dummy: |
| 136 | + freq: 1.0 |
| 137 | + plugin: easynav_planner/DummyPlanner |
| 138 | + cycle_time_nort: 0.2 |
| 139 | + cycle_time_rt: 0.001 |
| 140 | +
|
| 141 | + sensors_node: |
| 142 | + ros__parameters: |
| 143 | + use_sim_time: true |
| 144 | + forget_time: 0.5 |
| 145 | + perception_default_frame: odom |
| 146 | +
|
| 147 | + system_node: |
| 148 | + ros__parameters: |
| 149 | + use_sim_time: true |
| 150 | + use_real_time: false |
| 151 | + position_tolerance: 0.3 |
| 152 | + angle_tolerance: 0.15 |
| 153 | +
|
| 154 | +--- |
| 155 | + |
| 156 | +4. NavMap Build Parameters |
| 157 | +-------------------------- |
| 158 | + |
| 159 | +The **NavMapMapsManager** allows tuning of mesh generation parameters |
| 160 | +via YAML configuration. You may add the following optional fields |
| 161 | +under the ``navmap`` plugin section. |
| 162 | + |
| 163 | +**Available parameters** |
| 164 | + |
| 165 | ++----------------------+----------------------------------------------------------+ |
| 166 | +| **Parameter** | **Description** | |
| 167 | ++======================+==========================================================+ |
| 168 | +| ``resolution`` | In-plane sampling resolution (m) for voxelization. | |
| 169 | ++----------------------+----------------------------------------------------------+ |
| 170 | +| ``max_edge_len`` | Maximum triangle edge length (m). | |
| 171 | ++----------------------+----------------------------------------------------------+ |
| 172 | +| ``max_dz`` | Maximum allowed vertical jump (m) between vertices. | |
| 173 | ++----------------------+----------------------------------------------------------+ |
| 174 | +| ``max_slope_deg`` | Maximum slope (degrees) relative to the vertical axis. | |
| 175 | ++----------------------+----------------------------------------------------------+ |
| 176 | +| ``neighbor_radius`` | Neighborhood radius (m) for triangle connectivity. | |
| 177 | ++----------------------+----------------------------------------------------------+ |
| 178 | +| ``k_neighbors`` | Alternative to radius: number of nearest neighbors. | |
| 179 | ++----------------------+----------------------------------------------------------+ |
| 180 | +| ``min_area`` | Minimum triangle area (m²) to reject degenerate faces. | |
| 181 | ++----------------------+----------------------------------------------------------+ |
| 182 | +| ``use_radius`` | Use radius-based vs. k-NN connectivity. (bool) | |
| 183 | ++----------------------+----------------------------------------------------------+ |
| 184 | +| ``min_angle_deg`` | Minimum interior angle (degrees) to avoid slivers. | |
| 185 | ++----------------------+----------------------------------------------------------+ |
| 186 | +| ``max_surfaces`` | Keep only the N largest connected surfaces (0 = all). | |
| 187 | ++----------------------+----------------------------------------------------------+ |
| 188 | + |
| 189 | +These parameters allow fine control of NavMap mesh reconstruction quality. |
| 190 | + |
| 191 | +--- |
| 192 | + |
| 193 | +5. Visualize in RViz2 |
| 194 | +--------------------- |
| 195 | + |
| 196 | +Open **RViz2** to monitor both map managers. |
| 197 | + |
| 198 | +.. code-block:: bash |
| 199 | +
|
| 200 | + ros2 run rviz2 rviz2 --ros-args -p use_sim_time:=true |
| 201 | +
|
| 202 | +In RViz: |
| 203 | + |
| 204 | +- Add a **PointCloud2** display for **Bonxai** maps. |
| 205 | + - Select the topic published by BonxaiMapsManager (e.g., ``/maps_manager_node/bonxai/map``). |
| 206 | + - QoS: **Transient Local**. |
| 207 | + - You can visualize the cloud as boxes with configurable size for clearer 3D structure. |
| 208 | + |
| 209 | +- Add a **NavMapDisplay** (custom display type). |
| 210 | + - Select the topic published by NavMapMapsManager (e.g., ``/maps_manager_node/navmap/map``). |
| 211 | + - QoS: **Transient Local**. |
| 212 | + |
| 213 | +.. figure:: ../images/mapping_tut_bonxai.png |
| 214 | + :align: center |
| 215 | + :width: 70% |
| 216 | + |
| 217 | + Bonxai map visualization in RViz. |
| 218 | + |
| 219 | +.. figure:: ../images/mapping_tut_navmap.png |
| 220 | + :align: center |
| 221 | + :width: 70% |
| 222 | + |
| 223 | + NavMap mesh visualization in RViz. |
| 224 | + |
| 225 | +--- |
| 226 | + |
| 227 | +6. Save the Maps |
| 228 | +---------------- |
| 229 | + |
| 230 | +When both maps are visible and complete, you can store them to disk using |
| 231 | +their respective map manager services. |
| 232 | + |
| 233 | +**Save NavMap** |
| 234 | + |
| 235 | +.. code-block:: bash |
| 236 | +
|
| 237 | + ros2 service call /maps_manager_node/navmap/savemap std_srvs/srv/Trigger |
| 238 | +
|
| 239 | +This saves the NavMap to ``/tmp/map.navmap``. |
| 240 | +Rename and move it to your desired location (e.g. inside ``maps/``). |
| 241 | + |
| 242 | +**Save Bonxai Map** |
| 243 | + |
| 244 | +.. code-block:: bash |
| 245 | +
|
| 246 | + ros2 service call /maps_manager_node/bonxai/savemap std_srvs/srv/Trigger |
| 247 | +
|
| 248 | +This saves the Bonxai point cloud to ``/tmp/bonxai_map.pcd``. |
| 249 | + |
| 250 | +--- |
| 251 | + |
| 252 | +7. Summary |
| 253 | +---------- |
| 254 | + |
| 255 | +You have: |
| 256 | + |
| 257 | +- ✅ Aligned frames between ``world`` and ``map`` |
| 258 | +- ✅ Played a recorded ROS bag with point cloud data |
| 259 | +- ✅ Built Bonxai and NavMap maps simultaneously |
| 260 | +- ✅ Visualized them in RViz |
| 261 | +- ✅ Saved both maps to disk for future use |
| 262 | + |
| 263 | +These maps can now be used in EasyNav navigation stacks (e.g. with |
| 264 | +the **Costmap**, **GridMap**, or **NavMap** planners). |
| 265 | + |
| 266 | +--- |
| 267 | + |
| 268 | +**Next steps:** |
| 269 | + |
| 270 | +- :doc:`../developer_guide/design` |
| 271 | +- :doc:`../howtos/gridmap_mapping` |
0 commit comments