说明目标:
前置条件:
/home/robot-a/Desktop/drone_training_github_release。项目包中包含两个独立货舱相关 USD:
assets/cargo_bay/cargo_bay_resized_0p2_0p14_0p06.usdassets/cargo_bay/air_fpv_box.usd其中:
| 文件 | 作用 |
|---|---|
cargo_bay_resized_0p2_0p14_0p06.usd | 独立货舱模型,适合单独加载检查结构和尺寸 |
air_fpv_box.usd | 货物 / 箱体模型,可用于货舱开关动作验证 |
自定义无人机资产中也包含货舱相关引用:
xxxxxxxxxxassets/robots/sunray150_with_mid360_cargo/sunray150_with_mid360_cargo.usdaassets/robots/sunray150_with_mid360_cargo/air_fpv_box.usd仅检查货舱本体时,不需要先加载 PX4 或 Pegasus 的无人机 backend。
打开终端,进入项目包目录:
xxxxxxxxxxcd /home/robot-a/Desktop/drone_training_github_release./run_load_cargo_bay.sh脚本会调用 Isaac Sim,并执行:
xxxxxxxxxxisaac/load_cargo_bay.py如果 Isaac Sim 不在默认路径,可以先设置:
xxxxxxxxxxexport ISAACSIM_BIN=/home/robot-a/miniconda3/envs/env_isaacsim/bin/isaacsimcd /home/robot-a/Desktop/drone_training_github_release./run_load_cargo_bay.sh加载后,在 Stage 中检查是否出现货舱相关 prim。若仅需要确认 USD 能否打开,应避免同时启动 PX4、QGC 或 Offboard 控制脚本,以免混淆资产问题和飞控问题。
货舱控制使用项目包里的脚本:
xxxxxxxxxxcd /home/robot-a/Desktop/drone_training_github_release./run_cargo_bay_control.sh status./run_cargo_bay_control.sh left_open./run_cargo_bay_control.sh left_close./run_cargo_bay_control.sh bottom_open./run_cargo_bay_control.sh bottom_close命令含义:
| 命令 | 作用 |
|---|---|
status | 查询或请求输出货舱当前状态 |
left_open | 打开左侧舱门 |
left_close | 关闭左侧舱门 |
bottom_open | 打开底部舱门 |
bottom_close | 关闭底部舱门 |
脚本默认会依次尝试 source 可用的 ROS 2 环境,并优先使用 PX4_ROS_WS 指定的工作空间。如果使用单独工作空间,可以这样运行:
xxxxxxxxxxcd /home/robot-a/Desktop/drone_training_github_releasePX4_ROS_WS=/home/robot-a/Desktop/test_ws/ros2_px4_ws ./run_cargo_bay_control.sh status货舱控制只使用字符串话题,不直接依赖 PX4 Offboard:
xxxxxxxxxx/cargo_bay/command/cargo_bay/status可以用 ROS 2 命令检查:
xxxxxxxxxxsource /opt/ros/jazzy/setup.bashros2 topic list | grep cargo_bay手动发布字符串命令的形式如下:
xxxxxxxxxxros2 topic pub --once /cargo_bay/command std_msgs/msg/String "{data: 'left_open'}"ros2 topic echo /cargo_bay/status如果使用 Ubuntu 20.04 + Foxy 或 Ubuntu 22.04 + Humble,把 source 命令替换为对应版本:
xxxxxxxxxxsource /opt/ros/foxy/setup.bashxxxxxxxxxxsource /opt/ros/humble/setup.bash货舱看不到时,先确认:
assets/cargo_bay/ 下 USD 文件是否存在。run_load_cargo_bay.sh 中的 ISAACSIM_BIN 是否指向正确 Isaac Sim。控制命令无反应时,先确认:
/cargo_bay/command 和 /cargo_bay/status 是否存在。货舱模块用于资产加载和 ROS 2 字符串控制验证,不等同于 PX4 飞行控制。PX4 的起飞、移动、降落仍然使用模块三的 Offboard 控制菜单。