LifeRouter

command module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 1, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

README

LifeRouter

LifeRouter is a Go service for dynamic indoor route planning in multi-floor digital-twin environments. It builds a traversability grid from map images, connects floors through configured portals, and exposes pathfinding operations through NATS and typed Go clients.

The service supports two main workflows:

  • Agent pathfinding: adaptive route planning for tracked agents using dynamic environment data.
  • Emergency guidance: flow-field based routing toward one or more emergency goals, including optional preferred route graphs.

Features

  • Rasterized grid model for one or more floors.
  • Portal links between floors with configurable traversal cost.
  • Agent route planning, movement control, path watching, and path-cost queries.
  • Emergency flow-field start, stop, and flow watching.
  • NATS request/reply API with Go wrappers in pkg/pathfinding and pkg/emergency.
  • Public raw-NATS subject constants under pkg/subjects.
  • Embedded execution through the embedded package for tests, tools, or applications that want to run the dispatcher in process.
  • Public configuration and domain types under pkg/config and pkg/domain.
  • Map tuning helper under pkg/tuning.

Requirements

  • Go 1.25.3 or compatible with the module version in go.mod.
  • A reachable NATS server.
  • Geotruth-style external services or injected dependencies that provide object positions, floor/region data, movement publishing, object traversal costs, and emergency signaling.
  • Raster map images matching the configured grid dimensions.

Configuration

Runtime configuration is loaded from config/config.yaml by default. Missing values fall back to the defaults in internal/config.DefaultConfig. Internal tools, tests, benchmarks, or embedded callers can pass an explicit YAML path to internal/config.LoadConfig when they need a different configuration file, such as a scenario fixture under data/.

The main configuration groups are:

  • app: NATS URL and logging output.
  • grid: map layers, grid dimensions, meters-per-cell conversion, wall aura, and cross-floor portals.
  • pathfinding: agent and emergency tuning parameters.

Settings can also be overridden with PTHFSERVICE_* environment variables. For example, grid.cellsizem maps to PTHFSERVICE_GRID_CELLSIZEM.

Run

Build the service:

make build

Run it from the repository root:

go run .

The executable loads config/config.yaml through LoadConfig(nil), initializes the rasterized world, connects to NATS, subscribes to the pathfinding subjects, and shuts down on SIGINT or SIGTERM.

Use From Go

The module path is:

github.com/Kentalives/LifeRouter

Agent pathfinding clients use an existing NATS connection:

pf := pathfinding.New(nc)

comm, err := pf.AgentFindPath(ctx, [3]float64{10, 4, 0}, "Agent_1", 2.0, 0)
if err != nil {
	return err
}

done, err := comm.BlockingWait()
if err != nil {
	return err
}
<-done

return comm.ExitError(ctx)

Emergency flow-field clients use the same pattern:

em := emergency.New(nc)

if err := em.Start(ctx, [][3]float64{{1, 1, 0}}, nil, 5); err != nil {
	return err
}
defer em.Stop(ctx)

flows, err := em.FlowSub(ctx)
if err != nil {
	return err
}

for snapshot := range flows {
	_ = snapshot
}

For in-process execution, use embedded.Run with a *config.Config and *config.Dependencies. The default embedded dependencies are useful for local debugging, but production embedders should provide their own external-system implementation.

Development

Run the test suite:

make test

Open the generated coverage report:

go tool cover -html=coverage.out

After dependency changes, refresh module files and vendored dependencies:

make deps

Documentation

The full project manuals are available under doc/:

This README is intended as a short practical entry point, not a replacement for those manuals.

License

This project is licensed under the Apache License, Version 2.0.

See LICENSE for details.

Author

Created by Kentalives as a final year academic project at University of Santiago de Compostela.

Citation

If you use this project in academic work, please cite it as:

Kentalives. LifeRouter. Final year academic project, University of Santiago de Compostela, 2026.

Documentation

Overview

Command LifeRouter starts the standalone pathfinding service.

Directories

Path Synopsis
Package embedded starts the pathfinding service inside the caller process.
Package embedded starts the pathfinding service inside the caller process.
internal
app
Package app wires configuration, dependencies, grid initialization, NATS subscriptions, and dispatcher lifecycle for the pathfinding service.
Package app wires configuration, dependencies, grid initialization, NATS subscriptions, and dispatcher lifecycle for the pathfinding service.
config
Package config loads runtime configuration and stores the process-wide dependency handles used by internal service packages.
Package config loads runtime configuration and stores the process-wide dependency handles used by internal service packages.
domain
Package domain contains internal geometry helpers and small interfaces shared between grid, raster, and pathfinding packages.
Package domain contains internal geometry helpers and small interfaces shared between grid, raster, and pathfinding packages.
grid
Package grid models rasterized floor grids, cross-floor portals, and layer-qualified worlds used by the pathfinding algorithms.
Package grid models rasterized floor grids, cross-floor portals, and layer-qualified worlds used by the pathfinding algorithms.
log
Package log provides the service logger used by internal packages.
Package log provides the service logger used by internal packages.
mock
Package mock provides in-memory geotruth, external-system, and grid implementations for tests and local embedded runs.
Package mock provides in-memory geotruth, external-system, and grid implementations for tests and local embedded runs.
pathfinding/agent
Package agent implements adaptive per-agent pathfinding and movement control.
Package agent implements adaptive per-agent pathfinding and movement control.
pathfinding/core
Package core contains shared D* Lite primitives used by agent and emergency pathfinding.
Package core contains shared D* Lite primitives used by agent and emergency pathfinding.
pathfinding/emergency
Package emergency implements flow-field based emergency routing and signaling updates.
Package emergency implements flow-field based emergency routing and signaling updates.
raster
Package raster converts geometric shapes and map images into grid cost data.
Package raster converts geometric shapes and map images into grid cost data.
pkg
config
Package config defines the public runtime configuration and dependency injection types for the pathfinding service.
Package config defines the public runtime configuration and dependency injection types for the pathfinding service.
domain
Package domain defines public pathfinding domain types, constants, and error sentinels shared by the Go clients and NATS service.
Package domain defines public pathfinding domain types, constants, and error sentinels shared by the Go clients and NATS service.
emergency
Package emergency provides a typed Go client for the emergency flow-field NATS API.
Package emergency provides a typed Go client for the emergency flow-field NATS API.
pathfinding
Package pathfinding provides typed Go clients for agent route-planning and movement-control NATS APIs.
Package pathfinding provides typed Go clients for agent route-planning and movement-control NATS APIs.
snapshotstream
Package snapshotstream encodes floor-keyed uint8 grid snapshots for NATS streams.
Package snapshotstream encodes floor-keyed uint8 grid snapshots for NATS streams.
subjects
Package subjects defines the public raw-NATS subject names handled by the pathfinding service.
Package subjects defines the public raw-NATS subject names handled by the pathfinding service.
tuning
Package tuning exposes helpers for inspecting how map images rasterize into pathfinding grids, including text output and browser-based visualization for large grids.
Package tuning exposes helpers for inspecting how map images rasterize into pathfinding grids, including text output and browser-based visualization for large grids.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL