roslaunch multi vehicles launch files
what happened?
For each simulated vehicle, the following is required:
1. Gazebo model
格式: xacro file
路径: Firmware/Tools/sitl_gazebo/models/rotors_description/urdf/‘model’_base.xacro
调用参数: mavlink_udp_port (指定gazebo和px4交互的端口号)
arg name=“mavlink_udp_port” value=“14560”
该文件的作用: 用来生成一个包含指定端口(mavlink_udp_port)的 urdf 模型
This is defined as xacro file in Firmware/Tools/sitl_gazebo/models/rotors_description/urdf/‘model’_base.xacro see here. Currently, the model xacro file is assumed to end with base.xacro. This model should have an argument called mavlink_udp_port which defines the UDP port on which gazebo will communicate with PX4 node. The model’s xacro file will be used to generate an urdf model that contains UDP port that you select. To define the UDP port, set the mavlink_udp_port in the launch file for each vehicle, see here as an example.
If you are using the same vehicle model, you don’t need a separate xacro file for each vehicle. The same xacro file is adequate.
2. PX4 node
作用: 和gazebo仿真器进行通信
通信的端口号: 和Gazebo 飞机模型相同的UDP端口, 比如mavlink_udp_port
在sitl端设置UDP端口号, 在启动脚本中设置参数SITL_UDP_PRT, 为了和 mavlink_udp_port 匹配
launch文件中启动脚本的路径: 基于 vehicle 和 ID 参数
在启动脚本中为每一架飞机设置 MAV_SYS_ID 参数
和每一架飞机的ID相互匹配. 这个将有助于launch文件和脚本文件保持一致.
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 the SITL_UDP_PRT parameter in the startup file to match the mavlink_udp_port discussed previously, see here. The path of the startup file in the launch file is generated based on the vehicle and ID arguments, see here. The MAV_SYS_ID for each vehicle in the startup file, see here, should match the ID for that vehicle in the launch file here. This will help make sure you keep the configurations consistent between the launch file and the startup file.
3. MAVROS node(optional)
如果想要通过ROS和控制无人机, mavros node 需要运行在launch文件中
作用: 和 PX4 SITL app 连接
需要在启动脚本设置一个唯一的端口号, 见下图
这个唯一的端口号: 需要和 launch文件中mavros节点的端口号设置向匹配
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 vehicle 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 need to match those in the launch file for the MAVROS node, see here.