Skip to content

topological navigation 2 testing

Marc Hanheide edited this page Oct 15, 2026 · 6 revisions

Topological Navigation 2 Testing

How to run the tests of the ROS 2 implementation. CI (.github/workflows/ci.yaml) runs the same steps on every push to main and on pull requests.

The earlier content of this page (ROS 1 toponav2-devel branch, rosrun, RASberry tmule scenarios, /topological_map conversion) is obsolete and is in the git history of this wiki.

Unit tests without ROS 2

Most tests need only pure Python packages (Python 3.10 or 3.12 in CI):

python3 -m venv .venv && source .venv/bin/activate
pip install pytest pyyaml jsonschema networkx scipy numpy Pillow pyproj

# core package
cd topological_navigation
python -m pytest test/ \
    --ignore=test/test_navigationcore.py \
    --ignore=test/test_localisation2.py \
    --ignore=test/test_navigation2.py -v

# web app backend
cd ../topological_navigation_visual
python -m pytest test/test_web_state.py test/test_web_server.py -v

The ignored tests need ROS 2: test_navigationcore.py uses launch_pytest, and test_localisation2.py and test_navigation2.py import rclpy and the message packages. A root conftest.py puts the package on the Python path. The simulator tests (topological_nav_simulator/test) need geometry_msgs and run in the ROS job.

Full ROS 2 build and tests

On Humble or Jazzy (CI uses ros:humble-ros-base and ros:jazzy-ros-base containers):

cd ~/ws
colcon build --symlink-install
colcon test --event-handlers console_direct+
colcon test-result --verbose

# one package, or only the linters
colcon test --packages-select topological_navigation --event-handlers console_direct+
colcon test --packages-select topological_navigation \
    --pytest-args -k "test_flake8 or test_pep257"

Test map fixtures

Map fixtures are in topological_navigation/test/fixtures/ (see the fixtures README). They are also validated by the validate-schema workflow against config/tmap-schema.yaml.

Manual testing in simulation

Launch the stack as in the simulation tutorial and exercise a feature:

Feature How to test
Route planning Send GotoNode goals; watch /topological_navigation/Route and /current_edge
Runtime parameters ros2 param set /topological_navigation route_algorithm dijkstra, then send a goal; an invalid value is rejected
Edge parameter changes (set_ros_params) Add set_ros_params to an action or edge (doc/SET_ROS_PARAMS.md) and check the [PARAM] log lines of the navigation server, or ros2 param get <node> <param> during the segment
Statistics Start navigation2.py with -p stats_db_path:=/tmp/nav_stats.db, drive some goals, then topo_stats.py /tmp/nav_stats.db traversals ... (doc/TOPO_STATS.md)
Map recording See step 4 of the simulation tutorial
Map checks map_analyser.py check <map> (exit code reflects validity)

Clone this wiki locally