Skip to content

Conversation

@M3ngL
Copy link
Contributor

@M3ngL M3ngL commented Sep 24, 2025

Rustpilot in Mujoco with mujoco-rust.

RustPilot-MuJoCo启动说明以及运行效果

环境搭建

  1. 假设rust环境已配置完成

  2. 下载 RustPilot

mkdir ~/project && cd ~/project
git clone https://github.com/M3ngL/RustPilot.git RustPilot
  1. 安装 rust 包mujoco-rs-sysglfw-sys以及视频流的依赖
sudo apt update
sudo apt install clang libclang-dev
sudo apt install libxrandr-dev libx11-dev libxext-dev libxinerama-dev libxcursor-dev libxi-dev
sudo apt install ffmpeg
  1. 下载安装 MuJoCo 2.3.5 版本
mkdir -p ~/.local/mujoco
curl -L -O https://github.com/google-deepmind/mujoco/releases/download/2.3.5/mujoco-2.3.5-linux-x86_64.tar.gz
tar -zxvf mujoco-2.3.5-linux-x86_64.tar.gz && cd mujoco-2.3.5
cp -r * ../ && rm -r mujoco-2.3.5
  1. 设置 MuJoCo 以及 mujoco-rust 相关的环境变量
export LD_LIBRARY_PATH=~/.local/mujoco/lib
export LD_LIBRARY_PATH=$ONNXRUNTIME_DIR/lib:$LD_LIBRARY_PATH
  1. 下载安装 mediamtx
mkdir ~/project/mediamtx && cd ~/project/mediamtx
wget https://github.com/bluenviron/mediamtx/releases/download/v1.14.0/mediamtx_v1.14.0_linux_amd64.tar.gz
tar -zxvf mediamtx_v1.14.0_linux_amd64.tar.gz
chmod +x ./mediamtx

MediaMTX 能够充当视频流的中间代理服务器,能够将来自一个端点的视频流路由到另一个端点,实现无缝的分发和转换,支持多种协议如 SRT、WebRTC、RTSP、RTMP、LL-HLS、MPEG-TS 和 RTP 等

  1. 下载 QGroundControl 以及设置 QGC 相关功能
mkdir -p ~/project/qgc && cd ~/project/qgc
curl -O -L https://github.com/mavlink/qgroundcontrol/releases/download/v5.0.7/QGroundControl-x86_64.AppImage
chmod +x QGroundControl-x86_64.AppImage

设置QGC摇杆界面打开

image-20251014172822296

QGC打开视频流展示功能

image-20251014173831947

编译

Rust debug版本编译

cargo build --features mjsim

Rust release版本编译

cargo build --release --features mjsim

运行

mj_sim.sh 内容如下,该文件位于 ./start_scripts/mj_sim.sh

./target/debug/rust_pilot mujoco_sim ~/project/RustPilot/sim/mujoco_x2/scene.xml

./target/debug/rust_pilot mixer ~/project/RustPilot/mixers/mj_mixer.json

./target/debug/rust_pilot att_control

./target/debug/rust_pilot -- manual_ctrl

./target/debug/rust_pilot -- mavlink_gs --addr 127.0.0.1:14550 --joystick

终端执行命令

以下命令依次按照顺序执行

终端1,执行mediamtx

cd ~/project/mediamtx && ./mediamtx

image-20251014111405867

终端2,打开QGC

cd ~/project/qgc && ./QGroundControl-x86_64.AppImage

image-20251014111509391

终端3,打开RustPilot服务端

cd ~/project/RustPilot && ./target/debug/rust_pilot --server

image-20251014111302629

终端4,执行mjsim脚本

cd ~/project/RustPilot && ./start_scripts/mj_sim.sh

image-20251014150013330

@Ncerzzk
Copy link
Owner

Ncerzzk commented Oct 15, 2025

Thank you for the excellent contribution!
(the gazebo CI has broken for a time, I will fix it later.)

@Ncerzzk Ncerzzk merged commit 7b2f2aa into Ncerzzk:master Oct 15, 2025
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants