Explore Enterprise Education Gitee Premium Gitee AI AI teammates
Fetch the repository succeeded.
Donate
Please sign in before you donate.
Scan WeChat QR to Pay
Cancel
Complete
Prompt
Switch to Alipay.
OK
Cancel
1 Star 0 Fork 259

feng/UAVS

forked from wwy/UAVS
Create your Gitee Account
Explore and code with more than 14 million developers,Free private repositories !:)
Sign up
Already have an account? Sign in
文件
master
Branches (1)
master
master
Branches (1)
master
Clone or Download
Clone/Download
Prompt
To download the code, please copy the following command and execute it in the terminal
To ensure that your submitted code identity is correctly recognized by Gitee, please execute the following command.
When using the SSH protocol for the first time to clone or push code, follow the prompts below to complete the SSH configuration.
1 Generate RSA keys.
2 Obtain the content of the RSA public key and configure it in SSH Public Keys
To use SVN on Gitee, please visit the usage guide
When using the HTTPS protocol, the command line will prompt for account and password verification as follows. For security reasons, Gitee recommends configure and use personal access tokens instead of login passwords for cloning, pushing, and other operations.
Username for 'https://gitee.com': userName
Password for 'https://userName@gitee.com': # Private Token
master
Branches (1)
master
autoFly_test.py 4.10 KB
Copy Edit Raw Blame History
wangwei39120157028 authored 2021年02月12日 16:32 +08:00 . 2021年02月12日Update
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Intelligent scripting: Simplified operation process, detailed instructions can help flight control better take-off.
But this is just a test file.
"""
from __future__ import print_function
import time
from dronekit import connect, VehicleMode, LocationGlobalRelative
# 通过本地的14551端口,使用UDP连接到SITL模拟器
connection_string ='127.0.0.1:14550' #'tcp:127.0.0.1:5760' #
print('Connecting to vehicle on: %s' % connection_string)
# connect函数将会返回一个Vehicle类型的对象,即此处的vehicle
# 即可认为是无人机的主体,通过vehicle对象,我们可以直接控制无人机
vehicle = connect(connection_string, wait_ready=True)
# 定义arm_and_takeoff函数,使无人机解锁并起飞到目标高度
# 参数aTargetAltitude即为目标高度,单位为米
def arm_and_takeoff(aTargetAltitude):
# 进行起飞前检查
print("Basic pre-arm checks")
# vehicle.is_armable会检查飞控是否启动完成、有无GPS fix、卡曼滤波器
# 是否初始化完毕。若以上检查通过,则会返回True
while not vehicle.is_armable:
print(" Waiting for vehicle to initialise...")
time.sleep(1)
# 解锁无人机(电机将开始旋转)
print("Arming motors")
# 将无人机的飞行模式切换成"GUIDED"(一般建议在GUIDED模式下控制无人机)
vehicle.mode = VehicleMode("GUIDED")
# 通过设置vehicle.armed状态变量为True,解锁无人机
vehicle.armed = True
# 在无人机起飞之前,确认电机已经解锁
while not vehicle.armed:
print(" Waiting for arming...")
time.sleep(1)
# 发送起飞指令
print("Taking off!")
# simple_takeoff将发送指令,使无人机起飞并上升到目标高度
vehicle.simple_takeoff(aTargetAltitude)
# 在无人机上升到目标高度之前,阻塞程序
while True:
print(" Altitude: ", vehicle.location.global_relative_frame.alt)
# 当高度上升到目标高度的0.95倍时,即认为达到了目标高度,退出循环
# vehicle.location.global_relative_frame.alt为相对于home点的高度
if vehicle.location.global_relative_frame.alt >= aTargetAltitude * 0.95:
print("Reached target altitude")
break
# 等待1s
time.sleep(1)
# 调用上面声明的arm_and_takeoff函数,目标高度10m
arm_and_takeoff(10)
# 设置在运动时,默认的空速为3m/s
print("Set default/target airspeed to 3")
# vehicle.airspeed变量可读可写,且读、写时的含义不同。
# 读取时,为无人机的当前空速;写入时,设定无人机在执行航点任务时的默认速度
vehicle.airspeed = 3
# 发送指令,让无人机前往第一个航点
print("Going towards first point for 30 seconds ...")
# LocationGlobalRelative是一个类,它由经纬度(WGS84)和相对于home点的高度组成
# 这条语句将创建一个位于南纬35.361354,东经149.165218,相对home点高20m的位置
point1 = LocationGlobalRelative(-35.361354, 149.165218, 20)
# simple_goto函数将位置发送给无人机,生成一个目标航点
vehicle.simple_goto(point1)
# simple_goto函数只发送指令,不判断有没有到达目标航点
# 它可以被其他后续指令打断,此处延时30s,即让无人机朝向point1飞行30s
time.sleep(30)
# 发送指令,让无人机前往第二个航点
print("Going towards second point for 30 seconds (groundspeed set to 10 m/s) ...")
# 与之前类似,这条语句创建了另一个相对home高20m的点
point2 = LocationGlobalRelative(-35.363244, 149.168801, 20)
# simple_goto将目标航点发送给无人机,groundspeed=10设置飞行时的地速为10m/s
vehicle.simple_goto(point2, groundspeed=10)
# 与之前一样,延时30s
time.sleep(30)
# 发送"返航"指令
print("Returning to Launch")
# 返航,只需将无人机的飞行模式切换成"RTL(Return to Launch)"
# 无人机会自动返回home点的正上方,之后自动降落
vehicle.mode = VehicleMode("RTL")
# 退出之前,清除vehicle对象
print("Close vehicle object")
vehicle.close()
Loading...
Report
Report success
We will send you the feedback within 2 working days through the letter!
Please fill in the reason for the report carefully. Provide as detailed a description as possible.
Please select a report type
Cancel
Send
误判申诉

此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。

如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。

取消
提交

About

智能无人机路径规划仿真系统是一个具有操作控制精细、平台整合性强、全方向模型建立与应用自动化特点的软件。它以A、B两国在C区开展无人机战争为背景,该系统的核心功能是通过仿真平台规划无人机航线,并进行验证输出,数据可导入真实无人机,使其按照规定路线精准抵达战场任一位置,支持多人多设备编队联合行动。
No labels
BSD-3-Clause
Use BSD-3-Clause
Cancel

Releases

No release

Contributors

All

Activities

can not load any more
Edit
About
Homepage
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/feng_stack/UAVS.git
git@gitee.com:feng_stack/UAVS.git
feng_stack
UAVS
UAVS
master
Going to Help Center

Search

Comment
Repository Report
Back to the top
Login prompt
This operation requires login to the code cloud account. Please log in before operating.
Go to login
No account. Register

AltStyle によって変換されたページ (->オリジナル) /