首页 > 系统相关 >Ardupilot: 开启多个无人机SITL仿真实例Shell脚本

Ardupilot: 开启多个无人机SITL仿真实例Shell脚本

时间:2023-06-27 09:00:51浏览次数:27  
标签:index Shell SITL -- 0.0 num echo Ardupilot type

将该脚本文件放入Ardupilot目录下,文件名称为swarm.sh

例如: 开启三台Copter无人机仿真示例,可运行脚本: bash swarm.sh ArduCopter 3

#!/bin/bash

# run example: start run three ArduCopter sitl
# bash swarm.sh ArduCopter 3

# Vehicle start location
locs=(
        '22.71343050,114.40813420,0.0,0'  
        '22.71343050,114.40915080,0.0,0'  
        '22.71344530,114.41021830,0.0,0'
        '22.71345030,114.41111680,0.0,0'
        '22.71346020,114.41186790,0.0,0'
)

# mavproxy out udp port, Mission Planner connect this port, user can modify
udp='udp:192.168.124.11:14550'
types=("ArduCopter" "ArduPlane" "ArduRover")
type=$1             # in types
num=`expr $2 + 0`   # sitl count
have_type=0

if [ $# -lt 2 ]; then echo 'Input arg error!'; exit 0; fi

# check sitl instance count
if [ $num -gt ${#locs[*]} ]; then num=${#locs[*]}; fi

# check type
for t in ${types[*]}
do
    echo $t$type
    if [ $t = $type ]; then
        have_type=1;
        break;
    fi
done

# check pass, start run all sitl
# create shell term: gnome-terminal --titile='' --window -e "Run Command" --tab --title='' -e "Run Command" ... 
if [ $have_type -eq 1 ]
then
    echo 'Vehicle Count='${num}
    if [ $num -gt 0 ]
    then
        # gnome-terminal: create new terminal
        cmd='gnome-terminal --title="UAV0" --window -e '
        index=0
        sim=''
        tab=''
        for loc in ${locs[*]}
        do
            sim=${sim}${tab}'"Tools/autotest/sim_vehicle.py -v '${type}' -I '${index}' -l '${loc}' --auto-sysid --out='${udp}'"'
            index=`expr $index + 1`
            if [ $index -eq $num ]; then break; fi
            tab=' --tab --title="UAV'${index}'" -e '
        done
        runcmd=${cmd}${sim}
        echo $runcmd
        eval $runcmd #run cmd
    else
        echo 'Vehicle Count Error! Max Count: '${#locs[*]}
    fi
else
    echo 'Vehicle Type Error!'
    echo 'Vehicle Type: '
    for t in ${types[*]}:
    do
        echo '   '${t}
    done
fi 
# gnome-terminal --title="UAV" -- sim_vehicle.py -v ArduCopter -I 3 -l 22.71344530,114.41021830,0.0,0 --auto-sysid --out=udp:192.168.124.11:14550

 

标签:index,Shell,SITL,--,0.0,num,echo,Ardupilot,type
From: https://www.cnblogs.com/BlogsOfLei/p/17507717.html

相关文章

  • shell实现拒绝恶意IP的ssh访问
    Linux运维:shell实现拒绝恶意IP的ssh访问觉主 运维动力 2023-04-1819:30 发表于辽宁收录于合集#linux运维3个    编写shell脚本,在secure日志文件中查找失败登录20次以上的记录,将其IP地址添加到hosts.deny文件中,实现拒绝该IP的访问。1、创建shell脚本文件:auto_deny_......
  • Android adb shell content命令
      adbshellcontentusage:adbshellcontent[subcommand][options]usage:adbshellcontentinsert--uri<URI>[--user<USER_ID>]--bind<BINDING>[--bind<BINDING>...][--extra<BINDING>...] <URI>acontentprovide......
  • Linux扩展篇-shell编程(八)-shell字符串截取
    shell字符串截取,一般包含从指定位置和从指定字符截取。一、从指定位置截取从字符串左边开始计数格式:${string:start:length}从string字符串的左边第start个字符开始,向右截取length个字符。${string:start}从string字符串的左边第start个字符开始截取,直到最......
  • Shell判断是否包含给定字符串
    Shell判断是否包含给定字符串点击关注......
  • shell脚本双中括号比较数字踩坑
    shell的双中括号中,由于可以直接使用大于和小于号,便自作聪明认为可以直接判断两个数字的大小,直到遇到了以下的情况[core@localhost~]$a=5;b=3;if[[$a>$b]];thenechoaisbigger;elseechobisbigger;fi#结果输出aisbigger,结果是正确的#但是如果两个数字不是......
  • 分享我的 Shell 环境,git 操作效率提升 100% !
    换到一个新的开发环境,蛮多东西要折腾的。特地整理了一下,下次换新电脑也方便。git:不使用rebase,要加上这个设置:gitconfig--globalpull.rebasefalse全局配置工作用户名和邮箱,不然会影响到你提交代码:gitconfig--globaluser.name"???"gitconfig--globaluser.email......
  • Course overview + the shell
    虚拟机崩了,难受,不能即时玩……勉强试出来了几个Windows的指令,也还是蛮好玩的但还是记一下linux的date查看日期echo打印,后可接$PATH打印所有路径cd目录跳转..父目录.子目录ls显示文件ls-l显示文件的一些信息mv重命名两个参数cp复制两个参数rm删除rmdir只删空白......
  • linux 中shell脚本实现统计每一个read的长度
     001、[root@PC1test02]#lstest.fastq[root@PC1test02]#cattest.fastq##测试fastq数据@SRR8442980.988/2AAGG+:[email protected]/2AAGGTC+:FFF:,@SRR8442980.1134/1AAAAAAAATATAATTCCA+FFFFFFFFFFFFFFFFFF[root@PC1test02]#awk'{if((NR%......
  • MariaDB 工具介绍之 mariadb-shell
    MariaDBShell是一个命令行工具,它统一了MariaDB数据库产品的故障排除和管理。MariaDBShell23.03.2于2023-05-05发布。这个版本是一个技术预览版,不应该在生产环境中使用。安装通过页面https://mariadb.com/downloads/tools/下载安装包将安装包上传至服务器后,直接进行yum安......
  • xshell 常用命令
    Linux常用命令工具xshell工具链接:https://pan.baidu.com/s/1gLwhcbPQuRbOWK87sjTmBQ提取码:ep4nputty工具下载地址:https://www.putty.org/ xshell 常用快捷键#停止日志chrl+s#继续日志ctr......