1 Star 0 Fork 2

tb_huge/特洛无人机

forked from ZWT/特洛无人机 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
drone_by_simulation.py 2.17 KB
一键复制 编辑 原始数据 按行查看 历史
ZWT 提交于 2023-10-04 16:57 . feat: 初步实现无人机穿越圆环功能
import os.path
from util import *
from yoloDetections_to_npArray import tran
import yolov5
def getFiles(path):
ans = []
for root, dirs, files in os.walk(path):
for i in files:
ans.append(root + '/' + i)
return ans
class simulation_drone:
def __init__(self):
self.img_files = getFiles("imgs")
self.img_files_index = 0
self.gear = 0
def drone_increase_gear(self):
if self.gear < 3:
self.gear += 1
def drone_decrease_gear(self):
if self.gear > 0:
self.gear -= 1
def drone_get_gear(self):
return self.gear + 1
def drone_get_battery(self):
return 100
@fn_timer
def drone_move(self, a, b, c, d, speed_magnification=1):
log("drone_move", a, b, c, d, speed_magnification)
time.sleep(0.1)
@fn_timer
def drone_flip(self, direction):
log("drone_flip", direction)
time.sleep(0.1)
# 获取当前飞行速度
def drone_get_speed(self):
return 0
# 起飞
@fn_timer
def drone_takeoff(self):
log("drone_takeoff")
time.sleep(2)
# 停止
@fn_timer
def drone_stop(self):
log("drone_stop")
time.sleep(0.1)
# 降落
@fn_timer
def drone_land(self):
log("drone_land")
time.sleep(2)
def drone_init_camera(self):
log("drone_init_camera")
def drone_get_img(self):
img = cv2.imread(self.img_files[self.img_files_index])
self.img_files_index += 1
self.img_files_index %= len(self.img_files)
time.sleep(0.05)
return img
def drone_close_camera(self):
log("drone_close_camera")
def close(self):
log("drone_close")
#
# def main():
# drone = simulation_drone()
# img = drone.drone_get_img()
# model = yolov5.load('balloon_recognition_model.pt')
# while True:
# img = drone.drone_get_img()
# cv2.waitKey(1)
# image_recognition_results = model(img)
# img = tran(image_recognition_results)
# cv2.imshow("Drone", img)
# .drone_autonomous_operation(image_recognition_results)
#
#
# if __name__ == '__main__':
# main()
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/tb_huge/tello_drone.git
git@gitee.com:tb_huge/tello_drone.git
tb_huge
tello_drone
特洛无人机
master

搜索帮助