nav-explore-eval 0.3.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,136 @@
1
+ Metadata-Version: 2.4
2
+ Name: nav_explore_eval
3
+ Version: 0.3.3
4
+ Summary: Score any ROS 2 exploration run on coverage, map accuracy and time-to-percent.
5
+ Home-page: https://github.com/darshmenon/nav_explore_eval
6
+ Maintainer: darshmenon
7
+ Maintainer-email: darshmenon02@gmail.com
8
+ License: Apache-2.0
9
+ Classifier: License :: OSI Approved :: Apache Software License
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Intended Audience :: Science/Research
12
+ Classifier: Topic :: Scientific/Engineering
13
+ Requires-Python: >=3.8
14
+ Description-Content-Type: text/markdown
15
+ License-File: LICENSE
16
+ Requires-Dist: setuptools
17
+ Requires-Dist: numpy
18
+ Requires-Dist: pyyaml
19
+ Provides-Extra: plot
20
+ Requires-Dist: matplotlib; extra == "plot"
21
+ Provides-Extra: test
22
+ Requires-Dist: pytest; extra == "test"
23
+ Dynamic: classifier
24
+ Dynamic: description
25
+ Dynamic: description-content-type
26
+ Dynamic: home-page
27
+ Dynamic: license
28
+ Dynamic: license-file
29
+ Dynamic: maintainer
30
+ Dynamic: maintainer-email
31
+ Dynamic: provides-extra
32
+ Dynamic: requires-dist
33
+ Dynamic: requires-python
34
+ Dynamic: summary
35
+
36
+ # nav_explore_eval
37
+
38
+ [![CI](https://github.com/darshmenon/nav_explore_eval/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/darshmenon/nav_explore_eval/actions/workflows/ci.yml)
39
+ [![ROS 2](https://img.shields.io/badge/ROS%202-Humble%20%7C%20Jazzy%20%7C%20Kilted%20%7C%20Lyrical-blue)](https://docs.ros.org/)
40
+ [![License](https://img.shields.io/badge/license-Apache%202.0-green)](LICENSE)
41
+
42
+ **How good was that exploration run?** Score any ROS 2 exploration against a ground-truth map: coverage, wall accuracy, and time to 25 / 50 / 75 / 90 %. It only watches `/map` and `/odom`, so it works with any explorer, any SLAM and any robot.
43
+
44
+ ![Coverage of the explorable area growing over a 7-minute run, with wall F1 and false-free live](docs/demo.gif)
45
+
46
+ *A real 7-minute run: `explore:=true` on a Gazebo maze, scored against the exact ground truth built from the world file. Data: `docs/demo_run.json`, renderer: `docs/make_demo_gif.py`.*
47
+
48
+ Built alongside [rosnav](https://github.com/darshmenon/rosnav), a ROS 2 Nav2 stack with SLAM, frontier exploration and multi-robot fleets, and run on its Gazebo maze sim.
49
+
50
+ ## Install
51
+
52
+ ```bash
53
+ pip install nav_explore_eval # latest main instead: pip install git+https://github.com/darshmenon/nav_explore_eval
54
+ ```
55
+
56
+ `record` and reading bags need a sourced ROS 2 environment. A pip install puts the `nav_explore_eval` command on your PATH; run it directly. The `ros2 run` form below needs the colcon build.
57
+
58
+ ## Quick start
59
+
60
+ ```bash
61
+ # 1. exact ground truth from your Gazebo world (no SLAM run needed); --seed = robot spawn
62
+ ros2 run nav_explore_eval nav_explore_eval truth-from-world maze.world --out maze_truth --seed 0 0
63
+
64
+ # 2. start your explorer as usual, then score it live (writes a JSON report at the end)
65
+ ros2 run nav_explore_eval nav_explore_eval record --truth maze_truth.yaml --label my_explorer --out run.json --align
66
+
67
+ # 3. compare runs side by side, optional chart
68
+ ros2 run nav_explore_eval nav_explore_eval compare run.json other.json --png compare.png
69
+
70
+ # or score a map you already saved
71
+ ros2 run nav_explore_eval nav_explore_eval score map.yaml maze_truth.yaml --align
72
+ ```
73
+
74
+ Real output of the run above:
75
+
76
+ ```
77
+ label cov% f1% leak% path_m t25%(s) t50%(s) t75%(s) t90%(s)
78
+ builtin_maze 43.8 64.1 0.0 15.9 158 - - -
79
+ ```
80
+
81
+ ## What it measures
82
+
83
+ | Metric | Meaning |
84
+ |---|---|
85
+ | `coverage` | share of the **explorable** free space (reachable from the spawn point) the map has marked free |
86
+ | `wall F1` | precision and recall of wall cells within `--tol` metres (default 0.10) |
87
+ | `leak` (false-free) | share of real wall cells the map shows as free space, which is the dangerous error |
88
+ | `t25 … t90` | interpolated time to reach each coverage level (`-` = never reached) |
89
+ | `path_m` | distance driven, from `/odom` |
90
+
91
+ - **Auto-align** (`--align`): a SLAM map starts at the robot, not at the truth map's origin, so the tool finds the translation between the two frames by FFT correlation of the walls (the run above found a 1.5 m, 0.9 m offset).
92
+ - **Ground truth from the world file**: rasterises the box and cylinder collisions that cross the lidar height (`--z`) and counts only space reachable from `--seed` as explorable, so sealed-off rooms and the outside never count against you.
93
+
94
+ ## More commands
95
+
96
+ ```bash
97
+ # score a recorded rosbag2 offline (no live sim needed)
98
+ nav_explore_eval bag my_bag/ --truth maze_truth.yaml --label run1 --out run1.json --align
99
+
100
+ # repeat trials (restart the explorer before each), then mean +/- std grouped by label
101
+ nav_explore_eval record --truth maze_truth.yaml --label A --out results/A.json --align --repeat 5 --between ./restart.sh
102
+ nav_explore_eval stats results/
103
+
104
+ # one-file HTML report; add --map/--truth for the map-vs-truth overlay (leaks in red)
105
+ nav_explore_eval report results/ --out report.html --map slam_map.yaml --truth maze_truth.yaml
106
+
107
+ # multi-robot: merged coverage, each robot's unique share, overlap
108
+ nav_explore_eval record --robots robot1,robot2 --truth maze_truth.yaml --align
109
+ nav_explore_eval score-multi r1.yaml r2.yaml --truth maze_truth.yaml
110
+
111
+ # localisation error: compare /odom with a ground-truth Odometry topic (works for record and bag)
112
+ nav_explore_eval record --truth maze_truth.yaml --gt-odom /ground_truth/odom --align
113
+ nav_explore_eval bag my_bag/ --truth maze_truth.yaml --gt-odom /ground_truth/odom
114
+
115
+ # rotated SLAM frame: also search yaw
116
+ nav_explore_eval score map.yaml maze_truth.yaml --rotate
117
+ ```
118
+
119
+ Extra run metrics: `covered_area_m2` and `efficiency_m2_per_m` (area explored per metre driven).
120
+ See [`LEADERBOARD.md`](LEADERBOARD.md) to compare runs; add yours as `results/<name>.json` in a pull request (`nav_explore_eval validate` checks it).
121
+ Combining with fault injection: [docs/integrations.md](docs/integrations.md).
122
+
123
+ ## Limits
124
+
125
+ - Yaw search is a coarse grid (`--max-yaw`, 1 degree steps) about the world origin, and it multiplies align time.
126
+ - `truth-from-world` reads boxes, cylinders and meshes (as bounding boxes, so concave meshes are filled in); heightmaps and `<polyline>` are skipped with a warning.
127
+ - Two SLAM runs of the same world can score low on wall F1 even when they look alike. Raise `--tol` when comparing runs against each other, and prefer a world-file truth.
128
+ - Multi-robot assumes all maps share one frame (each is aligned to the truth separately).
129
+ - Localisation error (ATE) pairs poses by nearest time within 0.25 s and rigidly fits the trajectory first, so it measures drift, not frame offset. It also reports translational RPE over 1 m of path (`rpe_rmse_m`), a frame-independent local drift measure. It compares `/odom` to your ground-truth topic.
130
+
131
+ ## Roadmap
132
+
133
+ - true polygon footprints for meshes
134
+ - more entries on the leaderboard
135
+
136
+ Build: `colcon build --packages-select nav_explore_eval`. Tests: `python3 -m pytest test` (the live `record` tests run when ROS 2 is sourced). Part of a set with [nav2_doctor](https://github.com/darshmenon/nav2_doctor) and [nav2_fault_inject](https://github.com/darshmenon/nav2_fault_inject).
@@ -0,0 +1,101 @@
1
+ # nav_explore_eval
2
+
3
+ [![CI](https://github.com/darshmenon/nav_explore_eval/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/darshmenon/nav_explore_eval/actions/workflows/ci.yml)
4
+ [![ROS 2](https://img.shields.io/badge/ROS%202-Humble%20%7C%20Jazzy%20%7C%20Kilted%20%7C%20Lyrical-blue)](https://docs.ros.org/)
5
+ [![License](https://img.shields.io/badge/license-Apache%202.0-green)](LICENSE)
6
+
7
+ **How good was that exploration run?** Score any ROS 2 exploration against a ground-truth map: coverage, wall accuracy, and time to 25 / 50 / 75 / 90 %. It only watches `/map` and `/odom`, so it works with any explorer, any SLAM and any robot.
8
+
9
+ ![Coverage of the explorable area growing over a 7-minute run, with wall F1 and false-free live](docs/demo.gif)
10
+
11
+ *A real 7-minute run: `explore:=true` on a Gazebo maze, scored against the exact ground truth built from the world file. Data: `docs/demo_run.json`, renderer: `docs/make_demo_gif.py`.*
12
+
13
+ Built alongside [rosnav](https://github.com/darshmenon/rosnav), a ROS 2 Nav2 stack with SLAM, frontier exploration and multi-robot fleets, and run on its Gazebo maze sim.
14
+
15
+ ## Install
16
+
17
+ ```bash
18
+ pip install nav_explore_eval # latest main instead: pip install git+https://github.com/darshmenon/nav_explore_eval
19
+ ```
20
+
21
+ `record` and reading bags need a sourced ROS 2 environment. A pip install puts the `nav_explore_eval` command on your PATH; run it directly. The `ros2 run` form below needs the colcon build.
22
+
23
+ ## Quick start
24
+
25
+ ```bash
26
+ # 1. exact ground truth from your Gazebo world (no SLAM run needed); --seed = robot spawn
27
+ ros2 run nav_explore_eval nav_explore_eval truth-from-world maze.world --out maze_truth --seed 0 0
28
+
29
+ # 2. start your explorer as usual, then score it live (writes a JSON report at the end)
30
+ ros2 run nav_explore_eval nav_explore_eval record --truth maze_truth.yaml --label my_explorer --out run.json --align
31
+
32
+ # 3. compare runs side by side, optional chart
33
+ ros2 run nav_explore_eval nav_explore_eval compare run.json other.json --png compare.png
34
+
35
+ # or score a map you already saved
36
+ ros2 run nav_explore_eval nav_explore_eval score map.yaml maze_truth.yaml --align
37
+ ```
38
+
39
+ Real output of the run above:
40
+
41
+ ```
42
+ label cov% f1% leak% path_m t25%(s) t50%(s) t75%(s) t90%(s)
43
+ builtin_maze 43.8 64.1 0.0 15.9 158 - - -
44
+ ```
45
+
46
+ ## What it measures
47
+
48
+ | Metric | Meaning |
49
+ |---|---|
50
+ | `coverage` | share of the **explorable** free space (reachable from the spawn point) the map has marked free |
51
+ | `wall F1` | precision and recall of wall cells within `--tol` metres (default 0.10) |
52
+ | `leak` (false-free) | share of real wall cells the map shows as free space, which is the dangerous error |
53
+ | `t25 … t90` | interpolated time to reach each coverage level (`-` = never reached) |
54
+ | `path_m` | distance driven, from `/odom` |
55
+
56
+ - **Auto-align** (`--align`): a SLAM map starts at the robot, not at the truth map's origin, so the tool finds the translation between the two frames by FFT correlation of the walls (the run above found a 1.5 m, 0.9 m offset).
57
+ - **Ground truth from the world file**: rasterises the box and cylinder collisions that cross the lidar height (`--z`) and counts only space reachable from `--seed` as explorable, so sealed-off rooms and the outside never count against you.
58
+
59
+ ## More commands
60
+
61
+ ```bash
62
+ # score a recorded rosbag2 offline (no live sim needed)
63
+ nav_explore_eval bag my_bag/ --truth maze_truth.yaml --label run1 --out run1.json --align
64
+
65
+ # repeat trials (restart the explorer before each), then mean +/- std grouped by label
66
+ nav_explore_eval record --truth maze_truth.yaml --label A --out results/A.json --align --repeat 5 --between ./restart.sh
67
+ nav_explore_eval stats results/
68
+
69
+ # one-file HTML report; add --map/--truth for the map-vs-truth overlay (leaks in red)
70
+ nav_explore_eval report results/ --out report.html --map slam_map.yaml --truth maze_truth.yaml
71
+
72
+ # multi-robot: merged coverage, each robot's unique share, overlap
73
+ nav_explore_eval record --robots robot1,robot2 --truth maze_truth.yaml --align
74
+ nav_explore_eval score-multi r1.yaml r2.yaml --truth maze_truth.yaml
75
+
76
+ # localisation error: compare /odom with a ground-truth Odometry topic (works for record and bag)
77
+ nav_explore_eval record --truth maze_truth.yaml --gt-odom /ground_truth/odom --align
78
+ nav_explore_eval bag my_bag/ --truth maze_truth.yaml --gt-odom /ground_truth/odom
79
+
80
+ # rotated SLAM frame: also search yaw
81
+ nav_explore_eval score map.yaml maze_truth.yaml --rotate
82
+ ```
83
+
84
+ Extra run metrics: `covered_area_m2` and `efficiency_m2_per_m` (area explored per metre driven).
85
+ See [`LEADERBOARD.md`](LEADERBOARD.md) to compare runs; add yours as `results/<name>.json` in a pull request (`nav_explore_eval validate` checks it).
86
+ Combining with fault injection: [docs/integrations.md](docs/integrations.md).
87
+
88
+ ## Limits
89
+
90
+ - Yaw search is a coarse grid (`--max-yaw`, 1 degree steps) about the world origin, and it multiplies align time.
91
+ - `truth-from-world` reads boxes, cylinders and meshes (as bounding boxes, so concave meshes are filled in); heightmaps and `<polyline>` are skipped with a warning.
92
+ - Two SLAM runs of the same world can score low on wall F1 even when they look alike. Raise `--tol` when comparing runs against each other, and prefer a world-file truth.
93
+ - Multi-robot assumes all maps share one frame (each is aligned to the truth separately).
94
+ - Localisation error (ATE) pairs poses by nearest time within 0.25 s and rigidly fits the trajectory first, so it measures drift, not frame offset. It also reports translational RPE over 1 m of path (`rpe_rmse_m`), a frame-independent local drift measure. It compares `/odom` to your ground-truth topic.
95
+
96
+ ## Roadmap
97
+
98
+ - true polygon footprints for meshes
99
+ - more entries on the leaderboard
100
+
101
+ Build: `colcon build --packages-select nav_explore_eval`. Tests: `python3 -m pytest test` (the live `record` tests run when ROS 2 is sourced). Part of a set with [nav2_doctor](https://github.com/darshmenon/nav2_doctor) and [nav2_fault_inject](https://github.com/darshmenon/nav2_fault_inject).
@@ -0,0 +1 @@
1
+ __version__ = '0.3.3'
@@ -0,0 +1,72 @@
1
+ """Offline scoring of a rosbag2: replay /map and /odom in bag time and score like `record`."""
2
+ from .mapio import from_msg
3
+ from .runreport import Scorer, build_report
4
+
5
+
6
+ def read_bag(path, ns='', gt_topic=''):
7
+ """Yield (t_seconds_from_start, kind, msg) for map/odom messages, ordered by bag time."""
8
+ import rosbag2_py
9
+ from nav_msgs.msg import OccupancyGrid, Odometry
10
+ from rclpy.serialization import deserialize_message
11
+ uri = path.rstrip('/')
12
+ fmt = 'sqlite3'
13
+ if uri.endswith('.mcap'):
14
+ fmt = 'mcap'
15
+ reader = rosbag2_py.SequentialReader()
16
+ reader.open(rosbag2_py.StorageOptions(uri=uri, storage_id=fmt),
17
+ rosbag2_py.ConverterOptions('', ''))
18
+ pre = ('/' + ns.strip('/')) if ns else ''
19
+ topics = {pre + '/map': ('map', OccupancyGrid), pre + '/odom': ('odom', Odometry)}
20
+ if gt_topic:
21
+ topics[gt_topic] = ('gt', Odometry)
22
+ have = {t.name for t in reader.get_all_topics_and_types()}
23
+ if pre + '/map' not in have:
24
+ raise ValueError(f'bag has no {pre}/map topic (topics: {sorted(have)})')
25
+ t0 = None
26
+ while reader.has_next():
27
+ name, data, stamp = reader.read_next()
28
+ if name not in topics:
29
+ continue
30
+ if t0 is None:
31
+ t0 = stamp
32
+ kind, typ = topics[name]
33
+ yield (stamp - t0) / 1e9, kind, deserialize_message(data, typ)
34
+
35
+
36
+ def score_bag(path, truth, label='bag', interval=2.0, scorer_kw=None, ns='', stop_at=100.0, truth_path='', gt_topic=''):
37
+ """Score a bag -> run report dict. Raises ValueError if the bag has no map."""
38
+ scorer = Scorer(truth, **(scorer_kw or {}))
39
+ cur, pts, series, next_t, last_t, done = None, [], [], 0.0, 0.0, False
40
+ est, gt = [], []
41
+ for t, kind, msg in read_bag(path, ns, gt_topic):
42
+ if kind == 'gt':
43
+ gt.append((t, msg.pose.pose.position.x, msg.pose.pose.position.y))
44
+ continue
45
+ if kind == 'odom' or not done:
46
+ last_t = t
47
+ if kind == 'odom':
48
+ p = msg.pose.pose.position
49
+ est.append((t, p.x, p.y))
50
+ if not pts or abs(p.x - pts[-1][0]) + abs(p.y - pts[-1][1]) > 0.02:
51
+ pts.append((p.x, p.y))
52
+ continue
53
+ while cur is not None and next_t <= t and not done: # samples due before this map arrives
54
+ series.append((next_t, scorer(cur)))
55
+ next_t += interval
56
+ done = series[-1][1]['coverage_pct'] >= stop_at
57
+ if done:
58
+ continue # target reached: keep reading odom/gt only
59
+ if cur is None:
60
+ next_t = max(next_t, t) # first sample = first map
61
+ cur = from_msg(msg)
62
+ if cur is not None and (not series or series[-1][0] < last_t) and not done:
63
+ series.append((max(last_t, series[-1][0] if series else 0.0), scorer(cur)))
64
+ if not series:
65
+ raise ValueError('no /map messages in bag - nothing to score')
66
+ extra = {'source': 'rosbag', 'bag': str(path)}
67
+ if gt_topic:
68
+ from .metrics import localisation_error
69
+ loc = localisation_error(est, gt)
70
+ if loc:
71
+ extra['localisation'] = loc
72
+ return build_report(label, truth_path, series, pts, extra)