- Debugging/Logging - 飞行日志分析
- Debugging/Logging - ULog文件格式
- 教程
- 教程 - 地面站
- 教程 - 编写应用程序
- 教程 - QGC的视频流
- 教程 - 远距离视频流
- 教程 - u-blox M8P RTK
- 新手上路
- 新手上路 - 初始设置
- 新手上路 - 安装工具链
- 安装工具链 - Mac OS
- 安装工具链 - Linux
- Linux - Advanced Linux
- 安装工具链 - Windows
- 新手上路 - Fast RTPS installation
- 新手上路 - 代码编译
- 新手上路 - 高级配置
- 新手上路 - 贡献& 开发者电话会议
- 贡献& 开发者电话会议 - GIT例程
- 贡献& 开发者电话会议 - Documentation
- 新手上路 - Licenses
- 概念解读
- 概念解读 - 飞行模式
- 概念解读 - 结构概述
- 概念解读 - 飞行控制栈
- 概念解读 - 中间件
- 概念解读 - 混控和执行器
- 概念解读 - PWM限制状态机
- Hardware
- Hardware - 自驾仪硬件
- 机型 - 统一的基础代码
- 机型 - 参考机型
- 机型 - 添加一个新的机型
- Data Links - SiK Radio
- Data Links - Wifi数传
- Data Links - 数传
- I2C总线 - SF1XX lidar
- 传感器和执行机构总线 - UAVCAN总线
- UAVCAN总线 - UAVCAN Bootloader
- UAVCAN总线 - UAVCAN固件升级
- UAVCAN总线 - UAVCAN配置
- UAVCAN总线 - UAVCAN 的各种笔记
- 传感器和执行机构总线 - UART
- UART - uLanding Radar
- 传感器和执行机构总线 - 设置云台控制
- 传感器和执行机构总线 - 相机触发器
- Hardware - 协同电脑
- 仿真
- 仿真 - 基本仿真
- 仿真 - Gazebo仿真
- 仿真 - HITL仿真
- 仿真 - 连接到ROS
- 仿真 - AirSim仿真
- 仿真 - 多机仿真
- 中间件及架构
- 中间件及架构 - uORB消息机制
- 中间件及架构 - MAVLink消息机制
- 中间件及架构 - 守护程序
- 中间件及架构 - 驱动框架
- 模块 & 命令
- 模块 & 命令 - 命令
- 模块 & 命令 - 通信
- 模块 & 命令 - 驱动
- 模块 & 命令 - 系统
- Robotics
- Robotics - 用Linux进行外部控制
- Robotics - ROS
- ROS - 在RPi上安装ROS
- ROS - MAVROS (ROS上的MAVLink)
- ROS - MAVROS外部控制例程
- ROS - 外部位置估计
- ROS - Gazebo Octomap
- Robotics - DroneKit
- Debugging/Logging
- Debugging/Logging - FAQ
- Debugging/Logging - 系统控制台
- Debugging/Logging - 自驾仪调试
- Debugging/Logging - Sensor/Topic Debugging
- Debugging/Logging - 仿真调试
- Debugging/Logging - System-wide Replay
- Debugging/Logging - 发送调试的值
- Debugging/Logging - Profiling
- Debugging/Logging - 日志记录
- 教程 - 光流
- 教程 - ecl EKF
- 教程 - 飞行前检查
- 教程 - 着陆检测
- 教程 - Linux系统下使用S.Bus驱动
- Advanced Topics
- Advanced Topics - 系统启动
- Advanced Topics - 参数&配置
- Advanced Topics - 参考参数
- Advanced Topics - 安装Intel RealSense R200的驱动
- Advanced Topics - 切换状态估计器
- Advanced Topics - 外部模块
- Advanced Topics - STM32 Bootloader
- 测试和持续集成
- 测试和持续集成 - 持续集成
- 测试和持续集成 - Jenkins持续集成环境
- 测试和持续集成 - 综合测试
- 测试和持续集成 - Docker容器
- 测试和持续集成 - 维护
仿真 - 多机仿真
translated_page: https://github.com/PX4/Devguide/blob/master/en/simulation/sitl.md
translated_sha: b522243efef9deb5e2d3ae7bd03ae9ed0eee3418
Multi-Vehicle Simulation
This tutorial explains how to simulate multi UAV in Gazebo. This is a software in the loop (SITL) simulation.
Note: This is tested only in Linux.
Required
- ROS indigo or higher
- MAVROS package
- Gazebo 7 (see Gazebo Simulation)
- a clone of latest PX4/Firmware
Build and test
To test an example setup, follow the below steps,
- clone the PX4/Firmware code, then build the SITL code
cd Firmware_clone
git submodule update --init --recursive
make posix_sitl_default gazebo
source your environment,
source Tools/setup_gazebo.bash $(pwd) $(pwd)/build/posix_sitl_default
export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:$(pwd)
export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:$(pwd)/Tools/sitl_gazebo
run launch file,
roslaunch px4 multi_uav_mavros_sitl.launch
What’s happening?
For each simulated vehicle, the following is required,
Gazebo model: This is defined as
xacro
file inFirmware/Tools/sitl_gazebo/models/rotors_description/urdf/<model>_base.xacro
see here. Currently, the modelxacro
file is assumed to end with base.xacro. This model should have an argument calledmavlink_udp_port
which defines the UDP port on which gazebo will communicate with PX4 node. The model’sxacro
file will be used to generate ansdf
model that contains UDP port that you select. To define the UDP port, set themavlink_udp_port
in the launch file, see here.
NOTE: If you are using the same vehicle model, you don’t need a separatexacro
file for each vehicle. The samexacro
file is adequate.PX4 node: this is the SITL PX4 app. It communicates with the simulator, Gazebo, through the same UDP port defined in the Gazebo vehicle model, i.e.
mavlink_udp_port
. To set the UDP port on the PX4 SITL app side, you need to set theSITL_UDP_PRT
parameter in the startup file, see here. You also need to specify the path of the startup file, for each vehicle, in the launch file, see here. It is recommended that you set a unique mavlink ID for each vehicle in the startup file, see here.MAVROS node (optional): A seperate MAVROS node can be run in the launch file, see here, in order to connect to PX4 SITL app, if you want to control your vehcile through ROS. You need to start a mavlink stream on a unique set of ports in the startup file, see here. Those unique set of ports should matched when you launch MAVROS node, see here.
The launch file multi_uav_mavros_sitl.launch
does the following,
- loads a world in gazebo, see here.
for each vehicle,
loads gazebo model and runs PX4 SITL app instance, runs
<arg name="fcu_url" default="udp://:14540@localhost:14557"/>
<arg name="gcs_url" value=""/>
<arg name="tgt_system" value="1"/>
<arg name="tgt_component" value="1"/>
<arg name="rcS1" default="$(find px4)/posix-configs/SITL/init/$(arg est)/$(arg vehicle)_1"/>
<arg name="ID" value="1"/>
<include file="$(find px4)/launch/single_vehcile_spawn.launch">
<arg name="x" value="0"/>
<arg name="y" value="0"/>
<arg name="z" value="0"/>
<arg name="R" value="0"/>
<arg name="P" value="0"/>
<arg name="Y" value="0"/>
<arg name="vehicle" value="$(arg vehicle)"/>
<arg name="rcS" value="$(arg rcS1)"/>
<arg name="mavlink_udp_port" value="14560"/>
<arg name="ID" value="$(arg ID)"/>
</include>
runs a mavros node,
<include file="$(find mavros)/launch/node.launch">
<arg name="pluginlists_yaml" value="$(arg pluginlists_yaml)" />
<arg name="config_yaml" value="$(arg config_yaml)" />
<arg name="fcu_url" value="$(arg fcu_url)" />
<arg name="gcs_url" value="$(arg gcs_url)" />
<arg name="tgt_system" value="$(arg tgt_system)" />
<arg name="tgt_component" value="$(arg tgt_component)" />
</include>
The complete block for each vehicle looks like the following,
<!-- UAV2 iris_2 -->
<group ns="uav2">
<arg name="fcu_url" default="udp://:14541@localhost:14559"/>
<arg name="gcs_url" value=""/>
<arg name="tgt_system" value="2"/>
<arg name="tgt_component" value="1"/>
<arg name="rcS2" default="$(find px4)/posix-configs/SITL/init/$(arg est)/$(arg vehicle)_2"/>
<arg name="ID" value="2"/>
<include file="$(find px4)/launch/single_vehcile_spawn.launch">
<arg name="x" value="1"/>
<arg name="y" value="0"/>
<arg name="z" value="0"/>
<arg name="R" value="0"/>
<arg name="P" value="0"/>
<arg name="Y" value="0"/>
<arg name="vehicle" value="$(arg vehicle)"/>
<arg name="rcS" value="$(arg rcS2)"/>
<arg name="mavlink_udp_port" value="14562"/>
<arg name="ID" value="$(arg ID)"/>
</include>
<include file="$(find mavros)/launch/node.launch">
<arg name="pluginlists_yaml" value="$(arg pluginlists_yaml)" />
<arg name="config_yaml" value="$(arg config_yaml)" />
<arg name="fcu_url" value="$(arg fcu_url)" />
<arg name="gcs_url" value="$(arg gcs_url)" />
<arg name="tgt_system" value="$(arg tgt_system)" />
<arg name="tgt_component" value="$(arg tgt_component)" />
</include>
</group>
To simulate more vehicles, add more blocks with the appropriate changes in the startup files, and launch file’s parameters.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论