This repository contains a custom ROS 2 Nav2 costmap plugin that injects dynamic humans and obstacles published from Unity directly into the local costmap. The plugin is designed to support socially-aware navigation, human–robot interaction, and simulation-based research workflows.
Standard Nav2 costmaps are primarily designed for static maps and sensor-based obstacle layers (e.g., LiDAR, depth cameras). In simulation-heavy setups—especially when using Unity as a human and environment simulator—dynamic agents such as humans are often published externally and are not naturally integrated into the costmap.
This plugin addresses that gap by:
Subscribing to Unity-published dynamic agents
Converting their poses and shapes into costmap obstacles
Updating the local costmap in real time
✅ Custom Nav2 Costmap Layer Plugin
✅ Real-time integration of dynamic humans and obstacles
✅ Supports multiple agents published as separate topics
✅ Designed for social navigation research
✅ Compatible with custom local planners (e.g., Pure Pursuit, social-force–based planners)
✅ Works independently of global costmaps if needed
Unity ├── Human Avatars ├── Dynamic Objects │ ▼ ROS 2 Topics (Twist + Transform) │ ▼ Unity Costmap Plugin │ ▼ Nav2 Local Costmap │ ▼ Local Planner / Controller
The plugin consumes dynamic agent data published from Unity, typically containing:
Position (x, y)
Orientation
Velocity (optional)
Agent size / footprint (configurable)
The data is injected into the local costmap as dynamic obstacles.
🤖 Social navigation experiments
🚶 Human-aware path planning
🧪 Simulation-based HRI research
🎮 Unity–ROS 2 integration workflows
📊 Evaluation of social navigation metrics
Clone into your ROS 2 workspace:
cd ~/ros2_ws/src
git clone https://github.com/vefak/CustomCostmapPlugin-SocialNavigation
cd ~/ros2_ws
colcon build --symlink-install
source install/setup.bash
Add the plugin to your Nav2 local costmap parameters:
local_costmap:
ros__parameters:
plugins: ["unity_layer"]
unity_layer:
plugin: "unity_costmap_plugin::UnityLayer"
enabled: true
Additional parameters (topics, agent radius, update rate, etc.) can be configured in the same file.
This plugin is intended for local costmaps.
Memory safety is critical—ensure proper bounds checking when modifying costmap cells.
Designed primarily for simulation (Unity), not raw sensor input.
Tested with ROS 2 and Nav2-based navigation stacks.