惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Security Latest
Security Latest
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Stack Overflow Blog
Stack Overflow Blog
WordPress大学
WordPress大学
N
Netflix TechBlog - Medium
GbyAI
GbyAI
云风的 BLOG
云风的 BLOG
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
宝玉的分享
宝玉的分享
博客园 - 【当耐特】
C
Cyber Attacks, Cyber Crime and Cyber Security
雷峰网
雷峰网
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
T
Threat Research - Cisco Blogs
NISL@THU
NISL@THU
Spread Privacy
Spread Privacy
P
Proofpoint News Feed
J
Java Code Geeks
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
MyScale Blog
MyScale Blog
T
Tor Project blog
P
Proofpoint News Feed
C
CERT Recently Published Vulnerability Notes
P
Privacy & Cybersecurity Law Blog
MongoDB | Blog
MongoDB | Blog
Simon Willison's Weblog
Simon Willison's Weblog
C
Cybersecurity and Infrastructure Security Agency CISA
L
LINUX DO - 热门话题
小众软件
小众软件
G
GRAHAM CLULEY
P
Privacy International News Feed
AWS News Blog
AWS News Blog
Know Your Adversary
Know Your Adversary
P
Palo Alto Networks Blog
人人都是产品经理
人人都是产品经理
S
Schneier on Security
Scott Helme
Scott Helme
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
B
Blog RSS Feed
T
The Exploit Database - CXSecurity.com
Recent Announcements
Recent Announcements
E
Exploit-DB.com RSS Feed
C
CXSECURITY Database RSS Feed - CXSecurity.com
U
Unit 42
The Register - Security
The Register - Security
S
Securelist
Martin Fowler
Martin Fowler
Project Zero
Project Zero
大猫的无限游戏
大猫的无限游戏
Cisco Talos Blog
Cisco Talos Blog

博客园 - 西北逍遥

yolov8-pose监测人体关节并保存关节坐标 osg3.6绘制半球体 kinova jaco2 机械臂控制器故障灯闪烁(双绿灯)问题解决方法 IFC标准在学术界的研究与发展历程:从理论探索到产业实践的全面梳理IFC标准在学术界的研究与发展历程:从理论探索到产业实践的全面梳理 BIM的“普通话”:解密IFC标准如何重塑建筑行业 IfcCrewResource Qt重置 Brush pyqt 操作mysql数据库 泵仿真 Qt折线的显示与隐藏 Qt绘制折线 c++ Qt绘制传热云图 livox mid-70采集点云数据 随机配色 学习:LED灯闪烁 win10安装neo4j-community-3.5.7-windows win10安装MongoDB 3.0.15 Community python把图片合并成gif图 ubuntu20.04测试cuda start.bat Djstra求解最短路径
实验启动指令
西北逍遥 · 2026-05-08 · via 博客园 - 西北逍遥
一、环境准备
项目使用 Conda 管理两个独立的 Python 环境,分别对应仿真端和决策端。

环境名	Python 版本	用途	依赖文件
mujoco312	3.12	运行 MuJoCo 仿真和 Sim Manager	simulation/mujoco/requirements.txt
k1	3.8	运行 Decider 决策端	decider/requirements.txt
1.1 安装 Conda
mkdir -p ~/miniconda3
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ~/miniconda3/miniconda.sh
bash ~/miniconda3/miniconda.sh -b -u -p ~/miniconda3
rm -rf ~/miniconda3/miniconda.sh
~/miniconda3/bin/conda init bash
source ~/.bashrc
1.2 创建仿真环境 mujoco312
cd ./mos-sim/simulation/mujoco
conda create -n mujoco312 python=3.12 -y
conda activate mujoco312
pip install -r requirements.txt
可以先检查依赖是否就绪(检不检测都行,检测的话把稳一些^ ^):

python -c "import mujoco, torch, zmq, flask, fastapi, uvicorn; print('ok')"
1.3 创建决策环境 k1
cd ./mos-sim
conda create -n k1 python=3.8 -y
conda activate k1
pip install -r decider/requirements.txt
二、启动 Sim Manager(推荐)
Sim Manager 是一个基于 FastAPI 的网页管理器,可以在浏览器中可视化地启动、停止和管理多个仿真实例,并自动生成 Decider 启动命令。

2.1 启动 Manager 服务
在 mos-sim 项目根目录执行:

conda run -n mujoco312 uvicorn simulation.labbridge.sim_manager:app --host 0.0.0.0 --port 8000
兼容旧方式(仍可用):

cd ./mos-sim/simulation/mujoco
conda run -n mujoco312 python sim_manager.py --host 0.0.0.0 --port 8000
2.2 访问页面
入口	地址
Manager 前端页面(核心)	http://127.0.0.1:8000/
Swagger 文档	http://127.0.0.1:8000/docs
API 说明页	http://127.0.0.1:8000/manager/docs
2.3 在网页上的操作流程
启动仿真实例

在 Start Simulation 区域填写 team_size(如 3),以及可选的渲染参数。
zmq_port、webview_port 可留空,Manager 会自动分配可用端口。
点击 Start。
查看实例资源

在 Scanned Sim Processes 可以看到:
PID
ZMQ Port(Decider 用来控制的端口)
Team Size
WebView 链接(点击即可查看 3D 仿真画面)
停止仿真进程

在 Process Control 下拉选择 PID,点击 Stop PID。
点击 Stop External 可停止非 Manager 创建但被扫描到的仿真进程。
生成 Decider 启动命令

选择 PID 后展开 Decider Commands,页面会按红/蓝队和机器人编号自动生成命令,可直接复制到新终端使用。
查看日志

Start Log:启动结果
Action Log:停止/清理结果
三、启动 Decider 决策端
方式 A:单机器人启动(调试推荐)
打开新的终端,激活 k1 环境,使用 Sim Manager 分配的 ZMQ 端口启动:

cd ./mos-sim
conda activate k1

# 红队 0 号(--port 替换为 Sim Manager 分配的 ZMQ 端口)
python3 decider/decider.py --simulation --ip 127.0.0.1 --port 5555 --color red --id 0

# 蓝队 0 号
python3 decider/decider.py --simulation --ip 127.0.0.1 --port 5555 --color blue --id 0
主要参数:

参数	说明
--simulation	使用仿真模式(否则走真机协议)
--ip	Sim Manager 所在主机 IP(同机即 127.0.0.1)
--port	ZMQ 端口,从 Sim Manager 页面 Scanned Sim Processes 中复制
--color	red 或 blue
--id	机器人编号(0..6)
说明:蓝队会根据 match_config 自动做队伍 ID 偏移,红/蓝队可共用同一套策略代码。

方式 B:一键启动整支球队(Linux / macOS)
# 按 match_config 自动启动
./decider/scripts/start_team.sh

# 自定义数量
./decider/scripts/start_team.sh --red 2 --blue 1

# 重启全部 / 停止全部
./decider/scripts/start_team.sh --restart
./decider/scripts/start_team.sh --kill
脚本会通过 screen 为每个机器人单独开一个会话。查看某个机器人的日志:

screen -r decider_red_0     # 进入会话;按 Ctrl+A 然后 D 退出
四、纯命令行启动单个仿真(不用 Sim Manager)
如果只想本地跑一个仿真实例,不需要网页管理器,可以直接启动 sim2sim_runner.py:

cd ./mos-sim/simulation/mujoco
conda run -n mujoco312 python sim2sim_runner.py --team-size 3
默认端口:

WebView:http://localhost:5811
ZMQ REP:tcp://*:5555
常用参数:

参数	说明
--robot-type	机器人类型,k1(默认)或 pi_plus
--team-size	每队机器人数量(红蓝相等),范围 0..7,默认 1
--use-referee	启用内置裁判盒(开球 / 出界 / 角球 / 门球 / 进球 / 超时等)
示例(启动 pi_plus):

conda run -n mujoco312 python sim2sim_runner.py --robot-type pi_plus --team-size 3
固定 Robot ID 映射
0..6 -> robot_rp0..robot_rp6(红队)
7..13 -> robot_bp0..robot_bp6(蓝队)
即使 --team-size 小于 7,映射仍然固定;未启用的 ID 会被忽略。

五、可能遇到的问题
5.1 清理残留的 Decider 进程
ps -ef | grep decider.py | grep -v grep
sudo pkill -f decider.py
5.2 清理残留的仿真进程
方法 1:在 Sim Manager 页面点击 Stop External
方法 2:按 PID 手动 kill
5.3 Windows 用户注意事项
start_team.sh 依赖 screen 和 bash,在 Windows 上建议通过 WSL2 或直接在 Linux 服务器上运行。

decider.py 单独启动可以直接在 Windows PowerShell 里跑,把 python3 改成 python 即可:

conda activate k1
python decider/decider.py --simulation --ip 127.0.0.1 --port 5555 --color red --id 0
5.4 将 Sim Manager 持久化为 systemd 服务(可选)
适用于断开 SSH 后需要持续运行、或开机自动拉起 Manager 的场景,详细步骤见 simulation/mujoco/README.md。

六、启动流程总览
┌──────────────────────────────────────────────────────────────┐
│ 终端 1(仿真端 / mujoco312 环境)                               │
│   conda run -n mujoco312 \                                   │
│     uvicorn simulation.labbridge.sim_manager:app \           │
│     --host 0.0.0.0 --port 8000                               │
└──────────────────────────────────────────────────────────────┘
                          │
                          ▼
   浏览器打开 http://127.0.0.1:8000/
     → 点击 Start 启动仿真
     → 得到 ZMQ 端口(例如 5555)
     → WebView 实时查看 3D 画面
                          │
                          ▼
┌──────────────────────────────────────────────────────────────┐
│ 终端 2(决策端 / k1 环境)                                      │
│   conda activate k1                                          │
│   python3 decider/decider.py \                               │
│     --simulation --ip 127.0.0.1 --port 5555 \                │
│     --color red --id 0                                       │
└──────────────────────────────────────────────────────────────┘
                          │
                          ▼
   Decider 通过 ZMQ 连接仿真,按照 decider/user_entry.py 中
   game(agent) 的逻辑驱动机器人在球场上行动。
启动后在 WebView 页面就能看到机器人按照策略开始行动。多机器人只需重复打开多个终端,改变 --color 和 --id 即可。

###################