Tasks and Navigation Examples¶
The scripts in examples/cann/ and examples/pipeline/ show how to construct trajectory
inputs with task, import external recordings, and drive more elaborate models.
import_external_trajectory.py¶
Location:
examples/cann/import_external_trajectory.pyGoal: Replace the default random walk in
OpenLoopNavigationTaskwith external position samples.Workflow:
Generate (or load) a noisy random walk trajectory.
Initialise
OpenLoopNavigationTaskand callimport_data(position_data=..., times=...).Run
calculate_theta_sweep_data()to compute linear and angular speed gains for later theta-sweep analysis.Produce summary figures with
show_trajectory_analysisand optional matplotlib overlays.
Output:
import_external_trajectory.png,our_data_comparison.pngand console diagnostics.Extensions:
Swap
positionsfor recorded experiments; includehead_directionif you already have orientation data.Persist the dataset via
snt.save_data(...)so downstream scripts can reuse it.
hierarchical_path_integration.py¶
Location:
examples/cann/hierarchical_path_integration.pyGoal: Demonstrate the hierarchical path-integration network coupled to
OpenLoopNavigationTask.Workflow:
Simulate a long navigation session (
duration=1000) and store it astrajectory_test.npz.Build
HierarchicalNetwork, which stacks band, grid, and place-cell populations.Use
brainstate.compile.for_loopto prime the network (loc_input_strewarm-up) and then run the full trajectory.Compare compiled performance with
benchmark().
Output:
trajectory_graph.pngandband_grid_place_activity.npz(optional).Extensions:
Combine with CANN Network Examples to explore how connection parameters influence integration accuracy.
Replace the random walk with
OpenLoopNavigationTask.import_datato replay experimental paths.
Tips¶
OpenLoopNavigationTaskrelies on thecanns_libspatial backend for agent/environment simulation and will create the default environment on first run. You can customise layouts by passingwallsorobjects.For batch simulations, loop over
task.get_data()and write each dataset to disk—the pipeline examples happily consume cached trajectories.
Closed-loop navigation utilities¶
Location:
src/canns/task/closed_loop_navigation.pyGoal: Provide environment-aware movement planning tools, including cost-grid generation and geodesic visualisations, on top of the
canns_libclosed-loop agent implementation.Workflow:
Instantiate
ClosedLoopNavigationTask(or theTMazeClosedLoopNavigationTaskhelper).Call
build_movement_cost_grid()with your desireddx/dyresolution to obtain a labelled grid map where blocked cells carryINT32_MAXweight.Overlay the grid on the agent trajectory via
show_data(overlay_movement_cost=True, cost_grid=...)to inspect obstacles, or render the pairwise shortest-path distances withshow_geodesic_distance_matrix().
Output: Annotated matplotlib figures that highlight traversable cells vs. walls/holes and a dense geodesic distance matrix for custom planners.
Extensions:
Feed the returned
MovementCostGridinto other planners or export it to disk for debugging.Use the accompanying pytest in
tests/task/closed_loop_navigationas a template for custom maze regression tests.Render a more complex environment by running
uv run python examples/cann/closed_loop_complex_environment.py, which saves both the movement-cost overlay and geodesic heatmap tofigures/closed_loop_complex.