启动python脚本生成多机launch文件
cd ~/XTDrone/coordination/launch_generator
python3 generator.py
将生成出来的launch文件复制到PX4固件的launch文件夹
cp ~/XTDrone/coordination/launch_generator/multi_vehicle.launch ~/PX4_Firmware/launch/
启动多机PX4仿真
cd ~/PX4_Firmware/
roslaunch px4 multi_vehicle.launch
键入如下命令修改启动脚本
gedit ~/XTDrone/communication/multi_vehicle_communication.sh
#!/bin/bash
iris_num=0
typhoon_h480_num=0
solo_num=3
plane_num=3
rover_num=3
standard_vtol_num=0
tiltrotor_num=0
tailsitter_num=0
# 上面是需要按照所启动的无人机的数量进行相应的修改
vehicle_num=0
while(( $vehicle_num< iris_num))
do
python3 multirotor_communication.py iris $vehicle_num&
let "vehicle_num++"
done
vehicle_num=0
while(( $vehicle_num< typhoon_h480_num))
do
python3 multirotor_communication.py typhoon_h480 $vehicle_num&
let "vehicle_num++"
done
vehicle_num=0
while(( $vehicle_num< solo_num))
do
python3 multirotor_communication.py solo $vehicle_num&
let "vehicle_num++"
done
vehicle_num=0
while(( $vehicle_num< plane_num))
do
python3 plane_communication.py $vehicle_num&
let "vehicle_num++"
done
vehicle_num=0
while(( $vehicle_num< rover_num))
do
python3 rover_communication.py $vehicle_num&
let "vehicle_num++"
done
vehicle_num=0
while(( $vehicle_num< standard_vtol_num))
do
python3 vtol_communication.py standard_vtol $vehicle_num&
let "vehicle_num++"
done
vehicle_num=0
while(( $vehicle_num< tiltrotor_num))
do
python3 vtol_communication.py tiltrotor $vehicle_num&
let "vehicle_num++"
done
vehicle_num=0
while(( $vehicle_num< tailsitter_num))
do
python3 vtol_communication.py tailsitter $vehicle_num&
let "vehicle_num++"
done
注意:需要以python3来运行.py文件!!!
然后输入如下命令运行此脚本建立通信
cd ~/XTDrone/communication
bash multi_vehicle_communication.sh
连接成功后的示例:
建立通信后,可以在control目录下分别启动对应机型的键盘控制脚本,即可实现利用键盘同时控制多机型。
具体方法示例:
启动3架solo和3架iris四旋翼无人机的键盘控制脚本
分别在两个窗口输入如下命令
cd ~/XTDrone/control/keyboard
python3 multirotor_keyboard_control.py solo 3 vel
注意:第二个参数“3”需要改成前面launch文件中所启动的solo无人机个数
cd ~/XTDrone/control/keyboard
python3 multirotor_keyboard_control.py iris 3 vel
注意:第二个参数“3”需要改成前面launch文件中所启动的solo无人机个数