unity2moveit2/configs/docker/docker-compose.yml
ayuan9957 fe15edcbd5 Initial commit: Unity-MoveIt2 integrated robotic arm simulation system
- Unity frontend with ROS-TCP-Connector for ROS2 communication
- Docker-based ROS2 Jazzy backend with MoveIt2 integration
- Support for 1-9 DOF manipulators
- UR5 robot configuration and URDF files
- Assembly task feasibility analysis tools
- Comprehensive documentation and deployment guides

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-13 12:08:34 +08:00

424 lines
8.8 KiB
YAML
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

version: '3.8'
# Unity-MoveIt2 系统 Docker Compose 配置
# 此文件定义了完整系统的容器化部署
services:
# ROS2 TCP Bridge 服务
ros2-bridge:
build:
context: ../../ros2-workspace
dockerfile: Dockerfile
args:
ROS_DISTRO: humble
UBUNTU_VERSION: 22.04
container_name: unity-ros2-bridge
hostname: ros2-bridge
# 网络配置
ports:
- "10000:10000" # Unity TCP连接端口
- "11311:11311" # ROS Master端口如果需要ROS1兼容
# 环境变量
environment:
- ROS_DOMAIN_ID=42
- RMW_IMPLEMENTATION=rmw_cyclonedx_cpp
- PYTHONUNBUFFERED=1
- DISPLAY=${DISPLAY:-:0}
- QT_X11_NO_MITSHM=1
# 卷挂载
volumes:
- ../robots:/workspace/robots:ro
- ../ros2:/workspace/config:ro
- ../../logs:/workspace/logs
- /tmp/.X11-unix:/tmp/.X11-unix:rw
- ~/.Xauthority:/root/.Xauthority:rw
# 网络
networks:
- unity-ros-network
# 重启策略
restart: unless-stopped
# 健康检查
healthcheck:
test: ["CMD", "ros2", "node", "list"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
# 资源限制
deploy:
resources:
limits:
cpus: '2.0'
memory: 2G
reservations:
cpus: '0.5'
memory: 512M
# MoveIt2 规划服务
moveit-planner:
build:
context: ../../ros2-workspace
dockerfile: Dockerfile.moveit
args:
ROS_DISTRO: humble
ROBOT_NAME: niryo_one
container_name: unity-moveit-planner
hostname: moveit-planner
# 依赖服务
depends_on:
ros2-bridge:
condition: service_healthy
# 环境变量
environment:
- ROS_DOMAIN_ID=42
- RMW_IMPLEMENTATION=rmw_cyclonedx_cpp
- ROBOT_NAME=niryo_one
- MOVEIT_PLANNING_ATTEMPTS=10
- MOVEIT_PLANNING_TIME=5.0
# 卷挂载
volumes:
- ../robots:/workspace/robots:ro
- ../ros2:/workspace/config:ro
- ../../logs:/workspace/logs
# 网络
networks:
- unity-ros-network
# 重启策略
restart: unless-stopped
# 健康检查
healthcheck:
test: ["CMD", "ros2", "service", "list", "|", "grep", "plan_kinematic_path"]
interval: 30s
timeout: 10s
retries: 3
start_period: 60s
# 资源限制
deploy:
resources:
limits:
cpus: '4.0'
memory: 4G
reservations:
cpus: '1.0'
memory: 1G
# 可行性分析服务
feasibility-analyzer:
build:
context: ../../analysis-service
dockerfile: Dockerfile
container_name: unity-feasibility-analyzer
hostname: feasibility-analyzer
# 依赖服务
depends_on:
ros2-bridge:
condition: service_healthy
# 环境变量
environment:
- ROS_DOMAIN_ID=42
- RMW_IMPLEMENTATION=rmw_cyclonedx_cpp
- ANALYSIS_RESOLUTION=0.05
- CACHE_SIZE=1000
- WORKER_THREADS=4
# 卷挂载
volumes:
- ../analysis:/workspace/config:ro
- ../../logs:/workspace/logs
- ../../cache:/workspace/cache
# 网络
networks:
- unity-ros-network
# 重启策略
restart: unless-stopped
# 健康检查
healthcheck:
test: ["CMD", "ros2", "service", "list", "|", "grep", "analyze_feasibility"]
interval: 30s
timeout: 10s
retries: 3
start_period: 45s
# 资源限制
deploy:
resources:
limits:
cpus: '2.0'
memory: 3G
reservations:
cpus: '0.5'
memory: 512M
# 机器人仿真服务(可选)
robot-simulation:
build:
context: ../../ros2-workspace
dockerfile: Dockerfile.simulation
args:
ROS_DISTRO: humble
ROBOT_NAME: niryo_one
container_name: unity-robot-simulation
hostname: robot-simulation
# 依赖服务
depends_on:
moveit-planner:
condition: service_healthy
# 环境变量
environment:
- ROS_DOMAIN_ID=42
- RMW_IMPLEMENTATION=rmw_cyclonedx_cpp
- ROBOT_NAME=niryo_one
- USE_SIM_TIME=true
- GAZEBO_MODEL_PATH=/workspace/models
# 卷挂载
volumes:
- ../robots:/workspace/robots:ro
- ../../models:/workspace/models:ro
- ../../logs:/workspace/logs
# 网络
networks:
- unity-ros-network
# 重启策略
restart: unless-stopped
# 仅在需要时启动
profiles:
- simulation
# 资源限制
deploy:
resources:
limits:
cpus: '2.0'
memory: 2G
reservations:
cpus: '0.5'
memory: 512M
# 数据库服务(用于缓存和日志)
database:
image: postgres:15-alpine
container_name: unity-database
hostname: database
# 环境变量
environment:
- POSTGRES_DB=unity_ros
- POSTGRES_USER=unity_user
- POSTGRES_PASSWORD=unity_password
- POSTGRES_INITDB_ARGS=--encoding=UTF-8 --lc-collate=C --lc-ctype=C
# 卷挂载
volumes:
- postgres_data:/var/lib/postgresql/data
- ./init-db.sql:/docker-entrypoint-initdb.d/init-db.sql:ro
# 网络
networks:
- unity-ros-network
# 重启策略
restart: unless-stopped
# 健康检查
healthcheck:
test: ["CMD-SHELL", "pg_isready -U unity_user -d unity_ros"]
interval: 30s
timeout: 10s
retries: 3
start_period: 30s
# 仅在需要时启动
profiles:
- database
# 资源限制
deploy:
resources:
limits:
cpus: '1.0'
memory: 1G
reservations:
cpus: '0.25'
memory: 256M
# Redis缓存服务
redis-cache:
image: redis:7-alpine
container_name: unity-redis-cache
hostname: redis-cache
# 命令参数
command: redis-server --appendonly yes --maxmemory 512mb --maxmemory-policy allkeys-lru
# 卷挂载
volumes:
- redis_data:/data
# 网络
networks:
- unity-ros-network
# 重启策略
restart: unless-stopped
# 健康检查
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 30s
timeout: 10s
retries: 3
start_period: 10s
# 仅在需要时启动
profiles:
- cache
# 资源限制
deploy:
resources:
limits:
cpus: '0.5'
memory: 512M
reservations:
cpus: '0.1'
memory: 128M
# 监控服务
monitoring:
image: prom/prometheus:latest
container_name: unity-monitoring
hostname: monitoring
# 端口
ports:
- "9090:9090"
# 卷挂载
volumes:
- ./prometheus.yml:/etc/prometheus/prometheus.yml:ro
- prometheus_data:/prometheus
# 命令参数
command:
- '--config.file=/etc/prometheus/prometheus.yml'
- '--storage.tsdb.path=/prometheus'
- '--web.console.libraries=/etc/prometheus/console_libraries'
- '--web.console.templates=/etc/prometheus/consoles'
- '--storage.tsdb.retention.time=200h'
- '--web.enable-lifecycle'
# 网络
networks:
- unity-ros-network
# 重启策略
restart: unless-stopped
# 仅在需要时启动
profiles:
- monitoring
# 资源限制
deploy:
resources:
limits:
cpus: '1.0'
memory: 1G
reservations:
cpus: '0.25'
memory: 256M
# 日志聚合服务
log-aggregator:
image: fluent/fluent-bit:latest
container_name: unity-log-aggregator
hostname: log-aggregator
# 卷挂载
volumes:
- ./fluent-bit.conf:/fluent-bit/etc/fluent-bit.conf:ro
- ../../logs:/workspace/logs:ro
- /var/log:/var/log:ro
# 网络
networks:
- unity-ros-network
# 重启策略
restart: unless-stopped
# 仅在需要时启动
profiles:
- logging
# 资源限制
deploy:
resources:
limits:
cpus: '0.5'
memory: 512M
reservations:
cpus: '0.1'
memory: 128M
# 网络定义
networks:
unity-ros-network:
driver: bridge
ipam:
config:
- subnet: 172.20.0.0/16
driver_opts:
com.docker.network.bridge.name: unity-ros-br
# 卷定义
volumes:
postgres_data:
driver: local
redis_data:
driver: local
prometheus_data:
driver: local
# 扩展配置
x-common-variables: &common-variables
ROS_DOMAIN_ID: 42
RMW_IMPLEMENTATION: rmw_cyclonedx_cpp
PYTHONUNBUFFERED: 1
x-logging: &default-logging
driver: "json-file"
options:
max-size: "10m"
max-file: "3"
# 默认配置
x-defaults: &defaults
logging: *default-logging
networks:
- unity-ros-network