代码拉取完成,页面将自动刷新
同步操作将从 Xianhao Ji/IntelligentUAVChampionshipSimulator 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
import json
import websocket
import subprocess
import time
def run():
tmp = input("输入本机IP地址 (例如 123.123.123.123): ")
subprocess.Popen("run.bat -ResX=800 -ResY=480 -windowed", shell=True)
while 1:
try:
ws_client = websocket.create_connection("ws://"+tmp+":31245", timeout=3)
break
except Exception as e:
print("connecting to {0}".format(tmp))
print(e)
time.sleep(1)
time.sleep(1)
with open("./Settings/FPV.json") as f:
jdata = json.load(f)
jdata['LocalHostIp'] = tmp
with open("./Settings/FPV.json", "w") as f:
f.write(json.dumps(jdata))
with open("./Settings/RGBD.json") as f:
jdata = json.load(f)
jdata['LocalHostIp'] = tmp
with open("./Settings/RGBD.json", "w") as f:
f.write(json.dumps(jdata))
with open("./Settings/Stereo.json") as f:
jdata = json.load(f)
jdata['LocalHostIp'] = tmp
with open("./Settings/Stereo.json", "w") as f:
f.write(json.dumps(jdata))
print("{:*^30}".format(""))
print("{:*^26}".format("选择赛项"))
print("{:*^26}".format("0.极速穿圈-RGBD"))
print("{:*^24}".format("1.极速穿圈-双目"))
print("{:*^26}".format("2.自主飞行-RGBD"))
print("{:*^24}".format("3.自主飞行-双目"))
print("{:*^28}".format("4.FPV竞速"))
print("{:*^30}".format(""))
while 1:
tmp = input("输入编号: ")
if tmp == '0' or tmp == '1' or tmp == '2' or tmp == '3' or tmp == '4':
break
if(tmp=='0'):
ws_client.send(
json.dumps({
"command":"switch",
"map":"stage1",
"sensor": "RGBD"
})
)
ws_client.recv()
elif(tmp == '1'):
ws_client.send(
json.dumps({
"command":"switch",
"map":"stage1",
"sensor": "Stereo"
})
)
elif(tmp == '2'):
ws_client.send(
json.dumps({
"command":"switch",
"map":"stage2",
"sensor": "RGBD"
})
)
elif(tmp == '3'):
ws_client.send(
json.dumps({
"command":"switch",
"map":"stage2",
"sensor": "Stereo"
})
)
elif(tmp == '4'):
ws_client.send(
json.dumps({
"command":"switch",
"map":"stage3",
"sensor": "FPV"
})
)
if __name__=="__main__":
run()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。