MLAI Systems

Autonomous Delivery Navigation Agent

A planner-guided reinforcement learning agent for safer indoor pickup-and-delivery navigation.

GitHub

Domain

Reinforcement Learning, DQN, Reward Shaping

Built For

Indoor pickup-and-delivery navigation

My Work

Environment design, reward logic, DQN training, inference pipeline

Summary

Overview

Autonomous Delivery Navigation Agent is a reinforcement learning project built around indoor pickup-and-delivery tasks. It combines a grid-world environment, DQN-based action selection, A* planner guidance, FastAPI inference, and a 3D replay interface. The main focus is reward shaping: teaching the agent to balance progress, safety, waiting, and task completion under constrained navigation rules.

Case Study

How It Was Built

01

Objective

reward designpenalty zonesdelivery task

The goal was to build a navigation agent that does more than move from one point to another. It must follow pickup-and-delivery rules, avoid unsafe movement, handle penalty zones, and react to moving blockers. The project studies how reward design changes the agent’s behavior inside a constrained environment.

  • The task follows a fixed sequence: start, pickup, then delivery.
  • The map includes static obstacles, penalty zones, and dynamic obstacle paths.
  • The main question is whether reward shaping improves route quality, waiting behavior, and completion reliability.

02

Architecture

DQN policyA* guidancesafe action filtering

The final design uses a hybrid planner-guided RL approach. A* provides route structure, the DQN scores local actions, and a safety layer blocks invalid moves. This keeps learning focused on decision quality instead of basic path feasibility.

  • The agent is tested inside a rule-based delivery task, not just a free-movement demo.
  • Planner guidance reduces invalid rollouts while keeping learned action selection in the loop.
  • The replay layer makes route quality and failure cases easier to inspect.
Layer
Purpose
Environment
Defines the map, task rules, rewards, penalties, and obstacle behavior
Planner
Provides a valid Start → Pickup → Delivery route structure
DQN policy
Scores local actions under reward and penalty pressure
Safety filter
Blocks collisions, invalid movement, and wrong task order
3D replay
Visualizes route behavior, cargo state, and final outcome
Video demo showing the agent moving from start to pickup and then delivery in the 3D simulator.

03

Build Process

environment designreward shapingpolicy training

The workflow started with the environment, then moved into reward shaping, policy training, inference, and visual inspection. The 3D interface supports the training-to-evaluation loop by making each rollout easier to analyze.

  • Each stage supports the next: environment first, then rewards, then training, then replay.
  • Environment constraints directly affect learning by attaching cost to unsafe or invalid behavior.
  • Backend rollout output connects to a React Three Fiber visualizer for inspection.
Stage
What was built
Environment
Grid-based delivery world with pickup, delivery, obstacles, penalties, and waiting logic
Rewards
Mission rewards, movement cost, penalty-zone cost, collision penalties, wait penalties, and timeout penalties
Training
PyTorch DQN with replay buffer, target network, warm-up logic, and saved checkpoints
Planning
A* route guidance used to stabilize execution on custom maps
Inference
FastAPI endpoint that validates maps and returns replay-ready rollout data
Inspection
Browser-based 3D replay for checking route quality, cargo state, and task completion

04

Hybrid Navigation

global planninglocal policysafe execution

A pure DQN policy can be unstable on user-created layouts, so the final approach separates global route structure from local action choice. This makes execution more reliable on custom maps while still using learned behavior for movement decisions.

  • The DQN still matters because it handles local action choice under reward pressure.
  • The planner stabilizes execution rather than replacing the learned policy.
  • This setup makes reward design easier to evaluate because failed navigation does not dominate every rollout.
Component
Role
A* planner
Builds the overall route structure
DQN policy
Scores nearby actions based on learned reward behavior
Planner guidance
Keeps the rollout aligned with the delivery objective
Safety checks
Prevent collisions, invalid movement, and delivery before pickup

05

Reward Design

reward shapingpenalty modelingbehavior design

The reward function was designed to push the agent toward useful behavior, not just the shortest path. It combines progress signals, task rewards, wait costs, collision penalties, and penalty-zone costs so the agent must balance speed, safety, and completion.

  • Reward shaping creates more realistic behavior than shortest-path movement alone.
  • Penalty zones support cost-sensitive navigation instead of a simple blocked/free map.
  • Waiting is allowed for dynamic obstacles, but repeated waiting becomes expensive.
  • The reward values are explicit in the environment code, making behavior easier to inspect and tune.
Signal
Effect
Purpose
Pickup
+30
Reinforces progress through the required task sequence
Delivery
+100
Makes successful completion the highest-value outcome
Movement
-1 per move
Discourages wandering and encourages efficient routes
Progress shaping
+1 closer / -1 farther
Guides local movement without replacing the main objective
Penalty zones
Additional zone cost
Makes some valid cells risky instead of fully blocked
Collision or invalid move
-100
Strongly discourages unsafe or impossible actions
Early delivery
-5
Prevents delivery before pickup is complete
Wait
-4 base cost
Allows patience around moving blockers, but not for free
Repeated waiting
Extra penalties after multiple waits
Prevents waiting from becoming the safest default behavior
Timeout
-50
Penalizes unresolved episodes and pushes completion

06

Training Setup

PyTorchreplay buffercheckpointing

The training pipeline uses PyTorch DQN with replay memory, a target network, exploration scheduling, and checkpoint saving. The best validation checkpoint is used for inference when available.

  • The training loop includes warm-up logic before the main DQN updates.
  • The backend loads the best available checkpoint instead of always using the final checkpoint.
  • Saved metrics make it easier to compare success rate, reward, route quality, and collision behavior.
Setting
Value
Default episodes
200
Max steps per episode
220
Batch size
32
Discount factor
0.99
Learning rate
1e-4
Replay buffer size
50,000
Minimum replay size
500
Target network update
Every 250 global steps
Training interval
Every 4 global steps
Exploration
Epsilon decays from 1.0 to 0.05

08

Moving Obstacles

moving blockerstimeline replaywait behavior

Dynamic obstacles represent moving people, carts, or blockers inside the grid world. Their paths are validated by the backend and replayed with synchronized timeline frames.

  • Obstacle paths must stay in bounds, remain connected, and avoid reserved task cells.
  • The backend returns timeline data so movement stays synchronized with replay.
  • The agent can wait or choose safer local actions when a blocker interrupts the route.

09

Inference API

FastAPIpolicy inferencerollout metrics

The FastAPI backend connects the trained policy to the frontend. It validates the map, resolves the planner route, runs the guided rollout, and returns replay-ready output.

  • Uses the best available validation checkpoint when present.
  • Rejects impossible or invalid layouts before rollout.
  • Returns route data, task metrics, planner metadata, and timeline data for evaluation.
Output
Meaning
path
Executed route followed by the agent
planner_path
Route generated by the planner
pickup_step / delivery_step
Key task milestones inside the rollout
total_reward
Combined score from movement, penalties, and completion
dynamic_obstacle_timeline
Obstacle positions synchronized with replay

10

Build Stack

The stack combines PyTorch reinforcement learning, planner-guided inference, FastAPI backend services, and a lightweight 3D visualization layer for inspection.

PythonPyTorchDQNReinforcement LearningRoute PlanningReward DesignFastAPINext.jsReactTypeScriptThree.jsReact Three FiberTailwind CSS3D VisualizationCustom Map Editor

11

Result

guided RLreward shapingroute inspection

The final result is an RL-based indoor delivery simulator where a DQN policy operates inside a constrained environment with reward shaping, planner guidance, and safety validation.

  • The strongest technical value is in the RL environment and reward design, not only the UI.
  • The backend exposes the trained policy through replay-ready rollout data and metrics.
  • The frontend helps verify whether learned behavior matches the intended reward structure.
Feature
Result
Navigation method
Planner-guided DQN
Task type
Single-agent Start → Pickup → Delivery
Main focus
Reward shaping, penalty design, and stable local action learning
Backend
FastAPI inference service
Training stack
PyTorch DQN with replay buffer and target network
Inspection layer
Next.js, React, and React Three Fiber

12

Limitations

grid-based environment3D visualizationnot robotics deployment

This is a simulator, not a production robotics stack. The environment is grid-based, and the 3D scene visualizes behavior from that grid world.

  • The current task format is limited to one pickup and one delivery.
  • Planner-guided DQN is used here for stable simulated decision-making, not production deployment.

13

Reflection

reward shapingpolicy behaviorRL system design

This project showed me that reinforcement learning depends heavily on environment design. Planning adds structure, but the biggest improvement came from shaping incentives, penalties, and constraints so the agent learns safer and more useful behavior.

  • The biggest improvement came from combining planner guidance with reward-shaped DQN behavior.
  • The main takeaway is that good RL systems depend on incentives and constraints as much as on the model itself.

More Projects

View all projects